create-nx-workspace 22.6.0-rc.2 → 22.6.1

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 +1 @@
1
- {"version":3,"file":"create-nx-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/bin/create-nx-workspace.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"create-nx-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/bin/create-nx-workspace.ts"],"names":[],"mappings":"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"}
@@ -159,51 +159,7 @@ exports.commandsObject = yargs
159
159
  describe: chalk.dim `GitHub template repository to use. Available templates: nrwl/empty-template, nrwl/react-template, nrwl/angular-template, nrwl/typescript-template`,
160
160
  type: 'string',
161
161
  }), yargs_options_1.withNxCloud, yargs_options_1.withUseGitHub, yargs_options_1.withAllPrompts, yargs_options_1.withPackageManager, yargs_options_1.withGitOptions, yargs_options_1.withAnalytics), async function handler(argv) {
162
- await main(argv).catch(async (error) => {
163
- const { version } = require('../package.json');
164
- // Record error stat for telemetry
165
- const errorCode = error instanceof error_utils_1.CnwError ? error.code : 'UNKNOWN';
166
- const errorMessage = error instanceof Error ? error.message : String(error);
167
- const errorFile = error instanceof Error ? extractErrorFile(error) : undefined;
168
- useCloud = argv.nxCloud !== 'skip' && argv.nxCloud !== 'never';
169
- await (0, ab_testing_1.recordStat)({
170
- nxVersion: nx_version_1.nxVersion,
171
- command: 'create-nx-workspace',
172
- useCloud,
173
- meta: {
174
- type: 'error',
175
- flowVariant: (0, ab_testing_1.getFlowVariant)(),
176
- errorCode,
177
- errorMessage,
178
- errorFile: errorFile ?? '',
179
- template: chosenTemplate ?? '',
180
- preset: chosenPreset ?? '',
181
- nodeVersion: process.versions.node ?? '',
182
- packageManager: packageManager ?? '',
183
- aiAgent: (0, ai_output_1.isAiAgent)(),
184
- },
185
- });
186
- // Output error in appropriate format
187
- if ((0, ai_output_1.isAiAgent)()) {
188
- const errorCode = error instanceof error_utils_1.CnwError ? error.code : 'UNKNOWN';
189
- const errorMessage = error instanceof Error ? error.message : String(error);
190
- const errorLogPath = error instanceof error_utils_1.CnwError ? error.logFile : undefined;
191
- (0, ai_output_1.writeAiOutput)((0, ai_output_1.buildErrorResult)(errorMessage, errorCode, errorLogPath));
192
- }
193
- else if (error instanceof error_utils_1.CnwError) {
194
- output_1.output.error({
195
- title: `Failed to create workspace`,
196
- bodyLines: error.message.split('\n').filter((line) => line.trim()),
197
- });
198
- }
199
- else {
200
- output_1.output.error({
201
- title: `Failed to create workspace (v${version})`,
202
- bodyLines: (0, error_utils_1.mapErrorToBodyLines)(error),
203
- });
204
- }
205
- process.exit(1);
206
- });
162
+ await main(argv).catch(handleError);
207
163
  }, [normalizeArgsMiddleware])
208
164
  .help('help', chalk.dim `Show help`)
209
165
  .updateLocale(decorator_1.yargsDecorator)
@@ -243,6 +199,16 @@ process.on('uncaughtException', (error) => {
243
199
  });
244
200
  // Handle Ctrl+C gracefully - show helpful message if workspace was already created
