From 76dfc6241212a542bb30754c6a60003d9a221cf7 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Wed, 19 Apr 2023 10:59:41 -0400 Subject: [PATCH] feat(web): replace usages of @nrwl with @nx (#16376) --- packages/js/.babelrc | 2 +- packages/js/babel.ts | 2 +- .../convert-to-swc/convert-to-swc.spec.ts | 4 ++-- .../convert-to-swc/convert-to-swc.ts | 8 +++++-- packages/js/src/generators/init/init.ts | 2 +- .../js/src/generators/library/library.spec.ts | 20 ++++++++--------- packages/js/src/generators/library/library.ts | 14 ++++++------ .../update-15-8-0/rename-swcrc-config.spec.ts | 1 + .../src/utils/compiler-helper-dependency.ts | 4 ++-- .../js/src/utils/minimal-publish-script.ts | 2 +- packages/next/.eslintrc.json | 2 +- packages/next/generators.json | 2 +- packages/next/plugins/with-nx.ts | 12 ++++++++-- .../__snapshots__/application.spec.ts.snap | 4 ++-- .../application/application.spec.ts | 10 ++++----- .../application/files/common/.babelrc__tmpl__ | 4 ++-- .../files/common/next.config.js__tmpl__ | 22 +++++++++---------- .../generators/application/lib/add-linting.ts | 4 ++-- .../generators/application/lib/add-project.ts | 6 ++--- .../lib/create-application-files.helpers.ts | 4 ++-- .../application/lib/set-defaults.ts | 19 +++++----------- .../application/lib/update-jest-config.ts | 7 ++---- .../generators/custom-server/custom-server.ts | 13 ++++++----- .../files/server/main.ts__tmpl__ | 2 +- .../next/src/generators/init/init.spec.ts | 4 ++-- packages/next/src/generators/init/init.ts | 2 +- .../src/generators/library/library.spec.ts | 16 +++++++------- .../next/src/generators/library/library.ts | 10 ++++----- .../update-13-1-1/enable-swc.spec.ts | 8 +++++++ packages/next/src/utils/generate-globs.ts | 2 +- .../src/generators/plugin/plugin.spec.ts | 6 ++--- packages/react-native/generators.json | 2 +- packages/react-native/migrations.json | 20 ----------------- .../files/app/metro.config.js.template | 4 ++-- .../files/app/src/app/App.tsx.template | 4 ++-- .../files/app/tsconfig.json.template | 2 +- .../generators/application/lib/add-project.ts | 20 ++++++++--------- .../src/generators/component/schema.d.ts | 2 +- .../react-native/src/generators/init/init.ts | 4 ++-- .../files/lib/babel.config.json.template | 2 +- .../src/generators/library/library.spec.ts | 4 ++-- .../src/generators/library/library.ts | 4 ++-- .../src/generators/library/schema.d.ts | 2 +- .../configuration.spec.ts | 2 +- .../storybook-configuration/configuration.ts | 2 +- .../lib/create-storybook-files.ts | 2 ++ packages/react-native/src/utils/add-jest.ts | 4 ++-- .../utils/ensure-node-modules-symlink.spec.ts | 8 +++---- .../utils/find-all-npm-dependencies.spec.ts | 8 +++---- .../src/utils/find-all-npm-dependencies.ts | 7 ++++-- packages/react/.eslintrc.json | 2 +- packages/react/generators.json | 2 +- .../react/plugins/component-testing/index.ts | 4 ++-- .../component-testing/webpack-fallback.ts | 2 +- packages/react/plugins/storybook/index.ts | 2 +- packages/react/plugins/webpack.ts | 2 +- .../module-federation-dev-server.impl.ts | 2 +- .../module-federation-ssr-dev-server.impl.ts | 2 +- .../application/application.spec.ts | 18 +++++++-------- .../files/base-vite/tsconfig.app.json__tmpl__ | 6 ++--- .../files/base-webpack/.babelrc__tmpl__ | 2 +- .../base-webpack/tsconfig.app.json__tmpl__ | 6 ++--- .../base-webpack/webpack.config.js__tmpl__ | 4 ++-- .../files/nx-welcome/src/app/nx-welcome.tsx | 4 ++-- .../generators/application/lib/add-project.ts | 4 ++-- .../lib/install-common-dependencies.ts | 2 +- .../application/lib/set-defaults.ts | 6 ++--- .../application/lib/update-jest-config.ts | 6 ++--- ...press-component-configuration.spec.ts.snap | 8 +++---- .../files/cypress.config.ts__tpl__ | 2 +- ...module-federation.server.config.js__tmpl__ | 2 +- .../webpack.server.config.js__tmpl__ | 6 ++--- .../webpack.config.js__tmpl__ | 6 ++--- .../webpack.config.prod.js__tmpl__ | 6 ++--- .../react/src/generators/host/host.spec.ts | 4 ++-- .../generators/host/lib/setup-ssr-for-host.ts | 3 +-- packages/react/src/generators/init/init.ts | 8 +++---- .../library/files/common/.babelrc__tmpl__ | 2 +- .../files/common/tsconfig.lib.json__tmpl__ | 6 ++--- .../files/vite/tsconfig.lib.json__tmpl__ | 6 ++--- .../library/lib/add-rollup-build-target.ts | 6 ++--- .../lib/install-common-dependencies.ts | 2 +- .../generators/library/lib/set-defaults.ts | 6 ++--- .../src/generators/library/library.spec.ts | 10 ++++----- .../module-federation-ssr/server.ts__tmpl__ | 2 +- .../webpack.server.config.js__tmpl__ | 6 ++--- .../webpack.config.js__tmpl__ | 6 ++--- .../remote/lib/update-host-with-remote.ts | 6 ++--- .../src/generators/remote/remote.spec.ts | 4 ++-- .../src/generators/setup-ssr/setup-ssr.ts | 6 ++--- .../files/tailwind.config.js__tmpl__ | 2 +- .../setup-tailwind/lib/update-project.ts | 5 ++++- .../setup-tailwind/setup-tailwind.spec.ts | 2 +- .../generators/stories/stories.nextjs.spec.ts | 4 ++-- .../configuration.spec.ts | 2 +- .../storybook-configuration/configuration.ts | 3 ++- .../src/module-federation/load-config.ts | 2 +- .../rules/update-module-federation-project.ts | 6 ++--- packages/react/src/utils/jest-utils.ts | 4 ++-- packages/react/src/utils/lint.ts | 4 ++-- .../configuration/configuration.spec.ts | 4 ++-- .../init/__snapshots__/init.spec.ts.snap | 2 +- .../src/generators/init/init.spec.ts | 2 +- .../init/__snapshots__/init.spec.ts.snap | 2 +- packages/web/.eslintrc.json | 2 +- packages/web/babel.ts | 2 +- packages/web/generators.json | 2 +- .../web/src/executors/rollup/rollup.impl.ts | 2 +- .../src/generators/application/application.ts | 6 ++--- .../files/app-vite/.babelrc__tmpl__ | 2 +- .../app-vite/src/app/app.element.ts__tmpl__ | 4 ++-- .../files/app-webpack/.babelrc__tmpl__ | 2 +- .../src/app/app.element.ts__tmpl__ | 4 ++-- .../app-webpack/webpack.config.js__tmpl__ | 2 +- packages/web/src/generators/init/init.spec.ts | 6 ++--- packages/web/src/generators/init/init.ts | 4 ++-- .../static-serve-configuration.spec.ts | 12 +++++----- .../static-serve-configuration.ts | 4 ++-- .../preset/__snapshots__/preset.spec.ts.snap | 2 +- 119 files changed, 305 insertions(+), 305 deletions(-) diff --git a/packages/js/.babelrc b/packages/js/.babelrc index b63f0528f976c..fd4cbcdef1229 100644 --- a/packages/js/.babelrc +++ b/packages/js/.babelrc @@ -1,7 +1,7 @@ { "presets": [ [ - "@nrwl/js/babel", + "@nx/js/babel", { "useBuiltIns": "usage" } diff --git a/packages/js/babel.ts b/packages/js/babel.ts index 73f7e41feeb00..8f1e0935c7174 100644 --- a/packages/js/babel.ts +++ b/packages/js/babel.ts @@ -20,7 +20,7 @@ module.exports = function (api: any, options: NxWebBabelPresetOptions = {}) { const isModern = api.caller((caller) => caller?.isModern); - // This is set by `@nrwl/web:rollup` executor + // This is set by `@nx/web:rollup` executor const isNxPackage = api.caller((caller) => caller?.isNxPackage); const emitDecoratorMetadata = api.caller( diff --git a/packages/js/src/generators/convert-to-swc/convert-to-swc.spec.ts b/packages/js/src/generators/convert-to-swc/convert-to-swc.spec.ts index cb53133bb59d8..c1760f58cff95 100644 --- a/packages/js/src/generators/convert-to-swc/convert-to-swc.spec.ts +++ b/packages/js/src/generators/convert-to-swc/convert-to-swc.spec.ts @@ -36,13 +36,13 @@ describe('convert to swc', () => { expect( readProjectConfiguration(tree, 'tsc-lib').targets['build']['executor'] - ).toEqual('@nrwl/js:tsc'); + ).toEqual('@nx/js:tsc'); await convertToSwcGenerator(tree, { project: 'tsc-lib' }); expect( readProjectConfiguration(tree, 'tsc-lib').targets['build']['executor'] - ).toEqual('@nrwl/js:swc'); + ).toEqual('@nx/js:swc'); expect( tree.exists( join(readProjectConfiguration(tree, 'tsc-lib').root, '.swcrc') diff --git a/packages/js/src/generators/convert-to-swc/convert-to-swc.ts b/packages/js/src/generators/convert-to-swc/convert-to-swc.ts index 38d82b038bed4..fb55f63966e98 100644 --- a/packages/js/src/generators/convert-to-swc/convert-to-swc.ts +++ b/packages/js/src/generators/convert-to-swc/convert-to-swc.ts @@ -50,9 +50,13 @@ function updateProjectBuildTargets( ) { for (const target of projectTargets) { const targetConfiguration = projectConfiguration.targets[target]; - if (!targetConfiguration || targetConfiguration.executor !== '@nrwl/js:tsc') + if ( + !targetConfiguration || + (targetConfiguration.executor !== '@nx/js:tsc' && + targetConfiguration.executor !== '@nrwl/js:tsc') + ) continue; - targetConfiguration.executor = '@nrwl/js:swc'; + targetConfiguration.executor = '@nx/js:swc'; } updateProjectConfiguration(tree, projectName, projectConfiguration); diff --git a/packages/js/src/generators/init/init.ts b/packages/js/src/generators/init/init.ts index 667234a2259ea..86936f80bb1a2 100644 --- a/packages/js/src/generators/init/init.ts +++ b/packages/js/src/generators/init/init.ts @@ -33,7 +33,7 @@ export async function initGenerator( }); } const devDependencies = { - '@nrwl/js': nxVersion, + '@nx/js': nxVersion, prettier: prettierVersion, }; diff --git a/packages/js/src/generators/library/library.spec.ts b/packages/js/src/generators/library/library.spec.ts index 3db38105d6a4e..d8fb788cea1c6 100644 --- a/packages/js/src/generators/library/library.spec.ts +++ b/packages/js/src/generators/library/library.spec.ts @@ -756,7 +756,7 @@ describe('lib', () => { const config = readProjectConfiguration(tree, 'my-lib'); expect(config.targets.build).toEqual({ - executor: '@nrwl/js:tsc', + executor: '@nx/js:tsc', options: { assets: ['libs/my-lib/*.md'], main: 'libs/my-lib/src/index.ts', @@ -776,7 +776,7 @@ describe('lib', () => { const config = readProjectConfiguration(tree, 'my-lib'); expect(config.targets.build).toEqual({ - executor: '@nrwl/js:swc', + executor: '@nx/js:swc', options: { assets: ['libs/my-lib/*.md'], main: 'libs/my-lib/src/index.ts', @@ -830,7 +830,7 @@ describe('lib', () => { const config = readProjectConfiguration(tree, 'my-lib'); expect(config.targets.build).toEqual({ - executor: '@nrwl/js:tsc', + executor: '@nx/js:tsc', options: { assets: ['libs/my-lib/*.md'], main: 'libs/my-lib/src/index.ts', @@ -851,7 +851,7 @@ describe('lib', () => { const config = readProjectConfiguration(tree, 'my-lib'); expect(config.targets.build).toEqual({ - executor: '@nrwl/js:swc', + executor: '@nx/js:swc', options: { assets: ['libs/my-lib/*.md'], main: 'libs/my-lib/src/index.ts', @@ -935,7 +935,7 @@ describe('lib', () => { const config = readProjectConfiguration(tree, 'my-lib'); expect(config.targets.build).toEqual({ - executor: '@nrwl/js:tsc', + executor: '@nx/js:tsc', options: { assets: ['libs/my-lib/*.md'], main: 'libs/my-lib/src/index.ts', @@ -1011,7 +1011,7 @@ describe('lib', () => { expect(tree.exists('libs/my-lib/.babelrc')).toBeFalsy(); }); - it('should generate a .babelrc when flag is set to true (even if there is no `@nrwl/web` plugin installed)', async () => { + it('should generate a .babelrc when flag is set to true (even if there is no `@nx/web` plugin installed)', async () => { updateJson(tree, 'package.json', (json) => { json.devDependencies = {}; return json; @@ -1030,7 +1030,7 @@ describe('lib', () => { { "presets": [ [ - "@nrwl/js/babel", + "@nx/js/babel", { "useBuiltIns": "usage", }, @@ -1040,11 +1040,11 @@ describe('lib', () => { `); }); - it('should not generate a .babelrc when flag is not set and there is NOT a `@nrwl/web` package installed', async () => { + it('should not generate a .babelrc when flag is not set and there is NOT a `@nx/web` package installed', async () => { updateJson(tree, 'package.json', (json) => { json.devDependencies = { - '@nrwl/angular': '1.1.1', - '@nrwl/next': '1.1.1', + '@nx/angular': '1.1.1', + '@nx/next': '1.1.1', }; return json; }); diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts index b39037738103c..458ff7ec44a42 100644 --- a/packages/js/src/generators/library/library.ts +++ b/packages/js/src/generators/library/library.ts @@ -267,7 +267,7 @@ function addBabelRc(tree: Tree, options: NormalizedSchema) { const filename = '.babelrc'; const babelrc = { - presets: [['@nrwl/js/babel', { useBuiltIns: 'usage' }]], + presets: [['@nx/js/babel', { useBuiltIns: 'usage' }]], }; writeJson(tree, join(options.projectRoot, filename), babelrc); @@ -426,7 +426,7 @@ function normalizeOptions( * * In the past, the only way to get a non-buildable library was to set buildable to false. * Now, the only way to get a non-buildble library is to set bundler to none. - * By default, with nothing provided, libraries are buildable with `@nrwl/js:tsc`. + * By default, with nothing provided, libraries are buildable with `@nx/js:tsc`. */ options.bundler = options.bundler ?? options.compiler ?? 'tsc'; @@ -534,7 +534,7 @@ function addProjectDependencies( tree, {}, { - '@nrwl/esbuild': nxVersion, + '@nx/esbuild': nxVersion, '@types/node': typesNodeVersion, esbuild: esbuildVersion, } @@ -558,14 +558,14 @@ function addProjectDependencies( function getBuildExecutor(bundler: Bundler) { switch (bundler) { case 'esbuild': - return `@nrwl/esbuild:esbuild`; + return `@nx/esbuild:esbuild`; case 'rollup': - return `@nrwl/rollup:rollup`; + return `@nx/rollup:rollup`; case 'swc': case 'tsc': - return `@nrwl/js:${bundler}`; + return `@nx/js:${bundler}`; case 'vite': - return `@nrwl/vite:build`; + return `@nx/vite:build`; case 'none': default: return undefined; diff --git a/packages/js/src/migrations/update-15-8-0/rename-swcrc-config.spec.ts b/packages/js/src/migrations/update-15-8-0/rename-swcrc-config.spec.ts index edeb8e7eb5fbd..4b41010a742b8 100644 --- a/packages/js/src/migrations/update-15-8-0/rename-swcrc-config.spec.ts +++ b/packages/js/src/migrations/update-15-8-0/rename-swcrc-config.spec.ts @@ -66,6 +66,7 @@ async function setup(tree: Tree) { }); const projectConfig = readProjectConfiguration(tree, 'my-lib'); + projectConfig.targets.build.executor = '@nrwl/js:swc'; projectConfig.targets.test.executor = '@nrwl/jest:jest'; updateProjectConfiguration(tree, 'my-lib', projectConfig); diff --git a/packages/js/src/utils/compiler-helper-dependency.ts b/packages/js/src/utils/compiler-helper-dependency.ts index 9708b41d39bc4..6c467fd2ddf7b 100644 --- a/packages/js/src/utils/compiler-helper-dependency.ts +++ b/packages/js/src/utils/compiler-helper-dependency.ts @@ -16,12 +16,12 @@ export enum HelperDependency { } const jsExecutors = { - '@nrwl/js:tsc': { + '@nx/js:tsc': { helperDependency: HelperDependency.tsc, getConfigPath: (options: ExecutorOptions, contextRoot: string, _: string) => join(contextRoot, options.tsConfig), } as const, - '@nrwl/js:swc': { + '@nx/js:swc': { helperDependency: HelperDependency.swc, getConfigPath: ( options: SwcExecutorOptions, diff --git a/packages/js/src/utils/minimal-publish-script.ts b/packages/js/src/utils/minimal-publish-script.ts index 13fefbf98d59f..222a605d06873 100644 --- a/packages/js/src/utils/minimal-publish-script.ts +++ b/packages/js/src/utils/minimal-publish-script.ts @@ -10,7 +10,7 @@ const publishScriptContent = ` * You might need to authenticate with NPM before running this script. */ -import { readCachedProjectGraph } from '@nrwl/devkit'; +import { readCachedProjectGraph } from '@nx/devkit'; import { execSync } from 'child_process'; import { readFileSync, writeFileSync } from 'fs'; import chalk from 'chalk'; diff --git a/packages/next/.eslintrc.json b/packages/next/.eslintrc.json index 4a142b79a6e0f..5f199bc850003 100644 --- a/packages/next/.eslintrc.json +++ b/packages/next/.eslintrc.json @@ -12,7 +12,7 @@ "rules": { "no-restricted-imports": [ "error", - "@nrwl/workspace", + "@nx/workspace", "@angular-devkit/core", "@angular-devkit/schematics", "@angular-devkit/architect" diff --git a/packages/next/generators.json b/packages/next/generators.json index cabfd86d53426..573c45ef8e521 100644 --- a/packages/next/generators.json +++ b/packages/next/generators.json @@ -1,7 +1,7 @@ { "name": "nx/next", "version": "0.1", - "extends": ["@nrwl/react"], + "extends": ["@nx/react"], "schematics": { "init": { "factory": "./src/generators/init/init#nextInitSchematic", diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index bc2a6d590ad2c..101606427d16d 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -80,7 +80,10 @@ function getNxContext( } { const targetConfig = getTargetConfig(graph, target); - if ('@nrwl/next:build' === targetConfig.executor) { + if ( + '@nx/next:build' === targetConfig.executor || + '@nrwl/next:build' === targetConfig.executor + ) { return { node: graph.nodes[target.project], options: getOptions(graph, target), @@ -101,7 +104,12 @@ function getNxContext( return getNxContext(graph, devServerTarget); } else if ( - ['@nrwl/next:server', '@nrwl/next:export'].includes(targetConfig.executor) + [ + '@nx/next:server', + '@nx/next:export', + '@nrwl/next:server', + '@nrwl/next:export', + ].includes(targetConfig.executor) ) { const buildTarget = parseTargetString(targetOptions.buildTarget, graph); return getNxContext(graph, buildTarget); diff --git a/packages/next/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/next/src/generators/application/__snapshots__/application.spec.ts.snap index fcab00151a95d..c9c272447c351 100644 --- a/packages/next/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/next/src/generators/application/__snapshots__/application.spec.ts.snap @@ -347,9 +347,9 @@ exports[`app --style styled-jsx should use