Skip to content

Commit c3df152

Browse files
committed
feat(repo): add local Verdaccio workflow for testing packages
Why: Testing package changes locally has been painful: - npm/pnpm linking doesn't always work and doesn't mimic real published package behavior (symlinks behave differently than installed packages) - YALC is an older solution with the same limitation - it doesn't map 1:1 with how packages behave when published to npm - The common workaround was pushing to a branch and waiting for snapshot releases, which takes 5+ minutes per iteration from push to install Verdaccio solves this by running a local npm registry. Packages are built and published exactly as they would be to npm, then installed normally in test apps. This makes iteration cycles much shorter while testing real package behavior. What changed: - Added `local:registry:up` to start Verdaccio with npm proxy support - Added `local:registry:down` to stop the registry - Added `local:registry:pub` to build, publish with snapshot versions, and auto-reset git changes after publishing Usage: pnpm local:registry:up # Start registry (Terminal 1) pnpm local:registry:pub # Build & publish (Terminal 2) bun install --registry http://localhost:4873 # In test app
1 parent 9e4b30c commit c3df152

3 files changed

Lines changed: 77 additions & 1 deletion

File tree

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"lint:inspect": "pnpx @eslint/config-inspector@latest",
2525
"lint:packages": "FORCE_COLOR=1 turbo lint",
2626
"lint:publint": "FORCE_COLOR=1 turbo lint:publint",
27+
"local:registry:down": "./scripts/local-registry.sh down",
28+
"local:registry:pub": "./scripts/local-registry.sh pub",
29+
"local:registry:up": "./scripts/local-registry.sh up",
2730
"nuke": "node ./scripts/nuke.mjs",
2831
"prepare": "husky install",
2932
"release": "changeset publish && git push --follow-tags",

scripts/local-registry.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# Local Verdaccio Registry Script
4+
# Usage: ./scripts/local-registry.sh [up|down|pub]
5+
6+
set -e
7+
8+
REGISTRY_URL="http://localhost:4873"
9+
10+
case "$1" in
11+
up)
12+
echo ""
13+
echo "📦 Local Verdaccio Registry"
14+
echo "==========================="
15+
echo "Registry running at: $REGISTRY_URL"
16+
echo ""
17+
echo "To install packages in your test app:"
18+
echo " 1. Update package.json catalog: \"@clerk/backend\": \"local\""
19+
echo " 2. Run: bun install --registry $REGISTRY_URL"
20+
echo ""
21+
echo "To stop: pnpm local:registry:down"
22+
echo ""
23+
verdaccio --config verdaccio.install.yaml --listen 4873
24+
;;
25+
26+
down)
27+
pkill -f 'verdaccio.*4873' && echo "Verdaccio stopped" || echo "Verdaccio not running"
28+
;;
29+
30+
pub)
31+
# Ensure git changes are restored on exit (success or failure)
32+
cleanup() {
33+
git checkout -- 'packages/*/package.json' '.changeset/' 2>/dev/null || true
34+
}
35+
trap cleanup EXIT
36+
37+
# Restore any dirty package.json files first (from previous failed runs)
38+
# so turbo cache can be used
39+
cleanup
40+
41+
# Build all packages FIRST (uses turbo cache)
42+
# This must happen before versioning, otherwise the package.json
43+
# changes invalidate the turbo cache (package.json is in globalDependencies)
44+
pnpm build
45+
46+
# Clear existing @clerk packages from Verdaccio storage to force republish
47+
rm -rf .verdaccio/storage/@clerk
48+
49+
# Version packages with snapshot (uses snapshot.mjs which pins workspace deps
50+
# to exact versions, preventing semver issues with prereleases)
51+
pnpm version-packages:snapshot local
52+
53+
# Publish to Verdaccio using environment variable
54+
npm_config_registry=$REGISTRY_URL pnpm changeset publish --no-git-tag --tag local
55+
56+
echo ""
57+
echo "✅ Published to local Verdaccio"
58+
echo " Install with: bun install --registry $REGISTRY_URL"
59+
;;
60+
61+
*)
62+
echo "Usage: $0 [up|down|pub]"
63+
echo ""
64+
echo " up - Start Verdaccio registry"
65+
echo " down - Stop Verdaccio registry"
66+
echo " pub - Build and publish all packages"
67+
echo ""
68+
echo "Examples:"
69+
echo " $0 up"
70+
echo " $0 pub"
71+
exit 1
72+
;;
73+
esac

verdaccio.install.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ packages:
1515
publish: $all
1616
proxy: npmjs
1717
log: { type: stdout, format: pretty, level: http }
18-
max_body_size: 20mb
18+
max_body_size: 200mb

0 commit comments

Comments
 (0)