@angular/cli 14.0.0-next.5 → 14.0.0-next.8

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.
Files changed (108) hide show
  1. package/lib/cli/index.d.ts +0 -1
  2. package/lib/cli/index.js +3 -30
  3. package/lib/config/schema.json +26 -7
  4. package/lib/config/workspace-schema.d.ts +6 -1
  5. package/lib/init.js +7 -6
  6. package/package.json +17 -20
  7. package/src/analytics/analytics-collector.js +7 -1
  8. package/src/analytics/analytics.d.ts +10 -23
  9. package/src/analytics/analytics.js +99 -184
  10. package/src/command-builder/architect-base-command-module.d.ts +8 -1
  11. package/src/command-builder/architect-base-command-module.js +61 -7
  12. package/src/command-builder/architect-command-module.d.ts +0 -1
  13. package/src/command-builder/architect-command-module.js +16 -12
  14. package/src/command-builder/command-module.d.ts +5 -2
  15. package/src/command-builder/command-module.js +21 -8
  16. package/src/command-builder/command-runner.d.ts +1 -2
  17. package/src/command-builder/command-runner.js +54 -48
  18. package/src/command-builder/schematics-command-module.d.ts +19 -7
  19. package/src/command-builder/schematics-command-module.js +268 -50
  20. package/src/command-builder/utilities/command.d.ts +13 -0
  21. package/src/command-builder/utilities/command.js +27 -0
  22. package/src/command-builder/utilities/json-help.d.ts +16 -14
  23. package/src/command-builder/utilities/json-help.js +26 -22
  24. package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
  25. package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
  26. package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
  27. package/src/command-builder/utilities/schematic-workflow.js +68 -0
  28. package/src/commands/add/cli.d.ts +11 -1
  29. package/src/commands/add/cli.js +325 -6
  30. package/src/commands/add/long-description.md +1 -4
  31. package/src/commands/analytics/cli.d.ts +5 -10
  32. package/src/commands/analytics/cli.js +15 -50
  33. package/src/commands/analytics/info/cli.d.ts +16 -0
  34. package/src/commands/analytics/info/cli.js +26 -0
  35. package/src/commands/analytics/settings/cli.d.ts +35 -0
  36. package/src/commands/analytics/settings/cli.js +61 -0
  37. package/src/commands/cache/clean/cli.d.ts +17 -0
  38. package/src/commands/cache/clean/cli.js +32 -0
  39. package/src/commands/cache/cli.d.ts +17 -0
  40. package/src/commands/cache/cli.js +38 -0
  41. package/src/commands/cache/info/cli.d.ts +20 -0
  42. package/src/commands/cache/info/cli.js +82 -0
  43. package/src/commands/cache/long-description.md +53 -0
  44. package/src/commands/cache/settings/cli.d.ts +27 -0
  45. package/src/commands/cache/settings/cli.js +42 -0
  46. package/src/commands/cache/utilities.d.ts +11 -0
  47. package/src/commands/cache/utilities.js +50 -0
  48. package/src/commands/config/cli.d.ts +5 -2
  49. package/src/commands/config/cli.js +128 -6
  50. package/src/commands/deploy/cli.d.ts +2 -1
  51. package/src/commands/deploy/cli.js +27 -13
  52. package/src/commands/doc/cli.d.ts +1 -1
  53. package/src/commands/doc/cli.js +5 -1
  54. package/src/commands/e2e/cli.d.ts +3 -2
  55. package/src/commands/e2e/cli.js +14 -13
  56. package/src/commands/generate/cli.d.ts +14 -2
  57. package/src/commands/generate/cli.js +83 -36
  58. package/src/commands/lint/cli.d.ts +2 -1
  59. package/src/commands/lint/cli.js +6 -9
  60. package/src/commands/new/cli.d.ts +7 -3
  61. package/src/commands/new/cli.js +52 -6
  62. package/src/commands/update/cli.d.ts +31 -5
  63. package/src/commands/update/cli.js +709 -8
  64. package/src/commands/update/schematic/index.js +32 -19
  65. package/src/commands/version/cli.d.ts +0 -1
  66. package/src/commands/version/cli.js +19 -43
  67. package/src/typings-bazel.d.ts +14 -0
  68. package/src/typings.d.ts +0 -13
  69. package/src/utilities/color.js +5 -1
  70. package/src/utilities/config.d.ts +1 -1
  71. package/src/utilities/config.js +22 -11
  72. package/src/utilities/environment-options.d.ts +12 -0
  73. package/src/utilities/environment-options.js +24 -0
  74. package/src/utilities/find-up.js +5 -1
  75. package/src/utilities/memoize.d.ts +15 -0
  76. package/src/utilities/memoize.js +69 -0
  77. package/src/utilities/package-manager.d.ts +33 -5
  78. package/src/utilities/package-manager.js +252 -71
  79. package/src/utilities/package-metadata.d.ts +15 -37
  80. package/src/utilities/package-metadata.js +15 -27
  81. package/src/utilities/package-tree.d.ts +2 -2
  82. package/src/utilities/package-tree.js +5 -1
  83. package/src/utilities/project.js +5 -1
  84. package/src/utilities/prompt.d.ts +2 -0
  85. package/src/utilities/prompt.js +25 -4
  86. package/bin/postinstall/analytics-prompt.js +0 -27
  87. package/bin/postinstall/script.js +0 -16
  88. package/models/command.d.ts +0 -29
  89. package/models/command.js +0 -50
  90. package/models/interface.d.ts +0 -19
  91. package/models/interface.js +0 -9
  92. package/models/schematic-command.d.ts +0 -43
  93. package/models/schematic-command.js +0 -378
  94. package/src/commands/add/add-impl.d.ts +0 -22
  95. package/src/commands/add/add-impl.js +0 -331
  96. package/src/commands/analytics/long-description.md +0 -10
  97. package/src/commands/config/config-impl.d.ts +0 -17
  98. package/src/commands/config/config-impl.js +0 -151
  99. package/src/commands/generate/generate-impl.d.ts +0 -19
  100. package/src/commands/generate/generate-impl.js +0 -49
  101. package/src/commands/new/new-impl.d.ts +0 -18
  102. package/src/commands/new/new-impl.js +0 -38
  103. package/src/commands/update/update-impl.d.ts +0 -40
  104. package/src/commands/update/update-impl.js +0 -728
  105. package/src/utilities/install-package.d.ts +0 -16
  106. package/src/utilities/install-package.js +0 -193
  107. package/src/utilities/package-json.d.ts +0 -249
  108. package/src/utilities/package-json.js +0 -9
