@nx/angular 16.8.0-beta.7 → 16.8.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/generators.json CHANGED
@@ -74,7 +74,8 @@
74
74
  "factory": "./src/generators/move/compat",
75
75
  "schema": "./src/generators/move/schema.json",
76
76
  "aliases": ["mv"],
77
- "description": "Moves an Angular application or library to another folder within the workspace and updates the project configuration."
77
+ "description": "Moves an Angular application or library to another folder within the workspace and updates the project configuration.",
78
+ "x-deprecated": "Use the `@nx/workspace:move` generator instead. This generator will be removed in Nx v18."
78
79
  },
79
80
  "convert-to-with-mf": {
80
81
  "factory": "./src/generators/convert-to-with-mf/convert-to-with-mf.compat",
@@ -230,10 +231,11 @@
230
231
  "description": "Generate a Remote Angular Module Federation Application."
231
232
  },
232
233
  "move": {
233
- "factory": "./src/generators/move/move#angularMoveGenerator",
234
+ "factory": "./src/generators/move/move#angularMoveGeneratorInternal",
234
235
  "schema": "./src/generators/move/schema.json",
235
236
  "aliases": ["mv"],
236
- "description": "Moves an Angular application or library to another folder within the workspace and updates the project configuration."
237
+ "description": "Moves an Angular application or library to another folder within the workspace and updates the project configuration.",
238
+ "x-deprecated": "Use the `@nx/workspace:move` generator instead. This generator will be removed in Nx v18."
237
239
  },
238
240
  "convert-to-with-mf": {
239
241
  "factory": "./src/generators/convert-to-with-mf/convert-to-with-mf",
package/ng-package.json CHANGED
@@ -14,7 +14,6 @@
14
14
  "@phenomnomnominal/tsquery",
15
15
  "@typescript-eslint/",
16
16
  "chalk",
17
- "chokidar",
18
17
  "ignore",
19
18
  "minimatch",
20
19
  "rxjs-for-await",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "16.8.0-beta.7",
3
+ "version": "16.8.0-rc.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -26,6 +26,7 @@
26
26
  "./src/utils": "./src/utils/public-api.js",
27
27
  "./plugins/component-testing": "./plugins/component-testing.js",
28
28
  "./src/generators/utils": "./src/generators/utils/index.js",
29
+ "./src/generators/move/move-impl": "./src/generators/move/move-impl.js",
29
30
  "./src/builders/*/schema.json": "./src/builders/*/schema.json",
30
31
  "./src/builders/*.impl": "./src/builders/*.impl.js",
31
32
  "./src/executors/*/schema.json": "./src/executors/*/schema.json",
@@ -66,14 +67,14 @@
66
67
  "migrations": "./migrations.json"
67
68
  },
68
69
  "dependencies": {
69
- "@nrwl/angular": "16.8.0-beta.7",
70
- "@nx/cypress": "16.8.0-beta.7",
71
- "@nx/devkit": "16.8.0-beta.7",
72
- "@nx/jest": "16.8.0-beta.7",
73
- "@nx/js": "16.8.0-beta.7",
74
- "@nx/linter": "16.8.0-beta.7",
75
- "@nx/webpack": "16.8.0-beta.7",
76
- "@nx/workspace": "16.8.0-beta.7",
70
+ "@nrwl/angular": "16.8.0-rc.0",
71
+ "@nx/cypress": "16.8.0-rc.0",
72
+ "@nx/devkit": "16.8.0-rc.0",
73
+ "@nx/jest": "16.8.0-rc.0",
74
+ "@nx/js": "16.8.0-rc.0",
75
+ "@nx/linter": "16.8.0-rc.0",
76
+ "@nx/webpack": "16.8.0-rc.0",
77
+ "@nx/workspace": "16.8.0-rc.0",
77
78
  "@phenomnomnominal/tsquery": "~5.0.1",
78
79
  "@typescript-eslint/type-utils": "^5.36.1",
79
80
  "chalk": "^4.1.0",
@@ -110,5 +111,5 @@
110
111
  "module": "fesm2022/nx-angular.mjs",
111
112
  "typings": "index.d.ts",
112
113
  "sideEffects": false,
113
- "gitHead": "6175b0f2033a80504bdc79d6212de9377843d787"
114
+ "gitHead": "44d0b22f4f6c4a790e2ad4702bf27ffa15073582"
114
115
  }
@@ -1,4 +1,3 @@
1
- export * from './normalize-schema';
2
1
  export * from './update-module-name';
3
2
  export * from './update-ng-package';
4
3
  export * from './update-secondary-entry-points';
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./normalize-schema"), exports);
5
4
  tslib_1.__exportStar(require("./update-module-name"), exports);
6
5
  tslib_1.__exportStar(require("./update-ng-package"), exports);
7
6
  tslib_1.__exportStar(require("./update-secondary-entry-points"), exports);
