@@ -893,6 +893,41 @@ describe('isScaffoldableEmptyProject', () => {
893893 } ) ;
894894 } ) ;
895895
896+ it ( 'returns true for pnpm add -D void shape with generated pnpm-workspace.yaml' , ( ) => {
897+ withTempDir ( ( root ) => {
898+ writeFileSync (
899+ join ( root , 'package.json' ) ,
900+ JSON . stringify (
901+ {
902+ devDependencies : {
903+ void : '^0.8.9' ,
904+ } ,
905+ } ,
906+ null ,
907+ 2 ,
908+ ) + '\n' ,
909+ ) ;
910+ writeFileSync ( join ( root , 'pnpm-lock.yaml' ) , "lockfileVersion: '9.0'\n" ) ;
911+ writeFileSync (
912+ join ( root , 'pnpm-workspace.yaml' ) ,
913+ [
914+ 'allowBuilds:' ,
915+ ' better-sqlite3: set this to true or false' ,
916+ ' esbuild: set this to true or false' ,
917+ ' sharp: set this to true or false' ,
918+ ' workerd: set this to true or false' ,
919+ 'minimumReleaseAgeExclude:' ,
920+ ' - void@0.8.9' ,
921+ '' ,
922+ ] . join ( '\n' ) ,
923+ ) ;
924+ mkdirSync ( join ( root , 'node_modules' , 'void' ) , { recursive : true } ) ;
925+ writeFileSync ( join ( root , 'node_modules' , 'void' , 'package.json' ) , '{"name":"void"}\n' ) ;
926+
927+ expect ( isScaffoldableEmptyProject ( root ) ) . toBe ( true ) ;
928+ } ) ;
929+ } ) ;
930+
896931 it ( 'returns true when only void and a single Pages adapter are installed' , ( ) => {
897932 withTempDir ( ( root ) => {
898933 writeFileSync (
@@ -915,6 +950,27 @@ describe('isScaffoldableEmptyProject', () => {
915950 } ) ;
916951 } ) ;
917952
953+ it ( 'returns false when pnpm-workspace.yaml declares workspace packages' , ( ) => {
954+ withTempDir ( ( root ) => {
955+ writeFileSync (
956+ join ( root , 'package.json' ) ,
957+ JSON . stringify (
958+ {
959+ devDependencies : {
960+ void : '^0.8.9' ,
961+ } ,
962+ } ,
963+ null ,
964+ 2 ,
965+ ) + '\n' ,
966+ ) ;
967+ writeFileSync ( join ( root , 'pnpm-lock.yaml' ) , "lockfileVersion: '9.0'\n" ) ;
968+ writeFileSync ( join ( root , 'pnpm-workspace.yaml' ) , "packages:\n - 'packages/*'\n" ) ;
969+
970+ expect ( isScaffoldableEmptyProject ( root ) ) . toBe ( false ) ;
971+ } ) ;
972+ } ) ;
973+
918974 it ( 'returns true for a deleted starter that only has manifest and generated state left' , ( ) => {
919975 withTempDir ( ( root ) => {
920976 mkdirSync ( join ( root , '.void' ) , { recursive : true } ) ;
@@ -1270,6 +1326,63 @@ describe('isScaffoldableEmptyProject', () => {
12701326 }
12711327 } ) ;
12721328
1329+ it ( 'prompts for the scaffold toolchain after pnpm add -D void creates pnpm-workspace.yaml' , async ( ) => {
1330+ const root = mkdtempSync ( join ( tmpdir ( ) , 'void-init-' ) ) ;
1331+ try {
1332+ writeFileSync (
1333+ join ( root , 'package.json' ) ,
1334+ JSON . stringify (
1335+ {
1336+ devDependencies : {
1337+ void : '^0.8.9' ,
1338+ } ,
1339+ } ,
1340+ null ,
1341+ 2 ,
1342+ ) + '\n' ,
1343+ ) ;
1344+ writeFileSync ( join ( root , 'pnpm-lock.yaml' ) , "lockfileVersion: '9.0'\n" ) ;
1345+ writeFileSync (
1346+ join ( root , 'pnpm-workspace.yaml' ) ,
1347+ [
1348+ 'allowBuilds:' ,
1349+ ' better-sqlite3: set this to true or false' ,
1350+ ' esbuild: set this to true or false' ,
1351+ ' sharp: set this to true or false' ,
1352+ ' workerd: set this to true or false' ,
1353+ 'minimumReleaseAgeExclude:' ,
1354+ ' - void@0.8.9' ,
1355+ '' ,
1356+ ] . join ( '\n' ) ,
1357+ ) ;
1358+ mkdirSync ( join ( root , 'node_modules' , 'void' ) , { recursive : true } ) ;
1359+ writeFileSync ( join ( root , 'node_modules' , 'void' , 'package.json' ) , '{"name":"void"}\n' ) ;
1360+
1361+ mockSelect
1362+ . mockResolvedValueOnce ( 'vite-plus' )
1363+ . mockResolvedValueOnce ( 'react' )
1364+ . mockResolvedValueOnce ( 'static' )
1365+ . mockResolvedValueOnce ( 'generic' ) ;
1366+ mockConfirm . mockResolvedValueOnce ( false ) ;
1367+
1368+ await runInitCommand ( root ) ;
1369+
1370+ const pkg = JSON . parse ( readFileSync ( join ( root , 'package.json' ) , 'utf-8' ) ) ;
1371+ expect ( pkg . scripts . dev ) . toBe ( 'vp dev' ) ;
1372+ expect ( pkg . devDependencies [ 'vite-plus' ] ) . toBe ( '^0.1.21' ) ;
1373+ expect ( pkg . devDependencies . void ) . toBe ( '^0.8.9' ) ;
1374+ expect ( readFileSync ( join ( root , 'vite.config.ts' ) , 'utf-8' ) ) . toContain ( 'voidReact()' ) ;
1375+ expectPnpmAllowBuilds ( root ) ;
1376+
1377+ expect ( mockSelect . mock . calls [ 0 ] ?. [ 0 ] . message ) . toBe ( 'Choose a Pages scaffold toolchain:' ) ;
1378+ expect ( mockSelect . mock . calls [ 0 ] ?. [ 0 ] . initialValue ) . toBe ( 'vite-plus' ) ;
1379+ expect ( mockSelect . mock . calls [ 1 ] ?. [ 0 ] . message ) . toBe ( 'Choose a Pages framework to scaffold:' ) ;
1380+ expect ( mockSelect . mock . calls [ 2 ] ?. [ 0 ] . message ) . toBe ( 'Choose a Pages starter:' ) ;
1381+ } finally {
1382+ rmSync ( root , { recursive : true , force : true } ) ;
1383+ }
1384+ } ) ;
1385+
12731386 it ( 'offers to scaffold in a subfolder from a non-project parent directory' , async ( ) => {
12741387 const root = mkdtempSync ( join ( tmpdir ( ) , 'void-init-' ) ) ;
12751388 try {
0 commit comments