fix(core): Remove warning when Nx is not installed globally (#28868)
<!-- 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
d4b9e0dc30
commit
18bba6f4f7
@ -19,7 +19,6 @@ import { createWorkspace, CreateWorkspaceOptions } from 'create-nx-workspace';
|
|||||||
import { output } from 'create-nx-workspace/src/utils/output';
|
import { output } from 'create-nx-workspace/src/utils/output';
|
||||||
import { NxCloud } from 'create-nx-workspace/src/utils/nx/nx-cloud';
|
import { NxCloud } from 'create-nx-workspace/src/utils/nx/nx-cloud';
|
||||||
import type { PackageManager } from 'create-nx-workspace/src/utils/package-manager';
|
import type { PackageManager } from 'create-nx-workspace/src/utils/package-manager';
|
||||||
import { showNxWarning } from 'create-nx-workspace/src/utils/nx/show-nx-warning';
|
|
||||||
import {
|
import {
|
||||||
messages,
|
messages,
|
||||||
recordStat,
|
recordStat,
|
||||||
@ -150,8 +149,6 @@ async function main(parsedArgs: yargs.Arguments<CreateNxPluginArguments>) {
|
|||||||
populatedArguments
|
populatedArguments
|
||||||
);
|
);
|
||||||
|
|
||||||
showNxWarning(parsedArgs.pluginName);
|
|
||||||
|
|
||||||
await recordStat({
|
await recordStat({
|
||||||
nxVersion,
|
nxVersion,
|
||||||
command: 'create-nx-workspace',
|
command: 'create-nx-workspace',
|
||||||
|
|||||||
@ -25,7 +25,6 @@ import {
|
|||||||
withOptions,
|
withOptions,
|
||||||
withPackageManager,
|
withPackageManager,
|
||||||
} from '../src/internal-utils/yargs-options';
|
} from '../src/internal-utils/yargs-options';
|
||||||
import { showNxWarning } from '../src/utils/nx/show-nx-warning';
|
|
||||||
import { messages, recordStat } from '../src/utils/nx/ab-testing';
|
import { messages, recordStat } from '../src/utils/nx/ab-testing';
|
||||||
import { mapErrorToBodyLines } from '../src/utils/error-utils';
|
import { mapErrorToBodyLines } from '../src/utils/error-utils';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
@ -223,8 +222,6 @@ async function main(parsedArgs: yargs.Arguments<Arguments>) {
|
|||||||
parsedArgs
|
parsedArgs
|
||||||
);
|
);
|
||||||
|
|
||||||
showNxWarning(parsedArgs.name);
|
|
||||||
|
|
||||||
await recordStat({
|
await recordStat({
|
||||||
nxVersion,
|
nxVersion,
|
||||||
command: 'create-nx-workspace',
|
command: 'create-nx-workspace',
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
import { execSync } from 'child_process';
|
|
||||||
import { resolve } from 'path';
|
|
||||||
import { output } from '../output';
|
|
||||||
import { getPackageManagerCommand } from '../package-manager';
|
|
||||||
|
|
||||||
export function showNxWarning(workspaceName: string) {
|
|
||||||
try {
|
|
||||||
const pathToRunNxCommand = resolve(process.cwd(), workspaceName);
|
|
||||||
execSync('nx --version', {
|
|
||||||
cwd: pathToRunNxCommand,
|
|
||||||
stdio: ['ignore', 'ignore', 'ignore'],
|
|
||||||
windowsHide: false,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
// no nx found
|
|
||||||
const { exec, globalAdd } = getPackageManagerCommand();
|
|
||||||
output.addVerticalSeparator();
|
|
||||||
output.note({
|
|
||||||
title: `Nx CLI is not installed globally.`,
|
|
||||||
bodyLines: [
|
|
||||||
`This means that you will have to use "${exec} nx" to execute commands in the workspace.`,
|
|
||||||
`Run "${globalAdd} nx" to be able to execute command directly.`,
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user