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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LINTERS = void 0;
|
|
3
|
+
exports.FORMATTERS = exports.LINTERS = void 0;
|
|
4
4
|
exports.determineNxCloud = determineNxCloud;
|
|
5
5
|
exports.determineNxCloudV2 = determineNxCloudV2;
|
|
6
6
|
exports.determineIfGitHubWillBeUsed = determineIfGitHubWillBeUsed;
|
|
@@ -11,8 +11,8 @@ exports.determineDefaultBase = determineDefaultBase;
|
|
|
11
11
|
exports.confirmThirdPartyPreset = confirmThirdPartyPreset;
|
|
12
12
|
exports.determinePackageManager = determinePackageManager;
|
|
13
13
|
exports.determineLinterOptions = determineLinterOptions;
|
|
14
|
+
exports.determineFormatterOptions = determineFormatterOptions;
|
|
14
15
|
const tslib_1 = require("tslib");
|
|
15
|
-
const enquirer_1 = tslib_1.__importDefault(require("enquirer"));
|
|
16
16
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
17
17
|
const ab_testing_1 = require("../utils/nx/ab-testing");
|
|
18
18
|
const default_base_1 = require("../utils/git/default-base");
|
|
@@ -23,6 +23,7 @@ const create_workspace_options_1 = require("../create-workspace-options");
|
|
|
23
23
|
const ai_output_1 = require("../utils/ai/ai-output");
|
|
24
24
|
const error_utils_1 = require("../utils/error-utils");
|
|
25
25
|
const output_1 = require("../utils/output");
|
|
26
|
+
const prompt_helpers_1 = require("./prompt-helpers");
|
|
26
27
|
async function determineNxCloud(parsedArgs) {
|
|
27
28
|
if (parsedArgs.nxCloud) {
|
|
28
29
|
return parsedArgs.nxCloud;
|
|
@@ -58,40 +59,30 @@ async function determineIfGitHubWillBeUsed(parsedArgs) {
|
|
|
58
59
|
if (parsedArgs.nxCloud === 'yes' || parsedArgs.nxCloud === 'circleci') {
|
|
59
60
|
if (parsedArgs?.useGitHub)
|
|
60
61
|
return true;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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';
|
|
62
|
+
return (0, prompt_helpers_1.confirmationPrompt)({
|
|
63
|
+
message: 'Will you be using GitHub as your git hosting provider?',
|
|
64
|
+
});
|
|
71
65
|
}
|
|
72
66
|
return false;
|
|
73
67
|
}
|
|
74
68
|
async function nxCloudPrompt(key) {
|
|
75
|
-
const { message, choices, initial, fallback, footer
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
const { message, choices, initial, fallback, footer } = ab_testing_1.messages.getPrompt(key);
|
|
70
|
+
// These choices are `{ value, name }` with `name` as the display text — the
|
|
71
|
+
// inverse of enquirer's usual `{ name, message }`. Take `value` so the answer
|
|
72
|
+
// is the key the caller compares against, not the label.
|
|
73
|
+
const options = choices.map((c) => typeof c === 'string'
|
|
74
|
+
? { value: c }
|
|
75
|
+
: { value: c.value ?? c.name, label: c.message ?? c.name ?? c.value });
|
|
76
|
+
const answer = (await (0, prompt_helpers_1.selectPrompt)({
|
|
77
|
+
// No separate footer slot, so it is folded into the message.
|
|
78
|
+
message: `${message}\n${chalk_1.default.dim(footer)}`,
|
|
79
|
+
choices: options,
|
|
80
|
+
initial: options[initial ?? 0]?.value,
|
|
81
|
+
}));
|
|
82
|
+
if (fallback && answer === fallback.value) {
|
|
83
|
+
return nxCloudPrompt(fallback.key);
|
|
85
84
|
}
|
|
86
|
-
|
|
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
|
-
});
|
|
85
|
+
return answer;
|
|
95
86
|
}
|
|
96
87
|
async function determineTemplate(parsedArgs) {
|
|
97
88
|
if (parsedArgs.template)
|
|
@@ -103,37 +94,32 @@ async function determineTemplate(parsedArgs) {
|
|
|
103
94
|
// Docs generation needs preset flow to document all presets
|
|
104
95
|
if (process.env.NX_GENERATE_DOCS_PROCESS === 'true')
|
|
105
96
|
return 'custom';
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
],
|
|
133
|
-
initial: 0,
|
|
134
|
-
},
|
|
135
|
-
]);
|
|
136
|
-
return template;
|
|
97
|
+
return (0, prompt_helpers_1.selectPrompt)({
|
|
98
|
+
message: 'Which starter do you want to use?',
|
|
99
|
+
choices: [
|
|
100
|
+
{
|
|
101
|
+
value: 'nrwl/empty-template',
|
|
102
|
+
label: 'Minimal (empty monorepo without projects)',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
value: 'nrwl/react-template',
|
|
106
|
+
label: 'React (fullstack monorepo with React and Express)',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
value: 'nrwl/angular-template',
|
|
110
|
+
label: 'Angular (fullstack monorepo with Angular and Express)',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
value: 'nrwl/typescript-template',
|
|
114
|
+
label: 'NPM Packages (monorepo with TypeScript packages ready to publish)',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
value: 'custom',
|
|
118
|
+
label: 'Custom (advanced setup with additional frameworks)',
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
initial: 'nrwl/empty-template',
|
|
122
|
+
});
|
|
137
123
|
}
|
|
138
124
|
async function determineAiAgents(parsedArgs) {
|
|
139
125
|
if (parsedArgs.aiAgents) {
|
|
@@ -150,17 +136,14 @@ async function determineAiAgents(parsedArgs) {
|
|
|
150
136
|
return [];
|
|
151
137
|
}
|
|
152
138
|
async function aiAgentsPrompt() {
|
|
153
|
-
|
|
154
|
-
name: 'agents',
|
|
139
|
+
return (0, prompt_helpers_1.multiselectPrompt)({
|
|
155
140
|
message: 'Which AI agents, if any, would you like to set up?',
|
|
156
|
-
type: 'multiselect',
|
|
157
141
|
choices: create_workspace_options_1.supportedAgents.map((a) => ({
|
|
158
|
-
|
|
159
|
-
|
|
142
|
+
value: a,
|
|
143
|
+
label: create_workspace_options_1.agentDisplayMap[a],
|
|
160
144
|
})),
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
return (await enquirer_1.default.prompt([promptConfig])).agents;
|
|
145
|
+
required: false,
|
|
146
|
+
});
|
|
164
147
|
}
|
|
165
148
|
async function determineAnalytics(parsedArgs) {
|
|
166
149
|
if (typeof parsedArgs.analytics === 'boolean') {
|
|
@@ -170,15 +153,14 @@ async function determineAnalytics(parsedArgs) {
|
|
|
170
153
|
// Not asked in non-interactive/CI.
|
|
171
154
|
return 'unset';
|
|
172
155
|
}
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
]);
|
|
156
|
+
const enableAnalytics = await (0, prompt_helpers_1.selectPrompt)({
|
|
157
|
+
message: 'Help improve Nx by sharing your usage data?',
|
|
158
|
+
choices: [
|
|
159
|
+
{ value: 'Yes', label: 'Yes' },
|
|
160
|
+
{ value: 'No', label: 'No' },
|
|
161
|
+
],
|
|
162
|
+
initial: 'Yes',
|
|
163
|
+
});
|
|
182
164
|
return enableAnalytics === 'Yes' ? 'yes' : 'no';
|
|
183
165
|
}
|
|
184
166
|
async function determineDefaultBase(parsedArgs) {
|
|
@@ -186,21 +168,17 @@ async function determineDefaultBase(parsedArgs) {
|
|
|
186
168
|
return parsedArgs.defaultBase;
|
|
187
169
|
}
|
|
188
170
|
else if (parsedArgs.allPrompts) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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;
|
|
171
|
+
const defaultBase = await (0, prompt_helpers_1.textPrompt)({
|
|
172
|
+
message: `Main branch name`,
|
|
173
|
+
initialValue: `main`,
|
|
174
|
+
// Reject here so clearing the field re-prompts rather than aborting the
|
|
175
|
+
// run on the throw below.
|
|
176
|
+
validate: (value) => value.trim() ? undefined : 'Branch name cannot be empty',
|
|
203
177
|
});
|
|
178
|
+
if (!defaultBase) {
|
|
179
|
+
throw new error_utils_1.CnwError('INVALID_BRANCH_NAME', 'Branch name cannot be empty');
|
|
180
|
+
}
|
|
181
|
+
return defaultBase;
|
|
204
182
|
}
|
|
205
183
|
return (0, default_base_1.deduceDefaultBase)();
|
|
206
184
|
}
|
|
@@ -232,15 +210,14 @@ async function confirmThirdPartyPreset(packageName, interactive, trusted) {
|
|
|
232
210
|
if (interactive === false || (0, is_ci_1.isCI)() || (0, ai_output_1.isAiAgent)()) {
|
|
233
211
|
return true;
|
|
234
212
|
}
|
|
235
|
-
const
|
|
236
|
-
{
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
]);
|
|
213
|
+
const confirm = await (0, prompt_helpers_1.selectPrompt)({
|
|
214
|
+
message: `Install third-party preset '${packageName}'?`,
|
|
215
|
+
choices: [
|
|
216
|
+
{ value: 'No', label: 'No' },
|
|
217
|
+
{ value: 'Yes', label: 'Yes' },
|
|
218
|
+
],
|
|
219
|
+
initial: 'No',
|
|
220
|
+
});
|
|
244
221
|
return confirm === 'Yes';
|
|
245
222
|
}
|
|
246
223
|
async function determinePackageManager(parsedArgs) {
|
|
@@ -254,22 +231,16 @@ async function determinePackageManager(parsedArgs) {
|
|
|
254
231
|
])}`);
|
|
255
232
|
}
|
|
256
233
|
else if (parsedArgs.allPrompts) {
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
{ name: 'pnpm', message: 'PNPM' },
|
|
268
|
-
{ name: 'bun', message: 'Bun' },
|
|
269
|
-
],
|
|
270
|
-
},
|
|
271
|
-
])
|
|
272
|
-
.then((a) => a.packageManager);
|
|
234
|
+
return (0, prompt_helpers_1.selectPrompt)({
|
|
235
|
+
message: `Which package manager to use`,
|
|
236
|
+
choices: [
|
|
237
|
+
{ value: 'npm', label: 'NPM' },
|
|
238
|
+
{ value: 'yarn', label: 'Yarn' },
|
|
239
|
+
{ value: 'pnpm', label: 'PNPM' },
|
|
240
|
+
{ value: 'bun', label: 'Bun' },
|
|
241
|
+
],
|
|
242
|
+
initial: 'npm',
|
|
243
|
+
});
|
|
273
244
|
}
|
|
274
245
|
return (0, package_manager_1.detectInvokedPackageManager)();
|
|
275
246
|
}
|
|
@@ -281,25 +252,50 @@ exports.LINTERS = ['eslint', 'oxlint', 'none'];
|
|
|
281
252
|
async function determineLinterOptions(args) {
|
|
282
253
|
if (args.linter)
|
|
283
254
|
return args.linter;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
255
|
+
// ESLint is the non-interactive default; changing it means changing this
|
|
256
|
+
// line, not the option order.
|
|
257
|
+
if (!args.interactive || (0, is_ci_1.isCI)())
|
|
258
|
+
return 'eslint';
|
|
259
|
+
return (0, prompt_helpers_1.selectPrompt)({
|
|
260
|
+
message: `Which linter would you like to use?`,
|
|
261
|
+
// `value` is what's returned; `label` is what the list shows. Oxlint is
|
|
262
|
+
// labelled so it isn't presented as an equal of ESLint while the docs and
|
|
263
|
+
// the package both call it experimental.
|
|
264
|
+
choices: [
|
|
265
|
+
{ value: 'eslint', label: 'eslint' },
|
|
266
|
+
{ value: 'oxlint', label: 'oxlint (experimental)' },
|
|
267
|
+
{ value: 'none', label: 'none' },
|
|
268
|
+
],
|
|
269
|
+
initial: 'eslint',
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
// Order here is incidental; the prompt's own choice order sets the default. `satisfies` stops a typo
|
|
273
|
+
// getting in, and the coverage assertion below stops a member being dropped -
|
|
274
|
+
// on its own the array would happily be a subset, and the prompt would then
|
|
275
|
+
// reject a value the generator schemas still accept.
|
|
276
|
+
exports.FORMATTERS = [
|
|
277
|
+
'oxfmt',
|
|
278
|
+
'prettier',
|
|
279
|
+
'none',
|
|
280
|
+
];
|
|
281
|
+
const _formattersAreExhaustive = true;
|
|
282
|
+
async function determineFormatterOptions(args) {
|
|
283
|
+
if (args.formatter)
|
|
284
|
+
return args.formatter;
|
|
285
|
+
// Prettier is the non-interactive default; changing it means changing this
|
|
286
|
+
// line, not the option order.
|
|
287
|
+
if (!args.interactive || (0, is_ci_1.isCI)())
|
|
288
|
+
return 'prettier';
|
|
289
|
+
return (0, prompt_helpers_1.selectPrompt)({
|
|
290
|
+
message: `Which code formatter would you like to use?`,
|
|
291
|
+
// `value` is what's returned; `label` is what the list shows. oxfmt is
|
|
292
|
+
// labelled so it isn't presented as an equal of Prettier while it is
|
|
293
|
+
// pre-1.0.
|
|
294
|
+
choices: [
|
|
295
|
+
{ value: 'prettier', label: 'prettier' },
|
|
296
|
+
{ value: 'oxfmt', label: 'oxfmt (experimental)' },
|
|
297
|
+
{ value: 'none', label: 'none' },
|
|
298
|
+
],
|
|
299
|
+
initial: 'prettier',
|
|
300
|
+
});
|
|
305
301
|
}
|
|
@@ -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
|
+
}
|
|
@@ -5,12 +5,11 @@ exports.checkGitVersion = checkGitVersion;
|
|
|
5
5
|
exports.isGhCliAvailable = isGhCliAvailable;
|
|
6
6
|
exports.initializeGitRepo = initializeGitRepo;
|
|
7
7
|
exports.pushToGitHub = pushToGitHub;
|
|
8
|
-
const tslib_1 = require("tslib");
|
|
9
8
|
const child_process_1 = require("child_process");
|
|
10
9
|
const default_base_1 = require("./default-base");
|
|
11
10
|
const output_1 = require("../output");
|
|
12
11
|
const child_process_utils_1 = require("../child-process-utils");
|
|
13
|
-
const
|
|
12
|
+
const prompt_helpers_1 = require("../../internal-utils/prompt-helpers");
|
|
14
13
|
var VcsPushStatus;
|
|
15
14
|
(function (VcsPushStatus) {
|
|
16
15
|
VcsPushStatus["PushedToVcs"] = "PushedToVcs";
|
|
@@ -195,41 +194,41 @@ async function pushToGitHub(directory, options) {
|
|
|
195
194
|
// This runs while user is answering prompts, so validation is usually instant
|
|
196
195
|
populateExistingRepos(directory);
|
|
197
196
|
// First prompt: Ask if they want to push to GitHub
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
initial: 0,
|
|
205
|
-
},
|
|
206
|
-
]);
|
|
207
|
-
if (push !== 'Yes') {
|
|
197
|
+
// Cancelling is a decision not to push, not a failure to push.
|
|
198
|
+
const push = await (0, prompt_helpers_1.confirmationPrompt)({
|
|
199
|
+
message: 'Would you like to push this workspace to GitHub?',
|
|
200
|
+
onCancel: () => false,
|
|
201
|
+
});
|
|
202
|
+
if (!push) {
|
|
208
203
|
return VcsPushStatus.OptedOutOfPushingToVcs;
|
|
209
204
|
}
|
|
210
205
|
// Create default repository name using the username we already have
|
|
211
206
|
const defaultRepo = `${username}/${options.name}`;
|
|
212
207
|
const createRepoUrl = `https://github.com/new?name=${encodeURIComponent(options.name)}`;
|
|
213
208
|
// Second prompt: Ask where to create the repository with validation
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
209
|
+
// Validation runs synchronously, so the background fetch is resolved here
|
|
210
|
+
// rather than awaited inside it. It was started before the prompt above, so
|
|
211
|
+
// it has normally settled by now.
|
|
212
|
+
const existingRepos = await existingReposPromise;
|
|
213
|
+
// An empty name cannot come from the prompt - `validate` requires a slash -
|
|
214
|
+
// so it is unambiguous as the cancelled signal.
|
|
215
|
+
const repoName = await (0, prompt_helpers_1.textPrompt)({
|
|
216
|
+
message: 'Repository name (format: username/repo-name):',
|
|
217
|
+
initialValue: defaultRepo,
|
|
218
|
+
validate: (value) => {
|
|
219
|
+
if (!value.includes('/')) {
|
|
220
|
+
return 'Repository name must be in format: username/repo-name';
|
|
221
|
+
}
|
|
222
|
+
if (existingRepos?.has(value)) {
|
|
223
|
+
return `Repository '${value}' already exists. Choose a different name or create manually: ${createRepoUrl}`;
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
231
226
|
},
|
|
232
|
-
|
|
227
|
+
onCancel: () => '',
|
|
228
|
+
});
|
|
229
|
+
if (!repoName) {
|
|
230
|
+
return VcsPushStatus.OptedOutOfPushingToVcs;
|
|
231
|
+
}
|
|
233
232
|
// Create GitHub repository and push using gh CLI.
|
|
234
233
|
// Uses execAndWait (not spawnAndWait) so output is captured rather than
|
|
235
234
|
// streamed to the terminal. This prevents git push output from bleeding
|
|
@@ -174,8 +174,10 @@ const messageOptions = {
|
|
|
174
174
|
{ value: 'gitlab', name: 'Gitlab' },
|
|
175
175
|
{ value: 'azure', name: 'Azure DevOps' },
|
|
176
176
|
{ value: 'bitbucket-pipelines', name: 'BitBucket Pipelines' },
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
// Trailing newline puts a blank line before "Do it later". A leading
|
|
178
|
+
// one would split that choice from its own radio marker.
|
|
179
|
+
{ value: 'circleci', name: 'Circle CI\n' },
|
|
180
|
+
{ value: 'skip', name: 'Do it later' },
|
|
179
181
|
],
|
|
180
182
|
footer: `\nSelf-healing CI, remote caching, and task distribution are provided by Nx Cloud: ${exports.NX_CLOUD_HYPERLINK}`,
|
|
181
183
|
fallback: { value: 'skip', key: 'setupNxCloud' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nx-workspace",
|
|
3
|
-
"version": "23.2.0-beta.
|
|
3
|
+
"version": "23.2.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Smart Monorepos · Fast Builds",
|
|
6
6
|
"repository": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://nx.dev",
|
|
39
39
|
"dependencies": {
|
|
40
|
+
"@clack/prompts": "^1.7.0",
|
|
40
41
|
"axios": "1.18.1",
|
|
41
42
|
"chalk": "^4.1.0",
|
|
42
|
-
"enquirer": "~2.3.6",
|
|
43
43
|
"flat": "^5.0.2",
|
|
44
44
|
"open": "^8.4.0",
|
|
45
45
|
"ora": "^5.3.0",
|