Skip to content

Commit f487dbb

Browse files
feat(repo): add local Verdaccio workflow for testing packages (#7608)
Co-authored-by: Jacek Radko <jacek@clerk.dev>
1 parent d2cee35 commit f487dbb

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

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)