@angular/cli 12.0.0-rc.0 → 12.0.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/README.md +34 -30
- package/bin/ng +3 -3
- package/bin/postinstall/analytics-prompt.js +1 -1
- package/commands/add-impl.d.ts +7 -0
- package/commands/add-impl.js +18 -20
- package/commands/add.json +1 -2
- package/commands/add.md +1 -0
- package/commands/analytics-impl.d.ts +8 -1
- package/commands/analytics-impl.js +7 -7
- package/commands/analytics-long.md +8 -7
- package/commands/analytics.json +3 -15
- package/commands/build-impl.d.ts +1 -1
- package/commands/build-impl.js +3 -3
- package/commands/build.json +1 -1
- package/commands/config-impl.d.ts +2 -2
- package/commands/config-impl.js +16 -11
- package/commands/config-long.md +1 -1
- package/commands/config.json +1 -2
- package/commands/definitions.json +3 -5
- package/commands/deploy-impl.d.ts +1 -1
- package/commands/deploy-impl.js +3 -3
- package/commands/deploy-long.md +1 -1
- package/commands/deploy.json +1 -3
- package/commands/doc-impl.d.ts +1 -1
- package/commands/doc-impl.js +2 -2
- package/commands/doc.json +3 -4
- package/commands/e2e-impl.d.ts +1 -1
- package/commands/e2e-impl.js +1 -1
- package/commands/e2e-long.md +1 -1
- package/commands/e2e.json +1 -1
- package/commands/easter-egg-impl.d.ts +1 -1
- package/commands/easter-egg-impl.js +3 -3
- package/commands/easter-egg.json +1 -3
- package/commands/extract-i18n-impl.d.ts +1 -1
- package/commands/extract-i18n-impl.js +5 -4
- package/commands/generate-impl.d.ts +1 -1
- package/commands/generate-impl.js +9 -2
- package/commands/generate.json +2 -3
- package/commands/help-impl.d.ts +1 -1
- package/commands/help-impl.js +3 -3
- package/commands/help-long.md +5 -5
- package/commands/help.json +1 -3
- package/commands/lint-impl.d.ts +1 -1
- package/commands/lint-impl.js +3 -3
- package/commands/lint-long.md +1 -1
- package/commands/lint.json +1 -3
- package/commands/new-impl.d.ts +1 -1
- package/commands/new-impl.js +8 -1
- package/commands/new.json +3 -3
- package/commands/new.md +5 -5
- package/commands/run-impl.d.ts +1 -1
- package/commands/run-impl.js +1 -1
- package/commands/run-long.md +1 -1
- package/commands/run.json +2 -3
- package/commands/serve-impl.d.ts +2 -2
- package/commands/serve-impl.js +4 -4
- package/commands/serve.json +1 -1
- package/commands/test-impl.d.ts +1 -1
- package/commands/test-impl.js +1 -1
- package/commands/test-long.md +1 -1
- package/commands/test.json +1 -1
- package/commands/update-impl.d.ts +9 -2
- package/commands/update-impl.js +29 -23
- package/commands/update.d.ts +2 -1
- package/commands/update.json +1 -1
- package/commands/version-impl.d.ts +8 -0
- package/commands/version-impl.js +19 -6
- package/commands/version.json +2 -4
- package/lib/cli/index.d.ts +7 -0
- package/lib/cli/index.js +14 -16
- package/lib/config/schema.json +20 -12
- package/lib/config/workspace-schema.d.ts +4 -0
- package/lib/init.d.ts +1 -1
- package/lib/init.js +11 -10
- package/models/analytics-collector.d.ts +1 -2
- package/models/analytics-collector.js +7 -8
- package/models/analytics.d.ts +7 -0
- package/models/analytics.js +6 -8
- package/models/architect-command.d.ts +2 -2
- package/models/architect-command.js +10 -11
- package/models/command-runner.d.ts +1 -1
- package/models/command-runner.js +8 -7
- package/models/command.d.ts +3 -4
- package/models/command.js +17 -21
- package/models/error.d.ts +1 -1
- package/models/error.js +1 -1
- package/models/interface.d.ts +2 -2
- package/models/interface.js +7 -0
- package/models/parser.d.ts +1 -2
- package/models/parser.js +12 -15
- package/models/schematic-command.d.ts +1 -1
- package/models/schematic-command.js +48 -49
- package/models/schematic-engine-host.d.ts +1 -1
- package/models/schematic-engine-host.js +4 -4
- package/models/version.d.ts +1 -1
- package/models/version.js +1 -1
- package/package.json +14 -14
- package/src/commands/update/schematic/index.d.ts +7 -0
- package/src/commands/update/schematic/index.js +59 -56
- package/src/commands/update/schematic/npm-package-json.d.ts +1 -1
- package/src/commands/update/schematic/npm-package-json.js +7 -0
- package/src/commands/update/schematic/npm.d.ts +1 -1
- package/src/commands/update/schematic/npm.js +9 -4
- package/src/commands/update/schematic/package-json.d.ts +1 -1
- package/src/commands/update/schematic/package-json.js +1 -7
- package/src/commands/update/schematic/schema.json +2 -8
- package/utilities/color.d.ts +1 -1
- package/utilities/color.js +3 -3
- package/utilities/config.d.ts +1 -1
- package/utilities/config.js +24 -7
- package/utilities/find-up.d.ts +1 -1
- package/utilities/find-up.js +1 -1
- package/utilities/install-package.d.ts +7 -5
- package/utilities/install-package.js +37 -23
- package/utilities/json-file.d.ts +1 -1
- package/utilities/json-file.js +4 -4
- package/utilities/json-schema.d.ts +1 -1
- package/utilities/json-schema.js +30 -27
- package/utilities/log-file.d.ts +1 -1
- package/utilities/log-file.js +1 -1
- package/utilities/package-manager.d.ts +7 -0
- package/utilities/package-manager.js +5 -5
- package/utilities/package-metadata.d.ts +1 -1
- package/utilities/package-metadata.js +8 -1
- package/utilities/package-tree.d.ts +1 -1
- package/utilities/package-tree.js +1 -1
- package/utilities/project.d.ts +7 -0
- package/utilities/project.js +3 -3
- package/utilities/prompt.d.ts +7 -0
- package/utilities/prompt.js +3 -3
- package/utilities/spinner.d.ts +1 -1
- package/utilities/spinner.js +1 -1
- package/utilities/tty.d.ts +1 -1
- package/utilities/tty.js +1 -1
package/models/analytics.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSharedAnalytics = exports.getWorkspaceAnalytics = exports.hasWorkspaceAnalyticsConfiguration = exports.getGlobalAnalytics = exports.hasGlobalAnalyticsConfiguration = exports.promptProjectAnalytics = exports.promptGlobalAnalytics = exports.setAnalyticsConfig = exports.isPackageNameSafeForAnalytics = exports.analyticsPackageSafelist = exports.AnalyticsProperties = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.getSharedAnalytics = exports.getWorkspaceAnalytics = exports.hasWorkspaceAnalyticsConfiguration = exports.getGlobalAnalytics = exports.hasGlobalAnalyticsConfiguration = exports.promptProjectAnalytics = exports.promptGlobalAnalytics = exports.setAnalyticsConfig = exports.isPackageNameSafeForAnalytics = exports.analyticsPackageSafelist = exports.AnalyticsProperties = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const debug = require("debug");
|
|
13
13
|
const inquirer = require("inquirer");
|
|
@@ -16,7 +16,7 @@ const color_1 = require("../utilities/color");
|
|
|
16
16
|
const config_1 = require("../utilities/config");
|
|
17
17
|
const tty_1 = require("../utilities/tty");
|
|
18
18
|
const analytics_collector_1 = require("./analytics-collector");
|
|
19
|
-
|
|
19
|
+
/* eslint-disable no-console */
|
|
20
20
|
const analyticsDebug = debug('ng:analytics'); // Generate analytics, including settings and users.
|
|
21
21
|
let _defaultAngularCliPropertyCache;
|
|
22
22
|
exports.AnalyticsProperties = {
|
|
@@ -47,7 +47,7 @@ exports.analyticsPackageSafelist = [
|
|
|
47
47
|
'@schematics/angular',
|
|
48
48
|
];
|
|
49
49
|
function isPackageNameSafeForAnalytics(name) {
|
|
50
|
-
return exports.analyticsPackageSafelist.some(pattern => {
|
|
50
|
+
return exports.analyticsPackageSafelist.some((pattern) => {
|
|
51
51
|
if (typeof pattern == 'string') {
|
|
52
52
|
return pattern === name;
|
|
53
53
|
}
|
|
@@ -252,9 +252,7 @@ exports.getGlobalAnalytics = getGlobalAnalytics;
|
|
|
252
252
|
async function hasWorkspaceAnalyticsConfiguration() {
|
|
253
253
|
try {
|
|
254
254
|
const globalWorkspace = await config_1.getWorkspace('local');
|
|
255
|
-
const analyticsConfig = globalWorkspace
|
|
256
|
-
&& globalWorkspace.getCli()
|
|
257
|
-
&& globalWorkspace.getCli()['analytics'];
|
|
255
|
+
const analyticsConfig = globalWorkspace && globalWorkspace.getCli() && globalWorkspace.getCli()['analytics'];
|
|
258
256
|
if (analyticsConfig !== undefined) {
|
|
259
257
|
return true;
|
|
260
258
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
@@ -26,7 +26,7 @@ export declare abstract class ArchitectCommand<T extends ArchitectCommandOptions
|
|
|
26
26
|
missingTargetError: string | undefined;
|
|
27
27
|
initialize(options: T & Arguments): Promise<number | void>;
|
|
28
28
|
run(options: ArchitectCommandOptions & Arguments): Promise<number>;
|
|
29
|
-
protected runSingleTarget(target: Target, targetOptions: string[]): Promise<
|
|
29
|
+
protected runSingleTarget(target: Target, targetOptions: string[]): Promise<1 | 0>;
|
|
30
30
|
protected runArchitectTarget(options: ArchitectCommandOptions & Arguments): Promise<number>;
|
|
31
31
|
private getProjectNamesByTarget;
|
|
32
32
|
private _makeTargetSpecifier;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArchitectCommand = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ArchitectCommand = void 0;
|
|
11
11
|
const architect_1 = require("@angular-devkit/architect");
|
|
12
12
|
const node_1 = require("@angular-devkit/architect/node");
|
|
13
13
|
const core_1 = require("@angular-devkit/core");
|
|
@@ -25,7 +25,7 @@ class ArchitectCommand extends command_1.Command {
|
|
|
25
25
|
async initialize(options) {
|
|
26
26
|
this._registry = new core_1.json.schema.CoreSchemaRegistry();
|
|
27
27
|
this._registry.addPostTransform(core_1.json.schema.transforms.addUndefinedDefaults);
|
|
28
|
-
this._registry.useXDeprecatedProvider(msg => this.logger.warn(msg));
|
|
28
|
+
this._registry.useXDeprecatedProvider((msg) => this.logger.warn(msg));
|
|
29
29
|
if (!this.workspace) {
|
|
30
30
|
this.logger.fatal('A workspace is required for this command.');
|
|
31
31
|
return 1;
|
|
@@ -82,7 +82,7 @@ class ArchitectCommand extends command_1.Command {
|
|
|
82
82
|
const parsedOptions = parser_1.parseArguments([...commandLeftovers], optionDefs);
|
|
83
83
|
const builderLeftovers = parsedOptions['--'] || [];
|
|
84
84
|
leftoverMap.set(name, { optionDefs, parsedOptions });
|
|
85
|
-
potentialProjectNames = new Set(builderLeftovers.filter(x => potentialProjectNames.has(x)));
|
|
85
|
+
potentialProjectNames = new Set(builderLeftovers.filter((x) => potentialProjectNames.has(x)));
|
|
86
86
|
}
|
|
87
87
|
if (potentialProjectNames.size === 1) {
|
|
88
88
|
projectName = [...potentialProjectNames][0];
|
|
@@ -164,13 +164,13 @@ class ArchitectCommand extends command_1.Command {
|
|
|
164
164
|
const overrides = parser_1.parseArguments(targetOptions, targetOptionArray, this.logger);
|
|
165
165
|
const allowAdditionalProperties = typeof builderDesc.optionSchema === 'object' && builderDesc.optionSchema.additionalProperties;
|
|
166
166
|
if (overrides['--'] && !allowAdditionalProperties) {
|
|
167
|
-
(overrides['--'] || []).forEach(additional => {
|
|
167
|
+
(overrides['--'] || []).forEach((additional) => {
|
|
168
168
|
this.logger.fatal(`Unknown option: '${additional.split(/=/)[0]}'`);
|
|
169
169
|
});
|
|
170
170
|
return 1;
|
|
171
171
|
}
|
|
172
172
|
await this.reportAnalytics([this.description.name], {
|
|
173
|
-
...await this._architectHost.getOptionsForTarget(target),
|
|
173
|
+
...(await this._architectHost.getOptionsForTarget(target)),
|
|
174
174
|
...overrides,
|
|
175
175
|
});
|
|
176
176
|
const run = await this._architect.scheduleTarget(target, overrides, {
|
|
@@ -227,7 +227,7 @@ class ArchitectCommand extends command_1.Command {
|
|
|
227
227
|
}
|
|
228
228
|
getProjectNamesByTarget(targetName) {
|
|
229
229
|
const allProjectsForTargetName = [];
|
|
230
|
-
//
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
231
231
|
for (const [name, project] of this.workspace.projects) {
|
|
232
232
|
if (project.targets.has(targetName)) {
|
|
233
233
|
allProjectsForTargetName.push(name);
|
|
@@ -240,7 +240,7 @@ class ArchitectCommand extends command_1.Command {
|
|
|
240
240
|
else {
|
|
241
241
|
// For single target commands, we try the default project first,
|
|
242
242
|
// then the full list if it has a single project, then error out.
|
|
243
|
-
//
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
244
244
|
const maybeDefaultProject = this.workspace.extensions['defaultProject'];
|
|
245
245
|
if (maybeDefaultProject && allProjectsForTargetName.includes(maybeDefaultProject)) {
|
|
246
246
|
return [maybeDefaultProject];
|
|
@@ -269,8 +269,7 @@ class ArchitectCommand extends command_1.Command {
|
|
|
269
269
|
configuration = 'production';
|
|
270
270
|
}
|
|
271
271
|
if (commandOptions.configuration) {
|
|
272
|
-
configuration =
|
|
273
|
-
`${configuration ? `${configuration},` : ''}${commandOptions.configuration}`;
|
|
272
|
+
configuration = `${configuration ? `${configuration},` : ''}${commandOptions.configuration}`;
|
|
274
273
|
}
|
|
275
274
|
}
|
|
276
275
|
if (!project) {
|
package/models/command-runner.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runCommand = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.runCommand = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const fs_1 = require("fs");
|
|
13
13
|
const path_1 = require("path");
|
|
@@ -87,7 +87,9 @@ async function loadCommandDescription(name, path, registry) {
|
|
|
87
87
|
* @param commands The map of supported commands.
|
|
88
88
|
* @param options Additional options.
|
|
89
89
|
*/
|
|
90
|
-
async function runCommand(args, logger, workspace, commands = standardCommands, options = {
|
|
90
|
+
async function runCommand(args, logger, workspace, commands = standardCommands, options = {
|
|
91
|
+
currentDirectory: process.cwd(),
|
|
92
|
+
}) {
|
|
91
93
|
var _a;
|
|
92
94
|
// This registry is exclusively used for flattening schemas, and not for validating.
|
|
93
95
|
const registry = new core_1.schema.CoreSchemaRegistry([]);
|
|
@@ -151,7 +153,7 @@ async function runCommand(args, logger, workspace, commands = standardCommands,
|
|
|
151
153
|
for (const name of commandNames) {
|
|
152
154
|
const aliasDesc = await loadCommandDescription(name, commands[name], registry);
|
|
153
155
|
const aliases = aliasDesc.aliases;
|
|
154
|
-
if (aliases && aliases.some(alias => alias === commandName)) {
|
|
156
|
+
if (aliases && aliases.some((alias) => alias === commandName)) {
|
|
155
157
|
commandName = name;
|
|
156
158
|
description = aliasDesc;
|
|
157
159
|
break;
|
|
@@ -187,8 +189,7 @@ async function runCommand(args, logger, workspace, commands = standardCommands,
|
|
|
187
189
|
}
|
|
188
190
|
return map;
|
|
189
191
|
});
|
|
190
|
-
const analytics = options.analytics ||
|
|
191
|
-
(await _createAnalytics(!!workspace, description.name === 'update'));
|
|
192
|
+
const analytics = options.analytics || (await _createAnalytics(!!workspace, description.name === 'update'));
|
|
192
193
|
const context = {
|
|
193
194
|
workspace,
|
|
194
195
|
analytics,
|
package/models/command.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { analytics, logging } from '@angular-devkit/core';
|
|
9
9
|
import { AngularWorkspace } from '../utilities/config';
|
|
10
|
-
import { Arguments, CommandContext, CommandDescription, CommandDescriptionMap, CommandScope, Option
|
|
10
|
+
import { Arguments, CommandContext, CommandDescription, CommandDescriptionMap, CommandScope, Option } from './interface';
|
|
11
11
|
export interface BaseCommandOptions {
|
|
12
12
|
help?: boolean | string;
|
|
13
13
|
}
|
|
@@ -24,9 +24,8 @@ export declare abstract class Command<T extends BaseCommandOptions = BaseCommand
|
|
|
24
24
|
constructor(context: CommandContext, description: CommandDescription, logger: logging.Logger);
|
|
25
25
|
initialize(options: T & Arguments): Promise<number | void>;
|
|
26
26
|
printHelp(): Promise<number>;
|
|
27
|
-
printJsonHelp(
|
|
27
|
+
printJsonHelp(): Promise<number>;
|
|
28
28
|
protected printHelpUsage(): Promise<void>;
|
|
29
|
-
protected printHelpSubcommand(subcommand: SubCommandDescription): Promise<void>;
|
|
30
29
|
protected printHelpOptions(options?: Option[]): Promise<void>;
|
|
31
30
|
validateScope(scope?: CommandScope): Promise<void>;
|
|
32
31
|
reportAnalytics(paths: string[], options: Arguments, dimensions?: (boolean | number | string)[], metrics?: (boolean | number | string)[]): Promise<void>;
|
package/models/command.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Command = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Command = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const color_1 = require("../utilities/color");
|
|
13
13
|
const interface_1 = require("./interface");
|
|
@@ -30,34 +30,28 @@ class Command {
|
|
|
30
30
|
await this.printHelpOptions();
|
|
31
31
|
return 0;
|
|
32
32
|
}
|
|
33
|
-
async printJsonHelp(
|
|
34
|
-
const replacer = (key, value) => key === 'name'
|
|
35
|
-
? core_1.strings.dasherize(value)
|
|
36
|
-
: value;
|
|
33
|
+
async printJsonHelp() {
|
|
34
|
+
const replacer = (key, value) => key === 'name' ? core_1.strings.dasherize(value) : value;
|
|
37
35
|
this.logger.info(JSON.stringify(this.description, replacer, 2));
|
|
38
36
|
return 0;
|
|
39
37
|
}
|
|
40
38
|
async printHelpUsage() {
|
|
41
39
|
this.logger.info(this.description.description);
|
|
42
40
|
const name = this.description.name;
|
|
43
|
-
const args = this.description.options.filter(x => x.positional !== undefined);
|
|
44
|
-
const opts = this.description.options.filter(x => x.positional === undefined);
|
|
45
|
-
const argDisplay = args && args.length > 0 ? ' ' + args.map(a => `<${a.name}>`).join(' ') : '';
|
|
41
|
+
const args = this.description.options.filter((x) => x.positional !== undefined);
|
|
42
|
+
const opts = this.description.options.filter((x) => x.positional === undefined);
|
|
43
|
+
const argDisplay = args && args.length > 0 ? ' ' + args.map((a) => `<${a.name}>`).join(' ') : '';
|
|
46
44
|
const optionsDisplay = opts && opts.length > 0 ? ` [options]` : ``;
|
|
47
45
|
this.logger.info(`usage: ng ${name}${argDisplay}${optionsDisplay}`);
|
|
48
46
|
this.logger.info('');
|
|
49
47
|
}
|
|
50
|
-
async printHelpSubcommand(subcommand) {
|
|
51
|
-
this.logger.info(subcommand.description);
|
|
52
|
-
await this.printHelpOptions(subcommand.options);
|
|
53
|
-
}
|
|
54
48
|
async printHelpOptions(options = this.description.options) {
|
|
55
|
-
const args = options.filter(opt => opt.positional !== undefined);
|
|
56
|
-
const opts = options.filter(opt => opt.positional === undefined);
|
|
49
|
+
const args = options.filter((opt) => opt.positional !== undefined);
|
|
50
|
+
const opts = options.filter((opt) => opt.positional === undefined);
|
|
57
51
|
const formatDescription = (description) => ` ${description.replace(/\n/g, '\n ')}`;
|
|
58
52
|
if (args.length > 0) {
|
|
59
53
|
this.logger.info(`arguments:`);
|
|
60
|
-
args.forEach(o => {
|
|
54
|
+
args.forEach((o) => {
|
|
61
55
|
this.logger.info(` ${color_1.colors.cyan(o.name)}`);
|
|
62
56
|
if (o.description) {
|
|
63
57
|
this.logger.info(formatDescription(o.description));
|
|
@@ -70,11 +64,11 @@ class Command {
|
|
|
70
64
|
}
|
|
71
65
|
this.logger.info(`options:`);
|
|
72
66
|
opts
|
|
73
|
-
.filter(o => !o.hidden)
|
|
67
|
+
.filter((o) => !o.hidden)
|
|
74
68
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
75
|
-
.forEach(o => {
|
|
69
|
+
.forEach((o) => {
|
|
76
70
|
const aliases = o.aliases && o.aliases.length > 0
|
|
77
|
-
? '(' + o.aliases.map(a => `-${a}`).join(' ') + ')'
|
|
71
|
+
? '(' + o.aliases.map((a) => `-${a}`).join(' ') + ')'
|
|
78
72
|
: '';
|
|
79
73
|
this.logger.info(` ${color_1.colors.cyan('--' + core_1.strings.dasherize(o.name))} ${aliases}`);
|
|
80
74
|
if (o.description) {
|
|
@@ -91,6 +85,7 @@ class Command {
|
|
|
91
85
|
The ${this.description.name} command requires to be run outside of a project, but a
|
|
92
86
|
project definition was found at "${this.workspace.filePath}".
|
|
93
87
|
`);
|
|
88
|
+
// eslint-disable-next-line no-throw-literal
|
|
94
89
|
throw 1;
|
|
95
90
|
}
|
|
96
91
|
break;
|
|
@@ -100,6 +95,7 @@ class Command {
|
|
|
100
95
|
The ${this.description.name} command requires to be run in an Angular project, but a
|
|
101
96
|
project definition could not be found.
|
|
102
97
|
`);
|
|
98
|
+
// eslint-disable-next-line no-throw-literal
|
|
103
99
|
throw 1;
|
|
104
100
|
}
|
|
105
101
|
break;
|
|
@@ -130,7 +126,7 @@ class Command {
|
|
|
130
126
|
return this.printHelp();
|
|
131
127
|
}
|
|
132
128
|
else if (options.help === 'json' || options.help === 'JSON') {
|
|
133
|
-
return this.printJsonHelp(
|
|
129
|
+
return this.printJsonHelp();
|
|
134
130
|
}
|
|
135
131
|
else {
|
|
136
132
|
const startTime = +new Date();
|
package/models/error.d.ts
CHANGED
package/models/error.js
CHANGED
package/models/interface.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
@@ -128,7 +128,7 @@ export interface Option {
|
|
|
128
128
|
/**
|
|
129
129
|
* Deprecation. If this flag is not false a warning will be shown on the console. Either `true`
|
|
130
130
|
* or a string to show the user as a notice.
|
|
131
|
-
|
|
131
|
+
*/
|
|
132
132
|
deprecated?: boolean | string;
|
|
133
133
|
}
|
|
134
134
|
/**
|
package/models/interface.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.CommandScope = exports.OptionType = void 0;
|
|
4
11
|
/**
|
package/models/parser.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*
|
|
8
7
|
*/
|
|
9
8
|
import { BaseException, logging } from '@angular-devkit/core';
|
|
10
9
|
import { Arguments, Option } from './interface';
|
package/models/parser.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseArguments = exports.parseFreeFormArguments = exports.ParseArgumentException = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
|
-
*
|
|
11
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.parseArguments = exports.parseFreeFormArguments = exports.ParseArgumentException = void 0;
|
|
12
11
|
const core_1 = require("@angular-devkit/core");
|
|
13
12
|
const interface_1 = require("./interface");
|
|
14
13
|
class ParseArgumentException extends core_1.BaseException {
|
|
@@ -85,14 +84,12 @@ function _coerce(str, o, v) {
|
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
function _getOptionFromName(name, options) {
|
|
88
|
-
const camelName = /(-|_)/.test(name)
|
|
89
|
-
? core_1.strings.camelize(name)
|
|
90
|
-
: name;
|
|
87
|
+
const camelName = /(-|_)/.test(name) ? core_1.strings.camelize(name) : name;
|
|
91
88
|
for (const option of options) {
|
|
92
89
|
if (option.name === name || option.name === camelName) {
|
|
93
90
|
return option;
|
|
94
91
|
}
|
|
95
|
-
if (option.aliases.some(x => x === name || x === camelName)) {
|
|
92
|
+
if (option.aliases.some((x) => x === name || x === camelName)) {
|
|
96
93
|
return option;
|
|
97
94
|
}
|
|
98
95
|
}
|
|
@@ -102,7 +99,7 @@ function _removeLeadingDashes(key) {
|
|
|
102
99
|
const from = key.startsWith('--') ? 2 : key.startsWith('-') ? 1 : 0;
|
|
103
100
|
return key.substr(from);
|
|
104
101
|
}
|
|
105
|
-
function _assignOption(arg, nextArg, { options, parsedOptions, leftovers, ignored, errors, warnings }) {
|
|
102
|
+
function _assignOption(arg, nextArg, { options, parsedOptions, leftovers, ignored, errors, warnings, }) {
|
|
106
103
|
const from = arg.startsWith('--') ? 2 : 1;
|
|
107
104
|
let consumedNextArg = false;
|
|
108
105
|
let key = arg.substr(from);
|
|
@@ -162,9 +159,9 @@ function _assignOption(arg, nextArg, { options, parsedOptions, leftovers, ignore
|
|
|
162
159
|
if (v !== undefined) {
|
|
163
160
|
if (parsedOptions[option.name] !== v) {
|
|
164
161
|
if (parsedOptions[option.name] !== undefined && option.type !== interface_1.OptionType.Array) {
|
|
165
|
-
warnings.push(`Option ${JSON.stringify(option.name)} was already specified with value `
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
warnings.push(`Option ${JSON.stringify(option.name)} was already specified with value ` +
|
|
163
|
+
`${JSON.stringify(parsedOptions[option.name])}. The new value ${JSON.stringify(v)} ` +
|
|
164
|
+
`will override it.`);
|
|
168
165
|
}
|
|
169
166
|
parsedOptions[option.name] = v;
|
|
170
167
|
}
|
|
@@ -172,7 +169,7 @@ function _assignOption(arg, nextArg, { options, parsedOptions, leftovers, ignore
|
|
|
172
169
|
else {
|
|
173
170
|
let error = `Argument ${key} could not be parsed using value ${JSON.stringify(value)}.`;
|
|
174
171
|
if (option.enum) {
|
|
175
|
-
error += ` Valid values are: ${option.enum.map(x => JSON.stringify(x)).join(', ')}.`;
|
|
172
|
+
error += ` Valid values are: ${option.enum.map((x) => JSON.stringify(x)).join(', ')}.`;
|
|
176
173
|
}
|
|
177
174
|
else {
|
|
178
175
|
error += `Valid type(s) is: ${(option.types || [option.type]).join(', ')}`;
|
|
@@ -223,7 +220,7 @@ function parseFreeFormArguments(args) {
|
|
|
223
220
|
}
|
|
224
221
|
}
|
|
225
222
|
else if (arg.startsWith('-')) {
|
|
226
|
-
arg.split('').forEach(x => parsedOptions[x] = true);
|
|
223
|
+
arg.split('').forEach((x) => (parsedOptions[x] = true));
|
|
227
224
|
}
|
|
228
225
|
else {
|
|
229
226
|
leftovers.push(arg);
|
|
@@ -342,7 +339,7 @@ function parseArguments(args, options, logger) {
|
|
|
342
339
|
parsedOptions['--'] = [...positionals, ...leftovers];
|
|
343
340
|
}
|
|
344
341
|
if (warnings.length > 0 && logger) {
|
|
345
|
-
warnings.forEach(message => logger.warn(message));
|
|
342
|
+
warnings.forEach((message) => logger.warn(message));
|
|
346
343
|
}
|
|
347
344
|
if (errors.length > 0) {
|
|
348
345
|
throw new ParseArgumentException(errors, parsedOptions, ignored);
|