From aba338650a1a676f842d526ecd533ee1d1dbfa25 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Tue, 18 Apr 2023 17:17:55 -0400 Subject: [PATCH] feat(node): replace usages of @nrwl with @nx (#16379) --- packages/express/.eslintrc.json | 2 +- packages/express/generators.json | 2 +- .../express/src/generators/application/application.ts | 7 +------ packages/express/src/generators/init/init.spec.ts | 8 ++++---- packages/express/src/generators/init/init.ts | 4 ++-- packages/nest/.eslintrc.json | 2 +- packages/nest/generators.json | 2 +- .../convert-tslint-to-eslint/convert-tslint-to-eslint.ts | 6 +++--- packages/nest/src/generators/init/init.spec.ts | 4 ++-- packages/nest/src/generators/init/lib/add-dependencies.ts | 2 +- packages/nest/src/generators/library/lib/add-project.ts | 2 +- packages/nest/src/generators/library/library.spec.ts | 2 +- packages/node/.eslintrc.json | 2 +- packages/node/generators.json | 2 +- packages/node/src/executors/webpack/webpack.impl.ts | 2 +- .../node/src/generators/application/application.spec.ts | 2 +- packages/node/src/generators/application/application.ts | 4 ++-- .../application/files/common/webpack.config.js__tmpl__ | 2 +- packages/node/src/generators/init/init.spec.ts | 6 +++--- packages/node/src/generators/init/init.ts | 4 ++-- packages/node/src/generators/library/library.spec.ts | 6 +++--- packages/node/src/generators/library/library.ts | 2 +- 22 files changed, 35 insertions(+), 40 deletions(-) diff --git a/packages/express/.eslintrc.json b/packages/express/.eslintrc.json index 25d6c99d3c0dcd..ce0c5bf55bd76c 100644 --- a/packages/express/.eslintrc.json +++ b/packages/express/.eslintrc.json @@ -21,7 +21,7 @@ "rules": { "no-restricted-imports": [ "error", - "@nrwl/workspace", + "@nx/workspace", "@angular-devkit/core", "@angular-devkit/architect", "@angular-devkit/schematics" diff --git a/packages/express/generators.json b/packages/express/generators.json index d6811ef8fee627..6de991c05bb06a 100644 --- a/packages/express/generators.json +++ b/packages/express/generators.json @@ -1,7 +1,7 @@ { "name": "Nx Express", "version": "0.1", - "extends": ["@nrwl/workspace"], + "extends": ["@nx/workspace"], "generators": { "init": { "factory": "./src/generators/init/init#initGenerator", diff --git a/packages/express/src/generators/application/application.ts b/packages/express/src/generators/application/application.ts index 58a98625984d26..75047cc98655d6 100644 --- a/packages/express/src/generators/application/application.ts +++ b/packages/express/src/generators/application/application.ts @@ -60,13 +60,8 @@ server.on('error', console.error); toJS(tree); } } -// TODO (nicholas): Remove After Nx 16 -// @deprecated Use `nx g @nrwl/node:app --framework=express instead. -export async function applicationGenerator(tree: Tree, schema: Schema) { - console.warn( - 'As of Nx 16 using `nx g @nrwl/express:app` has been deprecated! Use `nx g @nrwl/node:app --framework=express instead.' - ); +export async function applicationGenerator(tree: Tree, schema: Schema) { const options = normalizeOptions(tree, schema); const initTask = await initGenerator(tree, { ...options, skipFormat: true }); const applicationTask = await nodeApplicationGenerator(tree, { diff --git a/packages/express/src/generators/init/init.spec.ts b/packages/express/src/generators/init/init.spec.ts index c6d8113ebf5da8..14985e0a75af6a 100644 --- a/packages/express/src/generators/init/init.spec.ts +++ b/packages/express/src/generators/init/init.spec.ts @@ -20,7 +20,7 @@ describe('init', () => { const existingVersion = '1.0.0'; addDependenciesToPackageJson( tree, - { '@nrwl/express': expressVersion, [existing]: existingVersion }, + { '@nx/express': expressVersion, [existing]: existingVersion }, { [existing]: existingVersion } ); await initGenerator(tree, {}); @@ -29,9 +29,9 @@ describe('init', () => { expect(packageJson.dependencies['express']).toBeDefined(); // add tslib expect(packageJson.dependencies['tslib']).toBeDefined(); - // move `@nrwl/express` to dev - expect(packageJson.dependencies['@nrwl/express']).toBeUndefined(); - expect(packageJson.devDependencies['@nrwl/express']).toBeDefined(); + // move `@nx/express` to dev + expect(packageJson.dependencies['@nx/express']).toBeUndefined(); + expect(packageJson.devDependencies['@nx/express']).toBeDefined(); // add express types expect(packageJson.devDependencies['@types/express']).toBeDefined(); // keep existing packages diff --git a/packages/express/src/generators/init/init.ts b/packages/express/src/generators/init/init.ts index 951728e33008ed..5a4d9a50efd1aa 100644 --- a/packages/express/src/generators/init/init.ts +++ b/packages/express/src/generators/init/init.ts @@ -15,7 +15,7 @@ import { import type { Schema } from './schema'; function updateDependencies(tree: Tree) { - removeDependenciesFromPackageJson(tree, ['@nrwl/express'], []); + removeDependenciesFromPackageJson(tree, ['@nx/express'], []); return addDependenciesToPackageJson( tree, @@ -25,7 +25,7 @@ function updateDependencies(tree: Tree) { }, { '@types/express': expressTypingsVersion, - '@nrwl/express': nxVersion, + '@nx/express': nxVersion, } ); } diff --git a/packages/nest/.eslintrc.json b/packages/nest/.eslintrc.json index 8b5501b5f63f97..6f8e4afa79adaf 100644 --- a/packages/nest/.eslintrc.json +++ b/packages/nest/.eslintrc.json @@ -24,7 +24,7 @@ "@angular-devkit/architect", "@angular-devkit/core", "@angular-devkit/schematics", - "@nrwl/workspace" + "@nx/workspace" ] } }, diff --git a/packages/nest/generators.json b/packages/nest/generators.json index 71271f4710abd5..74b92ab81193a2 100644 --- a/packages/nest/generators.json +++ b/packages/nest/generators.json @@ -1,7 +1,7 @@ { "name": "nx/nest", "version": "0.1", - "extends": ["@nrwl/workspace"], + "extends": ["@nx/workspace"], "schematics": { "application": { "factory": "./src/generators/application/application#applicationSchematic", diff --git a/packages/nest/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.ts b/packages/nest/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.ts index c014ee45e0b024..d7b194ec645000 100755 --- a/packages/nest/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.ts +++ b/packages/nest/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.ts @@ -24,8 +24,8 @@ export async function conversionGenerator( * to perform in order to convert a project from TSLint to ESLint, as well as some * extensibility points for adjusting the behavior on a per package basis. * - * E.g. @nrwl/angular projects might need to make different changes to the final - * ESLint config when compared with @nrwl/nest projects. + * E.g. @nx/angular projects might need to make different changes to the final + * ESLint config when compared with @nx/nest projects. * * See the ProjectConverter implementation for a full breakdown of what it does. */ @@ -113,7 +113,7 @@ export async function conversionGenerator( /** * Store user preferences for the collection */ - projectConverter.setDefaults('@nrwl/nest', defaults); + projectConverter.setDefaults('@nx/nest', defaults); /** * Based on user preference and remaining usage, remove TSLint from the workspace entirely. diff --git a/packages/nest/src/generators/init/init.spec.ts b/packages/nest/src/generators/init/init.spec.ts index f6e6d0ff05a3bd..0392dabc66e2b4 100644 --- a/packages/nest/src/generators/init/init.spec.ts +++ b/packages/nest/src/generators/init/init.spec.ts @@ -24,12 +24,12 @@ describe('init generator', () => { expect(packageJson.dependencies['reflect-metadata']).toBeDefined(); expect(packageJson.dependencies['rxjs']).toBeDefined(); expect(packageJson.dependencies['tslib']).toBeDefined(); - expect(packageJson.dependencies['@nrwl/nest']).toBeUndefined(); + expect(packageJson.dependencies['@nx/nest']).toBeUndefined(); expect(packageJson.devDependencies['@nestjs/schematics']).toBe( nestJsVersion ); expect(packageJson.devDependencies['@nestjs/testing']).toBe(nestJsVersion); - expect(packageJson.devDependencies['@nrwl/nest']).toBe(nxVersion); + expect(packageJson.devDependencies['@nx/nest']).toBe(nxVersion); }); it('should add jest config when unitTestRunner is jest', async () => { diff --git a/packages/nest/src/generators/init/lib/add-dependencies.ts b/packages/nest/src/generators/init/lib/add-dependencies.ts index 2fc1d84a57a7a8..793c0881654978 100644 --- a/packages/nest/src/generators/init/lib/add-dependencies.ts +++ b/packages/nest/src/generators/init/lib/add-dependencies.ts @@ -22,7 +22,7 @@ export function addDependencies(tree: Tree): GeneratorCallback { { '@nestjs/schematics': nestJsVersion, '@nestjs/testing': nestJsVersion, - '@nrwl/nest': nxVersion, + '@nx/nest': nxVersion, } ); } diff --git a/packages/nest/src/generators/library/lib/add-project.ts b/packages/nest/src/generators/library/lib/add-project.ts index bfa42c42f2f318..dac4adc3b6d6db 100644 --- a/packages/nest/src/generators/library/lib/add-project.ts +++ b/packages/nest/src/generators/library/lib/add-project.ts @@ -12,7 +12,7 @@ export function addProject(tree: Tree, options: NormalizedOptions): void { const project = readProjectConfiguration(tree, options.projectName); project.targets.build = { - executor: '@nrwl/js:tsc', + executor: '@nx/js:tsc', outputs: ['{options.outputPath}'], options: { outputPath: diff --git a/packages/nest/src/generators/library/library.spec.ts b/packages/nest/src/generators/library/library.spec.ts index ecb814062f71e3..63c5ebf13a66a1 100644 --- a/packages/nest/src/generators/library/library.spec.ts +++ b/packages/nest/src/generators/library/library.spec.ts @@ -71,7 +71,7 @@ describe('lib', () => { ).toMatchSnapshot(); }); - it('should remove the default file from @nrwl/node:lib', async () => { + it('should remove the default file from @nx/node:lib', async () => { await libraryGenerator(tree, { name: libName, global: true }); expect( diff --git a/packages/node/.eslintrc.json b/packages/node/.eslintrc.json index bb098f7edfafef..00d788c430458f 100644 --- a/packages/node/.eslintrc.json +++ b/packages/node/.eslintrc.json @@ -21,7 +21,7 @@ "rules": { "no-restricted-imports": [ "error", - "@nrwl/workspace", + "@nx/workspace", "@angular-devkit/core", "@angular-devkit/architect", "@angular-devkit/schematics" diff --git a/packages/node/generators.json b/packages/node/generators.json index 6512a1c90af9e9..59c0edb0f32cb1 100644 --- a/packages/node/generators.json +++ b/packages/node/generators.json @@ -1,7 +1,7 @@ { "name": "nx/node", "version": "0.1", - "extends": ["@nrwl/workspace"], + "extends": ["@nx/workspace"], "generators": { "init": { "factory": "./src/generators/init/init", diff --git a/packages/node/src/executors/webpack/webpack.impl.ts b/packages/node/src/executors/webpack/webpack.impl.ts index d3f84cc5a14230..ca45b286491fc9 100644 --- a/packages/node/src/executors/webpack/webpack.impl.ts +++ b/packages/node/src/executors/webpack/webpack.impl.ts @@ -11,7 +11,7 @@ export async function* webpackExecutor( context: ExecutorContext ) { logger.warn( - '"@nrwl/node:webpack" executor is deprecated. Use "@nrwl/webpack:webpack" instead in your project.json.' + '"@nx/node:webpack" executor is deprecated. Use "@nx/webpack:webpack" instead in your project.json.' ); yield* baseWebpackExecutor( { diff --git a/packages/node/src/generators/application/application.spec.ts b/packages/node/src/generators/application/application.spec.ts index e09a3d28ca25a4..d26bcd5d2cf8f2 100644 --- a/packages/node/src/generators/application/application.spec.ts +++ b/packages/node/src/generators/application/application.spec.ts @@ -51,7 +51,7 @@ describe('app', () => { }, }, serve: { - executor: '@nrwl/js:node', + executor: '@nx/js:node', defaultConfiguration: 'development', options: { buildTarget: 'my-node-app:build', diff --git a/packages/node/src/generators/application/application.ts b/packages/node/src/generators/application/application.ts index 68829533a5e90d..7fa379bb1639ac 100644 --- a/packages/node/src/generators/application/application.ts +++ b/packages/node/src/generators/application/application.ts @@ -134,7 +134,7 @@ function getEsBuildConfig( function getServeConfig(options: NormalizedSchema): TargetConfiguration { return { - executor: '@nrwl/js:node', + executor: '@nx/js:node', defaultConfiguration: 'development', options: { buildTarget: `${options.name}:build`, @@ -298,7 +298,7 @@ function addProjectDependencies( '@nx/webpack': nxVersion, }, esbuild: { - '@nrwl/esbuild': nxVersion, + '@nx/esbuild': nxVersion, esbuild: esbuildVersion, }, }; diff --git a/packages/node/src/generators/application/files/common/webpack.config.js__tmpl__ b/packages/node/src/generators/application/files/common/webpack.config.js__tmpl__ index 9d8cd094f7e876..e51dd73f9ca0ae 100644 --- a/packages/node/src/generators/application/files/common/webpack.config.js__tmpl__ +++ b/packages/node/src/generators/application/files/common/webpack.config.js__tmpl__ @@ -1,4 +1,4 @@ -const { composePlugins, withNx} = require('@nrwl/webpack'); +const { composePlugins, withNx} = require('@nx/webpack'); // Nx plugins for webpack. module.exports = composePlugins(withNx(), (config) => { diff --git a/packages/node/src/generators/init/init.spec.ts b/packages/node/src/generators/init/init.spec.ts index 9ba5160ee500f3..9b886594cfedba 100644 --- a/packages/node/src/generators/init/init.spec.ts +++ b/packages/node/src/generators/init/init.spec.ts @@ -23,7 +23,7 @@ describe('init', () => { addDependenciesToPackageJson( tree, { - '@nrwl/node': nxVersion, + '@nx/node': nxVersion, [existing]: existingVersion, }, { @@ -33,10 +33,10 @@ describe('init', () => { await initGenerator(tree, {}); const packageJson = readJson(tree, 'package.json'); - expect(packageJson.dependencies['@nrwl/node']).toBeUndefined(); + expect(packageJson.dependencies['@nx/node']).toBeUndefined(); expect(packageJson.dependencies['tslib']).toBeDefined(); expect(packageJson.dependencies[existing]).toBeDefined(); - expect(packageJson.devDependencies['@nrwl/node']).toBeDefined(); + expect(packageJson.devDependencies['@nx/node']).toBeDefined(); expect(packageJson.devDependencies[existing]).toBeDefined(); }); diff --git a/packages/node/src/generators/init/init.ts b/packages/node/src/generators/init/init.ts index 40970bb6302a0c..dded03c54edcdd 100644 --- a/packages/node/src/generators/init/init.ts +++ b/packages/node/src/generators/init/init.ts @@ -18,14 +18,14 @@ import { import { Schema } from './schema'; function updateDependencies(tree: Tree) { - removeDependenciesFromPackageJson(tree, ['@nrwl/node'], []); + removeDependenciesFromPackageJson(tree, ['@nx/node'], []); return addDependenciesToPackageJson( tree, { tslib: tslibVersion, }, - { '@nrwl/node': nxVersion, '@types/node': typesNodeVersion } + { '@nx/node': nxVersion, '@types/node': typesNodeVersion } ); } diff --git a/packages/node/src/generators/library/library.spec.ts b/packages/node/src/generators/library/library.spec.ts index 65c98c0a495347..3b4395165ec5d2 100644 --- a/packages/node/src/generators/library/library.spec.ts +++ b/packages/node/src/generators/library/library.spec.ts @@ -311,7 +311,7 @@ describe('lib', () => { const { build } = readProjectConfiguration(tree, 'my-lib').targets; - expect(build.executor).toEqual('@nrwl/js:tsc'); + expect(build.executor).toEqual('@nx/js:tsc'); }); it('should specify swc as compiler', async () => { @@ -323,7 +323,7 @@ describe('lib', () => { const { build } = readProjectConfiguration(tree, 'my-lib').targets; - expect(build.executor).toEqual('@nrwl/js:swc'); + expect(build.executor).toEqual('@nx/js:swc'); }); }); @@ -361,7 +361,7 @@ describe('lib', () => { expect(projectConfiguration.targets.build).toMatchInlineSnapshot(` { - "executor": "@nrwl/js:tsc", + "executor": "@nx/js:tsc", "options": { "assets": [ "libs/my-lib/*.md", diff --git a/packages/node/src/generators/library/library.ts b/packages/node/src/generators/library/library.ts index 97451bb9895bf8..9bb3e3deec43dd 100644 --- a/packages/node/src/generators/library/library.ts +++ b/packages/node/src/generators/library/library.ts @@ -159,7 +159,7 @@ function updateProject(tree: Tree, options: NormalizedSchema) { project.targets = project.targets || {}; project.targets.build = { - executor: `@nrwl/js:${options.compiler}`, + executor: `@nx/js:${options.compiler}`, outputs: ['{options.outputPath}'], options: { outputPath: joinPathFragments(