Skip to content

Commit 0279578

Browse files
committed
fix prepublish smoke test
1 parent 8d2c032 commit 0279578

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ jobs:
6060
echo "tag=latest" >> "$GITHUB_OUTPUT"
6161
fi
6262
63+
# Pack-and-import smoke test runs BEFORE publish (not inside
64+
# prepublishOnly). Running `npm pack` inside the prepublishOnly
65+
# hook of `npm publish` can hit a re-entrancy edge case on some
66+
# npm versions where the inner pack returns 0 without producing
67+
# a tarball, breaking the smoke check (seen on Node 22 / npm 10
68+
# in CI). Splitting it out keeps the validation while sidestepping
69+
# the lifecycle interaction.
70+
- name: Pack-and-import smoke test
71+
run: npm run check:pack
72+
6373
- name: Dry-run publish (validate package)
6474
run: npm publish --dry-run --tag ${{ steps.dist-tag.outputs.tag }}
6575
env:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"check:ai-examples-coverage": "node scripts/check-ai-examples-coverage.mjs",
157157
"check:docs-routes": "node scripts/check-docs-routes.mjs",
158158
"release:check": "npm run lint && npm run typescript && npm run typescript:mcp && npm run test && npm run check:chart-specs && npm run check:claude-md-coverage && npm run check:context7 && npm run check:mcp-registry && npm run check:surface && npm run check:ai-contracts && npm run check:ssr && npm run check:test-quality && npm run check:jsdoc-coverage && npm run check:ai-examples-coverage && npm run dist:prod && npm run size && npm run check:pack && npm pack --dry-run",
159-
"prepublishOnly": "npm run lint && npm run typescript && npm run typescript:mcp && npm run test && npm run check:chart-specs && npm run check:claude-md-coverage && npm run check:context7 && npm run check:mcp-registry && npm run check:surface && npm run check:ai-contracts && npm run check:ssr && npm run check:test-quality && npm run check:jsdoc-coverage && npm run check:ai-examples-coverage && rm -rf dist && npm run dist:prod && npm run size && npm run check:pack"
159+
"prepublishOnly": "npm run lint && npm run typescript && npm run typescript:mcp && npm run test && npm run check:chart-specs && npm run check:claude-md-coverage && npm run check:context7 && npm run check:mcp-registry && npm run check:surface && npm run check:ai-contracts && npm run check:ssr && npm run check:test-quality && npm run check:jsdoc-coverage && npm run check:ai-examples-coverage && rm -rf dist && npm run dist:prod && npm run size"
160160
},
161161
"targets": {
162162
"website": {

scripts/smoke-pack.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ function firstLine(err) {
4949
function findTarball(dir) {
5050
const files = readdirSync(dir)
5151
const tarball = files.find((f) => f.startsWith("semiotic-") && f.endsWith(".tgz"))
52-
if (!tarball) throw new Error(`no tarball produced in ${dir}`)
52+
if (!tarball) {
53+
// Surface what's actually in the dir so CI logs aren't a dead end —
54+
// npm pack returning 0 without producing a tarball is rare enough
55+
// that the directory listing is the single most useful breadcrumb.
56+
throw new Error(
57+
`no tarball produced in ${dir} (contents: ${files.length === 0 ? "<empty>" : files.join(", ")})`,
58+
)
59+
}
5360
return join(dir, tarball)
5461
}
5562

@@ -61,8 +68,13 @@ const failures = []
6168

6269
try {
6370
// Pack the working repo into a tarball inside the temp dir.
71+
// `--pack-destination` lands the tarball next to our temp consumer
72+
// project; capturing combined output keeps CI logs useful when npm
73+
// pack exits 0 but produces nothing (rare, but seen on some runners
74+
// when --pack-destination is silently ignored).
6475
console.log("▶ npm pack")
65-
run(`npm pack --pack-destination "${tmp}"`, { cwd: repoRoot })
76+
const packOut = run(`npm pack --pack-destination "${tmp}" 2>&1`, { cwd: repoRoot })
77+
if (packOut?.trim()) console.log(packOut.trim().split("\n").map((l) => ` ${l}`).join("\n"))
6678
const tarball = findTarball(tmp)
6779
console.log(` tarball: ${tarball}`)
6880

0 commit comments

Comments
 (0)