@nx/angular 20.0.2 → 20.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/package.json +7 -7
  2. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +2 -2
  3. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +2 -2
  4. package/src/migrations/update-14-2-0/remove-show-circular-dependencies-option.d.ts +0 -2
  5. package/src/migrations/update-14-2-0/remove-show-circular-dependencies-option.js +0 -23
  6. package/src/migrations/update-14-2-0/update-angular-cli.d.ts +0 -2
  7. package/src/migrations/update-14-2-0/update-angular-cli.js +0 -22
  8. package/src/migrations/update-14-2-0/update-libraries-secondary-entrypoints.d.ts +0 -2
  9. package/src/migrations/update-14-2-0/update-libraries-secondary-entrypoints.js +0 -34
  10. package/src/migrations/update-14-2-0/update-ngcc-target.d.ts +0 -2
  11. package/src/migrations/update-14-2-0/update-ngcc-target.js +0 -17
  12. package/src/migrations/update-14-2-0/update-router-initial-navigation.d.ts +0 -2
  13. package/src/migrations/update-14-2-0/update-router-initial-navigation.js +0 -73
  14. package/src/migrations/update-14-2-0/update-tsconfig-target.d.ts +0 -2
  15. package/src/migrations/update-14-2-0/update-tsconfig-target.js +0 -155
  16. package/src/migrations/update-14-5-0/migrate-mfe-to-mf.d.ts +0 -5
  17. package/src/migrations/update-14-5-0/migrate-mfe-to-mf.js +0 -90
  18. package/src/migrations/update-14-5-2/update-angular-cli.d.ts +0 -2
  19. package/src/migrations/update-14-5-2/update-angular-cli.js +0 -22
  20. package/src/migrations/update-14-6-0/update-angular-cli.d.ts +0 -2
  21. package/src/migrations/update-14-6-0/update-angular-cli.js +0 -22
  22. package/src/migrations/update-14-8-0/rename-webpack-server.d.ts +0 -2
  23. package/src/migrations/update-14-8-0/rename-webpack-server.js +0 -21
  24. package/src/migrations/update-15-0-0/add-karma-inputs.d.ts +0 -2
  25. package/src/migrations/update-15-0-0/add-karma-inputs.js +0 -41
  26. package/src/migrations/update-15-0-0/switch-to-jasmine-marbles.d.ts +0 -2
  27. package/src/migrations/update-15-0-0/switch-to-jasmine-marbles.js +0 -102
  28. package/src/migrations/update-15-2-0/remove-browserlist-config.d.ts +0 -4
  29. package/src/migrations/update-15-2-0/remove-browserlist-config.js +0 -59
  30. package/src/migrations/update-15-2-0/remove-platform-server-exports.d.ts +0 -2
  31. package/src/migrations/update-15-2-0/remove-platform-server-exports.js +0 -62
  32. package/src/migrations/update-15-2-0/update-angular-cli.d.ts +0 -2
  33. package/src/migrations/update-15-2-0/update-angular-cli.js +0 -22
  34. package/src/migrations/update-15-2-0/update-karma-main-file.d.ts +0 -2
  35. package/src/migrations/update-15-2-0/update-karma-main-file.js +0 -72
  36. package/src/migrations/update-15-2-0/update-typescript-target.d.ts +0 -2
  37. package/src/migrations/update-15-2-0/update-typescript-target.js +0 -52
  38. package/src/migrations/update-15-2-0/update-workspace-config.d.ts +0 -2
  39. package/src/migrations/update-15-2-0/update-workspace-config.js +0 -24
  40. package/src/migrations/update-15-5-0/update-angular-cli.d.ts +0 -2
  41. package/src/migrations/update-15-5-0/update-angular-cli.js +0 -22
  42. package/src/migrations/update-15-7-0/install-required-packages.d.ts +0 -2
  43. package/src/migrations/update-15-7-0/install-required-packages.js +0 -36
  44. package/src/migrations/update-15-8-0/update-angular-cli.d.ts +0 -2
  45. package/src/migrations/update-15-8-0/update-angular-cli.js +0 -22
  46. package/src/migrations/update-15-9-0/update-file-server-executor.d.ts +0 -2
  47. package/src/migrations/update-15-9-0/update-file-server-executor.js +0 -42
  48. package/src/migrations/update-15-9-0/update-testing-tsconfig.d.ts +0 -3
  49. package/src/migrations/update-15-9-0/update-testing-tsconfig.js +0 -32
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "20.0.2",
3
+ "version": "20.0.4",
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, Playwright 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- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -80,12 +80,12 @@
80
80
  "webpack-merge": "^5.8.0",
