@schematics/angular 14.0.0-rc.2 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/application/index.js +0 -6
- package/package.json +5 -4
- package/private/components.d.ts +8 -0
- package/private/components.js +14 -0
- package/private/standalone.d.ts +26 -0
- package/private/standalone.js +193 -0
- package/utility/latest-versions/package.json +2 -2
- package/utility/latest-versions.js +1 -1
package/application/index.js
CHANGED
|
@@ -82,12 +82,6 @@ function addAppToWorkspaceFile(options, appDir, folderName) {
|
|
|
82
82
|
schematics[`@schematics/angular:${type}`].skipTests = true;
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
if (options.strict) {
|
|
86
|
-
if (!('@schematics/angular:application' in schematics)) {
|
|
87
|
-
schematics['@schematics/angular:application'] = {};
|
|
88
|
-
}
|
|
89
|
-
schematics['@schematics/angular:application'].strict = true;
|
|
90
|
-
}
|
|
91
85
|
const sourceRoot = (0, core_1.join)((0, core_1.normalize)(projectRoot), 'src');
|
|
92
86
|
let budgets = [];
|
|
93
87
|
if (options.strict) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"description": "Schematics specific to Angular",
|
|
5
5
|
"homepage": "https://github.com/angular/angular-cli",
|
|
6
6
|
"keywords": [
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
"./utility": "./utility/index.js",
|
|
19
19
|
"./utility/*": "./utility/*.js",
|
|
20
20
|
"./migrations/migration-collection.json": "./migrations/migration-collection.json",
|
|
21
|
-
"./*": "./*.js"
|
|
21
|
+
"./*": "./*.js",
|
|
22
|
+
"./private/components": "./private/components.js"
|
|
22
23
|
},
|
|
23
24
|
"schematics": "./collection.json",
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@angular-devkit/core": "14.0.
|
|
26
|
-
"@angular-devkit/schematics": "14.0.
|
|
26
|
+
"@angular-devkit/core": "14.0.1",
|
|
27
|
+
"@angular-devkit/schematics": "14.0.1",
|
|
27
28
|
"jsonc-parser": "3.0.0"
|
|
28
29
|
},
|
|
29
30
|
"repository": {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
export { addModuleImportToStandaloneBootstrap, findBootstrapApplicationCall, importsProvidersFrom, } from './standalone';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.importsProvidersFrom = exports.findBootstrapApplicationCall = exports.addModuleImportToStandaloneBootstrap = void 0;
|
|
11
|
+
var standalone_1 = require("./standalone");
|
|
12
|
+
Object.defineProperty(exports, "addModuleImportToStandaloneBootstrap", { enumerable: true, get: function () { return standalone_1.addModuleImportToStandaloneBootstrap; } });
|
|
13
|
+
Object.defineProperty(exports, "findBootstrapApplicationCall", { enumerable: true, get: function () { return standalone_1.findBootstrapApplicationCall; } });
|
|
14
|
+
Object.defineProperty(exports, "importsProvidersFrom", { enumerable: true, get: function () { return standalone_1.importsProvidersFrom; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
9
|
+
import ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript';
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether the providers from a module are being imported in a `bootstrapApplication` call.
|
|
12
|
+
* @param tree File tree of the project.
|
|
13
|
+
* @param filePath Path of the file in which to check.
|
|
14
|
+
* @param className Class name of the module to search for.
|
|
15
|
+
*/
|
|
16
|
+
export declare function importsProvidersFrom(tree: Tree, filePath: string, className: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Adds an `importProvidersFrom` call to the `bootstrapApplication` call.
|
|
19
|
+
* @param tree File tree of the project.
|
|
20
|
+
* @param filePath Path to the file that should be updated.
|
|
21
|
+
* @param moduleName Name of the module that should be imported.
|
|
22
|
+
* @param modulePath Path from which to import the module.
|
|
23
|
+
*/
|
|
24
|
+
export declare function addModuleImportToStandaloneBootstrap(tree: Tree, filePath: string, moduleName: string, modulePath: string): void;
|
|
25
|
+
/** Finds the call to `bootstrapApplication` within a file. */
|
|
26
|
+
export declare function findBootstrapApplicationCall(sourceFile: ts.SourceFile): ts.CallExpression | null;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.findBootstrapApplicationCall = exports.addModuleImportToStandaloneBootstrap = exports.importsProvidersFrom = void 0;
|
|
14
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
15
|
+
const typescript_1 = __importDefault(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
16
|
+
const ast_utils_1 = require("../utility/ast-utils");
|
|
17
|
+
const change_1 = require("../utility/change");
|
|
18
|
+
/**
|
|
19
|
+
* Checks whether the providers from a module are being imported in a `bootstrapApplication` call.
|
|
20
|
+
* @param tree File tree of the project.
|
|
21
|
+
* @param filePath Path of the file in which to check.
|
|
22
|
+
* @param className Class name of the module to search for.
|
|
23
|
+
*/
|
|
24
|
+
function importsProvidersFrom(tree, filePath, className) {
|
|
25
|
+
const sourceFile = typescript_1.default.createSourceFile(filePath, tree.readText(filePath), typescript_1.default.ScriptTarget.Latest, true);
|
|
26
|
+
const bootstrapCall = findBootstrapApplicationCall(sourceFile);
|
|
27
|
+
const importProvidersFromCall = bootstrapCall ? findImportProvidersFromCall(bootstrapCall) : null;
|
|
28
|
+
return (!!importProvidersFromCall &&
|
|
29
|
+
importProvidersFromCall.arguments.some((arg) => typescript_1.default.isIdentifier(arg) && arg.text === className));
|
|
30
|
+
}
|
|
31
|
+
exports.importsProvidersFrom = importsProvidersFrom;
|
|
32
|
+
/**
|
|
33
|
+
* Adds an `importProvidersFrom` call to the `bootstrapApplication` call.
|
|
34
|
+
* @param tree File tree of the project.
|
|
35
|
+
* @param filePath Path to the file that should be updated.
|
|
36
|
+
* @param moduleName Name of the module that should be imported.
|
|
37
|
+
* @param modulePath Path from which to import the module.
|
|
38
|
+
*/
|
|
39
|
+
function addModuleImportToStandaloneBootstrap(tree, filePath, moduleName, modulePath) {
|
|
40
|
+
const sourceFile = typescript_1.default.createSourceFile(filePath, tree.readText(filePath), typescript_1.default.ScriptTarget.Latest, true);
|
|
41
|
+
const bootstrapCall = findBootstrapApplicationCall(sourceFile);
|
|
42
|
+
if (!bootstrapCall) {
|
|
43
|
+
throw new schematics_1.SchematicsException(`Could not find bootstrapApplication call in ${filePath}`);
|
|
44
|
+
}
|
|
45
|
+
const recorder = tree.beginUpdate(filePath);
|
|
46
|
+
const importCall = findImportProvidersFromCall(bootstrapCall);
|
|
47
|
+
const printer = typescript_1.default.createPrinter();
|
|
48
|
+
const sourceText = sourceFile.getText();
|
|
49
|
+
// Add imports to the module being added and `importProvidersFrom`. We don't
|
|
50
|
+
// have to worry about duplicates, because `insertImport` handles them.
|
|
51
|
+
[
|
|
52
|
+
(0, ast_utils_1.insertImport)(sourceFile, sourceText, moduleName, modulePath),
|
|
53
|
+
(0, ast_utils_1.insertImport)(sourceFile, sourceText, 'importProvidersFrom', '@angular/core'),
|
|
54
|
+
].forEach((change) => {
|
|
55
|
+
if (change instanceof change_1.InsertChange) {
|
|
56
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
// If there is an `importProvidersFrom` call already, reuse it.
|
|
60
|
+
if (importCall) {
|
|
61
|
+
recorder.insertRight(importCall.arguments[importCall.arguments.length - 1].getEnd(), `, ${moduleName}`);
|
|
62
|
+
}
|
|
63
|
+
else if (bootstrapCall.arguments.length === 1) {
|
|
64
|
+
// Otherwise if there is no options parameter to `bootstrapApplication`,
|
|
65
|
+
// create an object literal with a `providers` array and the import.
|
|
66
|
+
const newCall = typescript_1.default.factory.updateCallExpression(bootstrapCall, bootstrapCall.expression, bootstrapCall.typeArguments, [
|
|
67
|
+
...bootstrapCall.arguments,
|
|
68
|
+
typescript_1.default.factory.createObjectLiteralExpression([createProvidersAssignment(moduleName)], true),
|
|
69
|
+
]);
|
|
70
|
+
recorder.remove(bootstrapCall.getStart(), bootstrapCall.getWidth());
|
|
71
|
+
recorder.insertRight(bootstrapCall.getStart(), printer.printNode(typescript_1.default.EmitHint.Unspecified, newCall, sourceFile));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const providersLiteral = findProvidersLiteral(bootstrapCall);
|
|
75
|
+
if (providersLiteral) {
|
|
76
|
+
// If there's a `providers` array, add the import to it.
|
|
77
|
+
const newProvidersLiteral = typescript_1.default.factory.updateArrayLiteralExpression(providersLiteral, [
|
|
78
|
+
...providersLiteral.elements,
|
|
79
|
+
createImportProvidersFromCall(moduleName),
|
|
80
|
+
]);
|
|
81
|
+
recorder.remove(providersLiteral.getStart(), providersLiteral.getWidth());
|
|
82
|
+
recorder.insertRight(providersLiteral.getStart(), printer.printNode(typescript_1.default.EmitHint.Unspecified, newProvidersLiteral, sourceFile));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// Otherwise add a `providers` array to the existing object literal.
|
|
86
|
+
const optionsLiteral = bootstrapCall.arguments[1];
|
|
87
|
+
const newOptionsLiteral = typescript_1.default.factory.updateObjectLiteralExpression(optionsLiteral, [
|
|
88
|
+
...optionsLiteral.properties,
|
|
89
|
+
createProvidersAssignment(moduleName),
|
|
90
|
+
]);
|
|
91
|
+
recorder.remove(optionsLiteral.getStart(), optionsLiteral.getWidth());
|
|
92
|
+
recorder.insertRight(optionsLiteral.getStart(), printer.printNode(typescript_1.default.EmitHint.Unspecified, newOptionsLiteral, sourceFile));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
tree.commitUpdate(recorder);
|
|
96
|
+
}
|
|
97
|
+
exports.addModuleImportToStandaloneBootstrap = addModuleImportToStandaloneBootstrap;
|
|
98
|
+
/** Finds the call to `bootstrapApplication` within a file. */
|
|
99
|
+
function findBootstrapApplicationCall(sourceFile) {
|
|
100
|
+
const localName = findImportLocalName(sourceFile, 'bootstrapApplication', '@angular/platform-browser');
|
|
101
|
+
return localName ? findCall(sourceFile, localName) : null;
|
|
102
|
+
}
|
|
103
|
+
exports.findBootstrapApplicationCall = findBootstrapApplicationCall;
|
|
104
|
+
/** Find a call to `importProvidersFrom` within a `bootstrapApplication` call. */
|
|
105
|
+
function findImportProvidersFromCall(bootstrapCall) {
|
|
106
|
+
const providersLiteral = findProvidersLiteral(bootstrapCall);
|
|
107
|
+
const importProvidersName = findImportLocalName(bootstrapCall.getSourceFile(), 'importProvidersFrom', '@angular/core');
|
|
108
|
+
if (providersLiteral && importProvidersName) {
|
|
109
|
+
for (const element of providersLiteral.elements) {
|
|
110
|
+
// Look for an array element that calls the `importProvidersFrom` function.
|
|
111
|
+
if (typescript_1.default.isCallExpression(element) &&
|
|
112
|
+
typescript_1.default.isIdentifier(element.expression) &&
|
|
113
|
+
element.expression.text === importProvidersName) {
|
|
114
|
+
return element;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
/** Finds the `providers` array literal within a `bootstrapApplication` call. */
|
|
121
|
+
function findProvidersLiteral(bootstrapCall) {
|
|
122
|
+
// The imports have to be in the second argument of
|
|
123
|
+
// the function which has to be an object literal.
|
|
124
|
+
if (bootstrapCall.arguments.length > 1 &&
|
|
125
|
+
typescript_1.default.isObjectLiteralExpression(bootstrapCall.arguments[1])) {
|
|
126
|
+
for (const prop of bootstrapCall.arguments[1].properties) {
|
|
127
|
+
if (typescript_1.default.isPropertyAssignment(prop) &&
|
|
128
|
+
typescript_1.default.isIdentifier(prop.name) &&
|
|
129
|
+
prop.name.text === 'providers' &&
|
|
130
|
+
typescript_1.default.isArrayLiteralExpression(prop.initializer)) {
|
|
131
|
+
return prop.initializer;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Finds the local name of an imported symbol. Could be the symbol name itself or its alias.
|
|
139
|
+
* @param sourceFile File within which to search for the import.
|
|
140
|
+
* @param name Actual name of the import, not its local alias.
|
|
141
|
+
* @param moduleName Name of the module from which the symbol is imported.
|
|
142
|
+
*/
|
|
143
|
+
function findImportLocalName(sourceFile, name, moduleName) {
|
|
144
|
+
for (const node of sourceFile.statements) {
|
|
145
|
+
// Only look for top-level imports.
|
|
146
|
+
if (!typescript_1.default.isImportDeclaration(node) ||
|
|
147
|
+
!typescript_1.default.isStringLiteral(node.moduleSpecifier) ||
|
|
148
|
+
node.moduleSpecifier.text !== moduleName) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
// Filter out imports that don't have the right shape.
|
|
152
|
+
if (!node.importClause ||
|
|
153
|
+
!node.importClause.namedBindings ||
|
|
154
|
+
!typescript_1.default.isNamedImports(node.importClause.namedBindings)) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
// Look through the elements of the declaration for the specific import.
|
|
158
|
+
for (const element of node.importClause.namedBindings.elements) {
|
|
159
|
+
if ((element.propertyName || element.name).text === name) {
|
|
160
|
+
// The local name is always in `name`.
|
|
161
|
+
return element.name.text;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Finds a call to a function with a specific name.
|
|
169
|
+
* @param rootNode Node from which to start searching.
|
|
170
|
+
* @param name Name of the function to search for.
|
|
171
|
+
*/
|
|
172
|
+
function findCall(rootNode, name) {
|
|
173
|
+
let result = null;
|
|
174
|
+
rootNode.forEachChild(function walk(node) {
|
|
175
|
+
if (typescript_1.default.isCallExpression(node) &&
|
|
176
|
+
typescript_1.default.isIdentifier(node.expression) &&
|
|
177
|
+
node.expression.text === name) {
|
|
178
|
+
result = node;
|
|
179
|
+
}
|
|
180
|
+
if (!result) {
|
|
181
|
+
node.forEachChild(walk);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
/** Creates an `importProvidersFrom({{moduleName}})` call. */
|
|
187
|
+
function createImportProvidersFromCall(moduleName) {
|
|
188
|
+
return typescript_1.default.factory.createCallChain(typescript_1.default.factory.createIdentifier('importProvidersFrom'), undefined, undefined, [typescript_1.default.factory.createIdentifier(moduleName)]);
|
|
189
|
+
}
|
|
190
|
+
/** Creates a `providers: [importProvidersFrom({{moduleName}})]` property assignment. */
|
|
191
|
+
function createProvidersAssignment(moduleName) {
|
|
192
|
+
return typescript_1.default.factory.createPropertyAssignment('providers', typescript_1.default.factory.createArrayLiteralExpression([createImportProvidersFromCall(moduleName)]));
|
|
193
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "Package versions used by schematics in @schematics/angular.",
|
|
3
|
-
"comment": "This file is needed so that
|
|
3
|
+
"comment": "This file is needed so that dependencies are synced by Renovate.",
|
|
4
4
|
"private": true,
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@types/jasmine": "~4.0.0",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"karma-jasmine-html-reporter": "~1.7.0",
|
|
12
12
|
"karma-jasmine": "~5.0.0",
|
|
13
13
|
"karma": "~6.3.0",
|
|
14
|
-
"ng-packagr": "^14.0.0
|
|
14
|
+
"ng-packagr": "^14.0.0",
|
|
15
15
|
"rxjs": "~7.5.0",
|
|
16
16
|
"tslib": "^2.3.0",
|
|
17
17
|
"ts-node": "~10.7.0",
|
|
@@ -13,7 +13,7 @@ exports.latestVersions = {
|
|
|
13
13
|
// but ts_library doesn't support JSON inputs.
|
|
14
14
|
...require('./latest-versions/package.json')['dependencies'],
|
|
15
15
|
// As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
|
|
16
|
-
Angular: '^14.0.0
|
|
16
|
+
Angular: '^14.0.0',
|
|
17
17
|
// Since @angular-devkit/build-angular and @schematics/angular are always
|
|
18
18
|
// published together from the same monorepo, and they are both
|
|
19
19
|
// non-experimental, they will always have the same version.
|