create-nx-workspace 23.2.0-beta.0 → 23.2.0-beta.10
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 +13 -4
- package/dist/bin/create-nx-workspace.js +386 -555
- package/dist/internal.d.ts +3 -1
- package/dist/internal.js +7 -1
- package/dist/src/create-workspace.js +75 -4
- 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 +17 -1
- package/dist/src/internal-utils/prompts.js +150 -118
- package/dist/src/utils/ai/ai-output.js +9 -4
- 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/dist/src/utils/template/download-template.js +10 -3
- package/package.json +3 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.commandsObject = void 0;
|
|
4
|
+
exports.applyEmptyPresetAlias = applyEmptyPresetAlias;
|
|
4
5
|
exports.isValidWorkspaceName = isValidWorkspaceName;
|
|
5
6
|
exports.validateWorkspaceName = validateWorkspaceName;
|
|
6
7
|
exports.resolveSpecialFolderName = resolveSpecialFolderName;
|
|
7
8
|
exports.determineFolder = determineFolder;
|
|
9
|
+
exports.determinePresetOptions = determinePresetOptions;
|
|
8
10
|
const tslib_1 = require("tslib");
|
|
9
|
-
const enquirer_1 = tslib_1.__importDefault(require("enquirer"));
|
|
10
11
|
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
11
12
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
12
13
|
const create_workspace_options_1 = require("../src/create-workspace-options");
|
|
@@ -21,9 +22,11 @@ const prompts_1 = require("../src/internal-utils/prompts");
|
|
|
21
22
|
const yargs_options_1 = require("../src/internal-utils/yargs-options");
|
|
22
23
|
const ab_testing_1 = require("../src/utils/nx/ab-testing");
|
|
23
24
|
const error_utils_1 = require("../src/utils/error-utils");
|
|
25
|
+
const exit_codes_1 = require("../src/utils/exit-codes");
|
|
24
26
|
const fs_1 = require("fs");
|
|
25
27
|
const path_1 = require("path");
|
|
26
28
|
const is_ci_1 = require("../src/utils/ci/is-ci");
|
|
29
|
+
const prompt_helpers_1 = require("../src/internal-utils/prompt-helpers");
|
|
27
30
|
const git_1 = require("../src/utils/git/git");
|
|
28
31
|
const ai_output_1 = require("../src/utils/ai/ai-output");
|
|
29
32
|
function extractErrorFile(error) {
|
|
@@ -116,6 +119,18 @@ exports.commandsObject = yargs_1.default
|
|
|
116
119
|
.option('formatter', {
|
|
117
120
|
describe: chalk_1.default.dim `Code formatter to use.`,
|
|
118
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,
|
|
125
|
+
})
|
|
126
|
+
// `choices` is load-bearing, not documentation: `determineLinterOptions`
|
|
127
|
+
// returns `--linter` as-is and nothing downstream validates it — the
|
|
128
|
+
// `new`/`preset` schemas declare no enum — so a typo would surface only
|
|
129
|
+
// as an `Unsupported linter` throw partway through scaffolding.
|
|
130
|
+
.option('linter', {
|
|
131
|
+
describe: chalk_1.default.dim `Linter to use.`,
|
|
132
|
+
choices: [...prompts_1.LINTERS],
|
|
133
|
+
type: 'string',
|
|
119
134
|
})
|
|
120
135
|
.option('framework', {
|
|
121
136
|
describe: chalk_1.default.dim `Framework option to be used with certain stacks.`,
|
|
@@ -157,9 +172,9 @@ exports.commandsObject = yargs_1.default
|
|
|
157
172
|
default: true,
|
|
158
173
|
})
|
|
159
174
|
.option('aiAgents', {
|
|
160
|
-
describe: chalk_1.default.dim `List of AI agents to configure.`,
|
|
175
|
+
describe: chalk_1.default.dim `List of AI agents to configure. Use "none" to skip.`,
|
|
161
176
|
type: 'array',
|
|
162
|
-
choices: [...create_workspace_options_1.supportedAgents],
|
|
177
|
+
choices: [...create_workspace_options_1.supportedAgents, 'none'],
|
|
163
178
|
})
|
|
164
179
|
.option('template', {
|
|
165
180
|
describe: chalk_1.default.dim `GitHub template repository to use. Available templates: nrwl/empty-template, nrwl/react-template, nrwl/angular-template, nrwl/typescript-template`,
|
|
@@ -198,8 +213,10 @@ else {
|
|
|
198
213
|
exports.commandsObject.epilogue(`${chalk_1.default.cyan('Documentation:')}
|
|
199
214
|
https://nx.dev/getting-started/intro`);
|
|
200
215
|
}
|
|
201
|
-
// Node 24
|
|
202
|
-
//
|
|
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.
|
|
203
220
|
process.on('uncaughtException', (error) => {
|
|
204
221
|
if (error &&
|
|
205
222
|
typeof error === 'object' &&
|
|
@@ -239,7 +256,7 @@ process.on('SIGINT', async () => {
|
|
|
239
256
|
],
|
|
240
257
|
});
|
|
241
258
|
}
|
|
242
|
-
|
|
259
|
+
(0, exit_codes_1.exitAsInterrupted)();
|
|
243
260
|
});
|
|
244
261
|
let rawArgs;
|
|
245
262
|
async function main(parsedArgs) {
|
|
@@ -310,6 +327,11 @@ async function handleError(error) {
|
|
|
310
327
|
aiAgent: (0, ai_output_1.isAiAgent)(),
|
|
311
328
|
},
|
|
312
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
|
+
}
|
|
313
335
|
// Output error in appropriate format
|
|
314
336
|
if ((0, ai_output_1.isAiAgent)()) {
|
|
315
337
|
const errorCode = error instanceof error_utils_1.CnwError ? error.code : 'UNKNOWN';
|
|
@@ -344,30 +366,15 @@ async function handleError(error) {
|
|
|
344
366
|
async function normalizeArgsMiddleware(argv) {
|
|
345
367
|
try {
|
|
346
368
|
rawArgs = { ...argv };
|
|
347
|
-
// Map invalid/legacy presets to templates for all users
|
|
348
|
-
// These presets don't exist as npm packages and would fail if not mapped
|
|
349
|
-
const invalidPresetToTemplateMap = {
|
|
350
|
-
empty: 'nrwl/empty-template',
|
|
351
|
-
};
|
|
352
|
-
if (rawArgs.preset && !rawArgs.template) {
|
|
353
|
-
const mappedTemplate = invalidPresetToTemplateMap[rawArgs.preset];
|
|
354
|
-
if (mappedTemplate) {
|
|
355
|
-
output_1.output.log({
|
|
356
|
-
title: `Mapping preset '${rawArgs.preset}' to template '${mappedTemplate}'`,
|
|
357
|
-
});
|
|
358
|
-
argv.template = mappedTemplate;
|
|
359
|
-
rawArgs.template = mappedTemplate;
|
|
360
|
-
delete argv.preset;
|
|
361
|
-
delete rawArgs.preset;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
369
|
// AI Agent Detection: When an AI agent is detected, switch to AI-optimized mode
|
|
365
370
|
const aiMode = (0, ai_output_1.isAiAgent)();
|
|
366
371
|
if (aiMode) {
|
|
367
372
|
// Force non-interactive mode for AI agents
|
|
368
373
|
argv.interactive = false;
|
|
369
374
|
// Map legacy presets to templates for AI agents
|
|
370
|
-
// Many AI models were trained on old preset syntax, so we convert them
|
|
375
|
+
// Many AI models were trained on old preset syntax, so we convert them.
|
|
376
|
+
// Never add `empty` here - it must stay npm-only as the escape hatch
|
|
377
|
+
// when github.com is unreachable (see applyEmptyPresetAlias).
|
|
371
378
|
const legacyPresetToTemplateMap = {
|
|
372
379
|
ts: 'nrwl/empty-template',
|
|
373
380
|
apps: 'nrwl/empty-template',
|
|
@@ -426,6 +433,7 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
426
433
|
title: "Let's create a new workspace [https://nx.dev/getting-started/intro]",
|
|
427
434
|
});
|
|
428
435
|
}
|
|
436
|
+
applyEmptyPresetAlias(argv);
|
|
429
437
|
argv.workspaces ??= true;
|
|
430
438
|
argv.useProjectJson ??= !argv.workspaces;
|
|
431
439
|
useCloud = argv.nxCloud !== 'skip' && argv.nxCloud !== 'never';
|
|
@@ -604,10 +612,6 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
604
612
|
if (e instanceof error_utils_1.CnwError) {
|
|
605
613
|
throw e;
|
|
606
614
|
}
|
|
607
|
-
// Enquirer throws an empty string when user presses Ctrl+C
|
|
608
|
-
if (e === '') {
|
|
609
|
-
process.exit(130);
|
|
610
|
-
}
|
|
611
615
|
const message = e instanceof Error ? e.message : String(e);
|
|
612
616
|
throw new error_utils_1.CnwError('UNKNOWN', message);
|
|
613
617
|
}
|
|
@@ -616,6 +620,15 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
616
620
|
handleError(error);
|
|
617
621
|
}
|
|
618
622
|
}
|
|
623
|
+
// Map `empty` to the `ts` preset, not the template - sandboxed agents often
|
|
624
|
+
// cannot reach github.com. Wins over --template so appending --preset=empty
|
|
625
|
+
// to a failed command escapes the download.
|
|
626
|
+
function applyEmptyPresetAlias(argv) {
|
|
627
|
+
if (argv.preset === 'empty') {
|
|
628
|
+
argv.preset = preset_1.Preset.TS;
|
|
629
|
+
delete argv.template;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
619
632
|
function invariant(predicate, errorCode, message) {
|
|
620
633
|
if (!predicate) {
|
|
621
634
|
throw new error_utils_1.CnwError(errorCode, message);
|
|
@@ -721,24 +734,15 @@ async function determineFolder(parsedArgs) {
|
|
|
721
734
|
return promptForFolder(parsedArgs);
|
|
722
735
|
}
|
|
723
736
|
async function promptCreateInCurrentDir(dirName) {
|
|
724
|
-
|
|
725
|
-
{
|
|
726
|
-
|
|
727
|
-
message: `Create workspace in the current directory (${dirName})? Existing files may be overwritten.`,
|
|
728
|
-
type: 'autocomplete',
|
|
729
|
-
choices: [{ name: 'Yes' }, { name: 'No' }],
|
|
730
|
-
initial: 0,
|
|
731
|
-
},
|
|
732
|
-
]);
|
|
733
|
-
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
|
+
});
|
|
734
740
|
}
|
|
735
741
|
async function promptForFolder(parsedArgs) {
|
|
736
|
-
const reply =
|
|
737
|
-
{
|
|
738
|
-
name: 'folderName',
|
|
742
|
+
const reply = {
|
|
743
|
+
folderName: await (0, prompt_helpers_1.textPrompt)({
|
|
739
744
|
message: `Where would you like to create your workspace?`,
|
|
740
|
-
|
|
741
|
-
type: 'input',
|
|
745
|
+
initialValue: 'org',
|
|
742
746
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
743
747
|
validate: (value) => {
|
|
744
748
|
if (!value) {
|
|
@@ -750,10 +754,10 @@ async function promptForFolder(parsedArgs) {
|
|
|
750
754
|
if ((0, fs_1.existsSync)(value)) {
|
|
751
755
|
return `The directory '${value}' already exists`;
|
|
752
756
|
}
|
|
753
|
-
return
|
|
757
|
+
return undefined;
|
|
754
758
|
},
|
|
755
|
-
},
|
|
756
|
-
|
|
759
|
+
}),
|
|
760
|
+
};
|
|
757
761
|
// Fallback invariants in case validate is bypassed (e.g., in CI or non-interactive mode)
|
|
758
762
|
invariant(reply.folderName, 'INVALID_FOLDER_NAME', 'Folder name cannot be empty');
|
|
759
763
|
validateWorkspaceName(reply.folderName);
|
|
@@ -792,41 +796,33 @@ async function determineStack(parsedArgs) {
|
|
|
792
796
|
case preset_1.Preset.TsStandalone:
|
|
793
797
|
return 'none';
|
|
794
798
|
case preset_1.Preset.WebComponents:
|
|
799
|
+
return 'web';
|
|
795
800
|
default:
|
|
796
801
|
return 'unknown';
|
|
797
802
|
}
|
|
798
803
|
}
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
message: `Angular: Configures a Angular application with modern tooling.`,
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
name: `node`,
|
|
825
|
-
message: `Node: Configures a Node API application with your framework of choice.`,
|
|
826
|
-
},
|
|
827
|
-
],
|
|
828
|
-
},
|
|
829
|
-
]);
|
|
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
|
+
});
|
|
830
826
|
return stack;
|
|
831
827
|
}
|
|
832
828
|
async function determinePresetOptions(parsedArgs) {
|
|
@@ -841,51 +837,23 @@ async function determinePresetOptions(parsedArgs) {
|
|
|
841
837
|
return determineVueOptions(parsedArgs);
|
|
842
838
|
case 'node':
|
|
843
839
|
return determineNodeOptions(parsedArgs);
|
|
840
|
+
case 'web':
|
|
841
|
+
return determineWebOptions(parsedArgs);
|
|
844
842
|
default:
|
|
845
843
|
return parsedArgs;
|
|
846
844
|
}
|
|
847
845
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
},
|
|
860
|
-
{
|
|
861
|
-
name: 'No',
|
|
862
|
-
},
|
|
863
|
-
],
|
|
864
|
-
initial: opts?.preferPrettier ? 0 : 1,
|
|
865
|
-
skip: !args.interactive || (0, is_ci_1.isCI)(),
|
|
866
|
-
},
|
|
867
|
-
]);
|
|
868
|
-
return reply.prettier === 'Yes' ? 'prettier' : 'none';
|
|
869
|
-
}
|
|
870
|
-
async function determineLinterOptions(args, opts) {
|
|
871
|
-
const reply = await enquirer_1.default.prompt([
|
|
872
|
-
{
|
|
873
|
-
name: 'eslint',
|
|
874
|
-
message: `Would you like to use ESLint?`,
|
|
875
|
-
type: 'autocomplete',
|
|
876
|
-
choices: [
|
|
877
|
-
{
|
|
878
|
-
name: 'Yes',
|
|
879
|
-
},
|
|
880
|
-
{
|
|
881
|
-
name: 'No',
|
|
882
|
-
},
|
|
883
|
-
],
|
|
884
|
-
initial: opts?.preferEslint ? 0 : 1,
|
|
885
|
-
skip: !args.interactive || (0, is_ci_1.isCI)(),
|
|
886
|
-
},
|
|
887
|
-
]);
|
|
888
|
-
return reply.eslint === 'Yes' ? 'eslint' : 'none';
|
|
846
|
+
/**
|
|
847
|
+
* `web-components` prompts for nothing of its own — `style` and `e2eTestRunner`
|
|
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.
|
|
850
|
+
*/
|
|
851
|
+
async function determineWebOptions(parsedArgs) {
|
|
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
|
+
};
|
|
889
857
|
}
|
|
890
858
|
async function determineNoneOptions(parsedArgs) {
|
|
891
859
|
if ((!parsedArgs.preset || parsedArgs.preset === preset_1.Preset.TS) &&
|
|
@@ -893,7 +861,7 @@ async function determineNoneOptions(parsedArgs) {
|
|
|
893
861
|
parsedArgs.workspaces) {
|
|
894
862
|
return {
|
|
895
863
|
preset: preset_1.Preset.TS,
|
|
896
|
-
formatter: await determineFormatterOptions(parsedArgs),
|
|
864
|
+
formatter: await (0, prompts_1.determineFormatterOptions)(parsedArgs),
|
|
897
865
|
};
|
|
898
866
|
}
|
|
899
867
|
else {
|
|
@@ -917,7 +885,9 @@ async function determineNoneOptions(parsedArgs) {
|
|
|
917
885
|
}
|
|
918
886
|
}
|
|
919
887
|
if (preset === preset_1.Preset.TS) {
|
|
920
|
-
|
|
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) };
|
|
921
891
|
}
|
|
922
892
|
if (parsedArgs.js !== undefined) {
|
|
923
893
|
js = parsedArgs.js;
|
|
@@ -925,26 +895,36 @@ async function determineNoneOptions(parsedArgs) {
|
|
|
925
895
|
else if (preset === preset_1.Preset.TsStandalone) {
|
|
926
896
|
// Only standalone TS preset generates a default package, so we need to provide --js and --appName options.
|
|
927
897
|
appName = parsedArgs.name;
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
choices: [
|
|
934
|
-
{
|
|
935
|
-
name: 'Yes',
|
|
936
|
-
},
|
|
937
|
-
{
|
|
938
|
-
name: 'No',
|
|
939
|
-
},
|
|
940
|
-
],
|
|
941
|
-
initial: 0,
|
|
942
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
943
|
-
},
|
|
944
|
-
]);
|
|
945
|
-
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
|
+
}));
|
|
946
903
|
}
|
|
947
|
-
|
|
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.
|
|
912
|
+
const linter = preset === preset_1.Preset.TsStandalone
|
|
913
|
+
? await (0, prompts_1.determineLinterOptions)(parsedArgs)
|
|
914
|
+
: undefined;
|
|
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
|
+
};
|
|
948
928
|
}
|
|
949
929
|
}
|
|
950
930
|
async function determineReactOptions(parsedArgs) {
|
|
@@ -959,7 +939,6 @@ async function determineReactOptions(parsedArgs) {
|
|
|
959
939
|
let nextAppDir = false;
|
|
960
940
|
let nextSrcDir = false;
|
|
961
941
|
let linter;
|
|
962
|
-
let formatter;
|
|
963
942
|
const workspaces = parsedArgs.workspaces;
|
|
964
943
|
if (parsedArgs.preset && parsedArgs.preset !== preset_1.Preset.React) {
|
|
965
944
|
preset = parsedArgs.preset;
|
|
@@ -1008,24 +987,10 @@ async function determineReactOptions(parsedArgs) {
|
|
|
1008
987
|
}
|
|
1009
988
|
if (preset === preset_1.Preset.ReactStandalone || preset === preset_1.Preset.ReactMonorepo) {
|
|
1010
989
|
bundler = useReactRouter ? 'vite' : await determineReactBundler(parsedArgs);
|
|
1011
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1012
|
-
preferVitest: bundler === 'vite',
|
|
1013
|
-
});
|
|
1014
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1015
990
|
}
|
|
1016
991
|
else if (preset === preset_1.Preset.NextJs || preset === preset_1.Preset.NextJsStandalone) {
|
|
1017
992
|
nextAppDir = await determineNextAppDir(parsedArgs);
|
|
1018
993
|
nextSrcDir = await determineNextSrcDir(parsedArgs);
|
|
1019
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1020
|
-
exclude: 'vitest',
|
|
1021
|
-
});
|
|
1022
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1023
|
-
}
|
|
1024
|
-
else if (preset === preset_1.Preset.ReactNative || preset === preset_1.Preset.Expo) {
|
|
1025
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1026
|
-
exclude: 'vitest',
|
|
1027
|
-
});
|
|
1028
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1029
994
|
}
|
|
1030
995
|
if (parsedArgs.style) {
|
|
1031
996
|
style = parsedArgs.style;
|
|
@@ -1034,52 +999,58 @@ async function determineReactOptions(parsedArgs) {
|
|
|
1034
999
|
preset === preset_1.Preset.ReactMonorepo ||
|
|
1035
1000
|
preset === preset_1.Preset.NextJs ||
|
|
1036
1001
|
preset === preset_1.Preset.NextJsStandalone) {
|
|
1037
|
-
const reply =
|
|
1038
|
-
{
|
|
1039
|
-
name: 'style',
|
|
1002
|
+
const reply = {
|
|
1003
|
+
style: await (0, prompt_helpers_1.selectPrompt)({
|
|
1040
1004
|
message: `Default stylesheet format`,
|
|
1041
|
-
initial: 0,
|
|
1042
|
-
type: 'autocomplete',
|
|
1043
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1044
1005
|
choices: [
|
|
1006
|
+
{ value: 'css', label: 'CSS' },
|
|
1045
1007
|
{
|
|
1046
|
-
|
|
1047
|
-
|
|
1008
|
+
value: 'scss',
|
|
1009
|
+
label: 'SASS(.scss) [ https://sass-lang.com ]',
|
|
1048
1010
|
},
|
|
1049
1011
|
{
|
|
1050
|
-
|
|
1051
|
-
|
|
1012
|
+
value: 'less',
|
|
1013
|
+
label: 'LESS [ https://lesscss.org ]',
|
|
1052
1014
|
},
|
|
1053
1015
|
{
|
|
1054
|
-
|
|
1055
|
-
|
|
1016
|
+
value: 'styled-components',
|
|
1017
|
+
label: 'styled-components [ https://styled-components.com ]',
|
|
1056
1018
|
},
|
|
1057
1019
|
{
|
|
1058
|
-
|
|
1059
|
-
|
|
1020
|
+
value: '@emotion/styled',
|
|
1021
|
+
label: 'emotion [ https://emotion.sh ]',
|
|
1060
1022
|
},
|
|
1061
1023
|
{
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
},
|
|
1065
|
-
{
|
|
1066
|
-
name: 'styled-jsx',
|
|
1067
|
-
message: 'styled-jsx [ https://www.npmjs.com/package/styled-jsx ]',
|
|
1024
|
+
value: 'styled-jsx',
|
|
1025
|
+
label: 'styled-jsx [ https://www.npmjs.com/package/styled-jsx ]',
|
|
1068
1026
|
},
|
|
1069
1027
|
],
|
|
1070
|
-
|
|
1071
|
-
|
|
1028
|
+
initial: 'css',
|
|
1029
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1030
|
+
}),
|
|
1031
|
+
};
|
|
1072
1032
|
style = reply.style;
|
|
1073
1033
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
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);
|
|
1038
|
+
linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1039
|
+
if (preset === preset_1.Preset.ReactStandalone || preset === preset_1.Preset.ReactMonorepo) {
|
|
1040
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1041
|
+
preferVitest: bundler === 'vite',
|
|
1078
1042
|
});
|
|
1043
|
+
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1079
1044
|
}
|
|
1080
|
-
else {
|
|
1081
|
-
|
|
1082
|
-
|
|
1045
|
+
else if (preset === preset_1.Preset.NextJs || preset === preset_1.Preset.NextJsStandalone) {
|
|
1046
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs);
|
|
1047
|
+
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1048
|
+
}
|
|
1049
|
+
else if (preset === preset_1.Preset.ReactNative || preset === preset_1.Preset.Expo) {
|
|
1050
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1051
|
+
exclude: 'vitest',
|
|
1052
|
+
});
|
|
1053
|
+
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1083
1054
|
}
|
|
1084
1055
|
return {
|
|
1085
1056
|
preset,
|
|
@@ -1104,7 +1075,6 @@ async function determineVueOptions(parsedArgs) {
|
|
|
1104
1075
|
let unitTestRunner = undefined;
|
|
1105
1076
|
let e2eTestRunner = undefined;
|
|
1106
1077
|
let linter;
|
|
1107
|
-
let formatter;
|
|
1108
1078
|
const workspaces = parsedArgs.workspaces;
|
|
1109
1079
|
if (parsedArgs.preset && parsedArgs.preset !== preset_1.Preset.Vue) {
|
|
1110
1080
|
preset = parsedArgs.preset;
|
|
@@ -1143,53 +1113,40 @@ async function determineVueOptions(parsedArgs) {
|
|
|
1143
1113
|
}
|
|
1144
1114
|
}
|
|
1145
1115
|
}
|
|
1146
|
-
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1147
|
-
exclude: 'jest',
|
|
1148
|
-
});
|
|
1149
|
-
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1150
1116
|
if (parsedArgs.style) {
|
|
1151
1117
|
style = parsedArgs.style;
|
|
1152
1118
|
}
|
|
1153
1119
|
else {
|
|
1154
|
-
const reply =
|
|
1155
|
-
{
|
|
1156
|
-
name: 'style',
|
|
1120
|
+
const reply = {
|
|
1121
|
+
style: await (0, prompt_helpers_1.selectPrompt)({
|
|
1157
1122
|
message: `Default stylesheet format`,
|
|
1158
|
-
initial: 0,
|
|
1159
|
-
type: 'autocomplete',
|
|
1160
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1161
1123
|
choices: [
|
|
1124
|
+
{ value: 'css', label: 'CSS' },
|
|
1162
1125
|
{
|
|
1163
|
-
|
|
1164
|
-
|
|
1126
|
+
value: 'scss',
|
|
1127
|
+
label: 'SASS(.scss) [ https://sass-lang.com ]',
|
|
1165
1128
|
},
|
|
1166
1129
|
{
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
},
|
|
1170
|
-
{
|
|
1171
|
-
name: 'less',
|
|
1172
|
-
message: 'LESS [ https://lesscss.org ]',
|
|
1173
|
-
},
|
|
1174
|
-
{
|
|
1175
|
-
name: 'none',
|
|
1176
|
-
message: 'None',
|
|
1130
|
+
value: 'less',
|
|
1131
|
+
label: 'LESS [ https://lesscss.org ]',
|
|
1177
1132
|
},
|
|
1133
|
+
{ value: 'none', label: 'None' },
|
|
1178
1134
|
],
|
|
1179
|
-
|
|
1180
|
-
|
|
1135
|
+
initial: 'css',
|
|
1136
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1137
|
+
}),
|
|
1138
|
+
};
|
|
1181
1139
|
style = reply.style;
|
|
1182
1140
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
}
|
|
1141
|
+
// Asked outside the gate: neither answer depends on package-manager
|
|
1142
|
+
// workspaces, and `--no-workspaces` used to force prettier and ESLint
|
|
1143
|
+
// without asking.
|
|
1144
|
+
const formatter = await (0, prompts_1.determineFormatterOptions)(parsedArgs);
|
|
1145
|
+
linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1146
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs, {
|
|
1147
|
+
exclude: 'jest',
|
|
1148
|
+
});
|
|
1149
|
+
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1193
1150
|
return {
|
|
1194
1151
|
preset,
|
|
1195
1152
|
style,
|
|
@@ -1213,6 +1170,7 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1213
1170
|
const routing = parsedArgs.routing;
|
|
1214
1171
|
const prefix = parsedArgs.prefix;
|
|
1215
1172
|
const zoneless = parsedArgs.zoneless;
|
|
1173
|
+
const workspaces = parsedArgs.workspaces;
|
|
1216
1174
|
if (prefix) {
|
|
1217
1175
|
// https://github.com/angular/angular-cli/blob/main/packages/schematics/angular/utility/validation.ts#L11-L14
|
|
1218
1176
|
const htmlSelectorRegex = /^[a-zA-Z][.0-9a-zA-Z]*((:?-[0-9]+)*|(:?-[a-zA-Z][.0-9a-zA-Z]*(:?-[0-9]+)*)*)$/;
|
|
@@ -1249,78 +1207,64 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1249
1207
|
bundler = parsedArgs.bundler;
|
|
1250
1208
|
}
|
|
1251
1209
|
else {
|
|
1252
|
-
const reply =
|
|
1253
|
-
{
|
|
1254
|
-
name: 'bundler',
|
|
1210
|
+
const reply = {
|
|
1211
|
+
bundler: await (0, prompt_helpers_1.selectPrompt)({
|
|
1255
1212
|
message: `Which bundler would you like to use?`,
|
|
1256
|
-
type: 'autocomplete',
|
|
1257
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1258
1213
|
choices: [
|
|
1259
|
-
{
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
},
|
|
1263
|
-
{
|
|
1264
|
-
name: 'rspack',
|
|
1265
|
-
message: 'Rspack [ https://rspack.dev/ ]',
|
|
1266
|
-
},
|
|
1267
|
-
{
|
|
1268
|
-
name: 'webpack',
|
|
1269
|
-
message: 'Webpack [ https://webpack.js.org/ ]',
|
|
1270
|
-
},
|
|
1214
|
+
{ value: 'esbuild', label: 'esbuild [ https://esbuild.github.io/ ]' },
|
|
1215
|
+
{ value: 'rspack', label: 'Rspack [ https://rspack.dev/ ]' },
|
|
1216
|
+
{ value: 'webpack', label: 'Webpack [ https://webpack.js.org/ ]' },
|
|
1271
1217
|
],
|
|
1272
|
-
initial:
|
|
1273
|
-
|
|
1274
|
-
|
|
1218
|
+
initial: 'esbuild',
|
|
1219
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1220
|
+
}),
|
|
1221
|
+
};
|
|
1275
1222
|
bundler = reply.bundler;
|
|
1276
1223
|
}
|
|
1277
1224
|
if (parsedArgs.style) {
|
|
1278
1225
|
style = parsedArgs.style;
|
|
1279
1226
|
}
|
|
1280
1227
|
else {
|
|
1281
|
-
const reply =
|
|
1282
|
-
{
|
|
1283
|
-
name: 'style',
|
|
1228
|
+
const reply = {
|
|
1229
|
+
style: await (0, prompt_helpers_1.selectPrompt)({
|
|
1284
1230
|
message: `Default stylesheet format`,
|
|
1285
|
-
initial: 0,
|
|
1286
|
-
type: 'autocomplete',
|
|
1287
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1288
1231
|
choices: [
|
|
1232
|
+
{ value: 'css', label: 'CSS' },
|
|
1289
1233
|
{
|
|
1290
|
-
|
|
1291
|
-
|
|
1234
|
+
value: 'scss',
|
|
1235
|
+
label: 'SASS(.scss) [ https://sass-lang.com ]',
|
|
1292
1236
|
},
|
|
1293
1237
|
{
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
},
|
|
1297
|
-
{
|
|
1298
|
-
name: 'less',
|
|
1299
|
-
message: 'LESS [ https://lesscss.org ]',
|
|
1238
|
+
value: 'less',
|
|
1239
|
+
label: 'LESS [ https://lesscss.org ]',
|
|
1300
1240
|
},
|
|
1301
1241
|
],
|
|
1302
|
-
|
|
1303
|
-
|
|
1242
|
+
initial: 'css',
|
|
1243
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1244
|
+
}),
|
|
1245
|
+
};
|
|
1304
1246
|
style = reply.style;
|
|
1305
1247
|
}
|
|
1306
1248
|
if (parsedArgs.ssr !== undefined) {
|
|
1307
1249
|
ssr = parsedArgs.ssr;
|
|
1308
1250
|
}
|
|
1309
1251
|
else {
|
|
1310
|
-
const reply =
|
|
1311
|
-
{
|
|
1312
|
-
name: 'ssr',
|
|
1252
|
+
const reply = {
|
|
1253
|
+
ssr: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1313
1254
|
message: `Do you want to enable Server-Side Rendering (SSR)${bundler !== 'rspack'
|
|
1314
1255
|
? ' and Static Site Generation (SSG/Prerendering)?'
|
|
1315
1256
|
: '?'}`,
|
|
1316
|
-
|
|
1317
|
-
choices: [{ name: 'Yes' }, { name: 'No' }],
|
|
1318
|
-
initial: 1,
|
|
1257
|
+
initial: false,
|
|
1319
1258
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1320
|
-
|
|
1321
|
-
|
|
1259
|
+
skippedValue: true,
|
|
1260
|
+
}))
|
|
1261
|
+
? 'Yes'
|
|
1262
|
+
: 'No',
|
|
1263
|
+
};
|
|
1322
1264
|
ssr = reply.ssr === 'Yes';
|
|
1323
1265
|
}
|
|
1266
|
+
const formatter = await (0, prompts_1.determineFormatterOptions)(parsedArgs);
|
|
1267
|
+
const linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1324
1268
|
if (parsedArgs.unitTestRunner) {
|
|
1325
1269
|
unitTestRunner = parsedArgs.unitTestRunner;
|
|
1326
1270
|
}
|
|
@@ -1328,39 +1272,32 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1328
1272
|
unitTestRunner = undefined;
|
|
1329
1273
|
}
|
|
1330
1274
|
else {
|
|
1331
|
-
unitTestRunner = await
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
message: 'None',
|
|
1358
|
-
},
|
|
1359
|
-
],
|
|
1360
|
-
initial: 0,
|
|
1361
|
-
},
|
|
1362
|
-
])
|
|
1363
|
-
.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
|
+
}));
|
|
1364
1301
|
}
|
|
1365
1302
|
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
1366
1303
|
return {
|
|
@@ -1375,6 +1312,9 @@ async function determineAngularOptions(parsedArgs) {
|
|
|
1375
1312
|
ssr,
|
|
1376
1313
|
prefix,
|
|
1377
1314
|
zoneless,
|
|
1315
|
+
linter,
|
|
1316
|
+
formatter,
|
|
1317
|
+
workspaces,
|
|
1378
1318
|
};
|
|
1379
1319
|
}
|
|
1380
1320
|
async function determineNodeOptions(parsedArgs) {
|
|
@@ -1383,7 +1323,6 @@ async function determineNodeOptions(parsedArgs) {
|
|
|
1383
1323
|
let framework;
|
|
1384
1324
|
let docker;
|
|
1385
1325
|
let linter;
|
|
1386
|
-
let formatter;
|
|
1387
1326
|
let unitTestRunner = undefined;
|
|
1388
1327
|
const workspaces = parsedArgs.workspaces;
|
|
1389
1328
|
if (parsedArgs.preset) {
|
|
@@ -1421,39 +1360,24 @@ async function determineNodeOptions(parsedArgs) {
|
|
|
1421
1360
|
docker = parsedArgs.docker;
|
|
1422
1361
|
}
|
|
1423
1362
|
else {
|
|
1424
|
-
const reply =
|
|
1425
|
-
{
|
|
1426
|
-
name: 'docker',
|
|
1363
|
+
const reply = {
|
|
1364
|
+
docker: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1427
1365
|
message: 'Would you like to generate a Dockerfile? [https://docs.docker.com/]',
|
|
1428
|
-
|
|
1366
|
+
initial: false,
|
|
1429
1367
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
{
|
|
1436
|
-
name: 'No',
|
|
1437
|
-
},
|
|
1438
|
-
],
|
|
1439
|
-
initial: 1,
|
|
1440
|
-
},
|
|
1441
|
-
]);
|
|
1368
|
+
skippedValue: true,
|
|
1369
|
+
}))
|
|
1370
|
+
? 'Yes'
|
|
1371
|
+
: 'No',
|
|
1372
|
+
};
|
|
1442
1373
|
docker = reply.docker === 'Yes';
|
|
1443
1374
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
preferPrettier: true,
|
|
1451
|
-
});
|
|
1452
|
-
}
|
|
1453
|
-
else {
|
|
1454
|
-
linter = 'eslint';
|
|
1455
|
-
formatter = 'prettier';
|
|
1456
|
-
}
|
|
1375
|
+
// Asked outside the gate: neither answer depends on package-manager
|
|
1376
|
+
// workspaces, and `--no-workspaces` used to force prettier and ESLint
|
|
1377
|
+
// without asking.
|
|
1378
|
+
const formatter = await (0, prompts_1.determineFormatterOptions)(parsedArgs);
|
|
1379
|
+
linter = await (0, prompts_1.determineLinterOptions)(parsedArgs);
|
|
1380
|
+
unitTestRunner = await determineUnitTestRunner(parsedArgs);
|
|
1457
1381
|
return {
|
|
1458
1382
|
preset,
|
|
1459
1383
|
appName,
|
|
@@ -1466,65 +1390,56 @@ async function determineNodeOptions(parsedArgs) {
|
|
|
1466
1390
|
};
|
|
1467
1391
|
}
|
|
1468
1392
|
async function determinePackageBasedOrIntegratedOrStandalone() {
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
},
|
|
1488
|
-
],
|
|
1489
|
-
},
|
|
1490
|
-
]);
|
|
1393
|
+
const workspaceType = await (0, prompt_helpers_1.selectPrompt)({
|
|
1394
|
+
message: `Package-based monorepo, integrated monorepo, or standalone project?`,
|
|
1395
|
+
choices: [
|
|
1396
|
+
{
|
|
1397
|
+
value: 'package-based',
|
|
1398
|
+
label: 'Package-based Monorepo: Nx makes it fast, but lets you run things your way.',
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
value: 'integrated',
|
|
1402
|
+
label: 'Integrated Monorepo: Nx creates a monorepo that contains multiple projects.',
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
value: 'standalone',
|
|
1406
|
+
label: 'Standalone: Nx creates a single project and makes it fast.',
|
|
1407
|
+
},
|
|
1408
|
+
],
|
|
1409
|
+
initial: 'package-based',
|
|
1410
|
+
});
|
|
1491
1411
|
invariant(workspaceType, 'INVALID_WORKSPACE_TYPE', `Invalid workspace type. It must be one of the following: standalone, integrated. Got ${workspaceType}`);
|
|
1492
1412
|
return workspaceType;
|
|
1493
1413
|
}
|
|
1494
1414
|
async function determineStandaloneOrMonorepo() {
|
|
1495
|
-
const
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
},
|
|
1510
|
-
],
|
|
1511
|
-
},
|
|
1512
|
-
]);
|
|
1415
|
+
const workspaceType = await (0, prompt_helpers_1.selectPrompt)({
|
|
1416
|
+
message: `Integrated monorepo, or standalone project?`,
|
|
1417
|
+
choices: [
|
|
1418
|
+
{
|
|
1419
|
+
value: 'integrated',
|
|
1420
|
+
label: 'Integrated Monorepo: Nx creates a monorepo that contains multiple projects.',
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
value: 'standalone',
|
|
1424
|
+
label: 'Standalone: Nx creates a single project and makes it fast.',
|
|
1425
|
+
},
|
|
1426
|
+
],
|
|
1427
|
+
initial: 'standalone',
|
|
1428
|
+
});
|
|
1513
1429
|
invariant(workspaceType, 'INVALID_WORKSPACE_TYPE', `Invalid workspace type. It must be one of the following: standalone, integrated. Got ${workspaceType}`);
|
|
1514
1430
|
return workspaceType;
|
|
1515
1431
|
}
|
|
1516
1432
|
async function determineAppName(parsedArgs) {
|
|
1517
1433
|
if (parsedArgs.appName)
|
|
1518
1434
|
return parsedArgs.appName;
|
|
1519
|
-
const
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
]);
|
|
1435
|
+
const appName = await (0, prompt_helpers_1.textPrompt)({
|
|
1436
|
+
message: `Application name`,
|
|
1437
|
+
initialValue: parsedArgs.name,
|
|
1438
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1439
|
+
// Reject here so clearing the field re-prompts. The invariant below still
|
|
1440
|
+
// guards the skipped path, where no validator runs.
|
|
1441
|
+
validate: (value) => value.trim() ? undefined : 'Application name cannot be empty',
|
|
1442
|
+
});
|
|
1528
1443
|
invariant(appName, 'INVALID_APP_NAME', 'App name cannot be empty');
|
|
1529
1444
|
return appName;
|
|
1530
1445
|
}
|
|
@@ -1535,166 +1450,105 @@ async function determineReactFramework(parsedArgs) {
|
|
|
1535
1450
|
if (!parsedArgs.interactive) {
|
|
1536
1451
|
return 'none';
|
|
1537
1452
|
}
|
|
1538
|
-
const reply =
|
|
1539
|
-
{
|
|
1540
|
-
name: 'framework',
|
|
1453
|
+
const reply = {
|
|
1454
|
+
framework: await (0, prompt_helpers_1.selectPrompt)({
|
|
1541
1455
|
message: 'What framework would you like to use?',
|
|
1542
|
-
type: 'autocomplete',
|
|
1543
1456
|
choices: [
|
|
1544
1457
|
{
|
|
1545
|
-
|
|
1546
|
-
|
|
1458
|
+
value: 'none',
|
|
1459
|
+
label: 'None',
|
|
1547
1460
|
hint: ' I only want react, react-dom or react-router',
|
|
1548
1461
|
},
|
|
1462
|
+
{ value: 'next', label: 'Next.js [ https://nextjs.org/ ]' },
|
|
1463
|
+
{ value: 'expo', label: 'Expo [ https://expo.io/ ]' },
|
|
1549
1464
|
{
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
},
|
|
1553
|
-
{
|
|
1554
|
-
name: 'expo',
|
|
1555
|
-
message: 'Expo [ https://expo.io/ ]',
|
|
1556
|
-
},
|
|
1557
|
-
{
|
|
1558
|
-
name: 'react-native',
|
|
1559
|
-
message: 'React Native [ https://reactnative.dev/ ]',
|
|
1465
|
+
value: 'react-native',
|
|
1466
|
+
label: 'React Native [ https://reactnative.dev/ ]',
|
|
1560
1467
|
},
|
|
1561
1468
|
],
|
|
1562
|
-
initial:
|
|
1563
|
-
},
|
|
1564
|
-
|
|
1469
|
+
initial: 'none',
|
|
1470
|
+
}),
|
|
1471
|
+
};
|
|
1565
1472
|
return reply.framework;
|
|
1566
1473
|
}
|
|
1567
1474
|
async function determineReactBundler(parsedArgs) {
|
|
1568
1475
|
if (parsedArgs.bundler)
|
|
1569
1476
|
return parsedArgs.bundler;
|
|
1570
|
-
const reply =
|
|
1571
|
-
{
|
|
1572
|
-
name: 'bundler',
|
|
1477
|
+
const reply = {
|
|
1478
|
+
bundler: await (0, prompt_helpers_1.selectPrompt)({
|
|
1573
1479
|
message: `Which bundler would you like to use?`,
|
|
1574
|
-
type: 'autocomplete',
|
|
1575
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1576
1480
|
choices: [
|
|
1577
|
-
{
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
},
|
|
1581
|
-
{
|
|
1582
|
-
name: 'webpack',
|
|
1583
|
-
message: 'Webpack [ https://webpack.js.org/ ]',
|
|
1584
|
-
},
|
|
1585
|
-
{
|
|
1586
|
-
name: 'rspack',
|
|
1587
|
-
message: 'Rspack [ https://www.rspack.dev/ ]',
|
|
1588
|
-
},
|
|
1481
|
+
{ value: 'vite', label: 'Vite [ https://vite.dev/ ]' },
|
|
1482
|
+
{ value: 'webpack', label: 'Webpack [ https://webpack.js.org/ ]' },
|
|
1483
|
+
{ value: 'rspack', label: 'Rspack [ https://www.rspack.dev/ ]' },
|
|
1589
1484
|
],
|
|
1590
|
-
initial:
|
|
1591
|
-
|
|
1592
|
-
|
|
1485
|
+
initial: 'vite',
|
|
1486
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1487
|
+
}),
|
|
1488
|
+
};
|
|
1593
1489
|
return reply.bundler;
|
|
1594
1490
|
}
|
|
1595
1491
|
async function determineNextAppDir(parsedArgs) {
|
|
1596
1492
|
if (parsedArgs.nextAppDir !== undefined)
|
|
1597
1493
|
return parsedArgs.nextAppDir;
|
|
1598
|
-
const reply =
|
|
1599
|
-
{
|
|
1600
|
-
name: 'nextAppDir',
|
|
1494
|
+
const reply = {
|
|
1495
|
+
nextAppDir: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1601
1496
|
message: 'Would you like to use the App Router (recommended)?',
|
|
1602
|
-
type: 'autocomplete',
|
|
1603
1497
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
name: 'No',
|
|
1610
|
-
},
|
|
1611
|
-
],
|
|
1612
|
-
initial: 0,
|
|
1613
|
-
},
|
|
1614
|
-
]);
|
|
1498
|
+
skippedValue: true,
|
|
1499
|
+
}))
|
|
1500
|
+
? 'Yes'
|
|
1501
|
+
: 'No',
|
|
1502
|
+
};
|
|
1615
1503
|
return reply.nextAppDir === 'Yes';
|
|
1616
1504
|
}
|
|
1617
1505
|
async function determineNextSrcDir(parsedArgs) {
|
|
1618
1506
|
if (parsedArgs.nextSrcDir !== undefined)
|
|
1619
1507
|
return parsedArgs.nextSrcDir;
|
|
1620
|
-
const reply =
|
|
1621
|
-
{
|
|
1622
|
-
name: 'nextSrcDir',
|
|
1508
|
+
const reply = {
|
|
1509
|
+
nextSrcDir: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1623
1510
|
message: 'Would you like to use the src/ directory?',
|
|
1624
|
-
type: 'autocomplete',
|
|
1625
1511
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
name: 'No',
|
|
1632
|
-
},
|
|
1633
|
-
],
|
|
1634
|
-
initial: 0,
|
|
1635
|
-
},
|
|
1636
|
-
]);
|
|
1512
|
+
skippedValue: true,
|
|
1513
|
+
}))
|
|
1514
|
+
? 'Yes'
|
|
1515
|
+
: 'No',
|
|
1516
|
+
};
|
|
1637
1517
|
return reply.nextSrcDir === 'Yes';
|
|
1638
1518
|
}
|
|
1639
1519
|
async function determineVueFramework(parsedArgs) {
|
|
1640
1520
|
if (!!parsedArgs.framework)
|
|
1641
1521
|
return parsedArgs.framework;
|
|
1642
|
-
const reply =
|
|
1643
|
-
{
|
|
1644
|
-
name: 'framework',
|
|
1522
|
+
const reply = {
|
|
1523
|
+
framework: await (0, prompt_helpers_1.selectPrompt)({
|
|
1645
1524
|
message: 'What framework would you like to use?',
|
|
1646
|
-
type: 'autocomplete',
|
|
1647
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1648
1525
|
choices: [
|
|
1649
|
-
{
|
|
1650
|
-
|
|
1651
|
-
message: 'None',
|
|
1652
|
-
hint: ' I only want Vue',
|
|
1653
|
-
},
|
|
1654
|
-
{
|
|
1655
|
-
name: 'nuxt',
|
|
1656
|
-
message: 'Nuxt [ https://nuxt.com/ ]',
|
|
1657
|
-
},
|
|
1526
|
+
{ value: 'none', label: 'None', hint: ' I only want Vue' },
|
|
1527
|
+
{ value: 'nuxt', label: 'Nuxt [ https://nuxt.com/ ]' },
|
|
1658
1528
|
],
|
|
1659
|
-
initial:
|
|
1660
|
-
|
|
1661
|
-
|
|
1529
|
+
initial: 'none',
|
|
1530
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1531
|
+
}),
|
|
1532
|
+
};
|
|
1662
1533
|
return reply.framework;
|
|
1663
1534
|
}
|
|
1664
1535
|
async function determineNodeFramework(parsedArgs) {
|
|
1665
1536
|
if (!!parsedArgs.framework)
|
|
1666
1537
|
return parsedArgs.framework;
|
|
1667
|
-
const reply =
|
|
1668
|
-
{
|
|
1538
|
+
const reply = {
|
|
1539
|
+
framework: await (0, prompt_helpers_1.selectPrompt)({
|
|
1669
1540
|
message: 'What framework should be used?',
|
|
1670
|
-
type: 'autocomplete',
|
|
1671
|
-
name: 'framework',
|
|
1672
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1673
1541
|
choices: [
|
|
1674
|
-
{
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
},
|
|
1678
|
-
{
|
|
1679
|
-
name: 'express',
|
|
1680
|
-
message: 'Express [ https://expressjs.com/ ]',
|
|
1681
|
-
},
|
|
1682
|
-
{
|
|
1683
|
-
name: 'fastify',
|
|
1684
|
-
message: 'Fastify [ https://www.fastify.dev/ ]',
|
|
1685
|
-
},
|
|
1686
|
-
{
|
|
1687
|
-
name: 'koa',
|
|
1688
|
-
message: 'Koa [ https://koajs.com/ ]',
|
|
1689
|
-
},
|
|
1690
|
-
{
|
|
1691
|
-
name: 'nest',
|
|
1692
|
-
message: 'NestJs [ https://nestjs.com/ ]',
|
|
1693
|
-
},
|
|
1542
|
+
{ value: 'none', label: 'None' },
|
|
1543
|
+
{ value: 'express', label: 'Express [ https://expressjs.com/ ]' },
|
|
1544
|
+
{ value: 'fastify', label: 'Fastify [ https://www.fastify.dev/ ]' },
|
|
1545
|
+
{ value: 'koa', label: 'Koa [ https://koajs.com/ ]' },
|
|
1546
|
+
{ value: 'nest', label: 'NestJs [ https://nestjs.com/ ]' },
|
|
1694
1547
|
],
|
|
1695
|
-
initial:
|
|
1696
|
-
|
|
1697
|
-
|
|
1548
|
+
initial: 'none',
|
|
1549
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1550
|
+
}),
|
|
1551
|
+
};
|
|
1698
1552
|
return reply.framework;
|
|
1699
1553
|
}
|
|
1700
1554
|
async function determineUnitTestRunner(parsedArgs, options) {
|
|
@@ -1704,69 +1558,55 @@ async function determineUnitTestRunner(parsedArgs, options) {
|
|
|
1704
1558
|
else if (!parsedArgs.workspaces) {
|
|
1705
1559
|
return undefined;
|
|
1706
1560
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1561
|
+
// `none` sorts last and the preferred runner first, because the leading
|
|
1562
|
+
// choice is both the interactive default and the answer a skipped prompt
|
|
1563
|
+
// resolves to. Callers pass `exclude` to keep a runner they cannot support
|
|
1564
|
+
// off the list entirely.
|
|
1565
|
+
const choices = [
|
|
1566
|
+
{ value: 'none', label: 'None' },
|
|
1567
|
+
{ value: 'jest', label: 'Jest [ https://jestjs.io/ ]' },
|
|
1568
|
+
{ value: 'vitest', label: 'Vitest [ https://vitest.dev/ ]' },
|
|
1569
|
+
]
|
|
1570
|
+
.filter((t) => !options?.exclude || options.exclude !== t.value)
|
|
1571
|
+
.sort((a, b) => {
|
|
1572
|
+
if (a.value === 'none')
|
|
1573
|
+
return 1;
|
|
1574
|
+
if (b.value === 'none')
|
|
1575
|
+
return -1;
|
|
1576
|
+
if (options?.preferVitest && a.value === 'vitest')
|
|
1577
|
+
return -1;
|
|
1578
|
+
if (options?.preferVitest && b.value === 'vitest')
|
|
1579
|
+
return 1;
|
|
1580
|
+
return 0;
|
|
1581
|
+
});
|
|
1582
|
+
const reply = {
|
|
1583
|
+
unitTestRunner: await (0, prompt_helpers_1.selectPrompt)({
|
|
1709
1584
|
message: 'Which unit test runner would you like to use?',
|
|
1710
|
-
|
|
1711
|
-
|
|
1585
|
+
choices: [...choices],
|
|
1586
|
+
initial: choices[0].value,
|
|
1712
1587
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
name: 'none',
|
|
1716
|
-
message: 'None',
|
|
1717
|
-
},
|
|
1718
|
-
{
|
|
1719
|
-
name: 'jest',
|
|
1720
|
-
message: 'Jest [ https://jestjs.io/ ]',
|
|
1721
|
-
},
|
|
1722
|
-
{
|
|
1723
|
-
name: 'vitest',
|
|
1724
|
-
message: 'Vitest [ https://vitest.dev/ ]',
|
|
1725
|
-
},
|
|
1726
|
-
]
|
|
1727
|
-
.filter((t) => !options?.exclude || options.exclude !== t.name)
|
|
1728
|
-
.sort((a, b) => {
|
|
1729
|
-
if (a.name === 'none')
|
|
1730
|
-
return 1;
|
|
1731
|
-
if (b.name === 'none')
|
|
1732
|
-
return -1;
|
|
1733
|
-
if (options?.preferVitest && a.name === 'vitest')
|
|
1734
|
-
return -1;
|
|
1735
|
-
if (options?.preferVitest && b.name === 'vitest')
|
|
1736
|
-
return 1;
|
|
1737
|
-
return 0;
|
|
1738
|
-
}),
|
|
1739
|
-
initial: 0, // This should be either vite or jest
|
|
1740
|
-
},
|
|
1741
|
-
]);
|
|
1588
|
+
}),
|
|
1589
|
+
};
|
|
1742
1590
|
return reply.unitTestRunner;
|
|
1743
1591
|
}
|
|
1744
1592
|
async function determineE2eTestRunner(parsedArgs) {
|
|
1745
1593
|
if (parsedArgs.e2eTestRunner)
|
|
1746
1594
|
return parsedArgs.e2eTestRunner;
|
|
1747
|
-
const reply =
|
|
1748
|
-
{
|
|
1595
|
+
const reply = {
|
|
1596
|
+
e2eTestRunner: await (0, prompt_helpers_1.selectPrompt)({
|
|
1749
1597
|
message: 'Test runner to use for end to end (E2E) tests',
|
|
1750
|
-
type: 'autocomplete',
|
|
1751
|
-
name: 'e2eTestRunner',
|
|
1752
|
-
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1753
1598
|
choices: [
|
|
1754
1599
|
{
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
},
|
|
1758
|
-
{
|
|
1759
|
-
name: 'cypress',
|
|
1760
|
-
message: 'Cypress [ https://www.cypress.io/ ]',
|
|
1761
|
-
},
|
|
1762
|
-
{
|
|
1763
|
-
name: 'none',
|
|
1764
|
-
message: 'None',
|
|
1600
|
+
value: 'playwright',
|
|
1601
|
+
label: 'Playwright [ https://playwright.dev/ ]',
|
|
1765
1602
|
},
|
|
1603
|
+
{ value: 'cypress', label: 'Cypress [ https://www.cypress.io/ ]' },
|
|
1604
|
+
{ value: 'none', label: 'None' },
|
|
1766
1605
|
],
|
|
1767
|
-
initial:
|
|
1768
|
-
|
|
1769
|
-
|
|
1606
|
+
initial: 'playwright',
|
|
1607
|
+
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1608
|
+
}),
|
|
1609
|
+
};
|
|
1770
1610
|
return reply.e2eTestRunner;
|
|
1771
1611
|
}
|
|
1772
1612
|
async function determineReactRouter(parsedArgs) {
|
|
@@ -1774,23 +1614,14 @@ async function determineReactRouter(parsedArgs) {
|
|
|
1774
1614
|
return false;
|
|
1775
1615
|
if (parsedArgs.useReactRouter !== undefined)
|
|
1776
1616
|
return parsedArgs.useReactRouter;
|
|
1777
|
-
const reply =
|
|
1778
|
-
{
|
|
1617
|
+
const reply = {
|
|
1618
|
+
response: (await (0, prompt_helpers_1.confirmationPrompt)({
|
|
1779
1619
|
message: 'Would you like to use React Router for server-side rendering [https://reactrouter.com/]?',
|
|
1780
|
-
type: 'autocomplete',
|
|
1781
|
-
name: 'response',
|
|
1782
1620
|
skip: !parsedArgs.interactive || (0, is_ci_1.isCI)(),
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
{
|
|
1789
|
-
name: 'No',
|
|
1790
|
-
},
|
|
1791
|
-
],
|
|
1792
|
-
initial: 0,
|
|
1793
|
-
},
|
|
1794
|
-
]);
|
|
1621
|
+
skippedValue: true,
|
|
1622
|
+
}))
|
|
1623
|
+
? 'Yes'
|
|
1624
|
+
: 'No',
|
|
1625
|
+
};
|
|
1795
1626
|
return reply.response === 'Yes';
|
|
1796
1627
|
}
|