81
81
  "webpack": "^5.88.0",
82
82
  "@module-federation/enhanced": "0.6.6",
83
- "@nx/devkit": "20.0.2",
84
- "@nx/js": "20.0.2",
85
- "@nx/eslint": "20.0.2",
86
- "@nx/webpack": "20.0.2",
87
- "@nx/web": "20.0.2",
88
- "@nx/workspace": "20.0.2",
83
+ "@nx/devkit": "20.0.4",
84
+ "@nx/js": "20.0.4",
85
+ "@nx/eslint": "20.0.4",
86
+ "@nx/webpack": "20.0.4",
87
+ "@nx/web": "20.0.4",
88
+ "@nx/workspace": "20.0.4",
89
89
  "piscina": "^4.4.0"
90
90
  },
91
91
  "peerDependencies": {
@@ -67,8 +67,8 @@ async function* moduleFederationDevServerExecutor(schema, context) {
67
67
  options.staticRemotesPort ??= remotes.staticRemotePort;
68
68
  // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
69
69
  process.env.NX_MF_DEV_REMOTES = JSON.stringify([
70
- ...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []),
71
- project.name,
70
+ ...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
71
+ project.name.replace(/-/g, '_'),
72
72
  ]);
73
73
  const staticRemotesConfig = (0, parse_static_remotes_config_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
74
74
  const mappedLocationsOfStaticRemotes = await (0, lib_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
@@ -62,8 +62,8 @@ async function* moduleFederationSsrDevServerExecutor(schema, context) {
62
62
  const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options);
63
63
  // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
64
64
  process.env.NX_MF_DEV_REMOTES = JSON.stringify([
65
- ...(options.devRemotes ?? []),
66
- project.name,
65
+ ...(options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => r.replace(/-/g, '_')),
66
+ project.name.replace(/-/g, '_'),
67
67
  ]);
68
68
  const devRemotes = await (0, start_dev_remotes_1.startRemotes)(remotes.devRemotes, workspaceProjects, options, context);
69
69
  const staticRemotes = (0, start_static_remotes_1.startStaticRemotes)(staticRemotesConfig, context, options);
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
- const executors = [
7
- '@angular-devkit/build-angular:browser',
8
- '@angular-devkit/build-angular:server',
9
- '@nrwl/angular:webpack-browser',
10
- ];
11
- async function default_1(tree) {
12
- executors.forEach((executor) => {
13
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (_options, projectName, targetName, configurationName) => {
14
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
15
- const config = configurationName
16
- ? projectConfiguration.targets[targetName].configurations[configurationName]
17
- : projectConfiguration.targets[targetName].options;
18
- delete config.showCircularDependencies;
19
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
20
- });
21
- });
22
- await (0, devkit_1.formatFiles)(tree);
23
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const angularCliVersion = '~14.0.0';
6
- async function default_1(tree) {
7
- let shouldFormat = false;
8
- (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
9
- if (json.devDependencies?.['@angular/cli']) {
10
- json.devDependencies['@angular/cli'] = angularCliVersion;
11
- shouldFormat = true;
12
- }
13
- else if (json.dependencies?.['@angular/cli']) {
14
- json.dependencies['@angular/cli'] = angularCliVersion;
15
- shouldFormat = true;
16
- }
17
- return json;
18
- });
19
- if (shouldFormat) {
20
- await (0, devkit_1.formatFiles)(tree);
21
- }
22
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const libraryExecutors = [
7
- '@angular-devkit/build-angular:ng-packagr',
8
- '@nrwl/angular:ng-packagr-lite',
9
- '@nrwl/angular:package',
10
- ];
11
- async function default_1(tree) {
12
- const projects = (0, devkit_1.getProjects)(tree);
13
- for (const [, project] of projects) {
14
- if (!Object.values(project.targets ?? {}).some((target) => libraryExecutors.includes(target.executor))) {
15
- continue;
16
- }
17
- (0, devkit_1.visitNotIgnoredFiles)(tree, project.root, (filePath) => {
18
- if ((0, path_1.basename)(filePath) !== 'package.json' ||
19
- (0, devkit_1.normalizePath)(filePath) ===
20
- (0, devkit_1.joinPathFragments)(project.root, 'package.json')) {
21
- return;
22
- }
23
- const json = (0, devkit_1.readJson)(tree, filePath);
24
- if (json.ngPackage) {
25
- // Migrate ng-packagr config to an ng-packagr config file.
26
- const configFilePath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(filePath), 'ng-package.json');
27
- (0, devkit_1.writeJson)(tree, configFilePath, json.ngPackage);
28
- }
29
- // Delete package.json as it is no longer needed in APF 14.
30
- tree.delete(filePath);
31
- });
32
- }
33
- await (0, devkit_1.formatFiles)(tree);
34
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- async function default_1(tree) {
6
- let shouldFormat = false;
7
- (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
8
- if (json.scripts?.postinstall?.includes('ngcc ')) {
9
- json.scripts.postinstall = json.scripts.postinstall.replace(/(.*)(ngcc --properties es2015 )(.*)/, '$1ngcc --properties es2020 $3');
10
- shouldFormat = true;
11
- }
12
- return json;
13
- });
14
- if (shouldFormat) {
15
- await (0, devkit_1.formatFiles)(tree);
16
- }
17
- }
@@ -1,2 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const tsquery_1 = require("@phenomnomnominal/tsquery");
6
- const typescript_1 = require("typescript");
7
- async function default_1(tree) {
8
- const printer = (0, typescript_1.createPrinter)();
9
- const projects = await getProjectsWithAngularRouter(tree);
10
- for (const project of projects) {
11
- (0, devkit_1.visitNotIgnoredFiles)(tree, project.root, (filePath) => {
12
- // we are only interested in .ts files
13
- if (!filePath.endsWith('.ts')) {
14
- return;
15
- }
16
- const content = tree.read(filePath, 'utf-8');
17
- const ast = tsquery_1.tsquery.ast(content);
18
- const routerModuleForRootCall = getRouterModuleForRootCall(ast);
19
- if (!routerModuleForRootCall) {
20
- return;
21
- }
22
- const initialNavigationAssignment = getInitialNavigationAssignment(routerModuleForRootCall.arguments[1]);
23
- if (!initialNavigationAssignment) {
24
- return;
25
- }
26
- const updatedInitialNavigationAssignment = printer.printNode(typescript_1.EmitHint.Unspecified, typescript_1.factory.updatePropertyAssignment(initialNavigationAssignment, initialNavigationAssignment.name, typescript_1.factory.createIdentifier(`'enabledBlocking'`)), initialNavigationAssignment.getSourceFile());
27
- const updatedContent = `${content.slice(0, initialNavigationAssignment.getStart())}${updatedInitialNavigationAssignment}${content.slice(initialNavigationAssignment.getEnd())}`;
28
- tree.write(filePath, updatedContent);
29
- });
30
- }
31
- await (0, devkit_1.formatFiles)(tree);
32
- }
33
- function getInitialNavigationAssignment(extraOptionsLiteral) {
34
- for (const prop of extraOptionsLiteral.properties) {
35
- if ((0, typescript_1.isPropertyAssignment)(prop) &&
36
- ((0, typescript_1.isIdentifier)(prop.name) || (0, typescript_1.isStringLiteralLike)(prop.name)) &&
37
- prop.name.text === 'initialNavigation' &&
38
- needsMigration(prop)) {
39
- return prop;
40
- }
41
- }
42
- return null;
43
- }
44
- async function getProjectsWithAngularRouter(tree) {
45
- const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
46
- return Object.entries(projectGraph.dependencies)
47
- .filter(([node, dep]) => dep.some(({ target }) => target === 'npm:@angular/router' &&
48
- !projectGraph.externalNodes?.[node]))
49
- .map(([projectName]) => (0, devkit_1.readProjectConfiguration)(tree, projectName));
50
- }
51
- function getRouterModuleForRootCall(sourceFile) {
52
- // narrow down call expressions
53
- const routerModuleForRootCalls = (0, tsquery_1.tsquery)(sourceFile, 'CallExpression:has(PropertyAccessExpression:has(Identifier[name=RouterModule]):has(Identifier[name=forRoot]))', { visitAllChildren: true });
54
- for (const node of routerModuleForRootCalls) {
55
- if (isRouterModuleForRoot(node) &&
56
- node.arguments.length >= 2 &&
57
- (0, typescript_1.isObjectLiteralExpression)(node.arguments[1])) {
58
- return node;
59
- }
60
- }
61
- return null;
62
- }
63
- function isRouterModuleForRoot(node) {
64
- // make sure is not an outer call expression (NgModule call)
65
- return ((0, typescript_1.isPropertyAccessExpression)(node.expression) &&
66
- (0, typescript_1.isIdentifier)(node.expression.expression) &&
67
- node.expression.expression.text === 'RouterModule' &&
68
- (0, typescript_1.isIdentifier)(node.expression.name) &&
69
- node.expression.name.text === 'forRoot');
70
- }
71
- function needsMigration(node) {
72
- return ((0, typescript_1.isStringLiteralLike)(node.initializer) && node.initializer.text === 'enabled');
73
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,155 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const devkit_2 = require("@nx/devkit");
6
- const tsquery_1 = require("@phenomnomnominal/tsquery");
7
- const path_1 = require("path");
8
- const jestExecutor = '@nrwl/jest:jest';
9
- const executors = [
10
- '@angular-devkit/build-angular:browser',
11
- '@angular-devkit/build-angular:karma',
12
- '@angular-devkit/build-angular:ng-packagr',
13
- '@nrwl/angular:webpack-browser',
14
- '@nrwl/angular:delegate-build',
15
- '@nrwl/angular:ng-packagr-lite',
16
- '@nrwl/angular:package',
17
- ];
18
- const skipTargets = ['es2020', 'es2021', 'es2022', 'esnext'];
19
- async function default_1(tree) {
20
- const tsConfigPaths = await collectTsConfigPaths(tree);
21
- for (const tsConfigPath of tsConfigPaths) {
22
- (0, devkit_2.updateJson)(tree, tsConfigPath, (json) => {
23
- if (!json.compilerOptions?.target ||
24
- (json.compilerOptions?.target &&
25
- !skipTargets.includes(json.compilerOptions.target.toLowerCase()))) {
26
- json.compilerOptions ??= {};
27
- json.compilerOptions.target = 'es2020';
28
- }
29
- return json;
30
- }, {
31
- allowTrailingComma: true,
32
- disallowComments: false,
33
- });
34
- }
35
- await (0, devkit_2.formatFiles)(tree);
36
- }
37
- async function collectTsConfigPaths(tree) {
38
- const uniqueTsConfigs = new Set([]);
39
- const projectGraph = await (0, devkit_2.createProjectGraphAsync)();
40
- const angularProjects = Object.entries(projectGraph.dependencies)
41
- .filter(([node, dep]) => dep.some(({ target }) => target === 'npm:@angular/core' && !projectGraph.externalNodes?.[node]))
42
- .map(([projectName]) => ({
43
- projectName,
44
- project: (0, devkit_2.readProjectConfiguration)(tree, projectName),
45
- }));
46
- for (const { projectName, project } of angularProjects) {
47
- const tsConfigPath = (0, devkit_2.joinPathFragments)(project.root, 'tsconfig.json');
48
- if (tree.exists(tsConfigPath)) {
49
- uniqueTsConfigs.add(tsConfigPath);
50
- const targetTsConfigPaths = getProjectTsConfigPaths(tree, project, projectName, false);
51
- targetTsConfigPaths.forEach((tsConfigPath) => {
52
- const tsConfig = (0, devkit_1.readJson)(tree, tsConfigPath, {
53
- allowTrailingComma: true,
54
- disallowComments: false,
55
- });
56
- if (tsConfig.compilerOptions?.target) {
57
- uniqueTsConfigs.add(tsConfigPath);
58
- }
59
- });
60
- continue;
61
- }
62
- const tsConfigPaths = getProjectTsConfigPaths(tree, project, projectName);
63
- for (const tsConfigPath of tsConfigPaths) {
64
- uniqueTsConfigs.add(tsConfigPath);
65
- }
66
- }
67
- return Array.from(uniqueTsConfigs);
68
- }
69
- function getProjectTsConfigPaths(tree, project, projectName, shouldWarn = true) {
70
- const tsConfigPaths = new Set();
71
- for (const [targetName, target] of Object.entries(project.targets || {})) {
72
- if (executors.includes(target.executor)) {
73
- const tsConfigPathsFromTarget = getPathValuesFromTarget(target, 'tsConfig');
74
- tsConfigPathsFromTarget.forEach((tsConfigPath) => {
75
- if (tree.exists(tsConfigPath)) {
76
- tsConfigPaths.add(tsConfigPath);
77
- }
78
- else if (shouldWarn) {
79
- devkit_2.logger.warn(`The "${tsConfigPath}" file specified in the "${targetName}" target of the "${projectName}" project could not be found. ` +
80
- 'Skipping setting the target to ES2020.');
81
- }
82
- });
83
- }
84
- else if (target.executor === jestExecutor) {
85
- const tsConfigPathsFromJestTarget = getTsConfigPathsFromJestTarget(tree, target, targetName, projectName, shouldWarn);
86
- tsConfigPathsFromJestTarget.forEach((tsConfigPath) => {
87
- tsConfigPaths.add(tsConfigPath);
88
- });
89
- }
90
- else if (shouldWarn) {
91
- devkit_2.logger.warn(`The "${targetName}" target of the "${projectName}" project is using an executor not supported by the migration. ` +
92
- 'Skipping setting the TS target to ES2020 for the project.');
93
- }
94
- }
95
- return Array.from(tsConfigPaths);
96
- }
97
- function getTsConfigPathsFromJestTarget(tree, target, targetName, projectName, shouldWarn) {
98
- const tsConfigPaths = [];
99
- const jestConfigPaths = getPathValuesFromTarget(target, 'jestConfig');
100
- if (!jestConfigPaths.length && shouldWarn) {
101
- devkit_2.logger.warn(`The "${targetName}" target of the "${projectName}" project is using the "${jestExecutor}" executor but no "jestConfig" property was specified. ` +
102
- 'Skipping setting the TS compilation target to ES2020 for the project.');
103
- }
104
- for (const jestConfigPath of jestConfigPaths) {
105
- const tsConfigPath = getTsConfigFromJestConfig(tree, jestConfigPath, targetName, projectName, shouldWarn);
106
- if (tsConfigPath) {
107
- tsConfigPaths.push(tsConfigPath);
108
- }
109
- }
110
- return tsConfigPaths;
111
- }
112
- function getTsConfigFromJestConfig(tree, jestConfigPath, targetName, projectName, shouldWarn) {
113
- if (!tree.exists(jestConfigPath)) {
114
- if (shouldWarn) {
115
- devkit_2.logger.warn(`The "${jestConfigPath}" file specified in the "${targetName}" target of the "${projectName}" project could not be found. ` +
116
- `The TS config file used by the target can't be determined. Skipping setting the target to ES2020.`);
117
- }
118
- return undefined;
119
- }
120
- const jestConfig = tree.read(jestConfigPath, 'utf-8');
121
- const jestConfigAst = tsquery_1.tsquery.ast(jestConfig);
122
- const tsJestTsConfigStringLiteral = (0, tsquery_1.tsquery)(jestConfigAst, 'PropertyAssignment:has(Identifier[name=globals]) PropertyAssignment:has(StringLiteral[value=ts-jest]) PropertyAssignment:has(Identifier[name=tsconfig]) > StringLiteral', { visitAllChildren: true })[0];
123
- if (!tsJestTsConfigStringLiteral) {
124
- if (shouldWarn) {
125
- devkit_2.logger.warn(`Couldn't find the "tsconfig" property for "ts-jest" in the Jest configuration file "${jestConfigPath}" specified in the ` +
126
- `"${targetName}" target of the "${projectName}" project. The TS config file used by the target can't be determined. ` +
127
- 'Skipping setting the target to ES2020.');
128
- }
129
- return undefined;
130
- }
131
- const tsJestTsConfigValue = tsJestTsConfigStringLiteral
132
- .getText()
133
- .replace(/['"]/g, '');
134
- const tsConfigPath = tsJestTsConfigValue.replace('<rootDir>', (0, path_1.dirname)(jestConfigPath));
135
- if (!tree.exists(tsConfigPath)) {
136
- if (shouldWarn) {
137
- devkit_2.logger.warn(`The "${tsJestTsConfigValue}" file specified in the Jest configuration file "${jestConfigPath}" of the "${targetName}" target ` +
138
- `of the "${projectName}" project could not be found. Skipping setting the target to ES2020.`);
139
- }
140
- return undefined;
141
- }
142
- return tsConfigPath;
143
- }
144
- function getPathValuesFromTarget(target, option) {
145
- const values = [];
146
- if (target.options?.[option]) {
147
- values.push(target.options[option]);
148
- }
149
- Object.values(target.configurations ?? {}).forEach((options) => {
150
- if (options[option]) {
151
- values.push(options[option]);
152
- }
153
- });
154
- return values;
155
- }
@@ -1,5 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export declare function replaceNrwlAngularMfImport(fileContents: string): string;
3
- export declare function replaceExportedMFETypes(fileContents: string): string;
4
- export declare function renameSetupMfeGeneratorUsages(fileContents: string): string;
5
- export default function (tree: Tree): Promise<void>;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceNrwlAngularMfImport = replaceNrwlAngularMfImport;
4
- exports.replaceExportedMFETypes = replaceExportedMFETypes;
5
- exports.renameSetupMfeGeneratorUsages = renameSetupMfeGeneratorUsages;
6
- exports.default = default_1;
7
- const devkit_1 = require("@nx/devkit");
8
- const path_1 = require("path");
9
- const tsquery_1 = require("@phenomnomnominal/tsquery");
10
- const NRWL_ANGULAR_MFE_STATIC_IMPORT_SELECTOR = 'ImportDeclaration > StringLiteral[value="@nrwl/angular/mfe"]';
11
- const NRWL_ANGULAR_MFE_DYNAMIC_IMPORT_SELECTOR = 'CallExpression:has(ImportKeyword) > StringLiteral[value="@nrwl/angular/mfe"]';
12
- const NRWL_ANGULAR_MFE_TYPES_SELECTOR = 'ImportDeclaration:has(StringLiteral[value=@nrwl/angular/module-federation]) > ImportClause > NamedImports';
13
- function replaceNrwlAngularMfImport(fileContents) {
14
- let fileAst = tsquery_1.tsquery.ast(fileContents);
15
- if (fileContents.includes('@nrwl/angular/mfe')) {
16
- // This file definitely contains the string, however, we're interested in whether it is an import
17
- const staticQueryResult = (0, tsquery_1.tsquery)(fileAst, NRWL_ANGULAR_MFE_STATIC_IMPORT_SELECTOR, {
18
- visitAllChildren: true,
19
- });
20
- if (staticQueryResult && staticQueryResult.length > 0) {
21
- fileContents = `${fileContents.slice(0, staticQueryResult[0].getStart())}'@nrwl/angular/mf'${fileContents.slice(staticQueryResult[0].getEnd())}`;
22
- }
23
- fileAst = tsquery_1.tsquery.ast(fileContents);
24
- const dynamicQueryResult = (0, tsquery_1.tsquery)(fileAst, NRWL_ANGULAR_MFE_DYNAMIC_IMPORT_SELECTOR, {
25
- visitAllChildren: true,
26
- });
27
- if (dynamicQueryResult && dynamicQueryResult.length > 0) {
28
- fileContents = `${fileContents.slice(0, dynamicQueryResult[0].getStart())}'@nrwl/angular/mf'${fileContents.slice(dynamicQueryResult[0].getEnd())}`;
29
- }
30
- }
31
- return fileContents;
32
- }
33
- function replaceExportedMFETypes(fileContents) {
34
- const ast = tsquery_1.tsquery.ast(fileContents);
35
- const queryResult = (0, tsquery_1.tsquery)(ast, NRWL_ANGULAR_MFE_TYPES_SELECTOR, {
36
- visitAllChildren: true,
37
- });
38
- if (queryResult && queryResult.length > 0) {
39
- const TYPES_IMPORTED_FROM_NRWL_REGEX = /(MFERemotes|MFEConfig)+.*from+.+(@nrwl\/angular\/module-federation)+/g;
40
- if (TYPES_IMPORTED_FROM_NRWL_REGEX.test(fileContents)) {
41
- fileContents = fileContents.replace(/MFERemotes/g, 'MFRemotes');
42
- fileContents = fileContents.replace(/MFEConfig/g, 'MFConfig');
43
- }
44
- }
45
- return fileContents;
46
- }
47
- function renameSetupMfeGeneratorUsages(fileContents) {
48
- // Attempt to update any custom generator usage of the changed generators
49
- const NRWL_SETUP_MFE_IMPORT_SELECTOR = 'ImportDeclaration:has(StringLiteral[value=@nrwl/angular/generators]) > ImportClause:has(NamedImports:has(ImportSpecifier > Identifier[name=setupMfe]))';
50
- const SETUP_MFE_IMPORTED_FROM_NRWL_REGEX = /(setupMfe)+.*from+.+(@nrwl\/angular\/generators)+/g;
51
- const SETUP_MFE_FUNCTION_CALL_MFE_TYPE_PROPERTY_ASSIGNMENT_SELECTOR = 'CallExpression:has(Identifier[name=setupMf]) ObjectLiteralExpression > PropertyAssignment > Identifier[name=mfeType]';
52
- let ast = tsquery_1.tsquery.ast(fileContents);
53
- let queryResult = (0, tsquery_1.tsquery)(ast, NRWL_SETUP_MFE_IMPORT_SELECTOR, {
54
- visitAllChildren: true,
55
- });
56
- if (queryResult &&
57
- queryResult.length > 0 &&
58
- SETUP_MFE_IMPORTED_FROM_NRWL_REGEX.test(fileContents)) {
59
- fileContents = fileContents.replace(/setupMfe/g, 'setupMf');
60
- }
61
- ast = tsquery_1.tsquery.ast(fileContents);
62
- queryResult = (0, tsquery_1.tsquery)(ast, SETUP_MFE_FUNCTION_CALL_MFE_TYPE_PROPERTY_ASSIGNMENT_SELECTOR, {
63
- visitAllChildren: true,
64
- });
65
- while (queryResult && queryResult.length > 0) {
66
- const node = queryResult[0];
67
- fileContents = `${fileContents.slice(0, node.getStart())}mfType${fileContents.slice(node.getEnd())}`;
68
- ast = tsquery_1.tsquery.ast(fileContents);
69
- queryResult = (0, tsquery_1.tsquery)(ast, SETUP_MFE_FUNCTION_CALL_MFE_TYPE_PROPERTY_ASSIGNMENT_SELECTOR, {
70
- visitAllChildren: true,
71
- });
72
- }
73
- return fileContents;
74
- }
75
- async function default_1(tree) {
76
- (0, devkit_1.visitNotIgnoredFiles)(tree, '/', (path) => {
77
- const pathExtName = (0, path_1.extname)(path);
78
- if (pathExtName !== '.ts' && pathExtName !== '.js') {
79
- return;
80
- }
81
- let fileContents = tree.read(path, 'utf-8');
82
- fileContents = replaceNrwlAngularMfImport(fileContents);
83
- if (pathExtName === '.ts') {
84
- // Only TS files can import types and interfaces
85
- fileContents = replaceExportedMFETypes(fileContents);
86
- fileContents = renameSetupMfeGeneratorUsages(fileContents);
87
- }
88
- tree.write(path, fileContents);
89
- });
90
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const angularCliVersion = '~14.1.0';
6
- async function default_1(tree) {
7
- let shouldFormat = false;
8
- (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
9
- if (json.devDependencies?.['@angular/cli']) {
10
- json.devDependencies['@angular/cli'] = angularCliVersion;
11
- shouldFormat = true;
12
- }
13
- else if (json.dependencies?.['@angular/cli']) {
14
- json.dependencies['@angular/cli'] = angularCliVersion;
15
- shouldFormat = true;
16
- }
17
- return json;
18
- });
19
- if (shouldFormat) {
20
- await (0, devkit_1.formatFiles)(tree);
21
- }
22
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const angularCliVersion = '~14.2.0';
6
- async function default_1(tree) {
7
- let shouldFormat = false;
8
- (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
9
- if (json.devDependencies?.['@angular/cli']) {
10
- json.devDependencies['@angular/cli'] = angularCliVersion;
11
- shouldFormat = true;
12
- }
13
- else if (json.dependencies?.['@angular/cli']) {
14
- json.dependencies['@angular/cli'] = angularCliVersion;
15
- shouldFormat = true;
16
- }
17
- return json;
18
- });
19
- if (shouldFormat) {
20
- await (0, devkit_1.formatFiles)(tree);
21
- }
22
- }
@@ -1,2 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export default function renameWebpackServer(tree: Tree): void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = renameWebpackServer;
4
- const devkit_1 = require("@nx/devkit");
5
- function renameWebpackServer(tree) {
6
- const projects = (0, devkit_1.getProjects)(tree);
7
- const oldExecutorName = '@nrwl/angular:webpack-server';
8
- const newExecutorName = '@nrwl/angular:webpack-dev-server';
9
- for (const [projectName, project] of projects.entries()) {
10
- let stringifiedProject = JSON.stringify(project);
11
- if (!stringifiedProject.includes(oldExecutorName)) {
12
- continue;
13
- }
14
- for (const [targetName, target] of Object.entries(project.targets)) {
15
- if (target.executor === oldExecutorName) {
16
- target.executor = newExecutorName;
17
- }
18
- }
19
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
20
- }
21
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
- async function default_1(tree) {
7
- const nxJson = (0, devkit_1.readNxJson)(tree);
8
- const karmaTargets = getKarmaTargetNames(tree);
9
- const hasProductionFileset = !!nxJson.namedInputs?.production;
10
- if (karmaTargets.size > 0 && hasProductionFileset) {
11
- const productionFileset = new Set(nxJson.namedInputs.production);
12
- for (const exclusion of [
13
- '!{projectRoot}/**/*.spec.[jt]s',
14
- '!{projectRoot}/tsconfig.spec.json',
15
- '!{projectRoot}/karma.conf.js',
16
- ]) {
17
- productionFileset.add(exclusion);
18
- }
19
- nxJson.namedInputs.production = Array.from(productionFileset);
20
- }
21
- for (const targetName of karmaTargets) {
22
- nxJson.targetDefaults ??= {};
23
- const jestTargetDefaults = (nxJson.targetDefaults[targetName] ??= {});
24
- jestTargetDefaults.inputs ??= [
25
- 'default',
26
- hasProductionFileset ? '^production' : '^default',
27
- ...(tree.exists('karma.conf.js')
28
- ? ['{workspaceRoot}/karma.conf.js']
29
- : []),
30
- ];
31
- }
32
- (0, devkit_1.updateNxJson)(tree, nxJson);
33
- await (0, devkit_1.formatFiles)(tree);
34
- }
35
- function getKarmaTargetNames(tree) {
36
- const karmaTargetNames = new Set();
37
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@angular-devkit/build-angular:karma', (_, __, target) => {
38
- karmaTargetNames.add(target);
39
- });
40
- return karmaTargetNames;
41
- }
@@ -1,2 +0,0 @@
1
- import type { Tree } from '@nx/devkit';
2
- export default function switchToJasmineMarbles(tree: Tree): Promise<void>;