Skip to content

Commit d73acf4

Browse files
eluce2claude
andcommitted
fix(cli): use latest published versions in scaffold tests
Fixes CI failure where scaffolded projects reference unpublished @proofkit/* versions. Test now replaces versions with "latest" before running pnpm install. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 08e53f0 commit d73acf4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/cli/tests/test-utils.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
11
import { execSync } from "node:child_process";
2+
import { readFileSync, writeFileSync } from "node:fs";
3+
import { join } from "node:path";
4+
5+
/**
6+
* Replaces @proofkit/* package versions with "latest" in package.json
7+
* This fixes CI issues where scaffolded projects reference unpublished versions
8+
*/
9+
function useLatestProofkitVersions(projectDir: string): void {
10+
const pkgPath = join(projectDir, "package.json");
11+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
12+
13+
const replaceProofkitVersions = (deps: Record<string, string> | undefined) => {
14+
if (!deps) {
15+
return;
16+
}
17+
for (const name of Object.keys(deps)) {
18+
if (name.startsWith("@proofkit/")) {
19+
console.log(` Replacing ${name}@${deps[name]} with latest`);
20+
deps[name] = "latest";
21+
}
22+
}
23+
};
24+
25+
console.log("Using latest published @proofkit/* versions...");
26+
replaceProofkitVersions(pkg.dependencies);
27+
replaceProofkitVersions(pkg.devDependencies);
28+
29+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
30+
}
231

332
/**
433
* Verifies that a project at the given directory can be built without errors
@@ -9,6 +38,9 @@ export function verifyProjectBuilds(projectDir: string): void {
938
console.log(`\nVerifying project build in ${projectDir}...`);
1039

1140
try {
41+
// Replace unpublished @proofkit versions with latest
42+
useLatestProofkitVersions(projectDir);
43+
1244
console.log("Installing dependencies...");
1345
// Run pnpm install while ignoring workspace settings
1446
execSync("pnpm install --prefer-offline --ignore-workspace", {

0 commit comments

Comments
 (0)