chore: add prepublish guard against npm publish with workspace:* deps

小橘 <xiaoju@shazhou.work>
This commit is contained in:
2026-04-23 00:47:56 +00:00
parent 57881533a8
commit 96ea4b46ff
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -14,6 +14,7 @@
"access": "public"
},
"scripts": {
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
"build": "tsup",
"test": "vitest run"
},
+1
View File
@@ -11,6 +11,7 @@
"access": "public"
},
"scripts": {
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
"build": "tsup",
"test": "vitest run"
},
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# Prevent npm publish from shipping workspace:* dependencies.
# pnpm publish auto-converts them; npm publish does not.
if [ -z "$npm_execpath" ] || [[ "$npm_execpath" != *pnpm* ]]; then
if grep -q '"workspace:' package.json; then
echo "❌ Detected workspace:* dependencies in package.json."
echo " Use 'pnpm publish' instead of 'npm publish' to auto-convert them."
exit 1
fi
fi