Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): undo removal of @nrwl/cli and add warning when it is imported #9370

Merged
merged 1 commit into from Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/cli/bin/nx.ts
@@ -1,2 +1,9 @@
#!/usr/bin/env node

import { logger } from 'nx/src/shared/logger';
import { getPackageManagerCommand } from 'nx/src/shared/package-manager';

logger.warn('Please update your global install of Nx');
logger.warn(`- ${getPackageManagerCommand().addGlobal} nx`);

require('nx/bin/nx');
4 changes: 4 additions & 0 deletions packages/nx/src/shared/package-manager.ts
Expand Up @@ -8,6 +8,7 @@ export interface PackageManagerCommands {
install: string;
add: string;
addDev: string;
addGlobal: string;
rm: string;
exec: string;
list: string;
Expand Down Expand Up @@ -44,6 +45,7 @@ export function getPackageManagerCommand(
install: 'yarn',
add: 'yarn add -W',
addDev: 'yarn add -D -W',
addGlobal: 'yarn global add',
rm: 'yarn remove',
exec: 'yarn',
run: (script: string, args: string) => `yarn ${script} ${args}`,
Expand All @@ -59,6 +61,7 @@ export function getPackageManagerCommand(
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
add: 'pnpm add',
addDev: 'pnpm add -D',
addGlobal: 'pnpm add -g',
rm: 'pnpm rm',
exec: useExec ? 'pnpm exec' : 'pnpx',
run: (script: string, args: string) => `pnpm run ${script} -- ${args}`,
Expand All @@ -72,6 +75,7 @@ export function getPackageManagerCommand(
install: 'npm install',
add: 'npm install',
addDev: 'npm install -D',
addGlobal: 'npm install -g',
rm: 'npm rm',
exec: 'npx',
run: (script: string, args: string) => `npm run ${script} -- ${args}`,
Expand Down
6 changes: 3 additions & 3 deletions packages/workspace/migrations.json
Expand Up @@ -42,11 +42,11 @@
"cli": "nx",
"implementation": "./src/migrations/update-13-9-0/update-decorate-cli"
},
"13-9-0-replace-tao-and-cli-with-nx": {
"13-9-0-replace-tao-with-nx": {
"version": "13.9.0-beta.0",
"description": "Replace @nrwl/tao and @nrwl/cli with nx",
"description": "Replace @nrwl/tao with nx",
"cli": "nx",
"implementation": "./src/migrations/update-13-9-0/replace-tao-and-cli-with-nx"
"implementation": "./src/migrations/update-13-9-0/replace-tao-with-nx"
}
},
"packageJsonUpdates": {
Expand Down
Expand Up @@ -10,6 +10,7 @@
"devDependencies": {
<% if(cli === 'angular') { %>"@angular/cli": "<%= angularCliVersion %>",<% } %>
"nx": "<%= nxVersion %>",
"@nrwl/cli": "<%= nxVersion %>",
"@nrwl/workspace": "<%= nxVersion %>",
"@types/node": "16.11.7",
"typescript": "<%= typescriptVersion %>",
Expand Down
@@ -1,22 +1,21 @@
import { Tree, updateJson } from '@nrwl/devkit';

export function replaceTaoAndCLIWithNx(host: Tree) {
export function replaceTaoWithNx(host: Tree) {
updateJson(host, 'package.json', (json: any) => {
if (json.dependencies['@nrwl/workspace']) {
json.dependencies['nx'] = json.dependencies['@nrwl/workspace'];
} else if (json.devDependencies['@nrwl/workspace']) {
json.devDependencies['nx'] = json.devDependencies['@nrwl/workspace'];
}
removeTaoAndCLI(json.dependencies);
removeTaoAndCLI(json.devDependencies);
removeTao(json.dependencies);
removeTao(json.devDependencies);
return json;
});
}

function removeTaoAndCLI(json: any) {
function removeTao(json: any) {
if (!json) return;
json['@nrwl/tao'] = undefined;
json['@nrwl/cli'] = undefined;
}

export default replaceTaoAndCLIWithNx;
export default replaceTaoWithNx;