Skip to content

Commit eda6a28

Browse files
The engine-version check ignores manifest changes npm never publishes (#209)
The check from #200 failed the rc.5 release PR (#207): `pnpm bump-version` rewrites the engine's `@repo/*` devDependencies on every release bump, and devDependencies never ship in the published tarball, so the shipped engine is byte-identical while the check saw "packages/cli-engine changed". A change to the engine's manifest now counts only when something outside `devDependencies` differs. Four new tests pin the comparison. Unblocks #207. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
1 parent 16e963d commit eda6a28

2 files changed

Lines changed: 72 additions & 2 deletions

File tree

scripts/check-engine-version.mjs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ function isNotFoundError(error) {
2929

3030
const rootDir = dirname(dirname(fileURLToPath(import.meta.url)));
3131

32+
const ENGINE_MANIFEST = "packages/cli-engine/package.json";
33+
34+
/**
35+
* Whether a manifest change alters what npm publishes. devDependencies
36+
* never ship in the tarball — the release version sweep rewrites the
37+
* engine's `@repo/*` devDependencies on every bump, and that must not
38+
* read as "the engine changed".
39+
*
40+
* @param {Record<string, unknown>} base
41+
* @param {Record<string, unknown>} head
42+
* @returns {boolean}
43+
*/
44+
export function manifestChangeShips(base, head) {
45+
const shipped = ({ devDependencies: _dev, ...rest }) => rest;
46+
return JSON.stringify(shipped(base)) !== JSON.stringify(shipped(head));
47+
}
48+
3249
/**
3350
* @param {{ changedFiles: readonly string[], engineVersion: string, versionOnRegistry: boolean }} input
3451
* @returns {string | null} the failure message, or null when the change is fine
@@ -66,7 +83,21 @@ async function main() {
6683
["diff", "--name-only", mergeBase.trim(), "HEAD"],
6784
{ cwd: rootDir },
6885
);
69-
const changedFiles = diff.split("\n").filter(Boolean);
86+
let changedFiles = diff.split("\n").filter(Boolean);
87+
88+
if (changedFiles.includes(ENGINE_MANIFEST)) {
89+
const { stdout: baseManifest } = await execFileAsync(
90+
"git",
91+
["show", `${mergeBase.trim()}:${ENGINE_MANIFEST}`],
92+
{ cwd: rootDir },
93+
);
94+
const headManifest = readFileSync(join(rootDir, ENGINE_MANIFEST), "utf-8");
95+
if (
96+
!manifestChangeShips(JSON.parse(baseManifest), JSON.parse(headManifest))
97+
) {
98+
changedFiles = changedFiles.filter((file) => file !== ENGINE_MANIFEST);
99+
}
100+
}
70101

71102
const manifest = JSON.parse(
72103
readFileSync(join(rootDir, "packages/cli-engine/package.json"), "utf-8"),

scripts/check-engine-version.test.mjs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import assert from "node:assert/strict";
22
import { describe, it } from "node:test";
3-
import { engineBumpVerdict } from "./check-engine-version.mjs";
3+
import {
4+
engineBumpVerdict,
5+
manifestChangeShips,
6+
} from "./check-engine-version.mjs";
47

58
const NAMES_THE_STALE_VERSION = /0\.1\.1/;
69
const NAMES_THE_BUMP_COMMAND = /bump-cli-engine-version/;
@@ -46,3 +49,39 @@ describe("engineBumpVerdict", () => {
4649
assert.equal(verdict, null);
4750
});
4851
});
52+
53+
describe("manifestChangeShips", () => {
54+
const base = {
55+
name: "@prisma/cli-engine",
56+
version: "0.2.0",
57+
dependencies: { colorette: "^2.0.20" },
58+
devDependencies: { "@repo/tsconfig": "workspace:8.0.0-rc.4" },
59+
};
60+
61+
it("a devDependencies-only change does not ship", () => {
62+
const head = {
63+
...base,
64+
devDependencies: { "@repo/tsconfig": "workspace:8.0.0-rc.5" },
65+
};
66+
assert.equal(manifestChangeShips(base, head), false);
67+
});
68+
69+
it("a version change ships", () => {
70+
assert.equal(
71+
manifestChangeShips(base, { ...base, version: "0.2.1" }),
72+
true,
73+
);
74+
});
75+
76+
it("a dependencies change ships", () => {
77+
const head = { ...base, dependencies: { colorette: "^2.1.0" } };
78+
assert.equal(manifestChangeShips(base, head), true);
79+
});
80+
81+
it("an added field ships", () => {
82+
assert.equal(
83+
manifestChangeShips(base, { ...base, sideEffects: false }),
84+
true,
85+
);
86+
});
87+
});

0 commit comments

Comments
 (0)