@@ -0,0 +1,4 @@
1
+ export type MoveImplOptions = {
2
+ oldProjectName: string;
3
+ newProjectName: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
- import type { NormalizedSchema } from '../schema';
2
+ import type { MoveImplOptions } from './types';
3
3
  /**
4
4
  * Updates the Angular module name (including the spec file and index.ts)
5
5
  *
@@ -8,4 +8,4 @@ import type { NormalizedSchema } from '../schema';
8
8
  *
9
9
  * @param schema The options provided to the schematic
10
10
  */
11
- export declare function updateModuleName(tree: Tree, { projectName: oldProjectName, newProjectName }: NormalizedSchema): void;
11
+ export declare function updateModuleName(tree: Tree, { oldProjectName, newProjectName }: MoveImplOptions): void;
@@ -10,7 +10,13 @@ const devkit_1 = require("@nx/devkit");
10
10
  *
11
11
  * @param schema The options provided to the schematic
12
12
  */
13
- function updateModuleName(tree, { projectName: oldProjectName, newProjectName }) {
13
+ function updateModuleName(tree, { oldProjectName, newProjectName }) {
14
+ const unscopedNewProjectName = newProjectName.startsWith('@')
15
+ ? newProjectName.split('/')[1]
16
+ : newProjectName;
17
+ if (oldProjectName === unscopedNewProjectName) {
18
+ return;
19
+ }
14
20
  const project = (0, devkit_1.readProjectConfiguration)(tree, newProjectName);
15
21
  if (project.projectType === 'application') {
16
22
  // Expect the module to be something like 'app.module.ts' regardless of the folder name,
@@ -19,12 +25,12 @@ function updateModuleName(tree, { projectName: oldProjectName, newProjectName })
19
25
  }
20
26
  const moduleName = {
21
27
  from: `${(0, devkit_1.names)(oldProjectName).className}Module`,
22
- to: `${(0, devkit_1.names)(newProjectName).className}Module`,
28
+ to: `${(0, devkit_1.names)(unscopedNewProjectName).className}Module`,
23
29
  };
24
30
  const findModuleName = new RegExp(`\\b${moduleName.from}`, 'g');
25
31
  const moduleFile = {
26
32
  from: `${oldProjectName}.module`,
27
- to: `${newProjectName}.module`,
33
+ to: `${unscopedNewProjectName}.module`,
28
34
  };
29
35
  const findFileName = new RegExp(`\\b${moduleFile.from}`, 'g');
30
36
  const filesToRename = [
@@ -1,3 +1,3 @@
1
1
  import { Tree } from '@nx/devkit';
2
- import type { NormalizedSchema } from '../schema';
3
- export declare function updateNgPackage(tree: Tree, schema: NormalizedSchema): void;
2
+ import type { MoveImplOptions } from './types';
3
+ export declare function updateNgPackage(tree: Tree, schema: MoveImplOptions): void;
@@ -1,3 +1,3 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- import type { NormalizedSchema } from '../schema';
3
- export declare function updateSecondaryEntryPoints(tree: Tree, schema: NormalizedSchema): void;
2
+ import type { MoveImplOptions } from './types';
3
+ export declare function updateSecondaryEntryPoints(tree: Tree, schema: MoveImplOptions): void;
@@ -12,6 +12,9 @@ const libraryExecutors = [
12
12
  '@nrwl/angular:package',
13
13
  ];
14
14
  function updateSecondaryEntryPoints(tree, schema) {
15
+ if (schema.oldProjectName === schema.newProjectName) {
16
+ return;
17
+ }
15
18
  const project = (0, devkit_1.readProjectConfiguration)(tree, schema.newProjectName);
16
19
  if (project.projectType !== 'library') {
17
20
  return;
@@ -25,7 +28,7 @@ function updateSecondaryEntryPoints(tree, schema) {
25
28
  (0, devkit_1.joinPathFragments)(project.root, 'ng-package.json')) {
26
29
  return;
27
30
  }
28
- updateReadme(tree, (0, path_1.dirname)(filePath), schema.projectName, schema.newProjectName);
31
+ updateReadme(tree, (0, path_1.dirname)(filePath), schema.oldProjectName, schema.newProjectName);
29
32
  });
30
33
  }
31
34
  exports.updateSecondaryEntryPoints = updateSecondaryEntryPoints;
@@ -0,0 +1,7 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { MoveImplOptions } from './lib/types';
3
+ /**
4
+ * Angular-specific logic to move a project to another directory.
5
+ * This is invoked by the `@nx/workspace:move` generator.
6
+ */
7
+ export declare function move(tree: Tree, options: MoveImplOptions): Promise<void>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.move = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const lib_1 = require("./lib");
6
+ /**
7
+ * Angular-specific logic to move a project to another directory.
8
+ * This is invoked by the `@nx/workspace:move` generator.
9
+ */
10
+ async function move(tree, options) {
11
+ // while the project has already being moved at this point, the changes are
12
+ // still in the virtual tree and haven't been committed, so the project graph
13
+ // still contains the old project name
14
+ if (!(await isAngularProject(options.oldProjectName))) {
15
+ return;
16
+ }
17
+ (0, lib_1.updateModuleName)(tree, options);
18
+ (0, lib_1.updateNgPackage)(tree, options);
19
+ (0, lib_1.updateSecondaryEntryPoints)(tree, options);
20
+ }
21
+ exports.move = move;
22
+ async function isAngularProject(project) {
23
+ const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
24
+ return projectGraph.dependencies[project]?.some((dependency) => dependency.target === 'npm:@angular/core');
25
+ }
@@ -1,10 +1,4 @@
1
- import { Tree } from '@nx/devkit';
1
+ import type { Tree } from '@nx/devkit';
2
2
  import type { Schema } from './schema';
3
- /**
4
- * Moves an Angular lib/app to another folder (and renames it in the process)
5
- *
6
- * @remarks It's important to note that `updateModuleName` is done after the update
7
- * to the workspace, so it can't use the same tricks as the `@nx/workspace` rules
8
- * to get the before and after names and paths.
9
- */
10
3
  export declare function angularMoveGenerator(tree: Tree, schema: Schema): Promise<void>;
4
+ export declare function angularMoveGeneratorInternal(tree: Tree, schema: Schema): Promise<void>;
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.angularMoveGenerator = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const generators_1 = require("@nx/workspace/generators");
6
- const lib_1 = require("./lib");
7
- /**
8
- * Moves an Angular lib/app to another folder (and renames it in the process)
9
- *
10
- * @remarks It's important to note that `updateModuleName` is done after the update
11
- * to the workspace, so it can't use the same tricks as the `@nx/workspace` rules
12
- * to get the before and after names and paths.
13
- */
3
+ exports.angularMoveGeneratorInternal = exports.angularMoveGenerator = void 0;
4
+ const move_1 = require("@nx/workspace/src/generators/move/move");
14
5
  async function angularMoveGenerator(tree, schema) {
15
- const normalizedSchema = (0, lib_1.normalizeSchema)(tree, schema);
16
- await (0, generators_1.moveGenerator)(tree, { ...schema, skipFormat: true });
17
- (0, lib_1.updateModuleName)(tree, normalizedSchema);
18
- (0, lib_1.updateNgPackage)(tree, normalizedSchema);
19
- (0, lib_1.updateSecondaryEntryPoints)(tree, normalizedSchema);
20
- if (!normalizedSchema.skipFormat) {
21
- await (0, devkit_1.formatFiles)(tree);
22
- }
6
+ await angularMoveGeneratorInternal(tree, {
7
+ projectNameAndRootFormat: 'derived',
8
+ ...schema,
9
+ });
23
10
  }
24
11
  exports.angularMoveGenerator = angularMoveGenerator;
12
+ async function angularMoveGeneratorInternal(tree, schema) {
13
+ process.env.NX_ANGULAR_MOVE_INVOKED = 'true';
14
+ await (0, move_1.moveGeneratorInternal)(tree, schema);
15
+ }
16
+ exports.angularMoveGeneratorInternal = angularMoveGeneratorInternal;
@@ -1,12 +1,11 @@
1
+ import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+
1
3
  export interface Schema {
2
4
  projectName: string;
3
5
  destination: string;
4
6
  updateImportPath: boolean;
5
7
  importPath?: string;
6
8
  skipFormat?: boolean;
7
- }
8
-
9
- export interface NormalizedSchema extends Schema {
10
- oldProjectRoot: string;
11
- newProjectName: string;
9
+ newProjectName?: string;
10
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
12
11
  }
@@ -19,6 +19,13 @@
19
19
  "x-dropdown": "projects",
20
20
  "x-priority": "important"
21
21
  },
22
+ "newProjectName": {
23
+ "type": "string",
24
+ "alias": "project",
25
+ "description": "The new name of the project after the move.",
26
+ "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
27
+ "x-priority": "important"
28
+ },
22
29
  "destination": {
23
30
  "type": "string",
24
31
  "description": "The folder to move the Angular project into.",
@@ -28,6 +35,11 @@
28
35
  },
29
36
  "x-priority": "important"
30
37
  },
38
+ "projectNameAndRootFormat": {
39
+ "description": "Whether to generate the new project name and destination as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
40
+ "type": "string",
41
+ "enum": ["as-provided", "derived"]
42
+ },
31
43
  "importPath": {
32
44
  "type": "string",
33
45
  "description": "The new import path to use in the `tsconfig.base.json`."
@@ -1,3 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- import type { NormalizedSchema, Schema } from '../schema';
3
- export declare function normalizeSchema(tree: Tree, schema: Schema): NormalizedSchema;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeSchema = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const get_new_project_name_1 = require("../../utils/get-new-project-name");
6
- function normalizeSchema(tree, schema) {
7
- const newProjectName = (0, get_new_project_name_1.getNewProjectName)(schema.destination);
8
- const { root } = (0, devkit_1.readProjectConfiguration)(tree, schema.projectName);
9
- return {
10
- ...schema,
11
- newProjectName,
12
- oldProjectRoot: root,
13
- };
14
- }
15
- exports.normalizeSchema = normalizeSchema;