@@ -1,29 +0,0 @@
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 { analytics, logging } from '@angular-devkit/core';
9
- import { Option } from '../src/command-builder/utilities/json-schema';
10
- import { AngularWorkspace } from '../src/utilities/config';
11
- import { CommandContext } from './interface';
12
- export interface BaseCommandOptions {
13
- jsonHelp?: boolean;
14
- }
15
- export declare abstract class Command<T = {}> {
16
- protected readonly context: CommandContext;
17
- protected readonly commandName: string;
18
- protected allowMissingWorkspace: boolean;
19
- protected useReportAnalytics: boolean;
20
- readonly workspace?: AngularWorkspace;
21
- protected readonly analytics: analytics.Analytics;
22
- protected readonly commandOptions: Option[];
23
- protected readonly logger: logging.Logger;
24
- constructor(context: CommandContext, commandName: string);
25
- initialize(options: T): Promise<number | void>;
26
- reportAnalytics(paths: string[], options: T, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
27
- abstract run(options: T): Promise<number | void>;
28
- validateAndRun(options: T): Promise<number | void>;
29
- }
package/models/command.js DELETED
@@ -1,50 +0,0 @@
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.Command = void 0;
11
- const core_1 = require("@angular-devkit/core");
12
- class Command {
13
- constructor(context, commandName) {
14
- this.context = context;
15
- this.commandName = commandName;
16
- this.allowMissingWorkspace = false;
17
- this.useReportAnalytics = true;
18
- this.commandOptions = [];
19
- this.workspace = context.workspace;
20
- this.logger = context.logger;
21
- this.analytics = context.analytics || new core_1.analytics.NoopAnalytics();
22
- }
23
- async initialize(options) { }
24
- async reportAnalytics(paths, options, dimensions = [], metrics = []) {
25
- for (const option of this.commandOptions) {
26
- const ua = option.userAnalytics;
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- const v = options[option.name];
29
- if (v !== undefined && !Array.isArray(v) && ua) {
30
- dimensions[ua] = v;
31
- }
32
- }
33
- this.analytics.pageview('/command/' + paths.join('/'), { dimensions, metrics });
34
- }
35
- async validateAndRun(options) {
36
- let result = await this.initialize(options);
37
- if (typeof result === 'number' && result !== 0) {
38
- return result;
39
- }
40
- const startTime = +new Date();
41
- if (this.useReportAnalytics) {
42
- await this.reportAnalytics([this.commandName], options);
43
- }
44
- result = await this.run(options);
45
- const endTime = +new Date();
46
- this.analytics.timing(this.commandName, 'duration', endTime - startTime);
47
- return result;
48
- }
49
- }
50
- exports.Command = Command;
@@ -1,19 +0,0 @@
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 { analytics, logging } from '@angular-devkit/core';
9
- import { AngularWorkspace } from '../src/utilities/config';
10
- /**
11
- * A command runner context.
12
- */
13
- export interface CommandContext {
14
- currentDirectory: string;
15
- root: string;
16
- workspace?: AngularWorkspace;
17
- analytics?: analytics.Analytics;
18
- logger: logging.Logger;
19
- }
@@ -1,9 +0,0 @@
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 });
@@ -1,43 +0,0 @@
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 { FileSystemCollection, FileSystemEngine, FileSystemSchematic, NodeWorkflow } from '@angular-devkit/schematics/tools';
9
- import { BaseCommandOptions, Command } from './command';
10
- import { CommandContext } from './interface';
11
- export interface BaseSchematicSchema {
12
- debug?: boolean;
13
- dryRun?: boolean;
14
- force?: boolean;
15
- interactive?: boolean;
16
- defaults?: boolean;
17
- registry?: string;
18
- }
19
- export interface RunSchematicOptions extends BaseSchematicSchema {
20
- collectionName: string;
21
- schematicName: string;
22
- schematicOptions?: Record<string, unknown>;
23
- showNothingDone?: boolean;
24
- }
25
- export declare class UnknownCollectionError extends Error {
26
- constructor(collectionName: string);
27
- }
28
- export declare abstract class SchematicCommand<T extends BaseSchematicSchema & BaseCommandOptions> extends Command<T> {
29
- protected readonly allowPrivateSchematics: boolean;
30
- protected readonly useReportAnalytics = false;
31
- protected _workflow: NodeWorkflow;
32
- protected defaultCollectionName: string;
33
- protected collectionName: string;
34
- protected schematicName?: string;
35
- constructor(context: CommandContext, commandName: string);
36
- initialize(options: T): Promise<void>;
37
- protected getEngine(): FileSystemEngine;
38
- protected getCollection(collectionName: string): FileSystemCollection;
39
- protected getSchematic(collection: FileSystemCollection, schematicName: string, allowPrivate?: boolean): FileSystemSchematic;
40
- protected createWorkflow(options: BaseSchematicSchema): Promise<NodeWorkflow>;
41
- protected getDefaultSchematicCollection(): Promise<string>;
42
- protected runSchematic(options: RunSchematicOptions): Promise<number | void>;
43
- }
@@ -1,378 +0,0 @@
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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.SchematicCommand = exports.UnknownCollectionError = void 0;
30
- const core_1 = require("@angular-devkit/core");
31
- const schematics_1 = require("@angular-devkit/schematics");
32
- const tools_1 = require("@angular-devkit/schematics/tools");
33
- const inquirer = __importStar(require("inquirer"));
34
- const systemPath = __importStar(require("path"));
35
- const analytics_1 = require("../src/analytics/analytics");
36
- const json_schema_1 = require("../src/command-builder/utilities/json-schema");
37
- const color_1 = require("../src/utilities/color");
38
- const config_1 = require("../src/utilities/config");
39
- const package_manager_1 = require("../src/utilities/package-manager");
40
- const tty_1 = require("../src/utilities/tty");
41
- const command_1 = require("./command");
42
- const schematic_engine_host_1 = require("./schematic-engine-host");
43
- class UnknownCollectionError extends Error {
44
- constructor(collectionName) {
45
- super(`Invalid collection (${collectionName}).`);
46
- }
47
- }
48
- exports.UnknownCollectionError = UnknownCollectionError;
49
- class SchematicCommand extends command_1.Command {
50
- constructor(context, commandName) {
51
- super(context, commandName);
52
- this.allowPrivateSchematics = false;
53
- this.useReportAnalytics = false;
54
- this.defaultCollectionName = '@schematics/angular';
55
- this.collectionName = this.defaultCollectionName;
56
- }
57
- async initialize(options) {
58
- this._workflow = await this.createWorkflow(options);
59
- if (this.schematicName) {
60
- // Set the options.
61
- const collection = this.getCollection(this.collectionName);
62
- const schematic = this.getSchematic(collection, this.schematicName, true);
63
- const options = await (0, json_schema_1.parseJsonSchemaToOptions)(this._workflow.registry, schematic.description.schemaJson || {});
64
- this.commandOptions.push(...options);
65
- // Remove any user analytics from schematics that are NOT part of our safelist.
66
- for (const o of this.commandOptions) {
67
- if (o.userAnalytics && !(0, analytics_1.isPackageNameSafeForAnalytics)(this.collectionName)) {
68
- o.userAnalytics = undefined;
69
- }
70
- }
71
- }
72
- }
73
- getEngine() {
74
- return this._workflow.engine;
75
- }
76
- getCollection(collectionName) {
77
- const engine = this.getEngine();
78
- const collection = engine.createCollection(collectionName);
79
- if (collection === null) {
80
- throw new UnknownCollectionError(collectionName);
81
- }
82
- return collection;
83
- }
84
- getSchematic(collection, schematicName, allowPrivate) {
85
- return collection.createSchematic(schematicName, allowPrivate);
86
- }
87
- /*
88
- * Runtime hook to allow specifying customized workflow
89
- */
90
- async createWorkflow(options) {
91
- if (this._workflow) {
92
- return this._workflow;
93
- }
94
- const { force, dryRun } = options;
95
- const root = this.context.root;
96
- const workflow = new tools_1.NodeWorkflow(root, {
97
- force,
98
- dryRun,
99
- packageManager: await (0, package_manager_1.getPackageManager)(root),
100
- packageRegistry: options.registry,
101
- // A schema registry is required to allow customizing addUndefinedDefaults
102
- registry: new core_1.schema.CoreSchemaRegistry(schematics_1.formats.standardFormats),
103
- resolvePaths: this.workspace
104
- ? // Workspace
105
- this.collectionName === this.defaultCollectionName
106
- ? // Favor __dirname for @schematics/angular to use the build-in version
107
- [__dirname, process.cwd(), root]
108
- : [process.cwd(), root, __dirname]
109
- : // Global
110
- [__dirname, process.cwd()],
111
- schemaValidation: true,
112
- optionTransforms: [
113
- // Add configuration file defaults
114
- async (schematic, current) => {
115
- const projectName = typeof current.project === 'string'
116
- ? current.project
117
- : getProjectName();
118
- return {
119
- ...(await (0, config_1.getSchematicDefaults)(schematic.collection.name, schematic.name, projectName)),
120
- ...current,
121
- };
122
- },
123
- ],
124
- engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
125
- });
126
- const getProjectName = () => {
127
- if (this.workspace) {
128
- const projectNames = getProjectsByPath(this.workspace, process.cwd(), this.workspace.basePath);
129
- if (projectNames.length === 1) {
130
- return projectNames[0];
131
- }
132
- else {
133
- if (projectNames.length > 1) {
134
- this.logger.warn(core_1.tags.oneLine `
135
- Two or more projects are using identical roots.
136
- Unable to determine project using current working directory.
137
- Using default workspace project instead.
138
- `);
139
- }
140
- const defaultProjectName = this.workspace.extensions['defaultProject'];
141
- if (typeof defaultProjectName === 'string' && defaultProjectName) {
142
- return defaultProjectName;
143
- }
144
- }
145
- }
146
- return undefined;
147
- };
148
- workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
149
- workflow.registry.addSmartDefaultProvider('projectName', getProjectName);
150
- workflow.registry.useXDeprecatedProvider((msg) => this.logger.warn(msg));
151
- let shouldReportAnalytics = true;
152
- workflow.engineHost.registerOptionsTransform(async (_, options) => {
153
- if (shouldReportAnalytics) {
154
- shouldReportAnalytics = false;
155
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
- await this.reportAnalytics([this.commandName], options);
157
- }
158
- return options;
159
- });
160
- if (options.interactive !== false && (0, tty_1.isTTY)()) {
161
- workflow.registry.usePromptProvider((definitions) => {
162
- const questions = definitions
163
- .filter((definition) => !options.defaults || definition.default === undefined)
164
- .map((definition) => {
165
- var _a;
166
- const question = {
167
- name: definition.id,
168
- message: definition.message,
169
- default: definition.default,
170
- };
171
- const validator = definition.validator;
172
- if (validator) {
173
- question.validate = (input) => validator(input);
174
- // Filter allows transformation of the value prior to validation
175
- question.filter = async (input) => {
176
- for (const type of definition.propertyTypes) {
177
- let value;
178
- switch (type) {
179
- case 'string':
180
- value = String(input);
181
- break;
182
- case 'integer':
183
- case 'number':
184
- value = Number(input);
185
- break;
186
- default:
187
- value = input;
188
- break;
189
- }
190
- // Can be a string if validation fails
191
- const isValid = (await validator(value)) === true;
192
- if (isValid) {
193
- return value;
194
- }
195
- }
196
- return input;
197
- };
198
- }
199
- switch (definition.type) {
200
- case 'confirmation':
201
- question.type = 'confirm';
202
- break;
203
- case 'list':
204
- question.type = definition.multiselect ? 'checkbox' : 'list';
205
- question.choices = (_a = definition.items) === null || _a === void 0 ? void 0 : _a.map((item) => {
206
- return typeof item == 'string'
207
- ? item
208
- : {
209
- name: item.label,
210
- value: item.value,
211
- };
212
- });
213
- break;
214
- default:
215
- question.type = definition.type;
216
- break;
217
- }
218
- return question;
219
- });
220
- return inquirer.prompt(questions);
221
- });
222
- }
223
- return (this._workflow = workflow);
224
- }
225
- async getDefaultSchematicCollection() {
226
- let workspace = await (0, config_1.getWorkspace)('local');
227
- if (workspace) {
228
- const project = (0, config_1.getProjectByCwd)(workspace);
229
- if (project && workspace.getProjectCli(project)) {
230
- const value = workspace.getProjectCli(project)['defaultCollection'];
231
- if (typeof value == 'string') {
232
- return value;
233
- }
234
- }
235
- if (workspace.getCli()) {
236
- const value = workspace.getCli()['defaultCollection'];
237
- if (typeof value == 'string') {
238
- return value;
239
- }
240
- }
241
- }
242
- workspace = await (0, config_1.getWorkspace)('global');
243
- if (workspace && workspace.getCli()) {
244
- const value = workspace.getCli()['defaultCollection'];
245
- if (typeof value == 'string') {
246
- return value;
247
- }
248
- }
249
- return this.defaultCollectionName;
250
- }
251
- async runSchematic(options) {
252
- const { schematicOptions: input = {}, debug, dryRun } = options;
253
- let { collectionName, schematicName } = options;
254
- let nothingDone = true;
255
- let loggingQueue = [];
256
- let error = false;
257
- const workflow = this._workflow;
258
- // Get the option object from the schematic schema.
259
- const schematic = this.getSchematic(this.getCollection(collectionName), schematicName, this.allowPrivateSchematics);
260
- // Update the schematic and collection name in case they're not the same as the ones we
261
- // received in our options, e.g. after alias resolution or extension.
262
- collectionName = schematic.collection.description.name;
263
- schematicName = schematic.description.name;
264
- workflow.reporter.subscribe((event) => {
265
- nothingDone = false;
266
- // Strip leading slash to prevent confusion.
267
- const eventPath = event.path.startsWith('/') ? event.path.substr(1) : event.path;
268
- switch (event.kind) {
269
- case 'error':
270
- error = true;
271
- const desc = event.description == 'alreadyExist' ? 'already exists' : 'does not exist.';
272
- this.logger.warn(`ERROR! ${eventPath} ${desc}.`);
273
- break;
274
- case 'update':
275
- loggingQueue.push(core_1.tags.oneLine `
276
- ${color_1.colors.cyan('UPDATE')} ${eventPath} (${event.content.length} bytes)
277
- `);
278
- break;
279
- case 'create':
280
- loggingQueue.push(core_1.tags.oneLine `
281
- ${color_1.colors.green('CREATE')} ${eventPath} (${event.content.length} bytes)
282
- `);
283
- break;
284
- case 'delete':
285
- loggingQueue.push(`${color_1.colors.yellow('DELETE')} ${eventPath}`);
286
- break;
287
- case 'rename':
288
- const eventToPath = event.to.startsWith('/') ? event.to.substring(1) : event.to;
289
- loggingQueue.push(`${color_1.colors.blue('RENAME')} ${eventPath} => ${eventToPath}`);
290
- break;
291
- }
292
- });
293
- workflow.lifeCycle.subscribe((event) => {
294
- if (event.kind == 'end' || event.kind == 'post-tasks-start') {
295
- if (!error) {
296
- // Output the logging queue, no error happened.
297
- loggingQueue.forEach((log) => this.logger.info(log));
298
- }
299
- loggingQueue = [];
300
- error = false;
301
- }
302
- });
303
- // Temporary compatibility check for NPM 7
304
- if (collectionName === '@schematics/angular' && schematicName === 'ng-new') {
305
- if (!input.skipInstall &&
306
- (input.packageManager === undefined || input.packageManager === 'npm')) {
307
- await (0, package_manager_1.ensureCompatibleNpm)(this.context.root);
308
- }
309
- }
310
- return new Promise((resolve) => {
311
- workflow
312
- .execute({
313
- collection: collectionName,
314
- schematic: schematicName,
315
- options: input,
316
- debug: debug,
317
- logger: this.logger,
318
- allowPrivate: this.allowPrivateSchematics,
319
- })
320
- .subscribe({
321
- error: (err) => {
322
- // In case the workflow was not successful, show an appropriate error message.
323
- if (err instanceof schematics_1.UnsuccessfulWorkflowExecution) {
324
- // "See above" because we already printed the error.
325
- this.logger.fatal('The Schematic workflow failed. See above.');
326
- }
327
- else if (debug) {
328
- this.logger.fatal(`An error occurred:\n${err.message}\n${err.stack}`);
329
- }
330
- else {
331
- this.logger.fatal(err.message);
332
- }
333
- resolve(1);
334
- },
335
- complete: () => {
336
- const showNothingDone = !(options.showNothingDone === false);
337
- if (nothingDone && showNothingDone) {
338
- this.logger.info('Nothing to be done.');
339
- }
340
- if (dryRun) {
341
- this.logger.warn(`\nNOTE: The "dryRun" flag means no changes were made.`);
342
- }
343
- resolve();
344
- },
345
- });
346
- });
347
- }
348
- }
349
- exports.SchematicCommand = SchematicCommand;
350
- function getProjectsByPath(workspace, path, root) {
351
- if (workspace.projects.size === 1) {
352
- return Array.from(workspace.projects.keys());
353
- }
354
- const isInside = (base, potential) => {
355
- const absoluteBase = systemPath.resolve(root, base);
356
- const absolutePotential = systemPath.resolve(root, potential);
357
- const relativePotential = systemPath.relative(absoluteBase, absolutePotential);
358
- if (!relativePotential.startsWith('..') && !systemPath.isAbsolute(relativePotential)) {
359
- return true;
360
- }
361
- return false;
362
- };
363
- const projects = Array.from(workspace.projects.entries())
364
- .map(([name, project]) => [systemPath.resolve(root, project.root), name])
365
- .filter((tuple) => isInside(tuple[0], path))
366
- // Sort tuples by depth, with the deeper ones first. Since the first member is a path and
367
- // we filtered all invalid paths, the longest will be the deepest (and in case of equality
368
- // the sort is stable and the first declared project will win).
369
- .sort((a, b) => b[0].length - a[0].length);
370
- if (projects.length === 1) {
371
- return [projects[0][1]];
372
- }
373
- else if (projects.length > 1) {
374
- const firstPath = projects[0][0];
375
- return projects.filter((v) => v[0] === firstPath).map((v) => v[1]);
376
- }
377
- return [];
378
- }
@@ -1,22 +0,0 @@
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 { SchematicCommand } from '../../../models/schematic-command';
9
- import { Options } from '../../command-builder/command-module';
10
- import { AddCommandArgs } from './cli';
11
- declare type AddCommandOptions = Options<AddCommandArgs>;
12
- export declare class AddCommandModule extends SchematicCommand<AddCommandOptions> {
13
- readonly allowPrivateSchematics = true;
14
- run(options: AddCommandOptions): Promise<number | void>;
15
- private isProjectVersionValid;
16
- reportAnalytics(paths: string[], options: AddCommandOptions, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
17
- private isPackageInstalled;
18
- private executeSchematic;
19
- private findProjectVersion;
20
- private hasMismatchedPeer;
21
- }
22
- export {};