create-nx-workspace 23.2.0-beta.7 → 23.2.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  export { determineDefaultBase, determineLinterOptions, determineNxCloud, determinePackageManager, LINTERS, } from './src/internal-utils/prompts';
2
2
  export type { Linter } from './src/internal-utils/prompts';
3
+ export { selectPrompt, textPrompt, confirmationPrompt, } from './src/internal-utils/prompt-helpers';
3
4
  export { withAllPrompts, withGitOptions, withNxCloud, withOptions, withPackageManager, } from './src/internal-utils/yargs-options';
4
5
  export { output } from './src/utils/output';
5
6
  export type { NxCloud } from './src/utils/nx/nx-cloud';
package/dist/internal.js CHANGED
@@ -5,13 +5,17 @@
5
5
  // internal consumers and may change without semver protection. Mirrors
6
6
  // `@nx/devkit/internal`.
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.recordStat = exports.messages = exports.output = exports.withPackageManager = exports.withOptions = exports.withNxCloud = exports.withGitOptions = exports.withAllPrompts = exports.LINTERS = exports.determinePackageManager = exports.determineNxCloud = exports.determineLinterOptions = exports.determineDefaultBase = void 0;
8
+ exports.recordStat = exports.messages = exports.output = exports.withPackageManager = exports.withOptions = exports.withNxCloud = exports.withGitOptions = exports.withAllPrompts = exports.confirmationPrompt = exports.textPrompt = exports.selectPrompt = exports.LINTERS = exports.determinePackageManager = exports.determineNxCloud = exports.determineLinterOptions = exports.determineDefaultBase = void 0;
9
9
  var prompts_1 = require("./src/internal-utils/prompts");
10
10
  Object.defineProperty(exports, "determineDefaultBase", { enumerable: true, get: function () { return prompts_1.determineDefaultBase; } });
11
11
  Object.defineProperty(exports, "determineLinterOptions", { enumerable: true, get: function () { return prompts_1.determineLinterOptions; } });
12
12
  Object.defineProperty(exports, "determineNxCloud", { enumerable: true, get: function () { return prompts_1.determineNxCloud; } });
13
13
  Object.defineProperty(exports, "determinePackageManager", { enumerable: true, get: function () { return prompts_1.determinePackageManager; } });
14
14
  Object.defineProperty(exports, "LINTERS", { enumerable: true, get: function () { return prompts_1.LINTERS; } });
15
+ var prompt_helpers_1 = require("./src/internal-utils/prompt-helpers");
16
+ Object.defineProperty(exports, "selectPrompt", { enumerable: true, get: function () { return prompt_helpers_1.selectPrompt; } });
17
+ Object.defineProperty(exports, "textPrompt", { enumerable: true, get: function () { return prompt_helpers_1.textPrompt; } });
18
+ Object.defineProperty(exports, "confirmationPrompt", { enumerable: true, get: function () { return prompt_helpers_1.confirmationPrompt; } });
15
19
  var yargs_options_1 = require("./src/internal-utils/yargs-options");
16
20
  Object.defineProperty(exports, "withAllPrompts", { enumerable: true, get: function () { return yargs_options_1.withAllPrompts; } });
17
21
  Object.defineProperty(exports, "withGitOptions", { enumerable: true, get: function () { return yargs_options_1.withGitOptions; } });
@@ -22,7 +22,6 @@ const child_process_utils_1 = require("./utils/child-process-utils");
22
22
  const package_manager_1 = require("./utils/package-manager");
23
23
  const ai_output_1 = require("./utils/ai/ai-output");
24
24
  const prompts_1 = require("./internal-utils/prompts");
25
- const error_utils_2 = require("./utils/error-utils");
26
25
  // State for SIGINT handler - only set after workspace is fully installed
27
26
  let workspaceDirectory;
28
27
  let cloudConnectUrl;
