Skip to content

Commit

Permalink
feat(angular): replace usages of @nrwl with @nx (nrwl#16377)
Browse files Browse the repository at this point in the history
Co-authored-by: Colum Ferry <cferry09@gmail.com>
  • Loading branch information
FrozenPandaz and Coly010 committed Apr 19, 2023
1 parent 76dfc62 commit da158bc
Show file tree
Hide file tree
Showing 66 changed files with 290 additions and 270 deletions.
18 changes: 9 additions & 9 deletions e2e/angular-core/src/ng-add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
updateFile('angular.json', JSON.stringify(angularJson, null, 2));

// confirm that @nrwl dependencies do not exist yet
expect(packageJson.devDependencies['@nrwl/workspace']).not.toBeDefined();
expect(packageJson.devDependencies['@nx/workspace']).not.toBeDefined();

// run ng add
runNgAdd('@nrwl/angular', '--npm-scope projscope --default-base main');
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
watch: 'nx build --watch --configuration development',
test: 'nx test',
});
expect(updatedPackageJson.devDependencies['@nrwl/workspace']).toBeDefined();
expect(updatedPackageJson.devDependencies['@nx/workspace']).toBeDefined();
expect(updatedPackageJson.devDependencies['@angular/cli']).toBeDefined();

// check nx.json
Expand Down Expand Up @@ -297,7 +297,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
// check e2e project config
const e2eProjectConfig = readJson(`apps/${project}-e2e/project.json`);
expect(e2eProjectConfig.targets['cypress-run']).toEqual({
executor: '@nrwl/cypress:cypress',
executor: '@nx/cypress:cypress',
options: {
devServerTarget: `${project}:serve`,
cypressConfig: `apps/${e2eProject}/cypress.json`,
Expand All @@ -309,15 +309,15 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
},
});
expect(e2eProjectConfig.targets['cypress-open']).toEqual({
executor: '@nrwl/cypress:cypress',
executor: '@nx/cypress:cypress',
options: {
watch: true,
headless: false,
cypressConfig: `apps/${e2eProject}/cypress.json`,
},
});
expect(e2eProjectConfig.targets.e2e).toEqual({
executor: '@nrwl/cypress:cypress',
executor: '@nx/cypress:cypress',
options: {
devServerTarget: `${project}:serve`,
watch: true,
Expand Down Expand Up @@ -364,7 +364,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
// check e2e project config
const e2eProjectConfig = readJson(`apps/${project}-e2e/project.json`);
expect(e2eProjectConfig.targets['cypress-run']).toEqual({
executor: '@nrwl/cypress:cypress',
executor: '@nx/cypress:cypress',
options: {
devServerTarget: `${project}:serve`,
cypressConfig: `apps/${e2eProject}/cypress.config.ts`,
Expand All @@ -376,15 +376,15 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
},
});
expect(e2eProjectConfig.targets['cypress-open']).toEqual({
executor: '@nrwl/cypress:cypress',
executor: '@nx/cypress:cypress',
options: {
watch: true,
headless: false,
cypressConfig: `apps/${e2eProject}/cypress.config.ts`,
},
});
expect(e2eProjectConfig.targets.e2e).toEqual({
executor: '@nrwl/cypress:cypress',
executor: '@nx/cypress:cypress',
options: {
devServerTarget: `${project}:serve`,
watch: true,
Expand All @@ -411,7 +411,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {

const projectConfig = readJson(`apps/${project}/project.json`);
expect(projectConfig.targets.lint).toStrictEqual({
executor: '@nrwl/linter:eslint',
executor: '@nx/linter:eslint',
options: {
lintFilePatterns: [
`apps/${project}/src/**/*.ts`,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"files": ["**/*.ts"],
"excludedFiles": ["./src/migrations/**"],
"rules": {
"no-restricted-imports": ["error", "@nrwl/workspace"]
"no-restricted-imports": ["error", "@nx/workspace"]
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/generators.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Nx Angular",
"version": "0.1",
"extends": ["@schematics/angular", "@nrwl/workspace"],
"extends": ["@schematics/angular", "@nx/workspace"],
"schematics": {
"add-linting": {
"factory": "./src/generators/add-linting/compat",
Expand Down
1 change: 0 additions & 1 deletion packages/angular/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"deleteDestPath": false,
"allowedNonPeerDependencies": [
"@nx/",
"@nrwl/",
"@angular-devkit",
"@angular-eslint/",
"@nguniversal/builders",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function getStaticRemotes(
mfeConfig = require(mfConfigPath);
} catch {
throw new Error(
`Could not load ${mfConfigPath}. Was this project generated with "@nrwl/angular:host"?`
`Could not load ${mfConfigPath}. Was this project generated with "@nx/angular:host"?`
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ exports[`app nested should create project configs 1`] = `
"executor": "@angular-devkit/build-angular:dev-server",
},
"serve-static": {
"executor": "@nrwl/web:file-server",
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "my-dir-my-app:build",
},
Expand Down Expand Up @@ -645,7 +645,7 @@ exports[`app not nested should create project configs 1`] = `
"executor": "@angular-devkit/build-angular:dev-server",
},
"serve-static": {
"executor": "@nrwl/web:file-server",
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "my-app:build",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ describe('app', () => {
// should not update workspace configuration since --strict=true is the default
const nxJson = readJson<NxJsonConfiguration>(appTree, 'nx.json');
expect(
nxJson.generators['@nrwl/angular:application'].strict
nxJson.generators['@nx/angular:application'].strict
).not.toBeDefined();
});

Expand All @@ -676,7 +676,7 @@ describe('app', () => {
// check to see if the workspace configuration has been updated to turn off
// strict mode by default in future applications
const nxJson = readJson<NxJsonConfiguration>(appTree, 'nx.json');
expect(nxJson.generators['@nrwl/angular:application'].strict).toBe(false);
expect(nxJson.generators['@nx/angular:application'].strict).toBe(false);
});
});

Expand Down Expand Up @@ -712,7 +712,7 @@ describe('app', () => {
// ASSERT
expect(appTree.read('apps/app1/tailwind.config.js', 'utf-8'))
.toMatchInlineSnapshot(`
"const { createGlobPatternsForDependencies } = require('@nrwl/angular/tailwind');
"const { createGlobPatternsForDependencies } = require('@nx/angular/tailwind');
const { join } = require('path');
/** @type {import('tailwindcss').Config} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,9 @@ import { Component, ViewEncapsulation } from '@angular/core';
Add UI library
</summary>
<pre><span># Generate UI lib</span>
nx g @nrwl/angular:lib ui
nx g @nx/angular:lib ui
<span># Add a component</span>
nx g @nrwl/angular:component button --project ui</pre>
nx g @nx/angular:component button --project ui</pre>
</details>
<details>
<summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,9 @@ import { CommonModule } from '@angular/common';
Add UI library
</summary>
<pre><span># Generate UI lib</span>
nx g @nrwl/angular:lib ui
nx g @nx/angular:lib ui
<span># Add a component</span>
nx g @nrwl/angular:component button --project ui</pre>
nx g @nx/angular:component button --project ui</pre>
</details>
<details>
<summary>
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
removeScaffoldedE2e(tree, options, options.ngCliSchematicE2ERoot);

if (options.e2eTestRunner === 'cypress') {
// TODO: This can call `@nrwl/web:static-config` generator when ready
// TODO: This can call `@nx/web:static-config` generator when ready
addFileServerTarget(tree, options, 'serve-static');

await cypressProjectGenerator(tree, {
Expand All @@ -33,11 +33,11 @@ function addFileServerTarget(
options: NormalizedSchema,
targetName: string
) {
addDependenciesToPackageJson(tree, {}, { '@nrwl/web': nxVersion });
addDependenciesToPackageJson(tree, {}, { '@nx/web': nxVersion });

const projectConfig = readProjectConfiguration(tree, options.name);
projectConfig.targets[targetName] = {
executor: '@nrwl/web:file-server',
executor: '@nx/web:file-server',
options: {
buildTarget: `${options.name}:build`,
port: options.port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export function setApplicationStrictDefault(host: Tree, strict: boolean) {
const nxJson = readNxJson(host);

nxJson.generators = nxJson.generators || {};
nxJson.generators['@nrwl/angular:application'] =
nxJson.generators['@nrwl/angular:application'] || {};
nxJson.generators['@nrwl/angular:application'].strict =
nxJson.generators['@nrwl/angular:application'].strict ?? strict;
nxJson.generators['@nx/angular:application'] =
nxJson.generators['@nx/angular:application'] || {};
nxJson.generators['@nx/angular:application'].strict =
nxJson.generators['@nx/angular:application'].strict ?? strict;

updateNxJson(host, nxJson);
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`convertToWithMF should migrate a standard previous generated host config correctly 1`] = `
"const { withModuleFederation } = require('@nrwl/angular/module-federation');
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
"
`;

exports[`convertToWithMF should migrate a standard previous generated remote config correctly 1`] = `
"const { withModuleFederation } = require('@nrwl/angular/module-federation');
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
"
`;

exports[`convertToWithMF should migrate a standard previous generated remote config using object shared syntax correctly 1`] = `
"const { withModuleFederation } = require('@nrwl/angular/module-federation');
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('convertToWithMF', () => {
sourceRoot: 'apps/host1/src',
targets: {
build: {
executor: '@nrwl/angular:webpack-browser',
executor: '@nx/angular:webpack-browser',
options: {
customWebpackConfig: {
path: 'apps/host1/webpack.config.js',
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('convertToWithMF', () => {
sourceRoot: 'apps/remote1/src',
targets: {
build: {
executor: '@nrwl/angular:webpack-browser',
executor: '@nx/angular:webpack-browser',
options: {
customWebpackConfig: {
path: 'apps/remote1/webpack.config.js',
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('convertToWithMF', () => {
sourceRoot: 'apps/remote1/src',
targets: {
build: {
executor: '@nrwl/angular:webpack-browser',
executor: '@nx/angular:webpack-browser',
options: {
customWebpackConfig: {
path: 'apps/remote1/webpack.config.js',
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('convertToWithMF', () => {
sourceRoot: 'apps/remote1/src',
targets: {
build: {
executor: '@nrwl/angular:webpack-browser',
executor: '@nx/angular:webpack-browser',
options: {
customWebpackConfig: {
path: 'apps/remote1/webpack.config.js',
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('convertToWithMF', () => {
sourceRoot: 'apps/host1/src',
targets: {
build: {
executor: '@nrwl/angular:webpack-browser',
executor: '@nx/angular:webpack-browser',
options: {
customWebpackConfig: {
path: 'apps/host1/webpack.config.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const path = require('path');
const share = mf.share;
/**
* We use the NX_TSCONFIG_PATH environment variable when using the @nrwl/angular:webpack-browser
* We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser
* builder as it will generate a temporary tsconfig file which contains any required remappings of
* shared libraries.
* A remapping will occur when a library is buildable, as webpack needs to know the location of the
* built files for the buildable library.
* This NX_TSCONFIG_PATH environment variable is set by the @nrwl/angular:webpack-browser and it contains
* This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains
* the location of the generated temporary tsconfig file.
*/
const tsConfigPath =
Expand Down Expand Up @@ -95,12 +95,12 @@ const path = require('path');
const share = mf.share;
/**
* We use the NX_TSCONFIG_PATH environment variable when using the @nrwl/angular:webpack-browser
* We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser
* builder as it will generate a temporary tsconfig file which contains any required remappings of
* shared libraries.
* A remapping will occur when a library is buildable, as webpack needs to know the location of the
* built files for the buildable library.
* This NX_TSCONFIG_PATH environment variable is set by the @nrwl/angular:webpack-browser and it contains
* This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains
* the location of the generated temporary tsconfig file.
*/
const tsConfigPath =
Expand Down Expand Up @@ -188,12 +188,12 @@ const path = require('path');
const share = mf.share;
/**
* We use the NX_TSCONFIG_PATH environment variable when using the @nrwl/angular:webpack-browser
* We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser
* builder as it will generate a temporary tsconfig file which contains any required remappings of
* shared libraries.
* A remapping will occur when a library is buildable, as webpack needs to know the location of the
* built files for the buildable library.
* This NX_TSCONFIG_PATH environment variable is set by the @nrwl/angular:webpack-browser and it contains
* This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains
* the location of the generated temporary tsconfig file.
*/
const tsConfigPath =
Expand Down Expand Up @@ -270,12 +270,12 @@ const path = require('path');
const share = mf.share;
/**
* We use the NX_TSCONFIG_PATH environment variable when using the @nrwl/angular:webpack-browser
* We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser
* builder as it will generate a temporary tsconfig file which contains any required remappings of
* shared libraries.
* A remapping will occur when a library is buildable, as webpack needs to know the location of the
* built files for the buildable library.
* This NX_TSCONFIG_PATH environment variable is set by the @nrwl/angular:webpack-browser and it contains
* This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains
* the location of the generated temporary tsconfig file.
*/
const tsConfigPath =
Expand Down Expand Up @@ -363,12 +363,12 @@ const path = require('path');
const share = mf.share;
/**
* We use the NX_TSCONFIG_PATH environment variable when using the @nrwl/angular:webpack-browser
* We use the NX_TSCONFIG_PATH environment variable when using the @nx/angular:webpack-browser
* builder as it will generate a temporary tsconfig file which contains any required remappings of
* shared libraries.
* A remapping will occur when a library is buildable, as webpack needs to know the location of the
* built files for the buildable library.
* This NX_TSCONFIG_PATH environment variable is set by the @nrwl/angular:webpack-browser and it contains
* This NX_TSCONFIG_PATH environment variable is set by the @nx/angular:webpack-browser and it contains
* the location of the generated temporary tsconfig file.
*/
const tsConfigPath =
Expand Down
Loading

0 comments on commit da158bc

Please sign in to comment.