@@ -8,6 +8,13 @@ interface PackageJsonShape {
88 version ?: string ;
99 name ?: string ;
1010 packageManager ?: string ;
11+ devEngines ?: {
12+ packageManager ?: {
13+ name ?: string ;
14+ version ?: string ;
15+ onFail ?: string ;
16+ } ;
17+ } ;
1118 scripts ?: Record < string , string > ;
1219 dependencies ?: Record < string , string > ;
1320 devDependencies ?: Record < string , string > ;
@@ -47,7 +54,7 @@ const expectedProofkitVersions = new Map([
4754 `^${ readJsonFile < PackageJsonShape > ( join ( __dirname , ".." , ".." , "webviewer" , "package.json" ) ) . version } ` ,
4855 ] ,
4956] ) ;
50- const packageManagerPattern = / ^ ( n p m | p n p m | y a r n | b u n ) @ / ;
57+ const packageManagerVersionPattern = / ^ \^ ? \d + \. \d + \. \d + / ;
5158const ansiStylePrefixPattern = / ^ [ 0 - 9 ; ] * m / ;
5259
5360function runInit ( { appType, projectName } : { appType : "browser" | "webviewer" ; projectName : string } ) : string {
@@ -110,7 +117,7 @@ function checkNodeSyntax(projectDir: string, relativeFilePath: string): boolean
110117}
111118
112119function getPackageManagerName ( packageJson : PackageJsonShape ) : "npm" | "pnpm" | "yarn" | "bun" {
113- const raw = packageJson . packageManager ?. split ( "@" ) [ 0 ] ;
120+ const raw = packageJson . devEngines ?. packageManager ?. name ?? packageJson . packageManager ?. split ( "@" ) [ 0 ] ;
114121 if ( raw === "pnpm" || raw === "yarn" || raw === "bun" ) {
115122 return raw ;
116123 }
@@ -161,7 +168,10 @@ describe("Init scaffold contract tests", () => {
161168 expect ( packageJson . scripts ?. build ) . toBe ( "next build --turbopack" ) ;
162169 expect ( packageJson . scripts ?. proofkit ) . toBe ( "proofkit" ) ;
163170 expect ( packageJson . proofkitMetadata ?. initVersion ) . toBe ( cliVersion ) ;
164- expect ( packageJson . packageManager ) . toMatch ( packageManagerPattern ) ;
171+ expect ( packageJson . packageManager ) . toBeUndefined ( ) ;
172+ expect ( packageJson . devEngines ?. packageManager ?. name ) . toBe ( "pnpm" ) ;
173+ expect ( packageJson . devEngines ?. packageManager ?. version ) . toMatch ( packageManagerVersionPattern ) ;
174+ expect ( packageJson . devEngines ?. packageManager ?. onFail ) . toBe ( "download" ) ;
165175 expect ( allProofkitDependenciesUseCurrentVersions ( packageJson ) ) . toBe ( true ) ;
166176 expect ( readFileSync ( join ( browserProjectDir , "CLAUDE.md" ) , "utf-8" ) ) . toBe ( "@AGENTS.md\n" ) ;
167177 expect ( readFileSync ( join ( browserProjectDir , ".cursorignore" ) , "utf-8" ) ) . toBe ( "CLAUDE.md\n" ) ;
@@ -213,7 +223,10 @@ describe("Init scaffold contract tests", () => {
213223 expect ( packageJson . scripts ?. [ "typegen:ui" ] ) . toBe ( "pnpx @proofkit/typegen ui" ) ;
214224 expect ( packageJson . scripts ?. proofkit ) . toBe ( "proofkit" ) ;
215225 expect ( packageJson . proofkitMetadata ?. initVersion ) . toBe ( cliVersion ) ;
216- expect ( packageJson . packageManager ) . toMatch ( packageManagerPattern ) ;
226+ expect ( packageJson . packageManager ) . toBeUndefined ( ) ;
227+ expect ( packageJson . devEngines ?. packageManager ?. name ) . toBe ( "pnpm" ) ;
228+ expect ( packageJson . devEngines ?. packageManager ?. version ) . toMatch ( packageManagerVersionPattern ) ;
229+ expect ( packageJson . devEngines ?. packageManager ?. onFail ) . toBe ( "download" ) ;
217230 expect ( allProofkitDependenciesUseCurrentVersions ( packageJson ) ) . toBe ( true ) ;
218231 expect ( readFileSync ( join ( webviewerProjectDir , "CLAUDE.md" ) , "utf-8" ) ) . toBe ( "@AGENTS.md\n" ) ;
219232 expect ( readFileSync ( join ( webviewerProjectDir , ".cursorignore" ) , "utf-8" ) ) . toBe ( "CLAUDE.md\n" ) ;
0 commit comments