@@ -49,7 +48,7 @@ async function createWorkspace(preset, options, rawArgs) {
49
48
  // Otherwise refuse to write over an existing path (the CLI already guards
50
49
  // this in determineFolder; this protects direct createWorkspace() callers).
51
50
  if (!options.useCurrentDir && (0, node_fs_1.existsSync)(directory)) {
52
- throw new error_utils_2.CnwError('DIRECTORY_EXISTS', `The directory '${directory}' already exists. Choose a different name or remove the existing directory.`);
51
+ throw new error_utils_1.CnwError('DIRECTORY_EXISTS', `The directory '${directory}' already exists. Choose a different name or remove the existing directory.`);
53
52
  }
54
53
  const aiMode = (0, ai_output_1.isAiAgent)();
55
54
  // Use spinner for human mode, progress logs for AI mode
@@ -113,7 +112,7 @@ async function createWorkspace(preset, options, rawArgs) {
113
112
  if (thirdPartyPackageName) {
114
113
  const confirmed = await (0, prompts_1.confirmThirdPartyPreset)(thirdPartyPackageName, options.interactive, options.trustThirdPartyPreset);
115
114
  if (!confirmed) {
116
- throw new error_utils_2.CnwError('INVALID_PRESET', `Aborted: not installing third-party preset '${thirdPartyPackageName}'.`);
115
+ throw new error_utils_1.CnwError('INVALID_PRESET', `Aborted: not installing third-party preset '${thirdPartyPackageName}'.`);
117
116
  }
118
117
  }
119
118
  const tmpDir = await (0, create_sandbox_1.createSandbox)(packageManager);
@@ -0,0 +1,57 @@
1
+ export interface Choice<T extends string> {
2
+ value: T;
3
+ label?: string;
4
+ hint?: string;
5
+ }
6
+ /**
7
+ * What a cancel resolves to. Defaults to aborting workspace creation; callers
8
+ * pass one when cancelling means something the flow can carry on from.
9
+ */
10
+ export type OnCancel<T> = () => T;
11
+ /** A bare string is a choice whose label is its value. */
12
+ export type ChoiceOrValue<T extends string> = T | Choice<T>;
13
+ interface SelectPromptOptions<T extends string> {
14
+ message: string;
15
+ choices: readonly ChoiceOrValue<T>[];
16
+ /**
17
+ * Answer without prompting. The value is the first choice unless
18
+ * `skippedValue` says otherwise.
19
+ */
20
+ skip?: boolean;
21
+ skippedValue?: T;
22
+ /** Highlighted when the prompt opens. Has no bearing on `skip`. */
23
+ initial?: T;
24
+ onCancel?: OnCancel<T>;
25
+ }
26
+ export declare function selectPrompt<T extends string>(options: SelectPromptOptions<T>): Promise<T>;
27
+ export declare function confirmationPrompt(options: {
28
+ message: string;
29
+ skip?: boolean;
30
+ /** Answer used when skipped. Defaults to yes, matching a first-choice skip. */
31
+ skippedValue?: boolean;
32
+ initial?: boolean;
33
+ onCancel?: OnCancel<boolean>;
34
+ }): Promise<boolean>;
35
+ export declare function textPrompt(options: {
36
+ message: string;
37
+ initialValue?: string;
38
+ /**
39
+ * Runs synchronously; clack does not await validators.
40
+ *
41
+ * Always receives a string. clack validates on Enter *before* it coerces an
42
+ * empty submit to `''`, so it would otherwise hand `undefined` to a prompt
43
+ * declaring no `initialValue`; the wrapper below normalizes that, matching
44
+ * what enquirer passed.
45
+ */
46
+ validate?: (value: string) => string | undefined;
47
+ skip?: boolean;
48
+ skippedValue?: string;
49
+ onCancel?: OnCancel<string>;
50
+ }): Promise<string>;
51
+ export declare function multiselectPrompt<T extends string>(options: {
52
+ message: string;
53
+ choices: readonly ChoiceOrValue<T>[];
54
+ required?: boolean;
55
+ initialValues?: readonly T[];
56
+ }): Promise<T[]>;
57
+ export {};
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectPrompt = selectPrompt;
4
+ exports.confirmationPrompt = confirmationPrompt;
5
+ exports.textPrompt = textPrompt;
6
+ exports.multiselectPrompt = multiselectPrompt;
7
+ const error_utils_1 = require("../utils/error-utils");
8
+ /**
9
+ * `@clack/prompts` is ESM-only. A static import would compile to `require()`
10
+ * under CommonJS emit and throw ERR_REQUIRE_ESM; `module: nodenext` preserves
11
+ * this dynamic form.
12
+ */
13
+ async function prompts() {
14
+ return await import('@clack/prompts');
15
+ }
16
+ function toChoice(choice) {
17
+ return typeof choice === 'string' ? { value: choice } : choice;
18
+ }
19
+ async function selectPrompt(options) {
20
+ if (options.skip) {
21
+ return options.skippedValue ?? toChoice(options.choices[0]).value;
22
+ }
23
+ const choices = options.choices.map(toChoice);
24
+ const { autocomplete, isCancel } = await prompts();
25
+ const answer = await autocomplete({
26
+ message: options.message,
27
+ // `Option<Value>` is conditional on `Value extends Primitive`, which
28
+ // TypeScript cannot resolve while `T` is still generic.
29
+ options: choices.map((c) => ({
30
+ value: c.value,
31
+ label: c.label ?? c.value,
32
+ ...(c.hint ? { hint: c.hint } : {}),
33
+ })),
34
+ initialValue: options.initial ?? choices[0].value,
35
+ // A no-match filter leaves clack with an empty selection, and Enter then
36
+ // submits `undefined` rather than blocking. `isCancel` does not catch
37
+ // that, so downstream comparisons would silently take a wrong branch.
38
+ validate: (value) => value === undefined ? 'Pick one of the listed options' : undefined,
39
+ });
40
+ // Ctrl+C yields a sentinel rather than throwing.
41
+ if (isCancel(answer)) {
42
+ if (options.onCancel) {
43
+ return options.onCancel();
44
+ }
45
+ throw new error_utils_1.CnwError('CANCELLED', 'Cancelled.');
46
+ }
47
+ return answer;
48
+ }
49
+ async function confirmationPrompt(options) {
50
+ const answer = await selectPrompt({
51
+ message: options.message,
52
+ choices: [{ value: 'Yes' }, { value: 'No' }],
53
+ skip: options.skip,
54
+ skippedValue: options.skippedValue === undefined
55
+ ? undefined
56
+ : options.skippedValue
57
+ ? 'Yes'
58
+ : 'No',
59
+ initial: options.initial === false ? 'No' : 'Yes',
60
+ onCancel: options.onCancel
61
+ ? () => (options.onCancel() ? 'Yes' : 'No')
62
+ : undefined,
63
+ });
64
+ return answer === 'Yes';
65
+ }
66
+ async function textPrompt(options) {
67
+ if (options.skip) {
68
+ return options.skippedValue ?? options.initialValue ?? '';
69
+ }
70
+ const { text, isCancel } = await prompts();
71
+ const answer = await text({
72
+ message: options.message,
73
+ initialValue: options.initialValue,
74
+ validate: options.validate
75
+ ? (value) => options.validate(value ?? '')
76
+ : undefined,
77
+ });
78
+ if (isCancel(answer)) {
79
+ if (options.onCancel) {
80
+ return options.onCancel();
81
+ }
82
+ throw new error_utils_1.CnwError('CANCELLED', 'Cancelled.');
83
+ }
84
+ return answer;
85
+ }
86
+ async function multiselectPrompt(options) {
87
+ const choices = options.choices.map(toChoice);
88
+ const { multiselect, isCancel } = await prompts();
89
+ const answer = await multiselect({
90
+ message: options.message,
91
+ options: choices.map((c) => ({
92
+ value: c.value,
93
+ label: c.label ?? c.value,
94
+ ...(c.hint ? { hint: c.hint } : {}),
95
+ })),
96
+ required: options.required ?? false,
97
+ initialValues: options.initialValues
98
+ ? [...options.initialValues]
99
+ : undefined,
100
+ });
101
+ if (isCancel(answer)) {
102
+ throw new error_utils_1.CnwError('CANCELLED', 'Cancelled.');
103
+ }
104
+ return answer;
105
+ }
@@ -12,7 +12,6 @@ exports.confirmThirdPartyPreset = confirmThirdPartyPreset;
12
12
  exports.determinePackageManager = determinePackageManager;
13
13
  exports.determineLinterOptions = determineLinterOptions;
14
14
  const tslib_1 = require("tslib");
15
- const enquirer_1 = tslib_1.__importDefault(require("enquirer"));
16
15
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
17
16
  const ab_testing_1 = require("../utils/nx/ab-testing");
18
17
  const default_base_1 = require("../utils/git/default-base");
@@ -23,6 +22,7 @@ const create_workspace_options_1 = require("../create-workspace-options");
23
22
  const ai_output_1 = require("../utils/ai/ai-output");
24
23
  const error_utils_1 = require("../utils/error-utils");
25
24
  const output_1 = require("../utils/output");
25
+ const prompt_helpers_1 = require("./prompt-helpers");
26
26
  async function determineNxCloud(parsedArgs) {
27
27
  if (parsedArgs.nxCloud) {
28
28
  return parsedArgs.nxCloud;
@@ -58,40 +58,30 @@ async function determineIfGitHubWillBeUsed(parsedArgs) {
58
58
  if (parsedArgs.nxCloud === 'yes' || parsedArgs.nxCloud === 'circleci') {
59
59
  if (parsedArgs?.useGitHub)
60
60
  return true;
61
- const reply = await enquirer_1.default.prompt([
62
- {
63
- name: 'github',
64
- message: 'Will you be using GitHub as your git hosting provider?',
65
- type: 'autocomplete',
66
- choices: [{ name: 'Yes' }, { name: 'No' }],
67
- initial: 0,
68
- },
69
- ]);
70
- return reply.github === 'Yes';
61
+ return (0, prompt_helpers_1.confirmationPrompt)({
62
+ message: 'Will you be using GitHub as your git hosting provider?',
63
+ });
71
64
  }
72
65
  return false;
73
66
  }
74
67
  async function nxCloudPrompt(key) {
75
- const { message, choices, initial, fallback, footer, hint } = ab_testing_1.messages.getPrompt(key);
76
- const promptConfig = {
77
- name: 'NxCloud',
78
- message,
79
- type: 'autocomplete',
80
- choices,
81
- initial,
82
- }; // meeroslav: types in enquirer are not up to date
83
- if (footer) {
84
- promptConfig.footer = () => chalk_1.default.dim(footer);
68
+ const { message, choices, initial, fallback, footer } = ab_testing_1.messages.getPrompt(key);
69
+ // These choices are `{ value, name }` with `name` as the display text — the
70
+ // inverse of enquirer's usual `{ name, message }`. Take `value` so the answer
71
+ // is the key the caller compares against, not the label.
72
+ const options = choices.map((c) => typeof c === 'string'
73
+ ? { value: c }
74
+ : { value: c.value ?? c.name, label: c.message ?? c.name ?? c.value });
75
+ const answer = (await (0, prompt_helpers_1.selectPrompt)({
76
+ // No separate footer slot, so it is folded into the message.
77
+ message: `${message}\n${chalk_1.default.dim(footer)}`,
78
+ choices: options,
79
+ initial: options[initial ?? 0]?.value,
80
+ }));
81
+ if (fallback && answer === fallback.value) {
82
+ return nxCloudPrompt(fallback.key);
85
83
  }
86
- if (hint) {
87
- promptConfig.hint = () => chalk_1.default.dim(hint);
88
- }
89
- return enquirer_1.default.prompt([promptConfig]).then((a) => {
90
- if (fallback && a.NxCloud === fallback.value) {
91
- return nxCloudPrompt(fallback.key);
92
- }
93
- return a.NxCloud;
94
- });
84
+ return answer;
95
85
  }
96
86
  async function determineTemplate(parsedArgs) {
97
87
  if (parsedArgs.template)
@@ -103,37 +93,32 @@ async function determineTemplate(parsedArgs) {
103
93
  // Docs generation needs preset flow to document all presets
104
94
  if (process.env.NX_GENERATE_DOCS_PROCESS === 'true')
105
95
  return 'custom';
106
- const { template } = await enquirer_1.default.prompt([
107
- {
108
- name: 'template',
109
- message: 'Which starter do you want to use?',
110
- type: 'autocomplete',
111
- choices: [
112
- {
113
- name: 'nrwl/empty-template',
114
- message: 'Minimal (empty monorepo without projects)',
115
- },
116
- {
117
- name: 'nrwl/react-template',
118
- message: 'React (fullstack monorepo with React and Express)',
119
- },
120
- {
121
- name: 'nrwl/angular-template',
122
- message: 'Angular (fullstack monorepo with Angular and Express)',
123
- },
124
- {
125
- name: 'nrwl/typescript-template',
126
- message: 'NPM Packages (monorepo with TypeScript packages ready to publish)',
127
- },
128
- {
129
- name: 'custom',
130
- message: 'Custom (advanced setup with additional frameworks)',
131
- },
132
- ],
133
- initial: 0,
134
- },
135
- ]);
136
- return template;
96
+ return (0, prompt_helpers_1.selectPrompt)({
97
+ message: 'Which starter do you want to use?',
98
+ choices: [
99
+ {
100
+ value: 'nrwl/empty-template',
101
+ label: 'Minimal (empty monorepo without projects)',
102
+ },
103
+ {
104
+ value: 'nrwl/react-template',
105
+ label: 'React (fullstack monorepo with React and Express)',
106
+ },
107
+ {
108
+ value: 'nrwl/angular-template',
109
+ label: 'Angular (fullstack monorepo with Angular and Express)',
110
+ },
111
+ {
112
+ value: 'nrwl/typescript-template',
113
+ label: 'NPM Packages (monorepo with TypeScript packages ready to publish)',
114
+ },
115
+ {
116
+ value: 'custom',
117
+ label: 'Custom (advanced setup with additional frameworks)',
118
+ },
119
+ ],
120
+ initial: 'nrwl/empty-template',
121
+ });
137
122
  }
138
123
  async function determineAiAgents(parsedArgs) {
139
124
  if (parsedArgs.aiAgents) {
@@ -150,17 +135,14 @@ async function determineAiAgents(parsedArgs) {
150
135
  return [];
151
136
  }
152
137
  async function aiAgentsPrompt() {
153
- const promptConfig = {
154
- name: 'agents',
138
+ return (0, prompt_helpers_1.multiselectPrompt)({
155
139
  message: 'Which AI agents, if any, would you like to set up?',
156
- type: 'multiselect',
157
140
  choices: create_workspace_options_1.supportedAgents.map((a) => ({
158
- name: a,
159
- message: create_workspace_options_1.agentDisplayMap[a],
141
+ value: a,
142
+ label: create_workspace_options_1.agentDisplayMap[a],
160
143
  })),
161
- footer: () => chalk_1.default.dim('Multiple selections possible. <Space> to select. <Enter> to confirm.'),
162
- };
163
- return (await enquirer_1.default.prompt([promptConfig])).agents;
144
+ required: false,
145
+ });
164
146
  }
165
147
  async function determineAnalytics(parsedArgs) {
166
148
  if (typeof parsedArgs.analytics === 'boolean') {
@@ -170,15 +152,14 @@ async function determineAnalytics(parsedArgs) {
170
152
  // Not asked in non-interactive/CI.
171
153
  return 'unset';
172
154
  }
173
- const { enableAnalytics } = await enquirer_1.default.prompt([
174
- {
175
- name: 'enableAnalytics',
176
- message: 'Help improve Nx by sharing your usage data?',
177
- type: 'autocomplete',
178
- choices: [{ name: 'Yes' }, { name: 'No' }],
179
- initial: 0,
180
- },
181
- ]);
155
+ const enableAnalytics = await (0, prompt_helpers_1.selectPrompt)({
156
+ message: 'Help improve Nx by sharing your usage data?',
157
+ choices: [
158
+ { value: 'Yes', label: 'Yes' },
159
+ { value: 'No', label: 'No' },
160
+ ],
161
+ initial: 'Yes',
162
+ });
182
163
  return enableAnalytics === 'Yes' ? 'yes' : 'no';
183
164
  }
184
165
  async function determineDefaultBase(parsedArgs) {
@@ -186,21 +167,17 @@ async function determineDefaultBase(parsedArgs) {
186
167
  return parsedArgs.defaultBase;
187
168
  }
188
169
  else if (parsedArgs.allPrompts) {
189
- return enquirer_1.default
190
- .prompt([
191
- {
192
- name: 'DefaultBase',
193
- message: `Main branch name`,
194
- initial: `main`,
195
- type: 'input',
196
- },
197
- ])
198
- .then((a) => {
199
- if (!a.DefaultBase) {
200
- throw new error_utils_1.CnwError('INVALID_BRANCH_NAME', 'Branch name cannot be empty');
201
- }
202
- return a.DefaultBase;
170
+ const defaultBase = await (0, prompt_helpers_1.textPrompt)({
171
+ message: `Main branch name`,
172
+ initialValue: `main`,
173
+ // Reject here so clearing the field re-prompts rather than aborting the
174
+ // run on the throw below.
175
+ validate: (value) => value.trim() ? undefined : 'Branch name cannot be empty',
203
176
  });
177
+ if (!defaultBase) {
178
+ throw new error_utils_1.CnwError('INVALID_BRANCH_NAME', 'Branch name cannot be empty');
179
+ }
180
+ return defaultBase;
204
181
  }
205
182
  return (0, default_base_1.deduceDefaultBase)();
206
183
  }
@@ -232,15 +209,14 @@ async function confirmThirdPartyPreset(packageName, interactive, trusted) {
232
209
  if (interactive === false || (0, is_ci_1.isCI)() || (0, ai_output_1.isAiAgent)()) {
233
210
  return true;
234
211
  }
235
- const { confirm } = await enquirer_1.default.prompt([
236
- {
237
- name: 'confirm',
238
- message: `Install third-party preset '${packageName}'?`,
239
- type: 'autocomplete',
240
- choices: [{ name: 'No' }, { name: 'Yes' }],
241
- initial: 0,
242
- },
243
- ]);
212
+ const confirm = await (0, prompt_helpers_1.selectPrompt)({
213
+ message: `Install third-party preset '${packageName}'?`,
214
+ choices: [
215
+ { value: 'No', label: 'No' },
216
+ { value: 'Yes', label: 'Yes' },
217
+ ],
218
+ initial: 'No',
219
+ });
244
220
  return confirm === 'Yes';
245
221
  }
246
222
  async function determinePackageManager(parsedArgs) {
@@ -254,22 +230,16 @@ async function determinePackageManager(parsedArgs) {
254
230
  ])}`);
255
231
  }
256
232
  else if (parsedArgs.allPrompts) {
257
- return enquirer_1.default
258
- .prompt([
259
- {
260
- name: 'packageManager',
261
- message: `Which package manager to use`,
262
- initial: 0,
263
- type: 'autocomplete',
264
- choices: [
265
- { name: 'npm', message: 'NPM' },
266
- { name: 'yarn', message: 'Yarn' },
267
- { name: 'pnpm', message: 'PNPM' },
268
- { name: 'bun', message: 'Bun' },
269
- ],
270
- },
271
- ])
272
- .then((a) => a.packageManager);
233
+ return (0, prompt_helpers_1.selectPrompt)({
234
+ message: `Which package manager to use`,
235
+ choices: [
236
+ { value: 'npm', label: 'NPM' },
237
+ { value: 'yarn', label: 'Yarn' },
238
+ { value: 'pnpm', label: 'PNPM' },
239
+ { value: 'bun', label: 'Bun' },
240
+ ],
241
+ initial: 'npm',
242
+ });
273
243
  }
274
244
  return (0, package_manager_1.detectInvokedPackageManager)();
275
245
  }
@@ -281,25 +251,20 @@ exports.LINTERS = ['eslint', 'oxlint', 'none'];
281
251
  async function determineLinterOptions(args) {
282
252
  if (args.linter)
283
253
  return args.linter;
284
- const reply = await enquirer_1.default.prompt([
285
- {
286
- name: 'linter',
287
- message: `Which linter would you like to use?`,
288
- type: 'autocomplete',
289
- // `name` is the value returned; `message` is what the list shows. Oxlint
290
- // is labelled so it isn't presented as an equal of ESLint here while the
291
- // docs and the package both call it experimental.
292
- choices: [
293
- { name: 'eslint' },
294
- { name: 'oxlint', message: 'oxlint (experimental)' },
295
- { name: 'none' },
296
- ],
297
- // A skipped prompt resolves to the first choice and ignores `initial`, so
298
- // the order above is what makes ESLint the non-interactive default while
299
- // Oxlint is experimental. Reorder the choices to change it.
300
- initial: 0,
301
- skip: !args.interactive || (0, is_ci_1.isCI)(),
302
- },
303
- ]);
304
- return reply.linter;
254
+ // ESLint is the non-interactive default; changing it means changing this
255
+ // line, not the option order.
256
+ if (!args.interactive || (0, is_ci_1.isCI)())
257
+ return 'eslint';
258
+ return (0, prompt_helpers_1.selectPrompt)({
259
+ message: `Which linter would you like to use?`,
260
+ // `value` is what's returned; `label` is what the list shows. Oxlint is
261
+ // labelled so it isn't presented as an equal of ESLint while the docs and
262
+ // the package both call it experimental.
263
+ choices: [
264
+ { value: 'eslint', label: 'eslint' },
265
+ { value: 'oxlint', label: 'oxlint (experimental)' },
266
+ { value: 'none', label: 'none' },
267
+ ],
268
+ initial: 'eslint',
269
+ });
305
270
  }
@@ -2,7 +2,7 @@
2
2
  * Error codes for CNW errors.
3
3
  * These are used for telemetry and error tracking.
4
4
  */
5
- export type CnwErrorCode = 'DIRECTORY_EXISTS' | 'INVALID_WORKSPACE_NAME' | 'INVALID_FOLDER_NAME' | 'INVALID_BRANCH_NAME' | 'INVALID_PACKAGE_MANAGER' | 'INVALID_PATH' | 'INVALID_PRESET' | 'INVALID_WORKSPACE_TYPE' | 'INVALID_APP_NAME' | 'PRESET_FAILED' | 'SANDBOX_FAILED' | 'TEMPLATE_CLONE_FAILED' | 'CI_WORKFLOW_FAILED' | 'WORKSPACE_CREATION_FAILED' | 'ANGULAR_PREFIX_INVALID' | 'INVALID_BUNDLER' | 'NETWORK_ERROR' | 'PACKAGE_INSTALL_ERROR' | 'UNKNOWN';
5
+ export type CnwErrorCode = 'DIRECTORY_EXISTS' | 'INVALID_WORKSPACE_NAME' | 'INVALID_FOLDER_NAME' | 'INVALID_BRANCH_NAME' | 'INVALID_PACKAGE_MANAGER' | 'INVALID_PATH' | 'INVALID_PRESET' | 'INVALID_WORKSPACE_TYPE' | 'INVALID_APP_NAME' | 'PRESET_FAILED' | 'SANDBOX_FAILED' | 'TEMPLATE_CLONE_FAILED' | 'CI_WORKFLOW_FAILED' | 'WORKSPACE_CREATION_FAILED' | 'ANGULAR_PREFIX_INVALID' | 'INVALID_BUNDLER' | 'NETWORK_ERROR' | 'PACKAGE_INSTALL_ERROR' | 'CANCELLED' | 'UNKNOWN';
6
6
  /**
7
7
  * Custom error class for CNW errors.
8
8
  * Used for structured error reporting and telemetry.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Ends the process the way an interrupted process ends: by SIGINT, not by
3
+ * exiting with its conventional code.
4
+ *
5
+ * A shell reports 130 either way, but a parent using waitpid sees
6
+ * `signal: 'SIGINT'` rather than `code: 130`, which is what tools wrapping
7
+ * this CLI check to tell "the user pressed Ctrl+C" from "the command failed".
8
+ *
9
+ * Kept in sync with `packages/nx/src/utils/exit-codes.ts`; this package
10
+ * deliberately does not depend on `nx`.
11
+ */
12
+ export declare function exitAsInterrupted(): never;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exitAsInterrupted = exitAsInterrupted;
4
+ /**
5
+ * Ends the process the way an interrupted process ends: by SIGINT, not by
6
+ * exiting with its conventional code.
7
+ *
8
+ * A shell reports 130 either way, but a parent using waitpid sees
9
+ * `signal: 'SIGINT'` rather than `code: 130`, which is what tools wrapping
10
+ * this CLI check to tell "the user pressed Ctrl+C" from "the command failed".
11
+ *
12
+ * Kept in sync with `packages/nx/src/utils/exit-codes.ts`; this package
13
+ * deliberately does not depend on `nx`.
14
+ */
15
+ function exitAsInterrupted() {
16
+ // Windows has no signal disposition to inherit - `process.kill` there
17
+ // terminates with an arbitrary code - so keep the 128+SIGINT convention.
18
+ if (process.platform !== 'win32') {
19
+ // Any listener would swallow this; the default action is what terminates.
20
+ process.removeAllListeners('SIGINT');
21
+ process.kill(process.pid, 'SIGINT');
22
+ }
23
+ process.exit(130);
24
+ }