@nx/angular 20.0.3 → 20.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +7 -7
- package/src/migrations/update-14-2-0/remove-show-circular-dependencies-option.d.ts +0 -2
- package/src/migrations/update-14-2-0/remove-show-circular-dependencies-option.js +0 -23
- package/src/migrations/update-14-2-0/update-angular-cli.d.ts +0 -2
- package/src/migrations/update-14-2-0/update-angular-cli.js +0 -22
- package/src/migrations/update-14-2-0/update-libraries-secondary-entrypoints.d.ts +0 -2
- package/src/migrations/update-14-2-0/update-libraries-secondary-entrypoints.js +0 -34
- package/src/migrations/update-14-2-0/update-ngcc-target.d.ts +0 -2
- package/src/migrations/update-14-2-0/update-ngcc-target.js +0 -17
- package/src/migrations/update-14-2-0/update-router-initial-navigation.d.ts +0 -2
- package/src/migrations/update-14-2-0/update-router-initial-navigation.js +0 -73
- package/src/migrations/update-14-2-0/update-tsconfig-target.d.ts +0 -2
- package/src/migrations/update-14-2-0/update-tsconfig-target.js +0 -155
- package/src/migrations/update-14-5-0/migrate-mfe-to-mf.d.ts +0 -5
- package/src/migrations/update-14-5-0/migrate-mfe-to-mf.js +0 -90
- package/src/migrations/update-14-5-2/update-angular-cli.d.ts +0 -2
- package/src/migrations/update-14-5-2/update-angular-cli.js +0 -22
- package/src/migrations/update-14-6-0/update-angular-cli.d.ts +0 -2
- package/src/migrations/update-14-6-0/update-angular-cli.js +0 -22
- package/src/migrations/update-14-8-0/rename-webpack-server.d.ts +0 -2
- package/src/migrations/update-14-8-0/rename-webpack-server.js +0 -21
- package/src/migrations/update-15-0-0/add-karma-inputs.d.ts +0 -2
- package/src/migrations/update-15-0-0/add-karma-inputs.js +0 -41
- package/src/migrations/update-15-0-0/switch-to-jasmine-marbles.d.ts +0 -2
- package/src/migrations/update-15-0-0/switch-to-jasmine-marbles.js +0 -102
- package/src/migrations/update-15-2-0/remove-browserlist-config.d.ts +0 -4
- package/src/migrations/update-15-2-0/remove-browserlist-config.js +0 -59
- package/src/migrations/update-15-2-0/remove-platform-server-exports.d.ts +0 -2
- package/src/migrations/update-15-2-0/remove-platform-server-exports.js +0 -62
- package/src/migrations/update-15-2-0/update-angular-cli.d.ts +0 -2
- package/src/migrations/update-15-2-0/update-angular-cli.js +0 -22
- package/src/migrations/update-15-2-0/update-karma-main-file.d.ts +0 -2
- package/src/migrations/update-15-2-0/update-karma-main-file.js +0 -72
- package/src/migrations/update-15-2-0/update-typescript-target.d.ts +0 -2
- package/src/migrations/update-15-2-0/update-typescript-target.js +0 -52
- package/src/migrations/update-15-2-0/update-workspace-config.d.ts +0 -2
- package/src/migrations/update-15-2-0/update-workspace-config.js +0 -24
- package/src/migrations/update-15-5-0/update-angular-cli.d.ts +0 -2
- package/src/migrations/update-15-5-0/update-angular-cli.js +0 -22
- package/src/migrations/update-15-7-0/install-required-packages.d.ts +0 -2
- package/src/migrations/update-15-7-0/install-required-packages.js +0 -36
- package/src/migrations/update-15-8-0/update-angular-cli.d.ts +0 -2
- package/src/migrations/update-15-8-0/update-angular-cli.js +0 -22
- package/src/migrations/update-15-9-0/update-file-server-executor.d.ts +0 -2
- package/src/migrations/update-15-9-0/update-file-server-executor.js +0 -42
- package/src/migrations/update-15-9-0/update-testing-tsconfig.d.ts +0 -3
- 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.
|
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.
|
84
|
-
"@nx/js": "20.0.
|
85
|
-
"@nx/eslint": "20.0.
|
86
|
-
"@nx/webpack": "20.0.
|
87
|
-
"@nx/web": "20.0.
|
88
|
-
"@nx/workspace": "20.0.
|
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": {
|
@@ -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,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,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,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,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,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,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,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,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,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,102 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = switchToJasmineMarbles;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const path_1 = require("path");
|
6
|
-
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
7
|
-
const versions_1 = require("../../utils/versions");
|
8
|
-
const semver_1 = require("@nx/devkit/src/utils/semver");
|
9
|
-
const semver_2 = require("semver");
|
10
|
-
async function switchToJasmineMarbles(tree) {
|
11
|
-
const usesJasmineMarbles = await replaceJasmineMarbleUsagesInFiles(tree);
|
12
|
-
addJasmineMarblesDevDependencyIfUsed(tree, usesJasmineMarbles);
|
13
|
-
}
|
14
|
-
async function replaceJasmineMarbleUsagesInFiles(tree) {
|
15
|
-
let usesJasmineMarbles = false;
|
16
|
-
const projectGraph = await (() => {
|
17
|
-
try {
|
18
|
-
return (0, devkit_1.readCachedProjectGraph)();
|
19
|
-
}
|
20
|
-
catch {
|
21
|
-
return (0, devkit_1.createProjectGraphAsync)();
|
22
|
-
}
|
23
|
-
})();
|
24
|
-
const dirsToTraverse = Object.entries(projectGraph.dependencies)
|
25
|
-
.filter(([node, dep]) => dep.some(({ target }) => target === 'npm:@nrwl/angular' && !projectGraph.externalNodes?.[node]))
|
26
|
-
.map(([projectName]) => (0, devkit_1.readProjectConfiguration)(tree, projectName).root);
|
27
|
-
for (const dir of dirsToTraverse) {
|
28
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, dir, (path) => {
|
29
|
-
if ((0, path_1.extname)(path) !== '.ts') {
|
30
|
-
return;
|
31
|
-
}
|
32
|
-
const fileContents = tree.read(path, 'utf-8');
|
33
|
-
if (!fileContents.includes('@nrwl/angular/testing')) {
|
34
|
-
return;
|
35
|
-
}
|
36
|
-
const NRWL_ANGULAR_TESTING_IMPORT_SELECTOR = 'ImportDeclaration:has(StringLiteral[value="@nrwl/angular/testing"])';
|
37
|
-
const ast = tsquery_1.tsquery.ast(fileContents);
|
38
|
-
const nrwlAngularTestingImportNodes = (0, tsquery_1.tsquery)(ast, NRWL_ANGULAR_TESTING_IMPORT_SELECTOR, { visitAllChildren: true });
|
39
|
-
if (!nrwlAngularTestingImportNodes ||
|
40
|
-
nrwlAngularTestingImportNodes.length === 0) {
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
const jasmineMarblesExportsRegex = new RegExp(/(hot|cold|getTestScheduler|time)/);
|
44
|
-
if (!jasmineMarblesExportsRegex.test(nrwlAngularTestingImportNodes[0].getText())) {
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
const IMPORT_SPECIFIERS_SELECTOR = 'NamedImports > ImportSpecifier';
|
48
|
-
const importSpecifierNodes = (0, tsquery_1.tsquery)(nrwlAngularTestingImportNodes[0], IMPORT_SPECIFIERS_SELECTOR, { visitAllChildren: true });
|
49
|
-
if (!importSpecifierNodes || importSpecifierNodes.length === 0) {
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
const validNrwlTestingImports = [];
|
53
|
-
const validJasmineMarbleImports = [];
|
54
|
-
for (const node of importSpecifierNodes) {
|
55
|
-
const importSymbol = node.getText();
|
56
|
-
if (jasmineMarblesExportsRegex.test(importSymbol)) {
|
57
|
-
validJasmineMarbleImports.push(importSymbol);
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
validNrwlTestingImports.push(importSymbol);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
if (!usesJasmineMarbles && validJasmineMarbleImports.length > 0) {
|
64
|
-
usesJasmineMarbles = true;
|
65
|
-
}
|
66
|
-
const newFileContents = `${fileContents.slice(0, nrwlAngularTestingImportNodes[0].getStart())}${validNrwlTestingImports.length > 0
|
67
|
-
? `import {${validNrwlTestingImports.join(',')}} from '@nrwl/angular/testing';`
|
68
|
-
: ''}
|
69
|
-
${validJasmineMarbleImports.length > 0
|
70
|
-
? `import {${validJasmineMarbleImports.join(',')}} from 'jasmine-marbles';${fileContents.slice(nrwlAngularTestingImportNodes[0].getEnd(), -1)}`
|
71
|
-
: ''}`;
|
72
|
-
tree.write(path, newFileContents);
|
73
|
-
});
|
74
|
-
}
|
75
|
-
return usesJasmineMarbles;
|
76
|
-
}
|
77
|
-
function addJasmineMarblesDevDependencyIfUsed(tree, usesJasmineMarbles) {
|
78
|
-
if (!usesJasmineMarbles) {
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
82
|
-
const jasmineMarblesDependency = pkgJson.dependencies['jasmine-marbles'];
|
83
|
-
const jasmineMarblesDevDependency = pkgJson.devDependencies['jasmine-marbles'];
|
84
|
-
if (jasmineMarblesDependency || jasmineMarblesDevDependency) {
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
const jasmineMarblesVersion = getJasmineMarblesVersion(tree);
|
88
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
89
|
-
'jasmine-marbles': jasmineMarblesVersion,
|
90
|
-
});
|
91
|
-
}
|
92
|
-
function getJasmineMarblesVersion(tree) {
|
93
|
-
let rxjsVersion;
|
94
|
-
try {
|
95
|
-
const { dependencies, devDependencies } = (0, devkit_1.readJson)(tree, 'package.json');
|
96
|
-
rxjsVersion = (0, semver_1.checkAndCleanWithSemver)('rxjs', dependencies?.rxjs ?? devDependencies?.rxjs);
|
97
|
-
}
|
98
|
-
catch {
|
99
|
-
rxjsVersion = (0, semver_1.checkAndCleanWithSemver)('rxjs', versions_1.rxjsVersion);
|
100
|
-
}
|
101
|
-
return (0, semver_2.gte)(rxjsVersion, '7.0.0') ? versions_1.jasmineMarblesVersion : '~0.8.3';
|
102
|
-
}
|
@@ -1,59 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DEFAULT_BROWSERS = void 0;
|
4
|
-
exports.default = removeBrowserlistConfig;
|
5
|
-
require("nx/src/internal-testing-utils/mock-project-graph");
|
6
|
-
const devkit_1 = require("@nx/devkit");
|
7
|
-
const path_1 = require("path");
|
8
|
-
const validBrowserslistConfigFilenames = new Set([
|
9
|
-
'browserslist',
|
10
|
-
'.browserslistrc',
|
11
|
-
]);
|
12
|
-
exports.DEFAULT_BROWSERS = [
|
13
|
-
'last 1 Chrome version',
|
14
|
-
'last 1 Firefox version',
|
15
|
-
'last 2 Edge major versions',
|
16
|
-
'last 2 Safari major versions',
|
17
|
-
'last 2 iOS major versions',
|
18
|
-
'Firefox ESR',
|
19
|
-
];
|
20
|
-
async function removeBrowserlistConfig(tree) {
|
21
|
-
let browserslist;
|
22
|
-
try {
|
23
|
-
browserslist = await import('browserslist');
|
24
|
-
}
|
25
|
-
catch {
|
26
|
-
devkit_1.logger.warn('Skipping migration because the "browserslist" package could not be loaded.');
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
// Set the defaults to match the defaults in build-angular.
|
30
|
-
browserslist.defaults = exports.DEFAULT_BROWSERS;
|
31
|
-
const defaultSupportedBrowsers = new Set(browserslist(exports.DEFAULT_BROWSERS));
|
32
|
-
const es5Browsers = new Set(browserslist(['supports es6-module']));
|
33
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, '/', (path) => {
|
34
|
-
const fileName = (0, path_1.basename)(path);
|
35
|
-
if (!validBrowserslistConfigFilenames.has(fileName) ||
|
36
|
-
path.startsWith('node_modules')) {
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
const { defaults: browsersListConfig, ...otherConfigs } = browserslist.parseConfig(tree.read(path, 'utf-8'));
|
40
|
-
if (Object.keys(otherConfigs).length) {
|
41
|
-
// The config contains additional sections.
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
const browserslistInProject = browserslist(
|
45
|
-
// Exclude from the list ES5 browsers which are not supported.
|
46
|
-
browsersListConfig.map((s) => `${s} and supports es6-module`), {
|
47
|
-
ignoreUnknownVersions: true,
|
48
|
-
});
|
49
|
-
if (defaultSupportedBrowsers.size !== browserslistInProject.length) {
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
const shouldDelete = browserslistInProject.every((browser) => defaultSupportedBrowsers.has(browser));
|
53
|
-
if (shouldDelete) {
|
54
|
-
// All browsers are the same as the default config.
|
55
|
-
// Delete file as it's redundant.
|
56
|
-
tree.delete(path);
|
57
|
-
}
|
58
|
-
});
|
59
|
-
}
|
@@ -1,62 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = default_1;
|
4
|
-
const tslib_1 = require("tslib");
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
6
|
-
const ts = tslib_1.__importStar(require("typescript"));
|
7
|
-
const file_change_recorder_1 = require("../../utils/file-change-recorder");
|
8
|
-
async function default_1(tree) {
|
9
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, '/', (path) => {
|
10
|
-
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
|
11
|
-
const content = tree.read(path, 'utf8');
|
12
|
-
if (content.includes('@angular/platform-server') &&
|
13
|
-
content.includes('renderModule')) {
|
14
|
-
const source = ts.createSourceFile(path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
|
15
|
-
let recorder;
|
16
|
-
let printer;
|
17
|
-
ts.forEachChild(source, function analyze(node) {
|
18
|
-
if (!(ts.isExportDeclaration(node) &&
|
19
|
-
node.moduleSpecifier &&
|
20
|
-
ts.isStringLiteral(node.moduleSpecifier) &&
|
21
|
-
node.moduleSpecifier.text === '@angular/platform-server' &&
|
22
|
-
node.exportClause &&
|
23
|
-
ts.isNamedExports(node.exportClause))) {
|
24
|
-
// Not a @angular/platform-server named export.
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
const exportClause = node.exportClause;
|
28
|
-
const newElements = [];
|
29
|
-
for (const element of exportClause.elements) {
|
30
|
-
if (element.name.text !== 'renderModule') {
|
31
|
-
newElements.push(element);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
if (newElements.length === exportClause.elements.length) {
|
35
|
-
// No changes
|
36
|
-
return;
|
37
|
-
}
|
38
|
-
recorder ??= new file_change_recorder_1.FileChangeRecorder(tree, path);
|
39
|
-
if (newElements.length) {
|
40
|
-
// Update named exports as there are leftovers.
|
41
|
-
const newExportClause = ts.factory.updateNamedExports(exportClause, newElements);
|
42
|
-
printer ??= ts.createPrinter();
|
43
|
-
const fix = printer.printNode(ts.EmitHint.Unspecified, newExportClause, source);
|
44
|
-
const index = exportClause.getStart();
|
45
|
-
const length = exportClause.getWidth();
|
46
|
-
recorder.remove(index, index + length);
|
47
|
-
recorder.insertLeft(index, fix);
|
48
|
-
}
|
49
|
-
else {
|
50
|
-
// Delete export as no exports remain.
|
51
|
-
recorder.remove(node.getStart(), node.getStart() + node.getWidth());
|
52
|
-
}
|
53
|
-
ts.forEachChild(node, analyze);
|
54
|
-
});
|
55
|
-
if (recorder) {
|
56
|
-
recorder.applyChanges();
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
60
|
-
});
|
61
|
-
await (0, devkit_1.formatFiles)(tree);
|
62
|
-
}
|
@@ -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 = '~15.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,72 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = default_1;
|
4
|
-
const tslib_1 = require("tslib");
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
6
|
-
const ts = tslib_1.__importStar(require("typescript"));
|
7
|
-
const workspace_models_1 = require("@schematics/angular/utility/workspace-models");
|
8
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
9
|
-
const file_change_recorder_1 = require("../../utils/file-change-recorder");
|
10
|
-
async function default_1(tree) {
|
11
|
-
for (const file of findTestMainFiles(tree)) {
|
12
|
-
updateTestFile(tree, file);
|
13
|
-
}
|
14
|
-
await (0, devkit_1.formatFiles)(tree);
|
15
|
-
}
|
16
|
-
function findTestMainFiles(tree) {
|
17
|
-
const testFiles = new Set();
|
18
|
-
// find all test.ts files.
|
19
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, workspace_models_1.Builders.Karma, (options) => {
|
20
|
-
if (typeof options.main === 'string' && tree.exists(options.main)) {
|
21
|
-
testFiles.add(options.main);
|
22
|
-
}
|
23
|
-
});
|
24
|
-
return testFiles;
|
25
|
-
}
|
26
|
-
function updateTestFile(tree, file) {
|
27
|
-
const content = tree.read(file, 'utf8');
|
28
|
-
if (!content.includes('require.context')) {
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
const sourceFile = ts.createSourceFile(file, content.replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
|
32
|
-
const usedVariableNames = new Set();
|
33
|
-
const recorder = new file_change_recorder_1.FileChangeRecorder(tree, sourceFile.fileName);
|
34
|
-
ts.forEachChild(sourceFile, (node) => {
|
35
|
-
if (ts.isVariableStatement(node)) {
|
36
|
-
const variableDeclaration = node.declarationList.declarations[0];
|
37
|
-
if (ts
|
38
|
-
.getModifiers(node)
|
39
|
-
?.some((m) => m.kind === ts.SyntaxKind.DeclareKeyword)) {
|
40
|
-
// `declare const require`
|
41
|
-
if (variableDeclaration.name.getText() !== 'require') {
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
else {
|
46
|
-
// `const context = require.context('./', true, /\.spec\.ts$/);`
|
47
|
-
if (!variableDeclaration.initializer
|
48
|
-
?.getText()
|
49
|
-
.startsWith('require.context')) {
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
// add variable name as used.
|
53
|
-
usedVariableNames.add(variableDeclaration.name.getText());
|
54
|
-
}
|
55
|
-
// Delete node.
|
56
|
-
recorder.remove(node.getFullStart(), node.getFullStart() + node.getFullWidth());
|
57
|
-
}
|
58
|
-
if (usedVariableNames.size &&
|
59
|
-
ts.isExpressionStatement(node) && // context.keys().map(context);
|
60
|
-
ts.isCallExpression(node.expression) && // context.keys().map(context);
|
61
|
-
ts.isPropertyAccessExpression(node.expression.expression) && // context.keys().map
|
62
|
-
ts.isCallExpression(node.expression.expression.expression) && // context.keys()
|
63
|
-
ts.isPropertyAccessExpression(node.expression.expression.expression.expression) && // context.keys
|
64
|
-
ts.isIdentifier(node.expression.expression.expression.expression.expression) && // context
|
65
|
-
usedVariableNames.has(node.expression.expression.expression.expression.expression.getText())) {
|
66
|
-
// `context.keys().map(context);`
|
67
|
-
// `context.keys().forEach(context);`
|
68
|
-
recorder.remove(node.getFullStart(), node.getFullStart() + node.getFullWidth());
|
69
|
-
}
|
70
|
-
});
|
71
|
-
recorder.applyChanges();
|
72
|
-
}
|
@@ -1,52 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = updateTypescriptTarget;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const workspace_models_1 = require("@schematics/angular/utility/workspace-models");
|
6
|
-
function updateTarget(tree, tsconfigPath) {
|
7
|
-
(0, devkit_1.updateJson)(tree, tsconfigPath, (json) => ({
|
8
|
-
...json,
|
9
|
-
compilerOptions: {
|
10
|
-
...(json.compilerOptions ?? {}),
|
11
|
-
target: 'ES2022',
|
12
|
-
useDefineForClassFields: false,
|
13
|
-
},
|
14
|
-
}));
|
15
|
-
}
|
16
|
-
async function updateTypescriptTarget(tree) {
|
17
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
18
|
-
for (const [, project] of projects) {
|
19
|
-
if (!project.targets)
|
20
|
-
continue;
|
21
|
-
for (const [, target] of Object.entries(project.targets)) {
|
22
|
-
// Update all other known CLI builders that use a tsconfig
|
23
|
-
const tsConfigs = [
|
24
|
-
target.options || {},
|
25
|
-
...Object.values(target.configurations || {}),
|
26
|
-
]
|
27
|
-
.filter((opt) => typeof opt?.tsConfig === 'string')
|
28
|
-
.map((opt) => opt.tsConfig);
|
29
|
-
const uniqueTsConfigs = [...new Set(tsConfigs)];
|
30
|
-
if (uniqueTsConfigs.length < 1) {
|
31
|
-
continue;
|
32
|
-
}
|
33
|
-
const supportedExecutors = new Set([
|
34
|
-
workspace_models_1.Builders.Server,
|
35
|
-
workspace_models_1.Builders.Karma,
|
36
|
-
workspace_models_1.Builders.Browser,
|
37
|
-
workspace_models_1.Builders.NgPackagr,
|
38
|
-
'@nrwl/angular:webpack-browser',
|
39
|
-
'@nrwl/angular:ng-packagr-lite',
|
40
|
-
'@nrwl/angular:package',
|
41
|
-
'@nrwl/angular:delegate-build',
|
42
|
-
'@nrwl/jest:jest',
|
43
|
-
]);
|
44
|
-
if (supportedExecutors.has(target.executor)) {
|
45
|
-
for (const tsConfig of uniqueTsConfigs) {
|
46
|
-
updateTarget(tree, tsConfig);
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
|
-
await (0, devkit_1.formatFiles)(tree);
|
52
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = updateWorkspaceConfigurations;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const workspace_models_1 = require("@schematics/angular/utility/workspace-models");
|
6
|
-
async function updateWorkspaceConfigurations(tree) {
|
7
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
8
|
-
const supportedExecutors = new Set([workspace_models_1.Builders.Server]);
|
9
|
-
for (const [name, project] of projects) {
|
10
|
-
for (const [targetName, target] of Object.entries(project.targets || {})) {
|
11
|
-
if (!supportedExecutors.has(target.executor)) {
|
12
|
-
continue;
|
13
|
-
}
|
14
|
-
target.options.bundleDependencies = undefined;
|
15
|
-
for (const [configurationName, configuration] of Object.entries(target.configurations || {})) {
|
16
|
-
configuration.bundleDependencies = undefined;
|
17
|
-
target[configurationName] = configuration;
|
18
|
-
}
|
19
|
-
project.targets[targetName] = target;
|
20
|
-
(0, devkit_1.updateProjectConfiguration)(tree, name, project);
|
21
|
-
}
|
22
|
-
}
|
23
|
-
await (0, devkit_1.formatFiles)(tree);
|
24
|
-
}
|
@@ -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 = '~15.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,36 +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 child_process_1 = require("child_process");
|
6
|
-
const path_1 = require("path");
|
7
|
-
const version_utils_1 = require("../../generators/utils/version-utils");
|
8
|
-
const version_utils_2 = require("../../utils/version-utils");
|
9
|
-
async function default_1(tree) {
|
10
|
-
const packagesToInstall = [
|
11
|
-
'@angular-devkit/core',
|
12
|
-
'@angular-devkit/schematics',
|
13
|
-
'@schematics/angular',
|
14
|
-
];
|
15
|
-
const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
16
|
-
const angularMajorVersion = (0, version_utils_1.getInstalledAngularMajorVersion)(tree);
|
17
|
-
const angularDevkitVersion = (0, version_utils_2.getPkgVersionForAngularMajorVersion)('angularDevkitVersion', angularMajorVersion);
|
18
|
-
const angularCliVersion = pkgJson.devDependencies?.['@angular-devkit/build-angular'] ??
|
19
|
-
pkgJson.dependencies?.['@angular-devkit/build-angular'] ??
|
20
|
-
angularDevkitVersion;
|
21
|
-
const filteredPackages = packagesToInstall
|
22
|
-
.filter((pkg) => !pkgJson.devDependencies?.[pkg] && !pkgJson.dependencies?.[pkg])
|
23
|
-
.reduce((allPkgs, pkg) => ({ ...allPkgs, [pkg]: angularCliVersion }), {});
|
24
|
-
// even though we are going to install the packages directly, we still want
|
25
|
-
// to add them to the tree so the migrate command knows changes were made
|
26
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { ...filteredPackages });
|
27
|
-
// we need to install them immediately so the packages are available for
|
28
|
-
// other migrations that might be using them
|
29
|
-
pkgJson.devDependencies ??= {};
|
30
|
-
Object.entries(filteredPackages).forEach(([pkg, version]) => {
|
31
|
-
pkgJson.devDependencies[pkg] = version;
|
32
|
-
});
|
33
|
-
(0, devkit_1.writeJsonFile)((0, path_1.join)(tree.root, 'package.json'), pkgJson);
|
34
|
-
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
35
|
-
(0, child_process_1.execSync)(pmc.install, { stdio: [0, 1, 2] });
|
36
|
-
}
|
@@ -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 = '~15.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,42 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = updateFileServerExecutor;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const versions_1 = require("../../utils/versions");
|
6
|
-
async function updateFileServerExecutor(tree) {
|
7
|
-
const oldExecutor = '@nrwl/angular:file-server';
|
8
|
-
const newExecutor = '@nrwl/web:file-server';
|
9
|
-
let needsNrwlWeb = false;
|
10
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
11
|
-
if (nxJson.targetDefaults) {
|
12
|
-
let nxJsonChanged = false;
|
13
|
-
for (const [targetName, target] of Object.entries(nxJson.targetDefaults)) {
|
14
|
-
if (target.executor === oldExecutor) {
|
15
|
-
nxJson.targetDefaults[targetName].executor = newExecutor;
|
16
|
-
nxJsonChanged = true;
|
17
|
-
needsNrwlWeb = true;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
if (nxJsonChanged) {
|
21
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
25
|
-
for (const [projectName, project] of projects.entries()) {
|
26
|
-
let projectChanged = false;
|
27
|
-
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
28
|
-
if (target.executor === oldExecutor) {
|
29
|
-
project.targets[targetName].executor = newExecutor;
|
30
|
-
projectChanged = true;
|
31
|
-
needsNrwlWeb = true;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
if (projectChanged) {
|
35
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
36
|
-
}
|
37
|
-
}
|
38
|
-
if (needsNrwlWeb) {
|
39
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nrwl/web': versions_1.nxVersion });
|
40
|
-
}
|
41
|
-
await (0, devkit_1.formatFiles)(tree);
|
42
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.updateTestingTsconfigForJest = updateTestingTsconfigForJest;
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
6
|
-
async function updateTestingTsconfigForJest(tree) {
|
7
|
-
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
8
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
9
|
-
(0, executor_options_utils_1.forEachExecutorOptionsInGraph)(graph, '@nrwl/jest:jest', (options, projectName) => {
|
10
|
-
const projectConfig = projects.get(projectName);
|
11
|
-
if (!isJestPresetAngular(tree, options.jestConfig)) {
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
const tsconfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.spec.json');
|
15
|
-
if (tree.exists(tsconfigPath)) {
|
16
|
-
(0, devkit_1.updateJson)(tree, tsconfigPath, (json) => {
|
17
|
-
json.compilerOptions ??= {};
|
18
|
-
json.compilerOptions.target ??= 'es2016';
|
19
|
-
return json;
|
20
|
-
}, { expectComments: true, allowTrailingComma: true });
|
21
|
-
}
|
22
|
-
});
|
23
|
-
await (0, devkit_1.formatFiles)(tree);
|
24
|
-
}
|
25
|
-
function isJestPresetAngular(tree, jestConfigPath) {
|
26
|
-
if (jestConfigPath && tree.exists(jestConfigPath)) {
|
27
|
-
const contents = tree.read(jestConfigPath, 'utf-8');
|
28
|
-
return contents.includes('jest-preset-angular');
|
29
|
-
}
|
30
|
-
return false;
|
31
|
-
}
|
32
|
-
exports.default = updateTestingTsconfigForJest;
|