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.
@@ -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 enquirer_1 = tslib_1.__importDefault(require("enquirer"));
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
- const { push } = await enquirer_1.default.prompt([
199
- {
200
- name: 'push',
201
- message: 'Would you like to push this workspace to GitHub?',
202
- type: 'autocomplete',
203
- choices: [{ name: 'Yes' }, { name: 'No' }],
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
- const { repoName } = await enquirer_1.default.prompt([
215
- {
216
- name: 'repoName',
217
- message: 'Repository name (format: username/repo-name):',
218
- type: 'input',
219
- initial: defaultRepo,
220
- validate: async (value) => {
221
- if (!value.includes('/')) {
222
- return 'Repository name must be in format: username/repo-name';
223
- }
224
- // Wait for background fetch to complete before validating
225
- const existingRepos = await existingReposPromise;
226
- if (existingRepos?.has(value)) {
227
- return `Repository '${value}' already exists. Choose a different name or create manually: ${createRepoUrl}`;
228
- }
229
- return true;
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
@@ -44,7 +44,6 @@ interface MessageData {
44
44
  name: string;
45
45
  }>;
46
46
  footer: string;
47
- hint?: string;
48
47
  fallback?: {
49
48
  value: string;
50
49
  key: MessageKey;
@@ -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
- { value: 'circleci', name: 'Circle CI' },
178
- { value: 'skip', name: '\nDo it later' },
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.7",
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",