@schematics/angular 14.0.0-next.7 → 14.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-shell/index.js +4 -8
- package/application/files/src/test.ts.template +1 -1
- package/application/index.js +3 -3
- package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template +1 -1
- package/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +5 -2
- package/component/index.js +9 -14
- package/component/schema.d.ts +4 -0
- package/component/schema.json +6 -0
- package/directive/files/__name@dasherize@if-flat__/__name@dasherize__.directive.ts.template +2 -1
- package/directive/index.js +9 -18
- package/directive/schema.d.ts +4 -0
- package/directive/schema.json +6 -0
- package/e2e/index.js +5 -5
- package/library/files/src/test.ts.template +1 -1
- package/library/index.js +3 -4
- package/migrations/migration-collection.json +5 -0
- package/migrations/update-14/update-libraries-secondary-entrypoints.d.ts +10 -0
- package/migrations/update-14/update-libraries-secondary-entrypoints.js +51 -0
- package/module/index.js +8 -16
- package/package.json +10 -3
- package/pipe/files/__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template +2 -1
- package/pipe/index.js +8 -17
- package/pipe/schema.d.ts +4 -0
- package/pipe/schema.json +6 -0
- package/service-worker/index.js +4 -8
- package/third_party/github.com/Microsoft/TypeScript/BUILD.bazel +4 -4
- package/third_party/github.com/Microsoft/TypeScript/lib/typescript.d.ts +385 -290
- package/third_party/github.com/Microsoft/TypeScript/lib/typescript.js +11509 -9414
- package/universal/index.js +3 -7
- package/utility/ast-utils.js +26 -26
- package/utility/dependency.d.ts +45 -0
- package/utility/dependency.js +97 -0
- package/utility/find-module.d.ts +1 -0
- package/utility/find-module.js +5 -10
- package/utility/generate-from-files.js +2 -3
- package/utility/index.d.ts +10 -0
- package/utility/index.js +21 -0
- package/utility/json-file.js +1 -7
- package/utility/latest-versions/package.json +4 -3
- package/utility/latest-versions.js +1 -1
- package/utility/ng-ast-utils.js +2 -10
- package/utility/parse-name.js +0 -1
- package/utility/validation.js +1 -3
- package/utility/workspace-models.d.ts +6 -0
- package/utility/workspace-models.js +6 -0
- package/utility/workspace.d.ts +36 -3
- package/utility/workspace.js +70 -34
- package/web-worker/index.js +2 -2
- package/workspace/index.js +1 -2
package/universal/index.js
CHANGED
|
@@ -96,11 +96,7 @@ function updateConfigFile(options, tsConfigDirectory) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
function findBrowserModuleImport(host, modulePath) {
|
|
99
|
-
const
|
|
100
|
-
if (!moduleBuffer) {
|
|
101
|
-
throw new schematics_1.SchematicsException(`Module file (${modulePath}) not found`);
|
|
102
|
-
}
|
|
103
|
-
const moduleFileText = moduleBuffer.toString('utf-8');
|
|
99
|
+
const moduleFileText = host.readText(modulePath);
|
|
104
100
|
const source = ts.createSourceFile(modulePath, moduleFileText, ts.ScriptTarget.Latest, true);
|
|
105
101
|
const decoratorMetadata = (0, ast_utils_1.getDecoratorMetadata)(source, 'NgModule', '@angular/core')[0];
|
|
106
102
|
const browserModuleNode = (0, ast_utils_1.findNode)(decoratorMetadata, ts.SyntaxKind.Identifier, 'BrowserModule');
|
|
@@ -230,7 +226,7 @@ function default_1(options) {
|
|
|
230
226
|
}
|
|
231
227
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files/src'), [
|
|
232
228
|
(0, schematics_1.applyTemplates)({
|
|
233
|
-
...
|
|
229
|
+
...schematics_1.strings,
|
|
234
230
|
...options,
|
|
235
231
|
stripTsExtension: (s) => s.replace(/\.ts$/, ''),
|
|
236
232
|
hasLocalizePackage: !!(0, dependencies_1.getPackageJsonDependency)(host, '@angular/localize'),
|
|
@@ -239,7 +235,7 @@ function default_1(options) {
|
|
|
239
235
|
]);
|
|
240
236
|
const rootSource = (0, schematics_1.apply)((0, schematics_1.url)('./files/root'), [
|
|
241
237
|
(0, schematics_1.applyTemplates)({
|
|
242
|
-
...
|
|
238
|
+
...schematics_1.strings,
|
|
243
239
|
...options,
|
|
244
240
|
stripTsExtension: (s) => s.replace(/\.ts$/, ''),
|
|
245
241
|
tsConfigExtends,
|
package/utility/ast-utils.js
CHANGED
|
@@ -144,7 +144,6 @@ function getSourceNodes(sourceFile) {
|
|
|
144
144
|
exports.getSourceNodes = getSourceNodes;
|
|
145
145
|
function findNode(node, kind, text) {
|
|
146
146
|
if (node.kind === kind && node.getText() === text) {
|
|
147
|
-
// throw new Error(node.getText());
|
|
148
147
|
return node;
|
|
149
148
|
}
|
|
150
149
|
let foundNode = null;
|
|
@@ -284,27 +283,26 @@ function getMetadataField(node, metadataField) {
|
|
|
284
283
|
exports.getMetadataField = getMetadataField;
|
|
285
284
|
function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbolName, importPath = null) {
|
|
286
285
|
const nodes = getDecoratorMetadata(source, 'NgModule', '@angular/core');
|
|
287
|
-
|
|
286
|
+
const node = nodes[0];
|
|
288
287
|
// Find the decorator declaration.
|
|
289
|
-
if (!node) {
|
|
288
|
+
if (!node || !ts.isObjectLiteralExpression(node)) {
|
|
290
289
|
return [];
|
|
291
290
|
}
|
|
292
291
|
// Get all the children property assignment of object literals.
|
|
293
292
|
const matchingProperties = getMetadataField(node, metadataField);
|
|
294
293
|
if (matchingProperties.length == 0) {
|
|
295
294
|
// We haven't found the field in the metadata declaration. Insert a new field.
|
|
296
|
-
const expr = node;
|
|
297
295
|
let position;
|
|
298
296
|
let toInsert;
|
|
299
|
-
if (
|
|
300
|
-
position =
|
|
297
|
+
if (node.properties.length == 0) {
|
|
298
|
+
position = node.getEnd() - 1;
|
|
301
299
|
toInsert = `\n ${metadataField}: [\n${core_1.tags.indentBy(4) `${symbolName}`}\n ]\n`;
|
|
302
300
|
}
|
|
303
301
|
else {
|
|
304
|
-
|
|
305
|
-
position =
|
|
302
|
+
const childNode = node.properties[node.properties.length - 1];
|
|
303
|
+
position = childNode.getEnd();
|
|
306
304
|
// Get the indentation of the last element, if any.
|
|
307
|
-
const text =
|
|
305
|
+
const text = childNode.getFullText(source);
|
|
308
306
|
const matches = text.match(/^(\r?\n)(\s*)/);
|
|
309
307
|
if (matches) {
|
|
310
308
|
toInsert =
|
|
@@ -327,35 +325,33 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbol
|
|
|
327
325
|
}
|
|
328
326
|
const assignment = matchingProperties[0];
|
|
329
327
|
// If it's not an array, nothing we can do really.
|
|
330
|
-
if (
|
|
328
|
+
if (!ts.isPropertyAssignment(assignment) ||
|
|
329
|
+
!ts.isArrayLiteralExpression(assignment.initializer)) {
|
|
331
330
|
return [];
|
|
332
331
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
else {
|
|
339
|
-
node = arrLiteral.elements;
|
|
340
|
-
}
|
|
341
|
-
if (Array.isArray(node)) {
|
|
342
|
-
const nodeArray = node;
|
|
343
|
-
const symbolsArray = nodeArray.map((node) => core_1.tags.oneLine `${node.getText()}`);
|
|
332
|
+
let expresssion;
|
|
333
|
+
const assignmentInit = assignment.initializer;
|
|
334
|
+
const elements = assignmentInit.elements;
|
|
335
|
+
if (elements.length) {
|
|
336
|
+
const symbolsArray = elements.map((node) => core_1.tags.oneLine `${node.getText()}`);
|
|
344
337
|
if (symbolsArray.includes(core_1.tags.oneLine `${symbolName}`)) {
|
|
345
338
|
return [];
|
|
346
339
|
}
|
|
347
|
-
|
|
340
|
+
expresssion = elements[elements.length - 1];
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
expresssion = assignmentInit;
|
|
348
344
|
}
|
|
349
345
|
let toInsert;
|
|
350
|
-
let position =
|
|
351
|
-
if (
|
|
346
|
+
let position = expresssion.getEnd();
|
|
347
|
+
if (ts.isArrayLiteralExpression(expresssion)) {
|
|
352
348
|
// We found the field but it's empty. Insert it just before the `]`.
|
|
353
349
|
position--;
|
|
354
350
|
toInsert = `\n${core_1.tags.indentBy(4) `${symbolName}`}\n `;
|
|
355
351
|
}
|
|
356
352
|
else {
|
|
357
353
|
// Get the indentation of the last element, if any.
|
|
358
|
-
const text =
|
|
354
|
+
const text = expresssion.getFullText(source);
|
|
359
355
|
const matches = text.match(/^(\r?\n)(\s*)/);
|
|
360
356
|
if (matches) {
|
|
361
357
|
toInsert = `,${matches[1]}${core_1.tags.indentBy(matches[2].length) `${symbolName}`}`;
|
|
@@ -470,6 +466,9 @@ exports.getEnvironmentExportName = getEnvironmentExportName;
|
|
|
470
466
|
function getRouterModuleDeclaration(source) {
|
|
471
467
|
const result = getDecoratorMetadata(source, 'NgModule', '@angular/core');
|
|
472
468
|
const node = result[0];
|
|
469
|
+
if (!node || !ts.isObjectLiteralExpression(node)) {
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
473
472
|
const matchingProperties = getMetadataField(node, 'imports');
|
|
474
473
|
if (!matchingProperties) {
|
|
475
474
|
return;
|
|
@@ -490,7 +489,8 @@ exports.getRouterModuleDeclaration = getRouterModuleDeclaration;
|
|
|
490
489
|
function addRouteDeclarationToModule(source, fileToAdd, routeLiteral) {
|
|
491
490
|
const routerModuleExpr = getRouterModuleDeclaration(source);
|
|
492
491
|
if (!routerModuleExpr) {
|
|
493
|
-
throw new Error(`Couldn't find a route declaration in ${fileToAdd}
|
|
492
|
+
throw new Error(`Couldn't find a route declaration in ${fileToAdd}.\n` +
|
|
493
|
+
`Use the '--module' option to specify a different routing module.`);
|
|
494
494
|
}
|
|
495
495
|
const scopeConfigMethodArgs = routerModuleExpr.arguments;
|
|
496
496
|
if (!scopeConfigMethodArgs.length) {
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { Rule } from '@angular-devkit/schematics';
|
|
9
|
+
/**
|
|
10
|
+
* An enum used to specify the type of a dependency found within a package manifest
|
|
11
|
+
* file (`package.json`).
|
|
12
|
+
*/
|
|
13
|
+
export declare enum DependencyType {
|
|
14
|
+
Default = "dependencies",
|
|
15
|
+
Dev = "devDependencies",
|
|
16
|
+
Peer = "peerDependencies"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Adds a package as a dependency to a `package.json`. By default the `package.json` located
|
|
20
|
+
* at the schematic's root will be used. The `manifestPath` option can be used to explicitly specify
|
|
21
|
+
* a `package.json` in different location. The type of the dependency can also be specified instead
|
|
22
|
+
* of the default of the `dependencies` section by using the `type` option for either `devDependencies`
|
|
23
|
+
* or `peerDependencies`.
|
|
24
|
+
*
|
|
25
|
+
* When using this rule, {@link NodePackageInstallTask} does not need to be included directly by
|
|
26
|
+
* a schematic. A package manager install task will be automatically scheduled as needed.
|
|
27
|
+
*
|
|
28
|
+
* @param name The name of the package to add.
|
|
29
|
+
* @param specifier The package specifier for the package to add. Typically a SemVer range.
|
|
30
|
+
* @param options An optional object that can contain the `type` of the dependency
|
|
31
|
+
* and/or a path (`packageJsonPath`) of a manifest file (`package.json`) to modify.
|
|
32
|
+
* @returns A Schematics {@link Rule}
|
|
33
|
+
*/
|
|
34
|
+
export declare function addDependency(name: string, specifier: string, options?: {
|
|
35
|
+
/**
|
|
36
|
+
* The type of the dependency determines the section of the `package.json` to which the
|
|
37
|
+
* dependency will be added. Defaults to {@link DependencyType.Default} (`dependencies`).
|
|
38
|
+
*/
|
|
39
|
+
type?: DependencyType;
|
|
40
|
+
/**
|
|
41
|
+
* The path of the package manifest file (`package.json`) that will be modified.
|
|
42
|
+
* Defaults to `/package.json`.
|
|
43
|
+
*/
|
|
44
|
+
packageJsonPath?: string;
|
|
45
|
+
}): Rule;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.addDependency = exports.DependencyType = void 0;
|
|
34
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
35
|
+
const path = __importStar(require("path"));
|
|
36
|
+
const installTasks = new WeakMap();
|
|
37
|
+
/**
|
|
38
|
+
* An enum used to specify the type of a dependency found within a package manifest
|
|
39
|
+
* file (`package.json`).
|
|
40
|
+
*/
|
|
41
|
+
var DependencyType;
|
|
42
|
+
(function (DependencyType) {
|
|
43
|
+
DependencyType["Default"] = "dependencies";
|
|
44
|
+
DependencyType["Dev"] = "devDependencies";
|
|
45
|
+
DependencyType["Peer"] = "peerDependencies";
|
|
46
|
+
})(DependencyType = exports.DependencyType || (exports.DependencyType = {}));
|
|
47
|
+
/**
|
|
48
|
+
* Adds a package as a dependency to a `package.json`. By default the `package.json` located
|
|
49
|
+
* at the schematic's root will be used. The `manifestPath` option can be used to explicitly specify
|
|
50
|
+
* a `package.json` in different location. The type of the dependency can also be specified instead
|
|
51
|
+
* of the default of the `dependencies` section by using the `type` option for either `devDependencies`
|
|
52
|
+
* or `peerDependencies`.
|
|
53
|
+
*
|
|
54
|
+
* When using this rule, {@link NodePackageInstallTask} does not need to be included directly by
|
|
55
|
+
* a schematic. A package manager install task will be automatically scheduled as needed.
|
|
56
|
+
*
|
|
57
|
+
* @param name The name of the package to add.
|
|
58
|
+
* @param specifier The package specifier for the package to add. Typically a SemVer range.
|
|
59
|
+
* @param options An optional object that can contain the `type` of the dependency
|
|
60
|
+
* and/or a path (`packageJsonPath`) of a manifest file (`package.json`) to modify.
|
|
61
|
+
* @returns A Schematics {@link Rule}
|
|
62
|
+
*/
|
|
63
|
+
function addDependency(name, specifier, options = {}) {
|
|
64
|
+
const { type = DependencyType.Default, packageJsonPath = '/package.json' } = options;
|
|
65
|
+
return (tree, context) => {
|
|
66
|
+
var _a;
|
|
67
|
+
const manifest = tree.readJson(packageJsonPath);
|
|
68
|
+
const dependencySection = manifest[type];
|
|
69
|
+
if (!dependencySection) {
|
|
70
|
+
// Section is not present. The dependency can be added to a new object literal for the section.
|
|
71
|
+
manifest[type] = { [name]: specifier };
|
|
72
|
+
}
|
|
73
|
+
else if (dependencySection[name] === specifier) {
|
|
74
|
+
// Already present with same specifier
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
else if (dependencySection[name]) {
|
|
78
|
+
// Already present but different specifier
|
|
79
|
+
throw new Error(`Package dependency "${name}" already exists with a different specifier.`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Add new dependency in alphabetical order
|
|
83
|
+
const entries = Object.entries(dependencySection);
|
|
84
|
+
entries.push([name, specifier]);
|
|
85
|
+
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
86
|
+
manifest[type] = Object.fromEntries(entries);
|
|
87
|
+
}
|
|
88
|
+
tree.overwrite(packageJsonPath, JSON.stringify(manifest, null, 2));
|
|
89
|
+
const installPaths = (_a = installTasks.get(context)) !== null && _a !== void 0 ? _a : new Set();
|
|
90
|
+
if (!installPaths.has(packageJsonPath)) {
|
|
91
|
+
context.addTask(new tasks_1.NodePackageInstallTask({ workingDirectory: path.dirname(packageJsonPath) }));
|
|
92
|
+
installPaths.add(packageJsonPath);
|
|
93
|
+
installTasks.set(context, installPaths);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
exports.addDependency = addDependency;
|
package/utility/find-module.d.ts
CHANGED
package/utility/find-module.js
CHANGED
|
@@ -15,8 +15,7 @@ exports.ROUTING_MODULE_EXT = '-routing.module.ts';
|
|
|
15
15
|
* Find the module referred by a set of options passed to the schematics.
|
|
16
16
|
*/
|
|
17
17
|
function findModuleFromOptions(host, options) {
|
|
18
|
-
|
|
19
|
-
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
18
|
+
if (options.standalone || options.skipImport) {
|
|
20
19
|
return undefined;
|
|
21
20
|
}
|
|
22
21
|
const moduleExt = options.moduleExt || exports.MODULE_EXT;
|
|
@@ -38,11 +37,7 @@ function findModuleFromOptions(host, options) {
|
|
|
38
37
|
}
|
|
39
38
|
const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
|
|
40
39
|
for (const c of candidatesDirs) {
|
|
41
|
-
const candidateFiles = [
|
|
42
|
-
'',
|
|
43
|
-
`${moduleBaseName}.ts`,
|
|
44
|
-
`${moduleBaseName}${moduleExt}`,
|
|
45
|
-
].map((x) => (0, core_1.join)(c, x));
|
|
40
|
+
const candidateFiles = ['', `${moduleBaseName}.ts`, `${moduleBaseName}${moduleExt}`].map((x) => (0, core_1.join)(c, x));
|
|
46
41
|
for (const sc of candidateFiles) {
|
|
47
42
|
if (host.exists(sc)) {
|
|
48
43
|
return (0, core_1.normalize)(sc);
|
|
@@ -68,7 +63,7 @@ function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingMo
|
|
|
68
63
|
return (0, core_1.join)(dir.path, filteredMatches[0]);
|
|
69
64
|
}
|
|
70
65
|
else if (filteredMatches.length > 1) {
|
|
71
|
-
throw new Error(
|
|
66
|
+
throw new Error(`More than one module matches. Use the '--skip-import' option to skip importing ` +
|
|
72
67
|
'the component into the closest module or use the module option to specify a module.');
|
|
73
68
|
}
|
|
74
69
|
dir = dir.parent;
|
|
@@ -76,8 +71,8 @@ function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingMo
|
|
|
76
71
|
const errorMsg = foundRoutingModule
|
|
77
72
|
? 'Could not find a non Routing NgModule.' +
|
|
78
73
|
`\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
|
|
79
|
-
|
|
80
|
-
:
|
|
74
|
+
`\nUse the '--skip-import' option to skip importing in NgModule.`
|
|
75
|
+
: `Could not find an NgModule. Use the '--skip-import' option to skip importing in NgModule.`;
|
|
81
76
|
throw new Error(errorMsg);
|
|
82
77
|
}
|
|
83
78
|
exports.findModule = findModule;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.generateFromFiles = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
12
|
const parse_name_1 = require("./parse-name");
|
|
14
13
|
const workspace_1 = require("./workspace");
|
|
@@ -24,11 +23,11 @@ function generateFromFiles(options, extraTemplateValues = {}) {
|
|
|
24
23
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
25
24
|
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
|
26
25
|
(0, schematics_1.applyTemplates)({
|
|
27
|
-
...
|
|
26
|
+
...schematics_1.strings,
|
|
28
27
|
...options,
|
|
29
28
|
...extraTemplateValues,
|
|
30
29
|
}),
|
|
31
|
-
(0, schematics_1.move)(parsedPath.path + (options.flat ? '' : '/' +
|
|
30
|
+
(0, schematics_1.move)(parsedPath.path + (options.flat ? '' : '/' + schematics_1.strings.dasherize(options.name))),
|
|
32
31
|
]);
|
|
33
32
|
return (0, schematics_1.chain)([(0, schematics_1.mergeWith)(templateSource)]);
|
|
34
33
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { ProjectDefinition, TargetDefinition, WorkspaceDefinition, getWorkspace as readWorkspace, updateWorkspace, writeWorkspace, } from './workspace';
|
|
9
|
+
export { Builders as AngularBuilder } from './workspace-models';
|
|
10
|
+
export { DependencyType, addDependency } from './dependency';
|
package/utility/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.addDependency = exports.DependencyType = exports.AngularBuilder = exports.writeWorkspace = exports.updateWorkspace = exports.readWorkspace = void 0;
|
|
11
|
+
// Workspace related rules and types
|
|
12
|
+
var workspace_1 = require("./workspace");
|
|
13
|
+
Object.defineProperty(exports, "readWorkspace", { enumerable: true, get: function () { return workspace_1.getWorkspace; } });
|
|
14
|
+
Object.defineProperty(exports, "updateWorkspace", { enumerable: true, get: function () { return workspace_1.updateWorkspace; } });
|
|
15
|
+
Object.defineProperty(exports, "writeWorkspace", { enumerable: true, get: function () { return workspace_1.writeWorkspace; } });
|
|
16
|
+
var workspace_models_1 = require("./workspace-models");
|
|
17
|
+
Object.defineProperty(exports, "AngularBuilder", { enumerable: true, get: function () { return workspace_models_1.Builders; } });
|
|
18
|
+
// Package dependency related rules and types
|
|
19
|
+
var dependency_1 = require("./dependency");
|
|
20
|
+
Object.defineProperty(exports, "DependencyType", { enumerable: true, get: function () { return dependency_1.DependencyType; } });
|
|
21
|
+
Object.defineProperty(exports, "addDependency", { enumerable: true, get: function () { return dependency_1.addDependency; } });
|
package/utility/json-file.js
CHANGED
|
@@ -14,13 +14,7 @@ class JSONFile {
|
|
|
14
14
|
constructor(host, path) {
|
|
15
15
|
this.host = host;
|
|
16
16
|
this.path = path;
|
|
17
|
-
|
|
18
|
-
if (buffer) {
|
|
19
|
-
this.content = buffer.toString();
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
throw new Error(`Could not read '${path}'.`);
|
|
23
|
-
}
|
|
17
|
+
this.content = this.host.readText(this.path);
|
|
24
18
|
}
|
|
25
19
|
get JsonAst() {
|
|
26
20
|
if (this._jsonAst) {
|
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@types/jasmine": "~4.0.0",
|
|
7
7
|
"@types/node": "^14.15.0",
|
|
8
|
-
"jasmine-core": "~4.
|
|
8
|
+
"jasmine-core": "~4.1.0",
|
|
9
9
|
"karma-chrome-launcher": "~3.1.0",
|
|
10
10
|
"karma-coverage": "~2.2.0",
|
|
11
11
|
"karma-jasmine-html-reporter": "~1.7.0",
|
|
12
|
-
"karma-jasmine": "~
|
|
12
|
+
"karma-jasmine": "~5.0.0",
|
|
13
13
|
"karma": "~6.3.0",
|
|
14
|
-
"ng-packagr": "^14.0.0-next.
|
|
14
|
+
"ng-packagr": "^14.0.0-next.8",
|
|
15
15
|
"rxjs": "~7.5.0",
|
|
16
16
|
"tslib": "^2.3.0",
|
|
17
|
+
"ts-node": "~10.7.0",
|
|
17
18
|
"typescript": "~4.6.2",
|
|
18
19
|
"zone.js": "~0.11.4"
|
|
19
20
|
}
|
|
@@ -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-rc.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.
|
package/utility/ng-ast-utils.js
CHANGED
|
@@ -37,11 +37,7 @@ const path_1 = require("path");
|
|
|
37
37
|
const ts = __importStar(require("../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
38
38
|
const ast_utils_1 = require("../utility/ast-utils");
|
|
39
39
|
function findBootstrapModuleCall(host, mainPath) {
|
|
40
|
-
const
|
|
41
|
-
if (!mainBuffer) {
|
|
42
|
-
throw new schematics_1.SchematicsException(`Main file (${mainPath}) not found`);
|
|
43
|
-
}
|
|
44
|
-
const mainText = mainBuffer.toString('utf-8');
|
|
40
|
+
const mainText = host.readText(mainPath);
|
|
45
41
|
const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);
|
|
46
42
|
const allNodes = (0, ast_utils_1.getSourceNodes)(source);
|
|
47
43
|
let bootstrapCall = null;
|
|
@@ -70,11 +66,7 @@ function findBootstrapModulePath(host, mainPath) {
|
|
|
70
66
|
throw new schematics_1.SchematicsException('Bootstrap call not found');
|
|
71
67
|
}
|
|
72
68
|
const bootstrapModule = bootstrapCall.arguments[0];
|
|
73
|
-
const
|
|
74
|
-
if (!mainBuffer) {
|
|
75
|
-
throw new schematics_1.SchematicsException(`Client application main file (${mainPath}) not found`);
|
|
76
|
-
}
|
|
77
|
-
const mainText = mainBuffer.toString('utf-8');
|
|
69
|
+
const mainText = host.readText(mainPath);
|
|
78
70
|
const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);
|
|
79
71
|
const allNodes = (0, ast_utils_1.getSourceNodes)(source);
|
|
80
72
|
const bootstrapModuleRelativePath = allNodes
|
package/utility/parse-name.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.parseName = void 0;
|
|
11
|
-
// import { relative, Path } from "../../../angular_devkit/core/src/virtual-fs";
|
|
12
11
|
const core_1 = require("@angular-devkit/core");
|
|
13
12
|
function parseName(path, name) {
|
|
14
13
|
const nameWithoutPath = (0, core_1.basename)((0, core_1.normalize)(name));
|
package/utility/validation.js
CHANGED
|
@@ -8,15 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.validateHtmlSelector = exports.htmlSelectorRe = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
12
|
// Must start with a letter, and must contain only alphanumeric characters or dashes.
|
|
14
13
|
// When adding a dash the segment after the dash must also start with a letter.
|
|
15
14
|
exports.htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*(:?-[a-zA-Z][.0-9a-zA-Z]*)*$/;
|
|
16
15
|
function validateHtmlSelector(selector) {
|
|
17
16
|
if (selector && !exports.htmlSelectorRe.test(selector)) {
|
|
18
|
-
throw new schematics_1.SchematicsException(
|
|
19
|
-
is invalid.`);
|
|
17
|
+
throw new schematics_1.SchematicsException(`Selector (${selector}) is invalid.`);
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
exports.validateHtmlSelector = validateHtmlSelector;
|
|
@@ -9,6 +9,12 @@ export declare enum ProjectType {
|
|
|
9
9
|
Application = "application",
|
|
10
10
|
Library = "library"
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* An enum of the official Angular builders.
|
|
14
|
+
* Each enum value provides the fully qualified name of the associated builder.
|
|
15
|
+
* This enum can be used when analyzing the `builder` fields of project configurations from the
|
|
16
|
+
* `angular.json` workspace file.
|
|
17
|
+
*/
|
|
12
18
|
export declare enum Builders {
|
|
13
19
|
AppShell = "@angular-devkit/build-angular:app-shell",
|
|
14
20
|
Server = "@angular-devkit/build-angular:server",
|
|
@@ -13,6 +13,12 @@ var ProjectType;
|
|
|
13
13
|
ProjectType["Application"] = "application";
|
|
14
14
|
ProjectType["Library"] = "library";
|
|
15
15
|
})(ProjectType = exports.ProjectType || (exports.ProjectType = {}));
|
|
16
|
+
/**
|
|
17
|
+
* An enum of the official Angular builders.
|
|
18
|
+
* Each enum value provides the fully qualified name of the associated builder.
|
|
19
|
+
* This enum can be used when analyzing the `builder` fields of project configurations from the
|
|
20
|
+
* `angular.json` workspace file.
|
|
21
|
+
*/
|
|
16
22
|
var Builders;
|
|
17
23
|
(function (Builders) {
|
|
18
24
|
Builders["AppShell"] = "@angular-devkit/build-angular:app-shell";
|
package/utility/workspace.d.ts
CHANGED
|
@@ -7,9 +7,42 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { json, workspaces } from '@angular-devkit/core';
|
|
9
9
|
import { Rule, Tree } from '@angular-devkit/schematics';
|
|
10
|
-
export declare
|
|
11
|
-
export declare
|
|
12
|
-
export declare
|
|
10
|
+
export declare type WorkspaceDefinition = workspaces.WorkspaceDefinition;
|
|
11
|
+
export declare type ProjectDefinition = workspaces.ProjectDefinition;
|
|
12
|
+
export declare type TargetDefinition = workspaces.TargetDefinition;
|
|
13
|
+
/**
|
|
14
|
+
* Updates the workspace file (`angular.json`) found within the root of the schematic's tree.
|
|
15
|
+
* The workspace object model can be directly modified within the provided updater function
|
|
16
|
+
* with changes being written to the workspace file after the updater function returns.
|
|
17
|
+
* The spacing and overall layout of the file (including comments) will be maintained where
|
|
18
|
+
* possible when updating the file.
|
|
19
|
+
*
|
|
20
|
+
* @param updater An update function that can be used to modify the object model for the
|
|
21
|
+
* workspace. A {@link WorkspaceDefinition} is provided as the first argument to the function.
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateWorkspace(updater: (workspace: WorkspaceDefinition) => void | Rule | PromiseLike<void | Rule>): Rule;
|
|
24
|
+
/**
|
|
25
|
+
* Reads a workspace file (`angular.json`) from the provided {@link Tree} instance.
|
|
26
|
+
*
|
|
27
|
+
* @param tree A schematics {@link Tree} instance used to access the workspace file.
|
|
28
|
+
* @param path The path where a workspace file should be found. If a file is specified, the file
|
|
29
|
+
* path will be used. If a directory is specified, the file `angular.json` will be used from
|
|
30
|
+
* within the specified directory. Defaults to `/angular.json`.
|
|
31
|
+
* @returns A {@link WorkspaceDefinition} representing the workspace found at the specified path.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getWorkspace(tree: Tree, path?: string): Promise<WorkspaceDefinition>;
|
|
34
|
+
/**
|
|
35
|
+
* Writes a workspace file (`angular.json`) to the provided {@link Tree} instance.
|
|
36
|
+
* The spacing and overall layout of an exisitng file (including comments) will be maintained where
|
|
37
|
+
* possible when writing the file.
|
|
38
|
+
*
|
|
39
|
+
* @param tree A schematics {@link Tree} instance used to access the workspace file.
|
|
40
|
+
* @param workspace The {@link WorkspaceDefinition} to write.
|
|
41
|
+
* @param path The path where a workspace file should be written. If a file is specified, the file
|
|
42
|
+
* path will be used. If not provided, the definition's underlying file path stored during reading
|
|
43
|
+
* will be used.
|
|
44
|
+
*/
|
|
45
|
+
export declare function writeWorkspace(tree: Tree, workspace: WorkspaceDefinition, path?: string): Promise<void>;
|
|
13
46
|
/**
|
|
14
47
|
* Build a default project path for generating.
|
|
15
48
|
* @param project The project which will have its default path generated.
|