Skip to content

Commit

Permalink
fix(core): skip nx cloud prompt when interactive is false
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Nov 19, 2024
1 parent 25909b0 commit d984d71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion e2e/utils/create-project-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export function runCreateWorkspace(

const pm = getPackageManagerCommand({ packageManager });

let command = `${pm.createWorkspace} ${name} --preset=${preset} --nxCloud=skip --no-interactive`;
let command = `${pm.createWorkspace} ${name} --preset=${preset} --nxCloud=skip --packageManager=${packageManager} --no-interactive`;
if (appName) {
command += ` --appName=${appName}`;
}
Expand Down
22 changes: 14 additions & 8 deletions packages/create-nx-workspace/src/internal-utils/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as yargs from 'yargs';
import * as enquirer from 'enquirer';
import * as chalk from 'chalk';

import { MessageKey, messages } from '../utils/nx/ab-testing';
import { output } from '../utils/output';
import { deduceDefaultBase } from '../utils/git/default-base';
Expand All @@ -8,17 +11,18 @@ import {
packageManagerList,
} from '../utils/package-manager';
import { stringifyCollection } from '../utils/string-utils';
import enquirer = require('enquirer');
import { NxCloud } from '../utils/nx/nx-cloud';
import chalk = require('chalk');
import { isCI } from '../utils/ci/is-ci';

export async function determineNxCloud(
parsedArgs: yargs.Arguments<{ nxCloud: NxCloud }>
): Promise<NxCloud> {
if (parsedArgs.nxCloud === undefined) {
return nxCloudPrompt('setupCI');
} else {
if (parsedArgs.nxCloud) {
return parsedArgs.nxCloud;
} else if (!parsedArgs.interactive || isCI()) {
return 'skip';
} else {
return nxCloudPrompt('setupCI');
}
}

Expand Down Expand Up @@ -71,6 +75,8 @@ export async function determineDefaultBase(
): Promise<string> {
if (parsedArgs.defaultBase) {
return Promise.resolve(parsedArgs.defaultBase);
} else if (!parsedArgs.interactive || isCI()) {
return deduceDefaultBase();
}
if (parsedArgs.allPrompts) {
return enquirer
Expand Down Expand Up @@ -114,9 +120,9 @@ export async function determinePackageManager(
],
});
process.exit(1);
}

if (parsedArgs.allPrompts) {
} else if (!parsedArgs.interactive || isCI()) {
return 'npm';
} else if (parsedArgs.allPrompts) {
return enquirer
.prompt<{ packageManager: PackageManager }>([
{
Expand Down

0 comments on commit d984d71

Please sign in to comment.