Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"scripts": {
"build": "tsup",
"prepack": "node ../../scripts/assert-pnpm.mjs",
"prepublishOnly": "pnpm build",
"prepublishOnly": "node ../../scripts/assert-built.mjs",
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"scripts": {
"build": "tsup",
"prepack": "node ../../scripts/assert-pnpm.mjs",
"prepublishOnly": "pnpm build",
"prepublishOnly": "node ../../scripts/assert-built.mjs",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"scripts": {
"build": "tsup",
"prepack": "node ../../scripts/assert-pnpm.mjs",
"prepublishOnly": "pnpm build",
"prepublishOnly": "node ../../scripts/assert-built.mjs",
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/widget-embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"scripts": {
"build": "tsup",
"prepack": "node ../../scripts/assert-pnpm.mjs",
"prepublishOnly": "pnpm build",
"prepublishOnly": "node ../../scripts/assert-built.mjs",
"test": "echo \"covered by @fishaudio/agent-widget\" && exit 0",
"typecheck": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"scripts": {
"build": "tsup",
"prepack": "node ../../scripts/assert-pnpm.mjs",
"prepublishOnly": "pnpm build",
"prepublishOnly": "node ../../scripts/assert-built.mjs",
"test": "vitest run",
"typecheck": "tsc --noEmit",
"demo": "vite -c demo/vite.config.ts"
Expand Down
21 changes: 21 additions & 0 deletions scripts/assert-built.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// prepublishOnly guard: the package must already be built.
//
// Publishing used to rebuild each package, but `changeset publish` publishes
// packages concurrently and every build starts by emptying its dist/, so a
// sibling's types build could find a dependency's dist/ half-written. The
// release script builds everything once up front; this only checks that it
// happened.
import { existsSync } from "node:fs";
import { join } from "node:path";

const manifest = JSON.parse(
await import("node:fs/promises").then((fs) => fs.readFile("package.json", "utf8")),
);
const entry = manifest.main ?? manifest.module ?? manifest.types;
if (!entry || !existsSync(join(process.cwd(), entry))) {
console.error(
`${manifest.name}: ${entry ?? "dist/"} is missing. Run \`pnpm build\` at the repo root ` +
"(or `pnpm release`, which builds first) before publishing.",
);
process.exit(1);
}
Loading