@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.
- package/package.json +7 -7
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +2 -2
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +2 -2
- 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
@@ -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;
|