From f16cac92c13662abf31df9a2dc49bc7d5e333d9c Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Wed, 20 May 2026 19:40:07 +0300 Subject: [PATCH] fix: run full check in prepublishOnly before publish npm publish preflight now matches CI validation instead of build-only. --- .changeset/fix-prepublish-check-validation.md | 5 +++++ docs/packaging.md | 2 +- package.json | 2 +- src/package-scripts.test.ts | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-prepublish-check-validation.md create mode 100644 src/package-scripts.test.ts diff --git a/.changeset/fix-prepublish-check-validation.md b/.changeset/fix-prepublish-check-validation.md new file mode 100644 index 0000000..28af01f --- /dev/null +++ b/.changeset/fix-prepublish-check-validation.md @@ -0,0 +1,5 @@ +--- +"codemap": patch +--- + +Run full `check` (not build-only) in `prepublishOnly` so npm publish cannot skip tests or typecheck. diff --git a/docs/packaging.md b/docs/packaging.md index 7ecfa92..d483084 100644 --- a/docs/packaging.md +++ b/docs/packaging.md @@ -4,7 +4,7 @@ How **@stainless-code/codemap** is built and published. **Doc index:** [README.m ## Build & publish surface -- **`bun run build`** → **tsdown** (`tsdown.config.ts`) → **`dist/`** (main **`index.mjs`**, lazy CLI chunks from **`src/cli/main.ts`**, workers, shared chunks) + types. **`prepublishOnly`** runs build. +- **`bun run build`** → **tsdown** (`tsdown.config.ts`) → **`dist/`** (main **`index.mjs`**, lazy CLI chunks from **`src/cli/main.ts`**, workers, shared chunks) + types. **`prepublishOnly`** runs **`check`** (build, format, lint, tests, typecheck, golden). - **`package.json`**: **`bin`** and **`exports`** → **`./dist/index.mjs`**; **`files`**: **`CHANGELOG.md`**, **`dist/`**, **`templates/`** — no `src/` on npm. The `templates/` directory ships two parallel subtrees: diff --git a/package.json b/package.json index e4c02e1..6746404 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "lint:fix": "oxlint --fix", "pack": "bun run build && npm pack", "prepare": "husky || true", - "prepublishOnly": "bun run build", + "prepublishOnly": "bun run check", "qa:external": "bun scripts/qa-external-repo.ts", "release": "changeset publish", "test": "bun test ./src", diff --git a/src/package-scripts.test.ts b/src/package-scripts.test.ts new file mode 100644 index 0000000..96a69dd --- /dev/null +++ b/src/package-scripts.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, test } from "bun:test"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +const pkg = JSON.parse( + readFileSync(join(import.meta.dir, "..", "package.json"), "utf8"), +) as { scripts: Record }; + +describe("package.json publish scripts", () => { + test("prepublishOnly uses the same validation gate as check", () => { + expect(pkg.scripts.prepublishOnly).toBe("bun run check"); + expect(pkg.scripts.check).toContain("typecheck"); + expect(pkg.scripts.check).toContain("test"); + expect(pkg.scripts.check).toContain("test:golden"); + }); +});