create-nx-workspace
Advanced tools
Comparing version 20.4.0-canary.20250124-45847a6 to 20.4.0-canary.20250125-15fc599
@@ -25,2 +25,3 @@ import * as yargs from 'yargs'; | ||
nextSrcDir: boolean; | ||
unitTestRunner: 'none' | 'jest' | 'vitest'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
@@ -35,2 +36,3 @@ } | ||
standaloneApi: boolean; | ||
unitTestRunner: 'none' | 'jest' | 'vitest'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
@@ -48,2 +50,3 @@ bundler: 'webpack' | 'esbuild'; | ||
style: string; | ||
unitTestRunner: 'none' | 'vitest'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
@@ -55,4 +58,5 @@ } | ||
appName: string; | ||
framework: 'express' | 'fastify' | 'koa' | 'nest'; | ||
framework: 'none' | 'express' | 'fastify' | 'koa' | 'nest'; | ||
docker: boolean; | ||
unitTestRunner: 'none' | 'jest'; | ||
} | ||
@@ -59,0 +63,0 @@ interface UnknownStackArguments extends BaseArguments { |
@@ -103,2 +103,7 @@ "use strict"; | ||
}) | ||
.option('unitTestRunner', { | ||
describe: chalk.dim `Test runner to use for unit tests.`, | ||
choices: ['jest', 'vitest', 'none'], | ||
type: 'string', | ||
}) | ||
.option('ssr', { | ||
@@ -427,2 +432,3 @@ describe: chalk.dim `Enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) for the Angular application.`, | ||
let bundler = undefined; | ||
let unitTestRunner = undefined; | ||
let e2eTestRunner = undefined; | ||
@@ -489,2 +495,5 @@ let nextAppDir = false; | ||
bundler = await determineReactBundler(parsedArgs); | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
preferVitest: bundler === 'vite', | ||
}); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
@@ -495,10 +504,20 @@ } | ||
nextSrcDir = await determineNextSrcDir(parsedArgs); | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
exclude: 'vitest', | ||
}); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
} | ||
else if (preset === preset_1.Preset.RemixMonorepo || | ||
preset === preset_1.Preset.RemixStandalone || | ||
preset === preset_1.Preset.ReactNative || | ||
preset === preset_1.Preset.Expo) { | ||
preset === preset_1.Preset.RemixStandalone) { | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
preferVitest: true, | ||
}); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
} | ||
else if (preset === preset_1.Preset.ReactNative || preset === preset_1.Preset.Expo) { | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
exclude: 'vitest', | ||
}); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
} | ||
if (parsedArgs.style) { | ||
@@ -567,2 +586,3 @@ style = parsedArgs.style; | ||
nextSrcDir, | ||
unitTestRunner, | ||
e2eTestRunner, | ||
@@ -578,2 +598,3 @@ linter, | ||
let appName; | ||
let unitTestRunner = undefined; | ||
let e2eTestRunner = undefined; | ||
@@ -620,2 +641,5 @@ let linter; | ||
} | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
exclude: 'jest', | ||
}); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
@@ -667,2 +691,3 @@ if (parsedArgs.style) { | ||
appName, | ||
unitTestRunner, | ||
e2eTestRunner, | ||
@@ -678,2 +703,3 @@ linter, | ||
let appName; | ||
let unitTestRunner = undefined; | ||
let e2eTestRunner = undefined; | ||
@@ -809,2 +835,3 @@ let bundler = undefined; | ||
} | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
@@ -817,2 +844,3 @@ return { | ||
routing, | ||
unitTestRunner, | ||
e2eTestRunner, | ||
@@ -832,2 +860,3 @@ bundler, | ||
let formatter; | ||
let unitTestRunner = undefined; | ||
const workspaces = parsedArgs.workspaces ?? false; | ||
@@ -889,2 +918,5 @@ if (parsedArgs.preset) { | ||
} | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
exclude: 'vitest', | ||
}); | ||
if (workspaces) { | ||
@@ -906,2 +938,3 @@ linter = await determineLinterOptions(parsedArgs); | ||
workspaces, | ||
unitTestRunner, | ||
}; | ||
@@ -1152,2 +1185,46 @@ } | ||
} | ||
async function determineUnitTestRunner(parsedArgs, options) { | ||
if (parsedArgs.unitTestRunner) { | ||
return parsedArgs.unitTestRunner; | ||
} | ||
else if (!parsedArgs.workspaces) { | ||
return undefined; | ||
} | ||
const reply = await enquirer.prompt([ | ||
{ | ||
message: 'Which unit test runner would you like to use?', | ||
type: 'autocomplete', | ||
name: 'unitTestRunner', | ||
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(), | ||
choices: [ | ||
{ | ||
name: 'none', | ||
message: 'None', | ||
}, | ||
{ | ||
name: 'jest', | ||
message: 'Jest [ https://jestjs.io/ ]', | ||
}, | ||
{ | ||
name: 'vitest', | ||
message: 'Vitest [ https://vitest.dev/ ]', | ||
}, | ||
] | ||
.filter((t) => !options?.exclude || options.exclude !== t.name) | ||
.sort((a, b) => { | ||
if (a.name === 'none') | ||
return -1; | ||
if (b.name === 'none') | ||
return 1; | ||
if (options?.preferVitest && a.name === 'vitest') | ||
return -1; | ||
if (options?.preferVitest && b.name === 'vitest') | ||
return 1; | ||
return 0; | ||
}), | ||
initial: 0, | ||
}, | ||
]); | ||
return reply.unitTestRunner; | ||
} | ||
async function determineE2eTestRunner(parsedArgs) { | ||
@@ -1154,0 +1231,0 @@ if (parsedArgs.e2eTestRunner) |
{ | ||
"name": "create-nx-workspace", | ||
"version": "20.4.0-canary.20250124-45847a6", | ||
"version": "20.4.0-canary.20250125-15fc599", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Smart Monorepos · Fast CI", |
114186
3124