create-nx-workspace 23.2.0-beta.6 → 23.2.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/create-nx-workspace.d.ts +7 -2
- package/dist/bin/create-nx-workspace.js +345 -503
- package/dist/internal.d.ts +3 -1
- package/dist/internal.js +7 -1
- package/dist/src/create-workspace.js +2 -3
- package/dist/src/internal-utils/prompt-helpers.d.ts +57 -0
- package/dist/src/internal-utils/prompt-helpers.js +105 -0
- package/dist/src/internal-utils/prompts.d.ts +10 -0
- package/dist/src/internal-utils/prompts.js +114 -117
- package/dist/src/utils/error-utils.d.ts +1 -1
- package/dist/src/utils/exit-codes.d.ts +12 -0
- package/dist/src/utils/exit-codes.js +24 -0
- package/dist/src/utils/git/git.js +29 -30
- package/dist/src/utils/nx/ab-testing.d.ts +0 -1
- package/dist/src/utils/nx/ab-testing.js +4 -2
- package/package.json +2 -2
|
@@ -6,8 +6,8 @@ exports.isValidWorkspaceName = isValidWorkspaceName;
|
|
|
6
6
|
exports.validateWorkspaceName = validateWorkspaceName;
|
|
7
7
|
exports.resolveSpecialFolderName = resolveSpecialFolderName;
|
|
8
8
|
exports.determineFolder = determineFolder;
|
|
9
|
+
exports.determinePresetOptions = determinePresetOptions;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
|
-
const enquirer_1 = tslib_1.__importDefault(require("enquirer"));
|
|
11
11
|
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
12
12
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
13
13
|
const create_workspace_options_1 = require("../src/create-workspace-options");
|
|
@@ -22,9 +22,11 @@ const prompts_1 = require("../src/internal-utils/prompts");
|
|
|
22
22
|
const yargs_options_1 = require("../src/internal-utils/yargs-options");
|
|
23
23
|
const ab_testing_1 = require("../src/utils/nx/ab-testing");
|
|
24
24
|
const error_utils_1 = require("../src/utils/error-utils");
|
|
25
|
+
const exit_codes_1 = require("../src/utils/exit-codes");
|
|
25
26
|
const fs_1 = require("fs");
|
|
26
27
|
const path_1 = require("path");
|
|
27
28
|
const is_ci_1 = require("../src/utils/ci/is-ci");
|
|
29
|
+
const prompt_helpers_1 = require("../src/internal-utils/prompt-helpers");
|
|
28
30
|
const git_1 = require("../src/utils/git/git");
|
|
29
31
|
const ai_output_1 = require("../src/utils/ai/ai-output");
|
|
30
32
|
function extractErrorFile(error) {
|
|
@@ -117,6 +119,15 @@ exports.commandsObject = yargs_1.default
|
|
|
117
119
|
.option('formatter', {
|
|
118
120
|
describe: chalk_1.default.dim `Code formatter to use.`,
|
|
119
121
|
type: 'string',
|
|
122
|
+
})
|
|
123
|
+
// `choices` is load-bearing, not documentation: `determineLinterOptions`
|
|
124
|
+
// returns `--linter` as-is and nothing downstream validates it — the
|
|
125
|
+
// `new`/`preset` schemas declare no enum — so a typo would surface only
|
|
126
|
+
// as an `Unsupported linter` throw partway through scaffolding.
|
|
127
|
+
.option('linter', {
|
|
128
|
+
describe: chalk_1.default.dim `Linter to use.`,
|
|
129
|
+
choices: [...prompts_1.LINTERS],
|
|
130
|
+
type: 'string',
|
|
120
131
|
})
|
|
121
132
|
.option('framework', {
|
|
122
133
|
describe: chalk_1.default.dim `Framework option to be used with certain stacks.`,
|
|
@@ -199,8 +210,10 @@ else {
|
|
|
199
210
|
exports.commandsObject.epilogue(`${chalk_1.default.cyan('Documentation:')}
|
|
200
211
|
https://nx.dev/getting-started/intro`);
|
|
201
212
|
}
|
|
202
|
-
// Node 24
|
|
203
|
-
//
|
|
213
|
+
// Node 24's stricter readline throws ERR_USE_AFTER_CLOSE when a prompt library
|
|
214
|
+
// operates on a closed interface. Added for enquirer, which this package no
|
|
215
|
+
// longer uses; verify against Node 24 before removing.
|
|
216
|
+
// TODO(v24): drop if @clack/prompts proves not to need it.
|
|
204
217
|
process.on('uncaughtException', (error) => {
|
|
205
218
|
if (error &&
|
|
206
219
|
typeof error === 'object' &&
|
|
@@ -240,7 +253,7 @@ process.on('SIGINT', async () => {
|
|
|
240
253
|
],
|
|
241
254
|
});
|
|
242
255
|
}
|
|
243
|
-
|
|
256
|
+
(0, exit_codes_1.exitAsInterrupted)();
|
|
244
257
|
});
|
|
245
258
|
let rawArgs;
|
|
246
259
|
async function main(parsedArgs) {
|
|
@@ -311,6 +324,11 @@ async function handleError(error) {
|
|
|
311
324
|
aiAgent: (0, ai_output_1.isAiAgent)(),
|
|
312
325
|
},
|
|
313
326
|
});
|
|
327
|
+
// Cancelling is not a failure: no "Failed to create workspace" banner, and
|
|
328
|
+
// the process ends as interrupted rather than with a generic error code.
|
|
329
|
+
if (error instanceof error_utils_1.CnwError && error.code === 'CANCELLED') {
|
|
330
|
+
(0, exit_codes_1.exitAsInterrupted)();
|
|
331
|
+
}
|
|
314
332
|
// Output error in appropriate format
|
|
315
333
|
if ((0, ai_output_1.isAiAgent)()) {
|
|
316
334
|
const errorCode = error instanceof error_utils_1.CnwError ? error.code : 'UNKNOWN';
|
|
@@ -591,10 +609,6 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
591
609
|
if (e instanceof error_utils_1.CnwError) {
|
|
592
610
|
throw e;
|
|
593
611
|
}
|
|
594
|
-
// Enquirer throws an empty string when user presses Ctrl+C
|
|
595
|
-
if (e === '') {
|
|
596
|
-
process.exit(130);
|
|
597
|
-
}
|
|
598
612
|
const message = e instanceof Error ? e.message : String(e);
|
|
599
613
|
throw new error_utils_1.CnwError('UNKNOWN', message);
|
|
600
614
|
}
|
|
@@ -717,24 +731,15 @@ async function determineFolder(parsedArgs) {
|
|
|
717
731
|
return promptForFolder(parsedArgs);
|
|
718
732
|
}
|
|
719
733
|
async function promptCreateInCurrentDir(dirName) {
|
|
720
|
-
|
|
721
|
-
{
|
|
722
|
-
|
|
723
|
-
message: `Create workspace in the current directory (${dirName})? Existing files may be overwritten.`,
|
|
724
|
-
type: 'autocomplete',
|
|
725
|
-
choices: [{ name: 'Yes' }, { name: 'No' }],
|
|
726
|
-
initial: 0,
|
|
727
|
-
},
|
|
728
|
-
]);
|
|
729
|
-
return useCurrentDir === 'Yes';
|
|
734
|
+
return (0, prompt_helpers_1.confirmationPrompt)({
|
|
735
|
+
message: `Create workspace in the current directory (${dirName})? Existing files may be overwritten.`,
|
|
736
|
+
});
|
|
730
737
|
}
|
|
731
738
|
async function promptForFolder(parsedArgs) {
|
|
732
|
-
const reply =
|
|
733
|
-
{
|
|
734
|
-
name: 'folderName',
|
|
739
|
+
const reply = {
|
|
740
|
+
folderName: await (0, prompt_helpers_1.textPrompt)({
|
|
735
741
|
message: `Where would you like to create your workspace?`,
|
|
736
|
-
|
|
737
|
-
type: 'input',
|
|
742
|
+
initialValue: 'org',
|
|
738
743
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
739
744
|
validate: (value) => {
|
|
740
745
|
if (!value) {
|
|
@@ -746,10 +751,10 @@ async function promptForFolder(parsedArgs) {
|
|
|
746
751
|
if ((0, fs_1.existsSync)(value)) {
|
|
747
752
|
return `The directory '${value}' already exists`;
|
|
748
753
|
}
|
|
749
|
-
return
|
|
754
|
+
return undefined;
|
|
750
755
|
},
|
|
751
|
-
},
|
|
752
|
-
|
|
756
|
+
}),
|
|
757
|
+
};
|
|
753
758
|
// Fallback invariants in case validate is bypassed (e.g., in CI or non-interactive mode)
|
|
754
759
|
invariant(reply.folderName, 'INVALID_FOLDER_NAME', 'Folder name cannot be empty');
|
|
755
760
|
validateWorkspaceName(reply.folderName);
|
|
@@ -788,41 +793,33 @@ async function determineStack(parsedArgs) {
|
|
|
788
793
|
case preset_1.Preset.TsStandalone:
|
|
789
794
|
return 'none';
|
|
790
795
|
case preset_1.Preset.WebComponents:
|
|
796
|
+
return 'web';
|
|
791
797
|
default:
|
|
792
798
|
return 'unknown';
|
|
793
799
|
}
|
|
794
800
|
}
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
message: `Angular: Configures a Angular application with modern tooling.`,
|
|
818
|
-
},
|
|
819
|
-
{
|
|
820
|
-
name: `node`,
|
|
821
|
-
message: `Node: Configures a Node API application with your framework of choice.`,
|
|
822
|
-
},
|
|
823
|
-
],
|
|
824
|
-
},
|
|
825
|
-
]);
|
|
801
|
+
const stack = await (0, prompt_helpers_1.selectPrompt)({
|
|
802
|
+
message: `Which stack do you want to use?`,
|
|
803
|
+
choices: [
|
|
804
|
+
{ value: `none` },
|
|
805
|
+
{
|
|
806
|
+
value: `react`,
|
|
807
|
+
label: `React: Configures a React application with your framework of choice.`,
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
value: `vue`,
|
|
811
|
+
label: `Vue: Configures a Vue application with your framework of choice.`,
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
value: `angular`,
|
|
815
|
+
label: `Angular: Configures a Angular application with modern tooling.`,
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
value: `node`,
|
|
819
|
+
label: `Node: Configures a Node API application with your framework of choice.`,
|
|
820
|
+
},
|
|
821
|
+
],
|
|
822
|
+
});
|
|
826
823
|
return stack;
|
|
827
824
|
}
|
|
828
825
|
async function determinePresetOptions(parsedArgs) {
|
|
@@ -837,51 +834,32 @@ async function determinePresetOptions(parsedArgs) {
|
|
|
837
834
|
return determineVueOptions(parsedArgs);
|
|
838
835
|
case 'node':
|
|
839
836
|
return determineNodeOptions(parsedArgs);
|
|
837
|
+
case 'web':
|
|
838
|
+
return determineWebOptions(parsedArgs);
|
|
840
839
|
default:
|
|
841
840
|
return parsedArgs;
|
|
842
841
|
}
|
|
843
842
|
}
|
|
843
|
+
/**
|
|
844
|
+
* `web-components` prompts for nothing of its own — `style` and `e2eTestRunner`
|
|
845
|
+
* come from the CLI or fall back downstream — but the preset does generate a
|
|
846
|
+
* lintable app, so it still needs a linter.
|
|
847
|
+
*/
|
|
848
|
+
async function determineWebOptions(parsedArgs) {
|
|
849
|
+
return { linter: await (0, prompts_1.determineLinterOptions)(parsedArgs) };
|
|
850
|
+
}
|
|
844
851
|
async function determineFormatterOptions(args, opts) {
|
|
845
852
|
if (args.formatter)
|
|
846
853
|
return args.formatter;
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
{
|
|
857
|
-
name: 'No',
|
|
858
|
-
},
|
|
859
|
-
],
|
|
860
|
-
initial: opts?.preferPrettier ? 0 : 1,
|
|
861
|
-
skip: !args.interactive || (0, is_ci_1.isCI)(),
|
|
862
|
-
},
|
|
863
|
-
]);
|
|
864
|
-
return reply.prettier === 'Yes' ? 'prettier' : 'none';
|
|
865
|
-
}
|
|
866
|
-
async function determineLinterOptions(args, opts) {
|
|
867
|
-
const reply = await enquirer_1.default.prompt([
|
|
868
|
-
{
|
|
869
|
-
name: 'eslint',
|
|
870
|
-
message: `Would you like to use ESLint?`,
|
|
871
|
-
type: 'autocomplete',
|
|
872
|
-
choices: [
|
|
873
|
-
{
|
|
874
|
-
name: 'Yes',
|
|
875
|
-
},
|
|
876
|
-
{
|
|
877
|
-
name: 'No',
|
|
878
|
-
},
|
|
879
|
-
],
|
|
880
|
-
initial: opts?.preferEslint ? 0 : 1,
|
|
881
|
-
skip: !args.interactive || (0, is_ci_1.isCI)(),
|
|
882
|
-
},
|
|
883
|
-
]);
|
|
884
|
-
return reply.eslint === 'Yes' ? 'eslint' : 'none';
|
|
854
|
+
// A skipped run answers yes regardless of `preferPrettier`, which only moves
|
|
855
|
+
// the highlighted option when the prompt is shown.
|
|
856
|
+
const usePrettier = await (0, prompt_helpers_1.confirmationPrompt)({
|
|
857
|
+
message: `Would you like to use Prettier for code formatting?`,
|
|
858
|
+
initial: opts?.preferPrettier ?? false,
|
|
859
|
+
skip: !args.interactive || (0, is_ci_1.isCI)(),
|
|
860
|
+
skippedValue: true,
|
|
861
|
+
});
|
|
862
|
+
return usePrettier ? 'prettier' : 'none';
|
|
885
863
|
}
|
|
886
864
|
async function determineNoneOptions(parsedArgs) {
|
|
887
865
|
if ((!parsedArgs.preset || parsedArgs.preset === preset_1.Preset.TS) &&
|
|
@@ -921,26 +899,21 @@ async function determineNoneOptions(parsedArgs) {
|
|
|
921
899
|
else if (preset === preset_1.Preset.TsStandalone) {
|
|
922
900
|
// Only standalone TS preset generates a default package, so we need to provide --js and --appName options.
|
|
923
901
|
appName = parsedArgs.name;
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
choices: [
|
|
930
|
-
{
|
|
931
|
-
name: 'Yes',
|
|
932
|
-
},
|
|
933
|
-
{
|
|
934
|
-
name: 'No',
|
|
935
|
-
},
|
|
936
|
-
],
|
|
937
|
-
initial: 0,
|
|
938
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
939
|
-
},
|
|
940
|
-
]);
|
|
941
|
-
js = reply.ts === 'No';
|
|
902
|
+
js = !(await (0, prompt_helpers_1.confirmationPrompt)({
|
|
903
|
+
message: `Would you like to use TypeScript with this project?`,
|
|
904
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
905
|
+
skippedValue: true,
|
|
906
|
+
}));
|
|
942
907
|
}
|
|
943
|
-
|
|
908
|
+
// `ts-standalone` is the only preset on this stack that generates a
|
|
909
|
+
// lintable project; `apps`, `ts` and `npm` reach no generator that takes a
|
|
910
|
+
// linter, so asking would discard the answer.
|
|
911
|
+
const linter = preset === preset_1.Preset.TsStandalone
|
|
912
|
+
? await (0, prompts_1.determineLinterOptions)(parsedArgs)
|
|
913
|
+
: undefined;
|
|
914
|
+
// Omitted rather than set to `undefined`: the caller `Object.assign`s this
|
|
915
|
+
// over `argv`, so an explicit key would clobber a user's `--linter`.
|
|
916
|
+
return { preset, js, appName, ...(linter ? { linter } : {}) };
|
|
944
917
|
}
|
|
945
918
|
}
|
|
946
919
|
async function determineReactOptions(parsedArgs) {
|
|
@@ -1004,24 +977,10 @@ async function determineReactOptions(parsedArgs) {
|
|
|
1004
977
|
}
|
|
1005
978
|
if (preset === preset_1.Preset.ReactStandalone || preset === preset_1.Preset.ReactMonorepo) {
|
|
1006
979
|
bundler = useReactRouter ? 'vite' : await determineReactBundler(parsedArgs);
|
|
1007
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1008
|
-
preferVitest: bundler === 'vite',
|
|
1009
|
-
});
|
|
1010
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1011
980
|
}
|
|
1012
981
|
else if (preset === preset_1.Preset.NextJs || preset === preset_1.Preset.NextJsStandalone) {
|
|
1013
982
|
nextAppDir = await determineNextAppDir(parsedArgs);
|
|
1014
983
|
nextSrcDir = await determineNextSrcDir(parsedArgs);
|
|
1015
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1016
|
-
exclude: 'vitest',
|
|
1017
|
-
});
|
|
1018
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1019
|
-
}
|
|
1020
|
-
else if (preset === preset_1.Preset.ReactNative || preset === preset_1.Preset.Expo) {
|
|
1021
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1022
|
-
exclude: 'vitest',
|
|
1023
|
-
});
|
|
1024
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1025
984
|
}
|
|
1026
985
|
if (parsedArgs.style) {
|
|
1027
986
|
style = parsedArgs.style;
|
|
@@ -1030,51 +989,62 @@ async function determineReactOptions(parsedArgs) {
|
|
|
1030
989
|
preset === preset_1.Preset.ReactMonorepo ||
|
|
1031
990
|
preset === preset_1.Preset.NextJs ||
|
|
1032
991
|
preset === preset_1.Preset.NextJsStandalone) {
|
|
1033
|
-
const reply =
|
|
1034
|
-
{
|
|
1035
|
-
name: 'style',
|
|
992
|
+
const reply = {
|
|
993
|
+
style: await (0, prompt_helpers_1.selectPrompt)({
|
|
1036
994
|
message: `Default stylesheet format`,
|
|
1037
|
-
initial: 0,
|
|
1038
|
-
type: 'autocomplete',
|
|
1039
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1040
995
|
choices: [
|
|
996
|
+
{ value: 'css', label: 'CSS' },
|
|
1041
997
|
{
|
|
1042
|
-
|
|
1043
|
-
|
|
998
|
+
value: 'scss',
|
|
999
|
+
label: 'SASS(.scss) [ https://sass-lang.com ]',
|
|
1044
1000
|
},
|
|
1045
1001
|
{
|
|
1046
|
-
|
|
1047
|
-
|
|
1002
|
+
value: 'less',
|
|
1003
|
+
label: 'LESS [ https://lesscss.org ]',
|
|
1048
1004
|
},
|
|
1049
1005
|
{
|
|
1050
|
-
|
|
1051
|
-
|
|
1006
|
+
value: 'styled-components',
|
|
1007
|
+
label: 'styled-components [ https://styled-components.com ]',
|
|
1052
1008
|
},
|
|
1053
1009
|
{
|
|
1054
|
-
|
|
1055
|
-
|
|
1010
|
+
value: '@emotion/styled',
|
|
1011
|
+
label: 'emotion [ https://emotion.sh ]',
|
|
1056
1012
|
},
|
|
1057
1013
|
{
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
},
|
|
1061
|
-
{
|
|
1062
|
-
name: 'styled-jsx',
|
|
1063
|
-
message: 'styled-jsx [ https://www.npmjs.com/package/styled-jsx ]',
|
|
1014
|
+
value: 'styled-jsx',
|
|
1015
|
+
label: 'styled-jsx [ https://www.npmjs.com/package/styled-jsx ]',
|
|
1064
1016
|
},
|
|
1065
1017
|
],
|
|
1066
|
-
|
|
1067
|
-
|
|
1018
|
+
initial: 'css',
|
|
1019
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1020
|
+
}),
|
|
1021
|
+
};
|
|
1068
1022
|
style = reply.style;
|
|
1069
1023
|
}
|
|
1024
|
+
// Asked outside the gate: the linter is independent of package-manager
|
|
1025
|
+
// workspaces, and `--no-workspaces` used to force ESLint without asking.
|
|
1026
|
+
linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1027
|
+
if (preset === preset_1.Preset.ReactStandalone || preset === preset_1.Preset.ReactMonorepo) {
|
|
1028
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1029
|
+
preferVitest: bundler === 'vite',
|
|
1030
|
+
});
|
|
1031
|
+
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1032
|
+
}
|
|
1033
|
+
else if (preset === preset_1.Preset.NextJs ||
|
|
1034
|
+
preset === preset_1.Preset.NextJsStandalone ||
|
|
1035
|
+
preset === preset_1.Preset.ReactNative ||
|
|
1036
|
+
preset === preset_1.Preset.Expo) {
|
|
1037
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1038
|
+
exclude: 'vitest',
|
|
1039
|
+
});
|
|
1040
|
+
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1041
|
+
}
|
|
1070
1042
|
if (workspaces) {
|
|
1071
|
-
linter = await determineLinterOptions(parsedArgs, { preferEslint: true });
|
|
1072
1043
|
formatter = await determineFormatterOptions(parsedArgs, {
|
|
1073
1044
|
preferPrettier: true,
|
|
1074
1045
|
});
|
|
1075
1046
|
}
|
|
1076
1047
|
else {
|
|
1077
|
-
linter = 'eslint';
|
|
1078
1048
|
formatter = 'prettier';
|
|
1079
1049
|
}
|
|
1080
1050
|
return {
|
|
@@ -1139,51 +1109,44 @@ async function determineVueOptions(parsedArgs) {
|
|
|
1139
1109
|
}
|
|
1140
1110
|
}
|
|
1141
1111
|
}
|
|
1142
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1143
|
-
exclude: 'jest',
|
|
1144
|
-
});
|
|
1145
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1146
1112
|
if (parsedArgs.style) {
|
|
1147
1113
|
style = parsedArgs.style;
|
|
1148
1114
|
}
|
|
1149
1115
|
else {
|
|
1150
|
-
const reply =
|
|
1151
|
-
{
|
|
1152
|
-
name: 'style',
|
|
1116
|
+
const reply = {
|
|
1117
|
+
style: await (0, prompt_helpers_1.selectPrompt)({
|
|
1153
1118
|
message: `Default stylesheet format`,
|
|
1154
|
-
initial: 0,
|
|
1155
|
-
type: 'autocomplete',
|
|
1156
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1157
1119
|
choices: [
|
|
1120
|
+
{ value: 'css', label: 'CSS' },
|
|
1158
1121
|
{
|
|
1159
|
-
|
|
1160
|
-
|
|
1122
|
+
value: 'scss',
|
|
1123
|
+
label: 'SASS(.scss) [ https://sass-lang.com ]',
|
|
1161
1124
|
},
|
|
1162
1125
|
{
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
},
|
|
1166
|
-
{
|
|
1167
|
-
name: 'less',
|
|
1168
|
-
message: 'LESS [ https://lesscss.org ]',
|
|
1169
|
-
},
|
|
1170
|
-
{
|
|
1171
|
-
name: 'none',
|
|
1172
|
-
message: 'None',
|
|
1126
|
+
value: 'less',
|
|
1127
|
+
label: 'LESS [ https://lesscss.org ]',
|
|
1173
1128
|
},
|
|
1129
|
+
{ value: 'none', label: 'None' },
|
|
1174
1130
|
],
|
|
1175
|
-
|
|
1176
|
-
|
|
1131
|
+
initial: 'css',
|
|
1132
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1133
|
+
}),
|
|
1134
|
+
};
|
|
1177
1135
|
style = reply.style;
|
|
1178
1136
|
}
|
|
1137
|
+
// Asked outside the gate: the linter is independent of package-manager
|
|
1138
|
+
// workspaces, and `--no-workspaces` used to force ESLint without asking.
|
|
1139
|
+
linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1140
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1141
|
+
exclude: 'jest',
|
|
1142
|
+
});
|
|
1143
|
+
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1179
1144
|
if (workspaces) {
|
|
1180
|
-
linter = await determineLinterOptions(parsedArgs, { preferEslint: true });
|
|
1181
1145
|
formatter = await determineFormatterOptions(parsedArgs, {
|
|
1182
1146
|
preferPrettier: true,
|
|
1183
1147
|
});
|
|
1184
1148
|
}
|
|
1185
1149
|
else {
|
|
1186
|
-
linter = 'eslint';
|
|
1187
1150
|
formatter = 'prettier';
|
|
1188
1151
|
}
|
|
1189
1152
|
return {
|
|
@@ -1245,78 +1208,63 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1245
1208
|
bundler = parsedArgs.bundler;
|
|
1246
1209
|
}
|
|
1247
1210
|
else {
|
|
1248
|
-
const reply =
|
|
1249
|
-
{
|
|
1250
|
-
name: 'bundler',
|
|
1211
|
+
const reply = {
|
|
1212
|
+
bundler: await (0, prompt_helpers_1.selectPrompt)({
|
|
1251
1213
|
message: `Which bundler would you like to use?`,
|
|
1252
|
-
type: 'autocomplete',
|
|
1253
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1254
1214
|
choices: [
|
|
1255
|
-
{
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
},
|
|
1259
|
-
{
|
|
1260
|
-
name: 'rspack',
|
|
1261
|
-
message: 'Rspack [ https://rspack.dev/ ]',
|
|
1262
|
-
},
|
|
1263
|
-
{
|
|
1264
|
-
name: 'webpack',
|
|
1265
|
-
message: 'Webpack [ https://webpack.js.org/ ]',
|
|
1266
|
-
},
|
|
1215
|
+
{ value: 'esbuild', label: 'esbuild [ https://esbuild.github.io/ ]' },
|
|
1216
|
+
{ value: 'rspack', label: 'Rspack [ https://rspack.dev/ ]' },
|
|
1217
|
+
{ value: 'webpack', label: 'Webpack [ https://webpack.js.org/ ]' },
|
|
1267
1218
|
],
|
|
1268
|
-
initial:
|
|
1269
|
-
|
|
1270
|
-
|
|
1219
|
+
initial: 'esbuild',
|
|
1220
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1221
|
+
}),
|
|
1222
|
+
};
|
|
1271
1223
|
bundler = reply.bundler;
|
|
1272
1224
|
}
|
|
1273
1225
|
if (parsedArgs.style) {
|
|
1274
1226
|
style = parsedArgs.style;
|
|
1275
1227
|
}
|
|
1276
1228
|
else {
|
|
1277
|
-
const reply =
|
|
1278
|
-
{
|
|
1279
|
-
name: 'style',
|
|
1229
|
+
const reply = {
|
|
1230
|
+
style: await (0, prompt_helpers_1.selectPrompt)({
|
|
1280
1231
|
message: `Default stylesheet format`,
|
|
1281
|
-
initial: 0,
|
|
1282
|
-
type: 'autocomplete',
|
|
1283
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1284
1232
|
choices: [
|
|
1233
|
+
{ value: 'css', label: 'CSS' },
|
|
1285
1234
|
{
|
|
1286
|
-
|
|
1287
|
-
|
|
1235
|
+
value: 'scss',
|
|
1236
|
+
label: 'SASS(.scss) [ https://sass-lang.com ]',
|
|
1288
1237
|
},
|
|
1289
1238
|
{
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
},
|
|
1293
|
-
{
|
|
1294
|
-
name: 'less',
|
|
1295
|
-
message: 'LESS [ https://lesscss.org ]',
|
|
1239
|
+
value: 'less',
|
|
1240
|
+
label: 'LESS [ https://lesscss.org ]',
|
|
1296
1241
|
},
|
|
1297
1242
|
],
|
|
1298
|
-
|
|
1299
|
-
|
|
1243
|
+
initial: 'css',
|
|
1244
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1245
|
+
}),
|
|
1246
|
+
};
|
|
1300
1247
|
style = reply.style;
|
|
1301
1248
|
}
|
|
1302
1249
|
if (parsedArgs.ssr !== undefined) {
|
|
1303
1250
|
ssr = parsedArgs.ssr;
|
|
1304
1251
|
}
|
|
1305
1252
|
else {
|
|
1306
|
-
const reply =
|
|
1307
|
-
{
|
|
1308
|
-
name: 'ssr',
|
|
1253
|
+
const reply = {
|
|
1254
|
+
ssr: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1309
1255
|
message: `Do you want to enable Server-Side Rendering (SSR)${bundler !== 'rspack'
|
|
1310
1256
|
? ' and Static Site Generation (SSG/Prerendering)?'
|
|
1311
1257
|
: '?'}`,
|
|
1312
|
-
|
|
1313
|
-
choices: [{ name: 'Yes' }, { name: 'No' }],
|
|
1314
|
-
initial: 1,
|
|
1258
|
+
initial: false,
|
|
1315
1259
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1316
|
-
|
|
1317
|
-
|
|
1260
|
+
skippedValue: true,
|
|
1261
|
+
}))
|
|
1262
|
+
? 'Yes'
|
|
1263
|
+
: 'No',
|
|
1264
|
+
};
|
|
1318
1265
|
ssr = reply.ssr === 'Yes';
|
|
1319
1266
|
}
|
|
1267
|
+
const linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1320
1268
|
if (parsedArgs.unitTestRunner) {
|
|
1321
1269
|
unitTestRunner = parsedArgs.unitTestRunner;
|
|
1322
1270
|
}
|
|
@@ -1324,39 +1272,32 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1324
1272
|
unitTestRunner = undefined;
|
|
1325
1273
|
}
|
|
1326
1274
|
else {
|
|
1327
|
-
unitTestRunner = await
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
message: 'None',
|
|
1354
|
-
},
|
|
1355
|
-
],
|
|
1356
|
-
initial: 0,
|
|
1357
|
-
},
|
|
1358
|
-
])
|
|
1359
|
-
.then((r) => r.unitTestRunner);
|
|
1275
|
+
unitTestRunner = (await (0, prompt_helpers_1.selectPrompt)({
|
|
1276
|
+
message: 'Which unit test runner would you like to use?',
|
|
1277
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1278
|
+
choices: [
|
|
1279
|
+
...(bundler === 'esbuild'
|
|
1280
|
+
? [
|
|
1281
|
+
{
|
|
1282
|
+
value: 'vitest-angular',
|
|
1283
|
+
label: 'Vitest & Angular [ https://vitest.dev/ & https://angular.dev ]',
|
|
1284
|
+
},
|
|
1285
|
+
]
|
|
1286
|
+
: []),
|
|
1287
|
+
{
|
|
1288
|
+
value: 'vitest-analog',
|
|
1289
|
+
label: 'Vitest & Analog [ https://vitest.dev/ & https://analogjs.org/ ]',
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
value: 'jest',
|
|
1293
|
+
label: 'Jest [ https://jestjs.io/ ]',
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
value: 'none',
|
|
1297
|
+
label: 'None',
|
|
1298
|
+
},
|
|
1299
|
+
],
|
|
1300
|
+
}));
|
|
1360
1301
|
}
|
|
1361
1302
|
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1362
1303
|
return {
|
|
@@ -1371,6 +1312,7 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1371
1312
|
ssr,
|
|
1372
1313
|
prefix,
|
|
1373
1314
|
zoneless,
|
|
1315
|
+
linter,
|
|
1374
1316
|
};
|
|
1375
1317
|
}
|
|
1376
1318
|
async function determineNodeOptions(parsedArgs) {
|
|
@@ -1417,37 +1359,30 @@ async function determineNodeOptions(parsedArgs) {
|
|
|
1417
1359
|
docker = parsedArgs.docker;
|
|
1418
1360
|
}
|
|
1419
1361
|
else {
|
|
1420
|
-
const reply =
|
|
1421
|
-
{
|
|
1422
|
-
name: 'docker',
|
|
1362
|
+
const reply = {
|
|
1363
|
+
docker: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1423
1364
|
message: 'Would you like to generate a Dockerfile? [https://docs.docker.com/]',
|
|
1424
|
-
|
|
1365
|
+
initial: false,
|
|
1425
1366
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
{
|
|
1432
|
-
name: 'No',
|
|
1433
|
-
},
|
|
1434
|
-
],
|
|
1435
|
-
initial: 1,
|
|
1436
|
-
},
|
|
1437
|
-
]);
|
|
1367
|
+
skippedValue: true,
|
|
1368
|
+
}))
|
|
1369
|
+
? 'Yes'
|
|
1370
|
+
: 'No',
|
|
1371
|
+
};
|
|
1438
1372
|
docker = reply.docker === 'Yes';
|
|
1439
1373
|
}
|
|
1374
|
+
// Asked outside the gate: the linter is independent of package-manager
|
|
1375
|
+
// workspaces, and `--no-workspaces` used to force ESLint without asking.
|
|
1376
|
+
linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1440
1377
|
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1441
1378
|
exclude: 'vitest',
|
|
1442
1379
|
});
|
|
1443
1380
|
if (workspaces) {
|
|
1444
|
-
linter = await determineLinterOptions(parsedArgs, { preferEslint: true });
|
|
1445
1381
|
formatter = await determineFormatterOptions(parsedArgs, {
|
|
1446
1382
|
preferPrettier: true,
|
|
1447
1383
|
});
|
|
1448
1384
|
}
|
|
1449
1385
|
else {
|
|
1450
|
-
linter = 'eslint';
|
|
1451
1386
|
formatter = 'prettier';
|
|
1452
1387
|
}
|
|
1453
1388
|
return {
|
|
@@ -1462,65 +1397,56 @@ async function determineNodeOptions(parsedArgs) {
|
|
|
1462
1397
|
};
|
|
1463
1398
|
}
|
|
1464
1399
|
async function determinePackageBasedOrIntegratedOrStandalone() {
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
},
|
|
1484
|
-
],
|
|
1485
|
-
},
|
|
1486
|
-
]);
|
|
1400
|
+
const workspaceType = await (0, prompt_helpers_1.selectPrompt)({
|
|
1401
|
+
message: `Package-based monorepo, integrated monorepo, or standalone project?`,
|
|
1402
|
+
choices: [
|
|
1403
|
+
{
|
|
1404
|
+
value: 'package-based',
|
|
1405
|
+
label: 'Package-based Monorepo: Nx makes it fast, but lets you run things your way.',
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
value: 'integrated',
|
|
1409
|
+
label: 'Integrated Monorepo: Nx creates a monorepo that contains multiple projects.',
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
value: 'standalone',
|
|
1413
|
+
label: 'Standalone: Nx creates a single project and makes it fast.',
|
|
1414
|
+
},
|
|
1415
|
+
],
|
|
1416
|
+
initial: 'package-based',
|
|
1417
|
+
});
|
|
1487
1418
|
invariant(workspaceType, 'INVALID_WORKSPACE_TYPE', `Invalid workspace type. It must be one of the following: standalone, integrated. Got ${workspaceType}`);
|
|
1488
1419
|
return workspaceType;
|
|
1489
1420
|
}
|
|
1490
1421
|
async function determineStandaloneOrMonorepo() {
|
|
1491
|
-
const
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
},
|
|
1506
|
-
],
|
|
1507
|
-
},
|
|
1508
|
-
]);
|
|
1422
|
+
const workspaceType = await (0, prompt_helpers_1.selectPrompt)({
|
|
1423
|
+
message: `Integrated monorepo, or standalone project?`,
|
|
1424
|
+
choices: [
|
|
1425
|
+
{
|
|
1426
|
+
value: 'integrated',
|
|
1427
|
+
label: 'Integrated Monorepo: Nx creates a monorepo that contains multiple projects.',
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
value: 'standalone',
|
|
1431
|
+
label: 'Standalone: Nx creates a single project and makes it fast.',
|
|
1432
|
+
},
|
|
1433
|
+
],
|
|
1434
|
+
initial: 'standalone',
|
|
1435
|
+
});
|
|
1509
1436
|
invariant(workspaceType, 'INVALID_WORKSPACE_TYPE', `Invalid workspace type. It must be one of the following: standalone, integrated. Got ${workspaceType}`);
|
|
1510
1437
|
return workspaceType;
|
|
1511
1438
|
}
|
|
1512
1439
|
async function determineAppName(parsedArgs) {
|
|
1513
1440
|
if (parsedArgs.appName)
|
|
1514
1441
|
return parsedArgs.appName;
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
]);
|
|
1442
|
+
const appName = await (0, prompt_helpers_1.textPrompt)({
|
|
1443
|
+
message: `Application name`,
|
|
1444
|
+
initialValue: parsedArgs.name,
|
|
1445
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1446
|
+
// Reject here so clearing the field re-prompts. The invariant below still
|
|
1447
|
+
// guards the skipped path, where no validator runs.
|
|
1448
|
+
validate: (value) => value.trim() ? undefined : 'Application name cannot be empty',
|
|
1449
|
+
});
|
|
1524
1450
|
invariant(appName, 'INVALID_APP_NAME', 'App name cannot be empty');
|
|
1525
1451
|
return appName;
|
|
1526
1452
|
}
|
|
@@ -1531,166 +1457,105 @@ async function determineReactFramework(parsedArgs) {
|
|
|
1531
1457
|
if (!parsedArgs.interactive) {
|
|
1532
1458
|
return 'none';
|
|
1533
1459
|
}
|
|
1534
|
-
const reply =
|
|
1535
|
-
{
|
|
1536
|
-
name: 'framework',
|
|
1460
|
+
const reply = {
|
|
1461
|
+
framework: await (0, prompt_helpers_1.selectPrompt)({
|
|
1537
1462
|
message: 'What framework would you like to use?',
|
|
1538
|
-
type: 'autocomplete',
|
|
1539
1463
|
choices: [
|
|
1540
1464
|
{
|
|
1541
|
-
|
|
1542
|
-
|
|
1465
|
+
value: 'none',
|
|
1466
|
+
label: 'None',
|
|
1543
1467
|
hint: ' I only want react, react-dom or react-router',
|
|
1544
1468
|
},
|
|
1469
|
+
{ value: 'next', label: 'Next.js [ https://nextjs.org/ ]' },
|
|
1470
|
+
{ value: 'expo', label: 'Expo [ https://expo.io/ ]' },
|
|
1545
1471
|
{
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
},
|
|
1549
|
-
{
|
|
1550
|
-
name: 'expo',
|
|
1551
|
-
message: 'Expo [ https://expo.io/ ]',
|
|
1552
|
-
},
|
|
1553
|
-
{
|
|
1554
|
-
name: 'react-native',
|
|
1555
|
-
message: 'React Native [ https://reactnative.dev/ ]',
|
|
1472
|
+
value: 'react-native',
|
|
1473
|
+
label: 'React Native [ https://reactnative.dev/ ]',
|
|
1556
1474
|
},
|
|
1557
1475
|
],
|
|
1558
|
-
initial:
|
|
1559
|
-
},
|
|
1560
|
-
|
|
1476
|
+
initial: 'none',
|
|
1477
|
+
}),
|
|
1478
|
+
};
|
|
1561
1479
|
return reply.framework;
|
|
1562
1480
|
}
|
|
1563
1481
|
async function determineReactBundler(parsedArgs) {
|
|
1564
1482
|
if (parsedArgs.bundler)
|
|
1565
1483
|
return parsedArgs.bundler;
|
|
1566
|
-
const reply =
|
|
1567
|
-
{
|
|
1568
|
-
name: 'bundler',
|
|
1484
|
+
const reply = {
|
|
1485
|
+
bundler: await (0, prompt_helpers_1.selectPrompt)({
|
|
1569
1486
|
message: `Which bundler would you like to use?`,
|
|
1570
|
-
type: 'autocomplete',
|
|
1571
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1572
1487
|
choices: [
|
|
1573
|
-
{
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
},
|
|
1577
|
-
{
|
|
1578
|
-
name: 'webpack',
|
|
1579
|
-
message: 'Webpack [ https://webpack.js.org/ ]',
|
|
1580
|
-
},
|
|
1581
|
-
{
|
|
1582
|
-
name: 'rspack',
|
|
1583
|
-
message: 'Rspack [ https://www.rspack.dev/ ]',
|
|
1584
|
-
},
|
|
1488
|
+
{ value: 'vite', label: 'Vite [ https://vite.dev/ ]' },
|
|
1489
|
+
{ value: 'webpack', label: 'Webpack [ https://webpack.js.org/ ]' },
|
|
1490
|
+
{ value: 'rspack', label: 'Rspack [ https://www.rspack.dev/ ]' },
|
|
1585
1491
|
],
|
|
1586
|
-
initial:
|
|
1587
|
-
|
|
1588
|
-
|
|
1492
|
+
initial: 'vite',
|
|
1493
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1494
|
+
}),
|
|
1495
|
+
};
|
|
1589
1496
|
return reply.bundler;
|
|
1590
1497
|
}
|
|
1591
1498
|
async function determineNextAppDir(parsedArgs) {
|
|
1592
1499
|
if (parsedArgs.nextAppDir !== undefined)
|
|
1593
1500
|
return parsedArgs.nextAppDir;
|
|
1594
|
-
const reply =
|
|
1595
|
-
{
|
|
1596
|
-
name: 'nextAppDir',
|
|
1501
|
+
const reply = {
|
|
1502
|
+
nextAppDir: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1597
1503
|
message: 'Would you like to use the App Router (recommended)?',
|
|
1598
|
-
type: 'autocomplete',
|
|
1599
1504
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
name: 'No',
|
|
1606
|
-
},
|
|
1607
|
-
],
|
|
1608
|
-
initial: 0,
|
|
1609
|
-
},
|
|
1610
|
-
]);
|
|
1505
|
+
skippedValue: true,
|
|
1506
|
+
}))
|
|
1507
|
+
? 'Yes'
|
|
1508
|
+
: 'No',
|
|
1509
|
+
};
|
|
1611
1510
|
return reply.nextAppDir === 'Yes';
|
|
1612
1511
|
}
|
|
1613
1512
|
async function determineNextSrcDir(parsedArgs) {
|
|
1614
1513
|
if (parsedArgs.nextSrcDir !== undefined)
|
|
1615
1514
|
return parsedArgs.nextSrcDir;
|
|
1616
|
-
const reply =
|
|
1617
|
-
{
|
|
1618
|
-
name: 'nextSrcDir',
|
|
1515
|
+
const reply = {
|
|
1516
|
+
nextSrcDir: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1619
1517
|
message: 'Would you like to use the src/ directory?',
|
|
1620
|
-
type: 'autocomplete',
|
|
1621
1518
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
name: 'No',
|
|
1628
|
-
},
|
|
1629
|
-
],
|
|
1630
|
-
initial: 0,
|
|
1631
|
-
},
|
|
1632
|
-
]);
|
|
1519
|
+
skippedValue: true,
|
|
1520
|
+
}))
|
|
1521
|
+
? 'Yes'
|
|
1522
|
+
: 'No',
|
|
1523
|
+
};
|
|
1633
1524
|
return reply.nextSrcDir === 'Yes';
|
|
1634
1525
|
}
|
|
1635
1526
|
async function determineVueFramework(parsedArgs) {
|
|
1636
1527
|
if (!!parsedArgs.framework)
|
|
1637
1528
|
return parsedArgs.framework;
|
|
1638
|
-
const reply =
|
|
1639
|
-
{
|
|
1640
|
-
name: 'framework',
|
|
1529
|
+
const reply = {
|
|
1530
|
+
framework: await (0, prompt_helpers_1.selectPrompt)({
|
|
1641
1531
|
message: 'What framework would you like to use?',
|
|
1642
|
-
type: 'autocomplete',
|
|
1643
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1644
1532
|
choices: [
|
|
1645
|
-
{
|
|
1646
|
-
|
|
1647
|
-
message: 'None',
|
|
1648
|
-
hint: ' I only want Vue',
|
|
1649
|
-
},
|
|
1650
|
-
{
|
|
1651
|
-
name: 'nuxt',
|
|
1652
|
-
message: 'Nuxt [ https://nuxt.com/ ]',
|
|
1653
|
-
},
|
|
1533
|
+
{ value: 'none', label: 'None', hint: ' I only want Vue' },
|
|
1534
|
+
{ value: 'nuxt', label: 'Nuxt [ https://nuxt.com/ ]' },
|
|
1654
1535
|
],
|
|
1655
|
-
initial:
|
|
1656
|
-
|
|
1657
|
-
|
|
1536
|
+
initial: 'none',
|
|
1537
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1538
|
+
}),
|
|
1539
|
+
};
|
|
1658
1540
|
return reply.framework;
|
|
1659
1541
|
}
|
|
1660
1542
|
async function determineNodeFramework(parsedArgs) {
|
|
1661
1543
|
if (!!parsedArgs.framework)
|
|
1662
1544
|
return parsedArgs.framework;
|
|
1663
|
-
const reply =
|
|
1664
|
-
{
|
|
1545
|
+
const reply = {
|
|
1546
|
+
framework: await (0, prompt_helpers_1.selectPrompt)({
|
|
1665
1547
|
message: 'What framework should be used?',
|
|
1666
|
-
type: 'autocomplete',
|
|
1667
|
-
name: 'framework',
|
|
1668
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1669
1548
|
choices: [
|
|
1670
|
-
{
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
},
|
|
1674
|
-
{
|
|
1675
|
-
name: 'express',
|
|
1676
|
-
message: 'Express [ https://expressjs.com/ ]',
|
|
1677
|
-
},
|
|
1678
|
-
{
|
|
1679
|
-
name: 'fastify',
|
|
1680
|
-
message: 'Fastify [ https://www.fastify.dev/ ]',
|
|
1681
|
-
},
|
|
1682
|
-
{
|
|
1683
|
-
name: 'koa',
|
|
1684
|
-
message: 'Koa [ https://koajs.com/ ]',
|
|
1685
|
-
},
|
|
1686
|
-
{
|
|
1687
|
-
name: 'nest',
|
|
1688
|
-
message: 'NestJs [ https://nestjs.com/ ]',
|
|
1689
|
-
},
|
|
1549
|
+
{ value: 'none', label: 'None' },
|
|
1550
|
+
{ value: 'express', label: 'Express [ https://expressjs.com/ ]' },
|
|
1551
|
+
{ value: 'fastify', label: 'Fastify [ https://www.fastify.dev/ ]' },
|
|
1552
|
+
{ value: 'koa', label: 'Koa [ https://koajs.com/ ]' },
|
|
1553
|
+
{ value: 'nest', label: 'NestJs [ https://nestjs.com/ ]' },
|
|
1690
1554
|
],
|
|
1691
|
-
initial:
|
|
1692
|
-
|
|
1693
|
-
|
|
1555
|
+
initial: 'none',
|
|
1556
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1557
|
+
}),
|
|
1558
|
+
};
|
|
1694
1559
|
return reply.framework;
|
|
1695
1560
|
}
|
|
1696
1561
|
async function determineUnitTestRunner(parsedArgs, options) {
|
|
@@ -1700,69 +1565,55 @@ async function determineUnitTestRunner(parsedArgs, options) {
|
|
|
1700
1565
|
else if (!parsedArgs.workspaces) {
|
|
1701
1566
|
return undefined;
|
|
1702
1567
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1568
|
+
// `none` sorts last and the preferred runner first, because the leading
|
|
1569
|
+
// choice is both the interactive default and the answer a skipped prompt
|
|
1570
|
+
// resolves to. Callers pass `exclude` to keep a runner they cannot support
|
|
1571
|
+
// off the list entirely.
|
|
1572
|
+
const choices = [
|
|
1573
|
+
{ value: 'none', label: 'None' },
|
|
1574
|
+
{ value: 'jest', label: 'Jest [ https://jestjs.io/ ]' },
|
|
1575
|
+
{ value: 'vitest', label: 'Vitest [ https://vitest.dev/ ]' },
|
|
1576
|
+
]
|
|
1577
|
+
.filter((t) => !options?.exclude || options.exclude !== t.value)
|
|
1578
|
+
.sort((a, b) => {
|
|
1579
|
+
if (a.value === 'none')
|
|
1580
|
+
return 1;
|
|
1581
|
+
if (b.value === 'none')
|
|
1582
|
+
return -1;
|
|
1583
|
+
if (options?.preferVitest && a.value === 'vitest')
|
|
1584
|
+
return -1;
|
|
1585
|
+
if (options?.preferVitest && b.value === 'vitest')
|
|
1586
|
+
return 1;
|
|
1587
|
+
return 0;
|
|
1588
|
+
});
|
|
1589
|
+
const reply = {
|
|
1590
|
+
unitTestRunner: await (0, prompt_helpers_1.selectPrompt)({
|
|
1705
1591
|
message: 'Which unit test runner would you like to use?',
|
|
1706
|
-
|
|
1707
|
-
|
|
1592
|
+
choices: [...choices],
|
|
1593
|
+
initial: choices[0].value,
|
|
1708
1594
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
name: 'none',
|
|
1712
|
-
message: 'None',
|
|
1713
|
-
},
|
|
1714
|
-
{
|
|
1715
|
-
name: 'jest',
|
|
1716
|
-
message: 'Jest [ https://jestjs.io/ ]',
|
|
1717
|
-
},
|
|
1718
|
-
{
|
|
1719
|
-
name: 'vitest',
|
|
1720
|
-
message: 'Vitest [ https://vitest.dev/ ]',
|
|
1721
|
-
},
|
|
1722
|
-
]
|
|
1723
|
-
.filter((t) => !options?.exclude || options.exclude !== t.name)
|
|
1724
|
-
.sort((a, b) => {
|
|
1725
|
-
if (a.name === 'none')
|
|
1726
|
-
return 1;
|
|
1727
|
-
if (b.name === 'none')
|
|
1728
|
-
return -1;
|
|
1729
|
-
if (options?.preferVitest && a.name === 'vitest')
|
|
1730
|
-
return -1;
|
|
1731
|
-
if (options?.preferVitest && b.name === 'vitest')
|
|
1732
|
-
return 1;
|
|
1733
|
-
return 0;
|
|
1734
|
-
}),
|
|
1735
|
-
initial: 0, // This should be either vite or jest
|
|
1736
|
-
},
|
|
1737
|
-
]);
|
|
1595
|
+
}),
|
|
1596
|
+
};
|
|
1738
1597
|
return reply.unitTestRunner;
|
|
1739
1598
|
}
|
|
1740
1599
|
async function determineE2eTestRunner(parsedArgs) {
|
|
1741
1600
|
if (parsedArgs.e2eTestRunner)
|
|
1742
1601
|
return parsedArgs.e2eTestRunner;
|
|
1743
|
-
const reply =
|
|
1744
|
-
{
|
|
1602
|
+
const reply = {
|
|
1603
|
+
e2eTestRunner: await (0, prompt_helpers_1.selectPrompt)({
|
|
1745
1604
|
message: 'Test runner to use for end to end (E2E) tests',
|
|
1746
|
-
type: 'autocomplete',
|
|
1747
|
-
name: 'e2eTestRunner',
|
|
1748
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1749
1605
|
choices: [
|
|
1750
1606
|
{
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
},
|
|
1754
|
-
{
|
|
1755
|
-
name: 'cypress',
|
|
1756
|
-
message: 'Cypress [ https://www.cypress.io/ ]',
|
|
1757
|
-
},
|
|
1758
|
-
{
|
|
1759
|
-
name: 'none',
|
|
1760
|
-
message: 'None',
|
|
1607
|
+
value: 'playwright',
|
|
1608
|
+
label: 'Playwright [ https://playwright.dev/ ]',
|
|
1761
1609
|
},
|
|
1610
|
+
{ value: 'cypress', label: 'Cypress [ https://www.cypress.io/ ]' },
|
|
1611
|
+
{ value: 'none', label: 'None' },
|
|
1762
1612
|
],
|
|
1763
|
-
initial:
|
|
1764
|
-
|
|
1765
|
-
|
|
1613
|
+
initial: 'playwright',
|
|
1614
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1615
|
+
}),
|
|
1616
|
+
};
|
|
1766
1617
|
return reply.e2eTestRunner;
|
|
1767
1618
|
}
|
|
1768
1619
|
async function determineReactRouter(parsedArgs) {
|
|
@@ -1770,23 +1621,14 @@ async function determineReactRouter(parsedArgs) {
|
|
|
1770
1621
|
return false;
|
|
1771
1622
|
if (parsedArgs.useReactRouter !== undefined)
|
|
1772
1623
|
return parsedArgs.useReactRouter;
|
|
1773
|
-
const reply =
|
|
1774
|
-
{
|
|
1624
|
+
const reply = {
|
|
1625
|
+
response: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1775
1626
|
message: 'Would you like to use React Router for server-side rendering [https://reactrouter.com/]?',
|
|
1776
|
-
type: 'autocomplete',
|
|
1777
|
-
name: 'response',
|
|
1778
1627
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
{
|
|
1785
|
-
name: 'No',
|
|
1786
|
-
},
|
|
1787
|
-
],
|
|
1788
|
-
initial: 0,
|
|
1789
|
-
},
|
|
1790
|
-
]);
|
|
1628
|
+
skippedValue: true,
|
|
1629
|
+
}))
|
|
1630
|
+
? 'Yes'
|
|
1631
|
+
: 'No',
|
|
1632
|
+
};
|
|
1791
1633
|
return reply.response === 'Yes';
|
|
1792
1634
|
}
|