245
201
  process.on('SIGINT', async () => {
202
+ await (0, ab_testing_1.recordStat)({
203
+ nxVersion: nx_version_1.nxVersion,
204
+ command: 'create-nx-workspace',
205
+ useCloud: false,
206
+ meta: {
207
+ type: 'cancel',
208
+ flowVariant: (0, ab_testing_1.getFlowVariant)(),
209
+ aiAgent: (0, ai_output_1.isAiAgent)(),
210
+ },
211
+ });
246
212
  const { directory, connectUrl } = (0, create_workspace_1.getInterruptedWorkspaceState)();
247
213
  if (directory) {
248
214
  const path = require('path');
@@ -276,7 +242,7 @@ async function main(parsedArgs) {
276
242
  await (0, ab_testing_1.recordStat)({
277
243
  nxVersion: nx_version_1.nxVersion,
278
244
  command: 'create-nx-workspace',
279
- useCloud: parsedArgs.nxCloud !== 'skip' && parsedArgs.nxCloud !== 'never',
245
+ useCloud,
280
246
  meta: {
281
247
  type: 'complete',
282
248
  flowVariant: (0, ab_testing_1.getFlowVariant)(),
@@ -308,13 +274,54 @@ async function main(parsedArgs) {
308
274
  else if (parsedArgs.nxCloud && workspaceInfo.nxCloudInfo) {
309
275
  process.stdout.write(workspaceInfo.nxCloudInfo);
310
276
  }
311
- // if (isKnownPreset(parsedArgs.preset)) {
312
- // printSocialInformation();
313
- // } else {
314
- // output.log({
315
- // title: `Successfully applied preset: ${parsedArgs.preset}`,
316
- // });
317
- // }
277
+ }
278
+ async function handleError(error) {
279
+ const { version } = require('../package.json');
280
+ // Record error stat for telemetry
281
+ const errorCode = error instanceof error_utils_1.CnwError ? error.code : 'UNKNOWN';
282
+ const errorMessage = error instanceof Error ? error.message : String(error);
283
+ const errorFile = error instanceof Error ? extractErrorFile(error) : undefined;
284
+ await (0, ab_testing_1.recordStat)({
285
+ nxVersion: nx_version_1.nxVersion,
286
+ command: 'create-nx-workspace',
287
+ useCloud,
288
+ meta: {
289
+ type: 'error',
290
+ flowVariant: (0, ab_testing_1.getFlowVariant)(),
291
+ errorCode,
292
+ errorMessage,
293
+ errorFile: errorFile ?? '',
294
+ template: chosenTemplate ?? '',
295
+ preset: chosenPreset ?? '',
296
+ nodeVersion: process.versions.node ?? '',
297
+ packageManager: packageManager ?? '',
298
+ aiAgent: (0, ai_output_1.isAiAgent)(),
299
+ },
300
+ });
301
+ // Output error in appropriate format
302
+ if ((0, ai_output_1.isAiAgent)()) {
303
+ const errorCode = error instanceof error_utils_1.CnwError ? error.code : 'UNKNOWN';
304
+ const errorMessage = error instanceof Error ? error.message : String(error);
305
+ const errorLogPath = error instanceof error_utils_1.CnwError ? error.logFile : undefined;
306
+ (0, ai_output_1.writeAiOutput)((0, ai_output_1.buildErrorResult)(errorMessage, errorCode, errorLogPath));
307
+ }
308
+ else {
309
+ let bodyLines;
310
+ if (error instanceof error_utils_1.CnwError) {
311
+ bodyLines = error.message.split('\n').filter((line) => line.trim());
312
+ }
313
+ else if (error instanceof Error) {
314
+ bodyLines = (0, error_utils_1.mapErrorToBodyLines)(error);
315
+ }
316
+ else {
317
+ bodyLines = [String(error)];
318
+ }
319
+ output_1.output.error({
320
+ title: `Failed to create workspace`,
321
+ bodyLines,
322
+ });
323
+ }
324
+ process.exit(1);
318
325
  }
319
326
  /**
320
327
  * This function is used to normalize the arguments passed to the command.
@@ -323,272 +330,279 @@ async function main(parsedArgs) {
323
330
  * @param argv user arguments
324
331
  */
325
332
  async function normalizeArgsMiddleware(argv) {
326
- rawArgs = { ...argv };
327
- // Map invalid/legacy presets to templates for all users
328
- // These presets don't exist as npm packages and would fail if not mapped
329
- const invalidPresetToTemplateMap = {
330
- empty: 'nrwl/empty-template',
331
- };
332
- if (rawArgs.preset && !rawArgs.template) {
333
- const mappedTemplate = invalidPresetToTemplateMap[rawArgs.preset];
334
- if (mappedTemplate) {
335
- output_1.output.log({
336
- title: `Mapping preset '${rawArgs.preset}' to template '${mappedTemplate}'`,
337
- });
338
- argv.template = mappedTemplate;
339
- rawArgs.template = mappedTemplate;
340
- delete argv.preset;
341
- delete rawArgs.preset;
342
- }
343
- }
344
- // AI Agent Detection: When an AI agent is detected, switch to AI-optimized mode
345
- const aiMode = (0, ai_output_1.isAiAgent)();
346
- if (aiMode) {
347
- // Force non-interactive mode for AI agents
348
- argv.interactive = false;
349
- // Map legacy presets to templates for AI agents
350
- // Many AI models were trained on old preset syntax, so we convert them
351
- const legacyPresetToTemplateMap = {
352
- ts: 'nrwl/empty-template',
353
- apps: 'nrwl/empty-template',
354
- react: 'nrwl/react-template',
355
- 'react-monorepo': 'nrwl/react-template',
356
- angular: 'nrwl/angular-template',
357
- 'angular-monorepo': 'nrwl/angular-template',
358
- npm: 'nrwl/typescript-template',
359
- typescript: 'nrwl/typescript-template',
333
+ try {
334
+ rawArgs = { ...argv };
335
+ // Map invalid/legacy presets to templates for all users
336
+ // These presets don't exist as npm packages and would fail if not mapped
337
+ const invalidPresetToTemplateMap = {
338
+ empty: 'nrwl/empty-template',
360
339
  };
361
- // If AI provided a mappable preset without a template, convert it
362
340
  if (rawArgs.preset && !rawArgs.template) {
363
- const mappedTemplate = legacyPresetToTemplateMap[rawArgs.preset];
341
+ const mappedTemplate = invalidPresetToTemplateMap[rawArgs.preset];
364
342
  if (mappedTemplate) {
365
- (0, ai_output_1.logProgress)('starting', `Mapping legacy preset '${rawArgs.preset}' to template '${mappedTemplate}'`);
343
+ output_1.output.log({
344
+ title: `Mapping preset '${rawArgs.preset}' to template '${mappedTemplate}'`,
345
+ });
366
346
  argv.template = mappedTemplate;
367
347
  rawArgs.template = mappedTemplate;
368
- // Clear preset so template flow is used
369
348
  delete argv.preset;
370
349
  delete rawArgs.preset;
371
350
  }
372
351
  }
373
- // Check if --template or --preset was EXPLICITLY provided via CLI
374
- const templateProvided = Boolean(rawArgs.template);
375
- const presetProvided = Boolean(rawArgs.preset);
376
- // If no template/preset provided, output help and exit
377
- // AI agent must explicitly choose a template after asking the user
378
- if (!templateProvided && !presetProvided) {
379
- const workspaceName = argv.name || argv._[0];
380
- (0, ai_output_1.writeAiOutput)((0, ai_output_1.buildTemplateRequiredResult)(workspaceName));
381
- await (0, ab_testing_1.recordStat)({
382
- nxVersion: nx_version_1.nxVersion,
383
- command: 'create-nx-workspace',
384
- useCloud: false,
385
- meta: {
386
- type: 'cancel',
387
- flowVariant: (0, ab_testing_1.getFlowVariant)(),
388
- aiAgent: true,
389
- },
390
- });
391
- process.exit(0); // Exit 0 - JSON output has success: false, AI parses that
352
+ // AI Agent Detection: When an AI agent is detected, switch to AI-optimized mode
353
+ const aiMode = (0, ai_output_1.isAiAgent)();
354
+ if (aiMode) {
355
+ // Force non-interactive mode for AI agents
356
+ argv.interactive = false;
357
+ // Map legacy presets to templates for AI agents
358
+ // Many AI models were trained on old preset syntax, so we convert them
359
+ const legacyPresetToTemplateMap = {
360
+ ts: 'nrwl/empty-template',
361
+ apps: 'nrwl/empty-template',
362
+ react: 'nrwl/react-template',
363
+ 'react-monorepo': 'nrwl/react-template',
364
+ angular: 'nrwl/angular-template',
365
+ 'angular-monorepo': 'nrwl/angular-template',
366
+ npm: 'nrwl/typescript-template',
367
+ typescript: 'nrwl/typescript-template',
368
+ };
369
+ // If AI provided a mappable preset without a template, convert it
370
+ if (rawArgs.preset && !rawArgs.template) {
371
+ const mappedTemplate = legacyPresetToTemplateMap[rawArgs.preset];
372
+ if (mappedTemplate) {
373
+ (0, ai_output_1.logProgress)('starting', `Mapping legacy preset '${rawArgs.preset}' to template '${mappedTemplate}'`);
374
+ argv.template = mappedTemplate;
375
+ rawArgs.template = mappedTemplate;
376
+ // Clear preset so template flow is used
377
+ delete argv.preset;
378
+ delete rawArgs.preset;
379
+ }
380
+ }
381
+ // Check if --template or --preset was EXPLICITLY provided via CLI
382
+ const templateProvided = Boolean(rawArgs.template);
383
+ const presetProvided = Boolean(rawArgs.preset);
384
+ // If no template/preset provided, output help and exit
385
+ // AI agent must explicitly choose a template after asking the user
386
+ if (!templateProvided && !presetProvided) {
387
+ const workspaceName = argv.name || argv._[0];
388
+ (0, ai_output_1.writeAiOutput)((0, ai_output_1.buildTemplateRequiredResult)(workspaceName));
389
+ await (0, ab_testing_1.recordStat)({
390
+ nxVersion: nx_version_1.nxVersion,
391
+ command: 'create-nx-workspace',
392
+ useCloud: false,
393
+ meta: {
394
+ type: 'cancel',
395
+ flowVariant: (0, ab_testing_1.getFlowVariant)(),
396
+ aiAgent: true,
397
+ },
398
+ });
399
+ process.exit(0); // Exit 0 - JSON output has success: false, AI parses that
400
+ }
401
+ // Log starting progress (only if we have a template)
402
+ (0, ai_output_1.logProgress)('starting', `Creating Nx workspace v${nx_version_1.nxVersion}...`);
403
+ // Use suggested workspace name if not provided
404
+ // AI should check if directory exists and append number if needed (e.g., my-nx-repo-2)
405
+ if (!argv.name && !argv._[0]) {
406
+ argv.name = ai_output_1.SUGGESTED_WORKSPACE_NAME;
407
+ (0, ai_output_1.logProgress)('starting', `Using workspace name: ${argv.name} (if directory exists, re-run with a different name like my-nx-repo-2)`);
408
+ }
409
+ // Always enable Nx Cloud for AI agents - ignore --nxCloud=skip since the AI
410
+ // may pass it without asking the user. Nx Cloud is required for the full experience.
411
+ argv.nxCloud = 'yes';
412
+ // Skip GitHub push prompts in AI mode - we'll provide instructions in the success output
413
+ argv.skipGitHubPush = true;
392
414
  }
393
- // Log starting progress (only if we have a template)
394
- (0, ai_output_1.logProgress)('starting', `Creating Nx workspace v${nx_version_1.nxVersion}...`);
395
- // Use suggested workspace name if not provided
396
- // AI should check if directory exists and append number if needed (e.g., my-nx-repo-2)
397
- if (!argv.name && !argv._[0]) {
398
- argv.name = ai_output_1.SUGGESTED_WORKSPACE_NAME;
399
- (0, ai_output_1.logProgress)('starting', `Using workspace name: ${argv.name} (if directory exists, re-run with a different name like my-nx-repo-2)`);
415
+ else {
416
+ output_1.output.log({
417
+ title: "Let's create a new workspace [https://nx.dev/getting-started/intro]",
418
+ });
400
419
  }
401
- // Always enable Nx Cloud for AI agents - ignore --nxCloud=skip since the AI
402
- // may pass it without asking the user. Nx Cloud is required for the full experience.
403
- argv.nxCloud = 'yes';
404
- // Skip GitHub push prompts in AI mode - we'll provide instructions in the success output
405
- argv.skipGitHubPush = true;
406
- }
407
- else {
408
- output_1.output.log({
409
- title: "Let's create a new workspace [https://nx.dev/getting-started/intro]",
420
+ argv.workspaces ??= true;
421
+ argv.useProjectJson ??= !argv.workspaces;
422
+ useCloud = argv.nxCloud !== 'skip' && argv.nxCloud !== 'never';
423
+ await (0, ab_testing_1.recordStat)({
424
+ nxVersion: nx_version_1.nxVersion,
425
+ command: 'create-nx-workspace',
426
+ useCloud,
427
+ meta: {
428
+ type: 'start',
429
+ flowVariant: (0, ab_testing_1.getFlowVariant)(),
430
+ nodeVersion: process.versions.node,
431
+ aiAgent: (0, ai_output_1.isAiAgent)(),
432
+ },
410
433
  });
411
- }
412
- argv.workspaces ??= true;
413
- argv.useProjectJson ??= !argv.workspaces;
414
- await (0, ab_testing_1.recordStat)({
415
- nxVersion: nx_version_1.nxVersion,
416
- command: 'create-nx-workspace',
417
- useCloud: argv.nxCloud !== 'skip' && argv.nxCloud !== 'never',
418
- meta: {
419
- type: 'start',
420
- flowVariant: (0, ab_testing_1.getFlowVariant)(),
421
- nodeVersion: process.versions.node,
422
- aiAgent: (0, ai_output_1.isAiAgent)(),
423
- },
424
- });
425
- try {
426
- argv.name = await determineFolder(argv);
427
- const template = await (0, prompts_1.determineTemplate)(argv);
428
- chosenTemplate = template;
429
- if (template !== 'custom') {
430
- // Template flow - respects CLI arg, otherwise uses detected package manager (from invoking command)
431
- argv.template = template;
432
- const aiAgents = await (0, prompts_1.determineAiAgents)(argv);
433
- // Track GH CLI availability for telemetry
434
- const ghAvailable = (0, git_1.isGhCliAvailable)();
435
- let nxCloud;
436
- let completionMessageKey;
437
- let skipCloudConnect = false;
438
- let neverConnectToCloud = false;
439
- if (argv.skipGit === true) {
440
- nxCloud = 'skip';
441
- completionMessageKey = undefined;
442
- }
443
- else {
444
- const cloudChoice = await (0, prompts_1.determineNxCloudV2)(argv);
445
- if (cloudChoice === 'yes') {
446
- nxCloud = 'yes';
447
- skipCloudConnect = false;
448
- }
449
- else if (cloudChoice === 'skip') {
434
+ try {
435
+ argv.name = await determineFolder(argv);
436
+ const template = await (0, prompts_1.determineTemplate)(argv);
437
+ chosenTemplate = template;
438
+ if (template !== 'custom') {
439
+ // Template flow - respects CLI arg, otherwise uses detected package manager (from invoking command)
440
+ argv.template = template;
441
+ const aiAgents = await (0, prompts_1.determineAiAgents)(argv);
442
+ // Track GH CLI availability for telemetry
443
+ const ghAvailable = (0, git_1.isGhCliAvailable)();
444
+ let nxCloud;
445
+ let completionMessageKey;
446
+ let skipCloudConnect = false;
447
+ let neverConnectToCloud = false;
448
+ if (argv.skipGit === true) {
450
449
  nxCloud = 'skip';
450
+ completionMessageKey = undefined;
451
451
  }
452
452
  else {
453
- nxCloud = 'never';
454
- neverConnectToCloud = true;
453
+ const cloudChoice = await (0, prompts_1.determineNxCloudV2)(argv);
454
+ if (cloudChoice === 'yes') {
455
+ nxCloud = 'yes';
456
+ skipCloudConnect = false;
457
+ }
458
+ else if (cloudChoice === 'skip') {
459
+ nxCloud = 'skip';
460
+ }
461
+ else {
462
+ nxCloud = 'never';
463
+ neverConnectToCloud = true;
464
+ }
465
+ completionMessageKey =
466
+ cloudChoice === 'never'
467
+ ? undefined
468
+ : (0, ab_testing_1.getCompletionMessageKeyForVariant)();
455
469
  }
456
- completionMessageKey =
457
- cloudChoice === 'never'
458
- ? undefined
459
- : (0, ab_testing_1.getCompletionMessageKeyForVariant)();
460
- }
461
- const analytics = await (0, prompts_1.determineAnalytics)(argv);
462
- packageManager = argv.packageManager ?? (0, package_manager_1.detectInvokedPackageManager)();
463
- Object.assign(argv, {
464
- nxCloud,
465
- useGitHub: nxCloud !== 'skip' && nxCloud !== 'never',
466
- skipCloudConnect,
467
- neverConnectToCloud,
468
- completionMessageKey,
469
- packageManager,
470
- defaultBase: 'main',
471
- aiAgents,
472
- ghAvailable,
473
- analytics,
474
- });
475
- await (0, ab_testing_1.recordStat)({
476
- nxVersion: nx_version_1.nxVersion,
477
- command: 'create-nx-workspace',
478
- useCloud: nxCloud !== 'skip' && nxCloud !== 'never',
479
- meta: {
480
- type: 'precreate',
481
- flowVariant: (0, ab_testing_1.getFlowVariant)(),
482
- template: chosenTemplate,
483
- preset: '',
484
- nodeVersion: process.versions.node ?? '',
470
+ const analytics = await (0, prompts_1.determineAnalytics)(argv);
471
+ packageManager = argv.packageManager ?? (0, package_manager_1.detectInvokedPackageManager)();
472
+ Object.assign(argv, {
473
+ nxCloud,
474
+ useGitHub: nxCloud !== 'skip' && nxCloud !== 'never',
475
+ skipCloudConnect,
476
+ neverConnectToCloud,
477
+ completionMessageKey,
485
478
  packageManager,
486
- ghAvailable: ghAvailable ? 'true' : 'false',
487
- aiAgent: (0, ai_output_1.isAiAgent)(),
488
- },
489
- });
490
- }
491
- else {
492
- // Preset flow - existing behavior
493
- if (!argv.preset || (0, preset_1.isKnownPreset)(argv.preset)) {
494
- argv.stack = await determineStack(argv);
495
- const presetOptions = await determinePresetOptions(argv);
496
- Object.assign(argv, presetOptions);
479
+ defaultBase: 'main',
480
+ aiAgents,
481
+ ghAvailable,
482
+ analytics,
483
+ });
484
+ await (0, ab_testing_1.recordStat)({
485
+ nxVersion: nx_version_1.nxVersion,
486
+ command: 'create-nx-workspace',
487
+ useCloud,
488
+ meta: {
489
+ type: 'precreate',
490
+ flowVariant: (0, ab_testing_1.getFlowVariant)(),
491
+ template: chosenTemplate,
492
+ preset: '',
493
+ nodeVersion: process.versions.node ?? '',
494
+ packageManager,
495
+ ghAvailable: ghAvailable ? 'true' : 'false',
496
+ aiAgent: (0, ai_output_1.isAiAgent)(),
497
+ },
498
+ });
497
499
  }
498
500
  else {
499
- try {
500
- (0, get_third_party_preset_1.getPackageNameFromThirdPartyPreset)(argv.preset);
501
- }
502
- catch (e) {
503
- const message = e instanceof Error ? e.message : String(e);
504
- throw new error_utils_1.CnwError('INVALID_PRESET', `Could not find preset "${argv.preset}": ${message}`);
501
+ // Preset flow - existing behavior
502
+ if (!argv.preset || (0, preset_1.isKnownPreset)(argv.preset)) {
503
+ argv.stack = await determineStack(argv);
504
+ const presetOptions = await determinePresetOptions(argv);
505
+ Object.assign(argv, presetOptions);
505
506
  }
506
- }
507
- packageManager = await (0, prompts_1.determinePackageManager)(argv);
508
- const aiAgents = await (0, prompts_1.determineAiAgents)(argv);
509
- const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
510
- // Check if CLI arg was provided (use rawArgs to check original input)
511
- const cliNxCloudArgProvided = rawArgs.nxCloud !== undefined;
512
- let nxCloud;
513
- let useGitHub;
514
- let completionMessageKey;
515
- let skipCloudConnect = false;
516
- let neverConnectToCloud = false;
517
- if (argv.skipGit === true) {
518
- nxCloud = 'skip';
519
- useGitHub = undefined;
520
- }
521
- else if (cliNxCloudArgProvided) {
522
- // CLI arg provided: use existing flow (CI provider selection if needed)
523
- nxCloud = await (0, prompts_1.determineNxCloud)(argv);
524
- useGitHub =
525
- nxCloud === 'skip' || nxCloud === 'never'
526
- ? undefined
527
- : nxCloud === 'github' || (await (0, prompts_1.determineIfGitHubWillBeUsed)(argv));
528
- if (nxCloud === 'never') {
529
- neverConnectToCloud = true;
530
- }
531
- }
532
- else {
533
- // No CLI arg: use simplified prompt (same as template flow)
534
- const cloudChoice = await (0, prompts_1.determineNxCloudV2)(argv);
535
- if (cloudChoice === 'yes') {
536
- nxCloud = 'yes';
537
- skipCloudConnect = false;
507
+ else {
508
+ try {
509
+ (0, get_third_party_preset_1.getPackageNameFromThirdPartyPreset)(argv.preset);
510
+ }
511
+ catch (e) {
512
+ const message = e instanceof Error ? e.message : String(e);
513
+ throw new error_utils_1.CnwError('INVALID_PRESET', `Could not find preset "${argv.preset}": ${message}`);
514
+ }
538
515
  }
539
- else if (cloudChoice === 'skip') {
516
+ packageManager = await (0, prompts_1.determinePackageManager)(argv);
517
+ const aiAgents = await (0, prompts_1.determineAiAgents)(argv);
518
+ const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
519
+ // Check if CLI arg was provided (use rawArgs to check original input)
520
+ const cliNxCloudArgProvided = rawArgs.nxCloud !== undefined;
521
+ let nxCloud;
522
+ let useGitHub;
523
+ let completionMessageKey;
524
+ let skipCloudConnect = false;
525
+ let neverConnectToCloud = false;
526
+ if (argv.skipGit === true) {
540
527
  nxCloud = 'skip';
528
+ useGitHub = undefined;
529
+ }
530
+ else if (cliNxCloudArgProvided) {
531
+ // CLI arg provided: use existing flow (CI provider selection if needed)
532
+ nxCloud = await (0, prompts_1.determineNxCloud)(argv);
533
+ useGitHub =
534
+ nxCloud === 'skip' || nxCloud === 'never'
535
+ ? undefined
536
+ : nxCloud === 'github' ||
537
+ (await (0, prompts_1.determineIfGitHubWillBeUsed)(argv));
538
+ if (nxCloud === 'never') {
539
+ neverConnectToCloud = true;
540
+ }
541
541
  }
542
542
  else {
543
- nxCloud = 'never';
544
- neverConnectToCloud = true;
543
+ // No CLI arg: use simplified prompt (same as template flow)
544
+ const cloudChoice = await (0, prompts_1.determineNxCloudV2)(argv);
545
+ if (cloudChoice === 'yes') {
546
+ nxCloud = 'yes';
547
+ skipCloudConnect = false;
548
+ }
549
+ else if (cloudChoice === 'skip') {
550
+ nxCloud = 'skip';
551
+ }
552
+ else {
553
+ nxCloud = 'never';
554
+ neverConnectToCloud = true;
555
+ }
556
+ useGitHub =
557
+ nxCloud !== 'skip' && nxCloud !== 'never' ? true : undefined;
558
+ completionMessageKey =
559
+ cloudChoice === 'never'
560
+ ? undefined
561
+ : (0, ab_testing_1.getCompletionMessageKeyForVariant)();
545
562
  }
546
- useGitHub =
547
- nxCloud !== 'skip' && nxCloud !== 'never' ? true : undefined;
548
- completionMessageKey =
549
- cloudChoice === 'never'
550
- ? undefined
551
- : (0, ab_testing_1.getCompletionMessageKeyForVariant)();
552
- }
553
- const analytics = await (0, prompts_1.determineAnalytics)(argv);
554
- Object.assign(argv, {
555
- nxCloud,
556
- useGitHub,
557
- skipCloudConnect,
558
- neverConnectToCloud,
559
- completionMessageKey,
560
- packageManager,
561
- defaultBase,
562
- aiAgents,
563
- analytics,
564
- });
565
- chosenPreset = argv.preset ?? '';
566
- await (0, ab_testing_1.recordStat)({
567
- nxVersion: nx_version_1.nxVersion,
568
- command: 'create-nx-workspace',
569
- useCloud: nxCloud !== 'skip' && nxCloud !== 'never',
570
- meta: {
571
- type: 'precreate',
572
- flowVariant: (0, ab_testing_1.getFlowVariant)(),
573
- template: '',
574
- preset: chosenPreset ?? '',
575
- nodeVersion: process.versions.node ?? '',
563
+ const analytics = await (0, prompts_1.determineAnalytics)(argv);
564
+ Object.assign(argv, {
565
+ nxCloud,
566
+ useGitHub,
567
+ skipCloudConnect,
568
+ neverConnectToCloud,
569
+ completionMessageKey,
576
570
  packageManager,
577
- aiAgent: (0, ai_output_1.isAiAgent)(),
578
- },
579
- });
580
- }
581
- }
582
- catch (e) {
583
- if (e instanceof error_utils_1.CnwError) {
584
- throw e;
571
+ defaultBase,
572
+ aiAgents,
573
+ analytics,
574
+ });
575
+ chosenPreset = argv.preset ?? '';
576
+ await (0, ab_testing_1.recordStat)({
577
+ nxVersion: nx_version_1.nxVersion,
578
+ command: 'create-nx-workspace',
579
+ useCloud,
580
+ meta: {
581
+ type: 'precreate',
582
+ flowVariant: (0, ab_testing_1.getFlowVariant)(),
583
+ template: '',
584
+ preset: chosenPreset ?? '',
585
+ nodeVersion: process.versions.node ?? '',
586
+ packageManager,
587
+ aiAgent: (0, ai_output_1.isAiAgent)(),
588
+ },
589
+ });
590
+ }
585
591
  }
586
- // Enquirer throws an empty string when user presses Ctrl+C
587
- if (e === '') {
588
- process.exit(130);
592
+ catch (e) {
593
+ if (e instanceof error_utils_1.CnwError) {
594
+ throw e;
595
+ }
596
+ // Enquirer throws an empty string when user presses Ctrl+C
597
+ if (e === '') {
598
+ process.exit(130);
599
+ }
600
+ const message = e instanceof Error ? e.message : String(e);
601
+ throw new error_utils_1.CnwError('UNKNOWN', message);
589
602
  }
590
- const message = e instanceof Error ? e.message : String(e);
591
- throw new error_utils_1.CnwError('UNKNOWN', message);
603
+ }
604
+ catch (error) {
605
+ handleError(error);
592
606
  }
593
607
  }
594
608
  function invariant(predicate, errorCode, message) {
@@ -599,15 +613,7 @@ function invariant(predicate, errorCode, message) {
599
613
  function validateWorkspaceName(name) {
600
614
  const pattern = /^[a-zA-Z]/;
601
615
  if (!pattern.test(name)) {
602
- output_1.output.error({
603
- title: 'Invalid workspace name',
604
- bodyLines: [
605
- `The workspace name "${name}" is invalid.`,
606
- `Workspace names must start with a letter.`,
607
- `Examples of valid names: myapp, MyApp, my-app, my_app`,
608
- ],
609
- });
610
- process.exit(1);
616
+ throw new error_utils_1.CnwError('INVALID_WORKSPACE_NAME', `The workspace name "${name}" is invalid. Workspace names must start with a letter. Examples of valid names: myapp, MyApp, my-app, my_app`);
611
617
  }
612
618
  }
613
619
  async function determineFolder(parsedArgs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nx-workspace",
3
- "version": "22.6.0-rc.2",
3
+ "version": "22.6.1",
4
4
  "private": false,
5
5
  "description": "Smart Monorepos · Fast Builds",
6
6
  "repository": {
@@ -27,7 +27,7 @@ function spawnAndWait(command, args, cwd) {
27
27
  ESLINT_USE_FLAT_CONFIG: process.env.ESLINT_USE_FLAT_CONFIG ?? 'true',
28
28
  },
29
29
  shell: true,
30
- windowsHide: false,
30
+ windowsHide: true,
31
31
  });
32
32
  childProcess.on('exit', (code, signal) => {
33
33
  if (code === null)
@@ -46,7 +46,7 @@ function execAndWait(command, cwd, silenceErrors = false) {
46
46
  (0, child_process_1.exec)(command, {
47
47
  cwd,
48
48
  env: { ...process.env, NX_DAEMON: 'false' },
49
- windowsHide: false,
49
+ windowsHide: true,
50
50
  maxBuffer: 1024 * 1024 * 10, // 10MB — default 1MB can be exceeded by verbose PM output
51
51
  }, (error, stdout, stderr) => {
52
52
  if (error) {
@@ -9,7 +9,7 @@ const child_process_1 = require("child_process");
9
9
  function deduceDefaultBase() {
10
10
  const nxDefaultBase = 'main';
11
11
  try {
12
- return ((0, child_process_1.execSync)('git config --get init.defaultBranch', { windowsHide: false })
12
+ return ((0, child_process_1.execSync)('git config --get init.defaultBranch', { windowsHide: true })
13
13
  .toString()
14
14
  .trim() || nxDefaultBase);
15
15
  }
@@ -42,7 +42,7 @@ async function checkGitVersion() {
42
42
  */
43
43
  function isGitAvailable() {
44
44
  try {
45
- (0, child_process_1.execSync)('git --version', { stdio: 'ignore' });
45
+ (0, child_process_1.execSync)('git --version', { stdio: 'ignore', windowsHide: true });
46
46
  return true;
47
47
  }
48
48
  catch {
@@ -55,7 +55,7 @@ function isGitAvailable() {
55
55
  */
56
56
  function isGhCliAvailable() {
57
57
  try {
58
- (0, child_process_1.execSync)('gh --version', { stdio: 'ignore' });
58
+ (0, child_process_1.execSync)('gh --version', { stdio: 'ignore', windowsHide: true });
59
59
  return true;
60
60
  }
61
61
  catch {
@@ -285,7 +285,7 @@ function shouldRecordStats() {
285
285
  // Use npm to check registry - this works regardless of which package manager invoked us
286
286
  const stdout = (0, node_child_process_1.execSync)('npm config get registry', {
287
287
  encoding: 'utf-8',
288
- windowsHide: false,
288
+ windowsHide: true,
289
289
  });
290
290
  const url = new URL(stdout.trim());
291
291
  // don't record stats when testing locally
@@ -1 +1 @@
1
- {"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/create-nx-workspace/src/utils/package-manager.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB,yCAA0C,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAW,GAAG,cAAc,CAQrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,GAAE,cAAuC,GACtD;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAmDA;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,cAAuC,QAyBxD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAEjE;AAwBD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAuBjE;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAU,GACnB,MAAM,EAAE,CAWV;AAsCD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB5D;AAID,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,cAAc,EAC9B,GAAG,SAAgB,GAClB,MAAM,CAWR;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,IAAI,cAAc,CAiB5D"}
1
+ {"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/create-nx-workspace/src/utils/package-manager.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB,yCAA0C,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAW,GAAG,cAAc,CAQrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,GAAE,cAAuC,GACtD;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAmDA;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,cAAuC,QAyBxD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAEjE;AAwBD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAuBjE;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAU,GACnB,MAAM,EAAE,CAWV;AAsCD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB5D;AAID,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,cAAc,EAC9B,GAAG,SAAgB,GAClB,MAAM,CAkBR;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,IAAI,cAAc,CAiB5D"}
@@ -13,6 +13,7 @@ exports.detectInvokedPackageManager = detectInvokedPackageManager;
13
13
  const node_child_process_1 = require("node:child_process");
14
14
  const node_fs_1 = require("node:fs");
15
15
  const node_path_1 = require("node:path");
16
+ const error_utils_1 = require("./error-utils");
16
17
  /*
17
18
  * Because we don't want to depend on @nx/workspace (to speed up the workspace creation)
18
19
  * we duplicate the helper functions from @nx/workspace in this file.
@@ -212,13 +213,18 @@ function getPackageManagerVersion(packageManager, cwd = process.cwd()) {
212
213
  if (pmVersionCache.has(packageManager)) {
213
214
  return pmVersionCache.get(packageManager);
214
215
  }
215
- const version = (0, node_child_process_1.execSync)(`${packageManager} --version`, {
216
- cwd,
217
- encoding: 'utf-8',
218
- windowsHide: false,
219
- }).trim();
220
- pmVersionCache.set(packageManager, version);
221
- return version;
216
+ try {
217
+ const version = (0, node_child_process_1.execSync)(`${packageManager} --version`, {
218
+ cwd,
219
+ encoding: 'utf-8',
220
+ windowsHide: true,
221
+ }).trim();
222
+ pmVersionCache.set(packageManager, version);
223
+ return version;
224
+ }
225
+ catch {
226
+ throw new error_utils_1.CnwError('INVALID_PACKAGE_MANAGER', `Package manager '${packageManager}' is not installed or not found in PATH.`);
227
+ }
222
228
  }
223
229
  /**
224
230
  * Detects which package manager was used to invoke create-nx-{plugin|workspace} command