create-nx-workspace
Advanced tools
Comparing version 0.0.0-pr-29314-e664f92 to 0.0.0-pr-29408-73bb882
@@ -6,2 +6,5 @@ import * as yargs from 'yargs'; | ||
preset: Preset; | ||
linter?: 'none' | 'eslint'; | ||
formatter?: 'none' | 'prettier'; | ||
workspaces?: boolean; | ||
} | ||
@@ -13,3 +16,2 @@ interface NoneArguments extends BaseArguments { | ||
appName?: string | undefined; | ||
formatter?: 'none' | 'prettier'; | ||
} | ||
@@ -25,6 +27,4 @@ interface ReactArguments extends BaseArguments { | ||
nextSrcDir: boolean; | ||
unitTestRunner: 'none' | 'jest' | 'vitest'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
linter?: 'none' | 'eslint'; | ||
formatter?: 'none' | 'prettier'; | ||
workspaces?: boolean; | ||
} | ||
@@ -38,2 +38,3 @@ interface AngularArguments extends BaseArguments { | ||
standaloneApi: boolean; | ||
unitTestRunner: 'none' | 'jest' | 'vitest'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
@@ -51,2 +52,3 @@ bundler: 'webpack' | 'esbuild'; | ||
style: string; | ||
unitTestRunner: 'none' | 'vitest'; | ||
e2eTestRunner: 'none' | 'cypress' | 'playwright'; | ||
@@ -58,4 +60,5 @@ } | ||
appName: string; | ||
framework: 'express' | 'fastify' | 'koa' | 'nest'; | ||
framework: 'none' | 'express' | 'fastify' | 'koa' | 'nest'; | ||
docker: boolean; | ||
unitTestRunner: 'none' | 'jest'; | ||
} | ||
@@ -62,0 +65,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,3 +598,7 @@ linter, | ||
let appName; | ||
let unitTestRunner = undefined; | ||
let e2eTestRunner = undefined; | ||
let linter; | ||
let formatter; | ||
const workspaces = parsedArgs.workspaces ?? false; | ||
if (parsedArgs.preset && parsedArgs.preset !== preset_1.Preset.Vue) { | ||
@@ -591,3 +615,5 @@ preset = parsedArgs.preset; | ||
const framework = await determineVueFramework(parsedArgs); | ||
const workspaceType = await determineStandaloneOrMonorepo(); | ||
const workspaceType = workspaces | ||
? 'monorepo' | ||
: await determineStandaloneOrMonorepo(); | ||
if (workspaceType === 'standalone') { | ||
@@ -616,2 +642,5 @@ appName = parsedArgs.appName ?? parsedArgs.name; | ||
} | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
exclude: 'jest', | ||
}); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
@@ -651,3 +680,20 @@ if (parsedArgs.style) { | ||
} | ||
return { preset, style, appName, e2eTestRunner }; | ||
if (workspaces) { | ||
linter = await determineLinterOptions(parsedArgs); | ||
formatter = await determineFormatterOptions(parsedArgs); | ||
} | ||
else { | ||
linter = 'eslint'; | ||
formatter = 'prettier'; | ||
} | ||
return { | ||
preset, | ||
style, | ||
appName, | ||
unitTestRunner, | ||
e2eTestRunner, | ||
linter, | ||
formatter, | ||
workspaces, | ||
}; | ||
} | ||
@@ -658,2 +704,3 @@ async function determineAngularOptions(parsedArgs) { | ||
let appName; | ||
let unitTestRunner = undefined; | ||
let e2eTestRunner = undefined; | ||
@@ -789,2 +836,3 @@ let bundler = undefined; | ||
} | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs); | ||
e2eTestRunner = await determineE2eTestRunner(parsedArgs); | ||
@@ -797,2 +845,3 @@ return { | ||
routing, | ||
unitTestRunner, | ||
e2eTestRunner, | ||
@@ -810,2 +859,6 @@ bundler, | ||
let docker; | ||
let linter; | ||
let formatter; | ||
let unitTestRunner = undefined; | ||
const workspaces = parsedArgs.workspaces ?? false; | ||
if (parsedArgs.preset) { | ||
@@ -830,3 +883,5 @@ preset = parsedArgs.preset; | ||
framework = await determineNodeFramework(parsedArgs); | ||
const workspaceType = await determineStandaloneOrMonorepo(); | ||
const workspaceType = workspaces | ||
? 'monorepo' | ||
: await determineStandaloneOrMonorepo(); | ||
if (workspaceType === 'standalone') { | ||
@@ -865,2 +920,13 @@ preset = preset_1.Preset.NodeStandalone; | ||
} | ||
unitTestRunner = await determineUnitTestRunner(parsedArgs, { | ||
exclude: 'vitest', | ||
}); | ||
if (workspaces) { | ||
linter = await determineLinterOptions(parsedArgs); | ||
formatter = await determineFormatterOptions(parsedArgs); | ||
} | ||
else { | ||
linter = 'eslint'; | ||
formatter = 'prettier'; | ||
} | ||
return { | ||
@@ -871,2 +937,6 @@ preset, | ||
docker, | ||
linter, | ||
formatter, | ||
workspaces, | ||
unitTestRunner, | ||
}; | ||
@@ -1117,2 +1187,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) { | ||
@@ -1119,0 +1233,0 @@ if (parsedArgs.e2eTestRunner) |
{ | ||
"name": "create-nx-workspace", | ||
"version": "0.0.0-pr-29314-e664f92", | ||
"version": "0.0.0-pr-29408-73bb882", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Smart Monorepos · Fast CI", |
@@ -83,6 +83,6 @@ "use strict"; | ||
case preset_1.Preset.WebComponents: | ||
return ['apps/**', 'packages/**']; | ||
return ['apps/*']; | ||
default: | ||
return ['packages/**']; | ||
return ['packages/*']; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
114178
3124