fix(core): skip nx cloud prompt when interactive is false (#28949)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
37adb48db8
commit
59a3db8685
@ -372,7 +372,7 @@ export function runCreatePlugin(
|
|||||||
|
|
||||||
let command = `${
|
let command = `${
|
||||||
pm.runUninstalledPackage
|
pm.runUninstalledPackage
|
||||||
} create-nx-plugin@${getPublishedVersion()} ${name} --nxCloud=skip`;
|
} create-nx-plugin@${getPublishedVersion()} ${name} --nxCloud=skip --no-interactive`;
|
||||||
|
|
||||||
if (packageManager && !useDetectedPm) {
|
if (packageManager && !useDetectedPm) {
|
||||||
command += ` --package-manager=${packageManager}`;
|
command += ` --package-manager=${packageManager}`;
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
|
import * as enquirer from 'enquirer';
|
||||||
|
import * as chalk from 'chalk';
|
||||||
|
|
||||||
import { MessageKey, messages } from '../utils/nx/ab-testing';
|
import { MessageKey, messages } from '../utils/nx/ab-testing';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { deduceDefaultBase } from '../utils/git/default-base';
|
import { deduceDefaultBase } from '../utils/git/default-base';
|
||||||
@ -8,17 +11,18 @@ import {
|
|||||||
packageManagerList,
|
packageManagerList,
|
||||||
} from '../utils/package-manager';
|
} from '../utils/package-manager';
|
||||||
import { stringifyCollection } from '../utils/string-utils';
|
import { stringifyCollection } from '../utils/string-utils';
|
||||||
import enquirer = require('enquirer');
|
|
||||||
import { NxCloud } from '../utils/nx/nx-cloud';
|
import { NxCloud } from '../utils/nx/nx-cloud';
|
||||||
import chalk = require('chalk');
|
import { isCI } from '../utils/ci/is-ci';
|
||||||
|
|
||||||
export async function determineNxCloud(
|
export async function determineNxCloud(
|
||||||
parsedArgs: yargs.Arguments<{ nxCloud: NxCloud }>
|
parsedArgs: yargs.Arguments<{ nxCloud: NxCloud }>
|
||||||
): Promise<NxCloud> {
|
): Promise<NxCloud> {
|
||||||
if (parsedArgs.nxCloud === undefined) {
|
if (parsedArgs.nxCloud) {
|
||||||
return nxCloudPrompt('setupCI');
|
|
||||||
} else {
|
|
||||||
return parsedArgs.nxCloud;
|
return parsedArgs.nxCloud;
|
||||||
|
} else if (!parsedArgs.interactive || isCI()) {
|
||||||
|
return 'skip';
|
||||||
|
} else {
|
||||||
|
return nxCloudPrompt('setupCI');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +74,8 @@ export async function determineDefaultBase(
|
|||||||
parsedArgs: yargs.Arguments<{ defaultBase?: string }>
|
parsedArgs: yargs.Arguments<{ defaultBase?: string }>
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (parsedArgs.defaultBase) {
|
if (parsedArgs.defaultBase) {
|
||||||
return Promise.resolve(parsedArgs.defaultBase);
|
return parsedArgs.defaultBase;
|
||||||
}
|
} else if (parsedArgs.allPrompts) {
|
||||||
if (parsedArgs.allPrompts) {
|
|
||||||
return enquirer
|
return enquirer
|
||||||
.prompt<{ DefaultBase: string }>([
|
.prompt<{ DefaultBase: string }>([
|
||||||
{
|
{
|
||||||
@ -93,7 +96,7 @@ export async function determineDefaultBase(
|
|||||||
return a.DefaultBase;
|
return a.DefaultBase;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve(deduceDefaultBase());
|
return deduceDefaultBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function determinePackageManager(
|
export async function determinePackageManager(
|
||||||
@ -103,7 +106,7 @@ export async function determinePackageManager(
|
|||||||
|
|
||||||
if (packageManager) {
|
if (packageManager) {
|
||||||
if (packageManagerList.includes(packageManager as PackageManager)) {
|
if (packageManagerList.includes(packageManager as PackageManager)) {
|
||||||
return Promise.resolve(packageManager as PackageManager);
|
return packageManager as PackageManager;
|
||||||
}
|
}
|
||||||
output.error({
|
output.error({
|
||||||
title: 'Invalid package manager',
|
title: 'Invalid package manager',
|
||||||
@ -114,9 +117,7 @@ export async function determinePackageManager(
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
} else if (parsedArgs.allPrompts) {
|
||||||
|
|
||||||
if (parsedArgs.allPrompts) {
|
|
||||||
return enquirer
|
return enquirer
|
||||||
.prompt<{ packageManager: PackageManager }>([
|
.prompt<{ packageManager: PackageManager }>([
|
||||||
{
|
{
|
||||||
@ -135,5 +136,5 @@ export async function determinePackageManager(
|
|||||||
.then((a) => a.packageManager);
|
.then((a) => a.packageManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(detectInvokedPackageManager());
|
return detectInvokedPackageManager();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -229,7 +229,7 @@ function addE2eProject(host: Tree, options: NormalizedSchema) {
|
|||||||
{
|
{
|
||||||
pluginName: options.project,
|
pluginName: options.project,
|
||||||
cliName: options.name,
|
cliName: options.name,
|
||||||
packageManagerCommands: getPackageManagerCommand('npm'),
|
packageManagerCommands: getPackageManagerCommand(),
|
||||||
pluginPackageName,
|
pluginPackageName,
|
||||||
tmpl: '',
|
tmpl: '',
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,13 @@ describe('<%= cliName %>', () => {
|
|||||||
let projectDirectory: string;
|
let projectDirectory: string;
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
if (projectDirectory) {
|
||||||
// Cleanup the test project
|
// Cleanup the test project
|
||||||
rmSync(projectDirectory, {
|
rmSync(projectDirectory, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
force: true,
|
force: true,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -43,7 +45,7 @@ function createTestProject(extraArgs = '') {
|
|||||||
});
|
});
|
||||||
|
|
||||||
execSync(
|
execSync(
|
||||||
`<%= packageManagerCommands.exec %> --yes <%= cliName %>@e2e ${projectName} ${extraArgs}`,
|
`<%= packageManagerCommands.dlx %> <%= cliName %>@e2e ${projectName} ${extraArgs}`,
|
||||||
{
|
{
|
||||||
cwd: dirname(projectDirectory),
|
cwd: dirname(projectDirectory),
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
|
|||||||
@ -111,7 +111,7 @@ function addFiles(host: Tree, options: NormalizedSchema) {
|
|||||||
...options,
|
...options,
|
||||||
tmpl: '',
|
tmpl: '',
|
||||||
rootTsConfigPath: getRelativePathToRootTsConfig(host, options.projectRoot),
|
rootTsConfigPath: getRelativePathToRootTsConfig(host, options.projectRoot),
|
||||||
packageManagerCommands: getPackageManagerCommand('npm'),
|
packageManagerCommands: getPackageManagerCommand(),
|
||||||
pluginPackageName,
|
pluginPackageName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ describe('<%= pluginName %>', () => {
|
|||||||
|
|
||||||
// The plugin has been built and published to a local registry in the jest globalSetup
|
// The plugin has been built and published to a local registry in the jest globalSetup
|
||||||
// Install the plugin built with the latest source code into the test repo
|
// Install the plugin built with the latest source code into the test repo
|
||||||
execSync(`<%= packageManagerCommands.install %> <%= pluginPackageName %>@e2e`, {
|
execSync(`<%= packageManagerCommands.addDev %> <%= pluginPackageName %>@e2e`, {
|
||||||
cwd: projectDirectory,
|
cwd: projectDirectory,
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
env: process.env,
|
env: process.env,
|
||||||
@ -18,11 +18,13 @@ describe('<%= pluginName %>', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
if (projectDirectory) {
|
||||||
// Cleanup the test project
|
// Cleanup the test project
|
||||||
rmSync(projectDirectory, {
|
rmSync(projectDirectory, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
force: true,
|
force: true,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ function createTestProject() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
execSync(
|
execSync(
|
||||||
`<%= packageManagerCommands.exec %> --yes create-nx-workspace@latest ${projectName} --preset apps --nxCloud=skip --no-interactive`,
|
`<%= packageManagerCommands.dlx %> create-nx-workspace@latest ${projectName} --preset apps --nxCloud=skip --no-interactive`,
|
||||||
{
|
{
|
||||||
cwd: dirname(projectDirectory),
|
cwd: dirname(projectDirectory),
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user