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.
- package/dist/bin/create-nx-workspace.js +285 -458
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +5 -1
- package/dist/src/create-workspace.js +2 -3
- package/dist/src/internal-utils/prompt-helpers.d.ts +57 -0
- package/dist/src/internal-utils/prompt-helpers.js +105 -0
- package/dist/src/internal-utils/prompts.js +103 -138
- 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
|
@@ -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.8",
|
|
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",
|