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