Skip to content

Commit d26d893

Browse files
committed
fix: stop the pack guard from blocking the release script
npm runs pre<name> for any script, so naming the release script "pack" made prepack its own pre-hook - and prepack is the guard that refuses to pack the repository root. npm run pack therefore always exited 1, which is exactly what the release workflow calls. Renamed to pack.release, matching build.release and clean.build. The guard still fires for a real npm pack or npm publish at the root, which is what it is for.
1 parent 9e2e87e commit d26d893

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/npm_release_cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
echo IS_RELEASE=$IS_RELEASE >> $GITHUB_OUTPUT
106106
107107
- name: Build nativescript
108-
run: npm run pack
108+
run: npm run pack.release
109109

110110
- name: Upload npm package artifact
111111
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
3232
"prettier": "prettier --write ./lib/**/*{.ts,.d.ts} ./test/**/*{.ts,.d.ts}",
3333
"build.release": "npm run clean.build && tsc -p tsconfig.release.json && node scripts/generate-test-deps.js && node scripts/copy-assets.js --release && node scripts/set-ga-id.js live --dir dist && node scripts/set-ga-id.js verify --dir dist",
34-
"pack": "npm run build.release && npm pack ./dist"
34+
"pack.release": "npm run build.release && npm pack ./dist"
3535
},
3636
"repository": {
3737
"type": "git",

scripts/guard-root-pack.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
// the repository root would produce a tarball with everything nested one level
33
// deeper - every path the CLI resolves through __dirname would break, silently.
44
// npm pack ./dist runs dist's own manifest, so this guard does not fire for it.
5+
//
6+
// The release script is deliberately not called "pack": npm runs pre<name> for
7+
// any script, so `npm run pack` would fire this guard as its own pre-hook.
58
console.error(
69
[
710
"Refusing to pack the repository root.",
811
"",
912
"The published package is assembled in dist/. Use:",
10-
" npm run pack",
13+
" npm run pack.release",
1114
"",
1215
"which builds dist/ and runs `npm pack ./dist`.",
1316
].join("\n")

0 commit comments

Comments
 (0)