@angular/cli 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/lib/config/schema.json +18 -0
- package/lib/config/workspace-schema.d.ts +12 -0
- package/package.json +17 -17
- package/src/analytics/analytics.d.ts +1 -1
- package/src/analytics/analytics.js +22 -20
- package/src/command-builder/architect-base-command-module.d.ts +9 -2
- package/src/command-builder/architect-base-command-module.js +65 -3
- package/src/command-builder/architect-command-module.d.ts +4 -1
- package/src/command-builder/architect-command-module.js +37 -11
- package/src/command-builder/command-module.d.ts +1 -1
- package/src/command-builder/command-module.js +21 -7
- package/src/command-builder/command-runner.js +41 -30
- package/src/command-builder/schematics-command-module.d.ts +0 -3
- package/src/command-builder/schematics-command-module.js +21 -23
- package/src/command-builder/utilities/command.d.ts +1 -1
- package/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
- package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
- package/src/command-builder/utilities/schematic-engine-host.d.ts +2 -2
- package/src/command-builder/utilities/schematic-engine-host.js +33 -18
- package/src/commands/analytics/settings/cli.js +2 -2
- package/src/commands/cache/settings/cli.d.ts +2 -2
- package/src/commands/cache/settings/cli.js +2 -2
- package/src/commands/cache/utilities.d.ts +1 -1
- package/src/commands/cache/utilities.js +7 -8
- package/src/commands/completion/cli.d.ts +16 -0
- package/src/commands/completion/cli.js +61 -0
- package/src/commands/completion/long-description.md +5 -0
- package/src/commands/config/cli.js +15 -14
- package/src/commands/deploy/cli.d.ts +2 -1
- package/src/commands/deploy/cli.js +27 -13
- package/src/commands/e2e/cli.d.ts +2 -1
- package/src/commands/e2e/cli.js +14 -13
- package/src/commands/lint/cli.d.ts +2 -1
- package/src/commands/lint/cli.js +6 -9
- package/src/commands/new/cli.js +7 -2
- package/src/commands/run/cli.d.ts +2 -0
- package/src/commands/run/cli.js +24 -0
- package/src/commands/update/cli.js +3 -2
- package/src/utilities/completion.d.ts +22 -0
- package/src/utilities/completion.js +219 -0
- package/src/utilities/config.d.ts +4 -3
- package/src/utilities/config.js +11 -5
- package/src/utilities/environment-options.d.ts +1 -0
- package/src/utilities/environment-options.js +8 -1
- package/src/utilities/json-file.js +1 -0
- package/src/utilities/memoize.d.ts +15 -0
- package/src/utilities/memoize.js +69 -0
- package/src/utilities/package-manager.js +13 -2
- package/src/utilities/prompt.d.ts +2 -0
- package/src/utilities/prompt.js +18 -1
package/lib/config/schema.json
CHANGED
|
@@ -812,6 +812,12 @@
|
|
|
812
812
|
"alias": "t",
|
|
813
813
|
"x-user-analytics": 10
|
|
814
814
|
},
|
|
815
|
+
"standalone": {
|
|
816
|
+
"description": "Whether the generated component is standalone.",
|
|
817
|
+
"type": "boolean",
|
|
818
|
+
"default": false,
|
|
819
|
+
"x-user-analytics": 15
|
|
820
|
+
},
|
|
815
821
|
"viewEncapsulation": {
|
|
816
822
|
"description": "The view encapsulation strategy to use in the new component.",
|
|
817
823
|
"enum": [
|
|
@@ -964,6 +970,12 @@
|
|
|
964
970
|
"format": "html-selector",
|
|
965
971
|
"description": "The HTML selector to use for this directive."
|
|
966
972
|
},
|
|
973
|
+
"standalone": {
|
|
974
|
+
"description": "Whether the generated directive is standalone.",
|
|
975
|
+
"type": "boolean",
|
|
976
|
+
"default": false,
|
|
977
|
+
"x-user-analytics": 15
|
|
978
|
+
},
|
|
967
979
|
"flat": {
|
|
968
980
|
"type": "boolean",
|
|
969
981
|
"description": "When true (the default), creates the new files at the top level of the current project.",
|
|
@@ -1251,6 +1263,12 @@
|
|
|
1251
1263
|
"description": "Do not import this pipe into the owning NgModule.",
|
|
1252
1264
|
"x-user-analytics": 18
|
|
1253
1265
|
},
|
|
1266
|
+
"standalone": {
|
|
1267
|
+
"description": "Whether the generated pipe is standalone.",
|
|
1268
|
+
"type": "boolean",
|
|
1269
|
+
"default": false,
|
|
1270
|
+
"x-user-analytics": 15
|
|
1271
|
+
},
|
|
1254
1272
|
"module": {
|
|
1255
1273
|
"type": "string",
|
|
1256
1274
|
"description": "The declaring NgModule.",
|
|
@@ -292,6 +292,10 @@ export interface AngularComponentOptionsSchema {
|
|
|
292
292
|
* Do not create "spec.ts" test files for the new component.
|
|
293
293
|
*/
|
|
294
294
|
skipTests?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Whether the generated component is standalone.
|
|
297
|
+
*/
|
|
298
|
+
standalone?: boolean;
|
|
295
299
|
/**
|
|
296
300
|
* The file extension or preprocessor to use for style files, or 'none' to skip generating
|
|
297
301
|
* the style file.
|
|
@@ -369,6 +373,10 @@ export interface AngularDirectiveOptionsSchema {
|
|
|
369
373
|
* Do not create "spec.ts" test files for the new class.
|
|
370
374
|
*/
|
|
371
375
|
skipTests?: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Whether the generated directive is standalone.
|
|
378
|
+
*/
|
|
379
|
+
standalone?: boolean;
|
|
372
380
|
}
|
|
373
381
|
/**
|
|
374
382
|
* Generates a new, generic enum definition for the given or default project.
|
|
@@ -640,6 +648,10 @@ export interface AngularPipeOptionsSchema {
|
|
|
640
648
|
* Do not create "spec.ts" test files for the new pipe.
|
|
641
649
|
*/
|
|
642
650
|
skipTests?: boolean;
|
|
651
|
+
/**
|
|
652
|
+
* Whether the generated pipe is standalone.
|
|
653
|
+
*/
|
|
654
|
+
standalone?: boolean;
|
|
643
655
|
}
|
|
644
656
|
/**
|
|
645
657
|
* Generates a new, generic resolver definition in the given or default project.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/cli",
|
|
3
|
-
"version": "14.0.0-
|
|
3
|
+
"version": "14.0.0-rc.0",
|
|
4
4
|
"description": "CLI tool for Angular",
|
|
5
5
|
"main": "lib/cli/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,36 +25,36 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/angular/angular-cli",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@angular-devkit/architect": "0.1400.0-
|
|
29
|
-
"@angular-devkit/core": "14.0.0-
|
|
30
|
-
"@angular-devkit/schematics": "14.0.0-
|
|
31
|
-
"@schematics/angular": "14.0.0-
|
|
28
|
+
"@angular-devkit/architect": "0.1400.0-rc.0",
|
|
29
|
+
"@angular-devkit/core": "14.0.0-rc.0",
|
|
30
|
+
"@angular-devkit/schematics": "14.0.0-rc.0",
|
|
31
|
+
"@schematics/angular": "14.0.0-rc.0",
|
|
32
32
|
"@yarnpkg/lockfile": "1.1.0",
|
|
33
33
|
"ansi-colors": "4.1.1",
|
|
34
34
|
"debug": "4.3.4",
|
|
35
|
-
"ini": "
|
|
36
|
-
"inquirer": "8.2.
|
|
35
|
+
"ini": "3.0.0",
|
|
36
|
+
"inquirer": "8.2.4",
|
|
37
37
|
"jsonc-parser": "3.0.0",
|
|
38
38
|
"npm-package-arg": "9.0.2",
|
|
39
|
-
"npm-pick-manifest": "7.0.
|
|
39
|
+
"npm-pick-manifest": "7.0.1",
|
|
40
40
|
"open": "8.4.0",
|
|
41
41
|
"ora": "5.4.1",
|
|
42
|
-
"pacote": "13.0
|
|
42
|
+
"pacote": "13.3.0",
|
|
43
43
|
"resolve": "1.22.0",
|
|
44
|
-
"semver": "7.3.
|
|
44
|
+
"semver": "7.3.7",
|
|
45
45
|
"symbol-observable": "4.0.0",
|
|
46
46
|
"uuid": "8.3.2",
|
|
47
|
-
"yargs": "17.4.
|
|
47
|
+
"yargs": "17.4.1"
|
|
48
48
|
},
|
|
49
49
|
"ng-update": {
|
|
50
50
|
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
|
51
51
|
"packageGroup": {
|
|
52
|
-
"@angular/cli": "14.0.0-
|
|
53
|
-
"@angular-devkit/architect": "0.1400.0-
|
|
54
|
-
"@angular-devkit/build-angular": "14.0.0-
|
|
55
|
-
"@angular-devkit/build-webpack": "0.1400.0-
|
|
56
|
-
"@angular-devkit/core": "14.0.0-
|
|
57
|
-
"@angular-devkit/schematics": "14.0.0-
|
|
52
|
+
"@angular/cli": "14.0.0-rc.0",
|
|
53
|
+
"@angular-devkit/architect": "0.1400.0-rc.0",
|
|
54
|
+
"@angular-devkit/build-angular": "14.0.0-rc.0",
|
|
55
|
+
"@angular-devkit/build-webpack": "0.1400.0-rc.0",
|
|
56
|
+
"@angular-devkit/core": "14.0.0-rc.0",
|
|
57
|
+
"@angular-devkit/schematics": "14.0.0-rc.0"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
@@ -22,7 +22,7 @@ export declare function isPackageNameSafeForAnalytics(name: string): boolean;
|
|
|
22
22
|
* @param global Which config to use. "global" for user-level, and "local" for project-level.
|
|
23
23
|
* @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
|
|
24
24
|
*/
|
|
25
|
-
export declare function setAnalyticsConfig(global: boolean, value: string | boolean): void
|
|
25
|
+
export declare function setAnalyticsConfig(global: boolean, value: string | boolean): Promise<void>;
|
|
26
26
|
/**
|
|
27
27
|
* Prompt the user for usage gathering permission.
|
|
28
28
|
* @param force Whether to ask regardless of whether or not the user is using an interactive shell.
|
|
@@ -87,22 +87,21 @@ exports.isPackageNameSafeForAnalytics = isPackageNameSafeForAnalytics;
|
|
|
87
87
|
* @param global Which config to use. "global" for user-level, and "local" for project-level.
|
|
88
88
|
* @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
|
|
89
89
|
*/
|
|
90
|
-
function setAnalyticsConfig(global, value) {
|
|
90
|
+
async function setAnalyticsConfig(global, value) {
|
|
91
|
+
var _a;
|
|
92
|
+
var _b;
|
|
91
93
|
const level = global ? 'global' : 'local';
|
|
92
94
|
analyticsDebug('setting %s level analytics to: %s', level, value);
|
|
93
|
-
const
|
|
94
|
-
if (!
|
|
95
|
+
const workspace = await (0, config_1.getWorkspace)(level);
|
|
96
|
+
if (!workspace) {
|
|
95
97
|
throw new Error(`Could not find ${level} workspace.`);
|
|
96
98
|
}
|
|
97
|
-
const cli =
|
|
98
|
-
if (
|
|
99
|
-
throw new Error(`Invalid config found at ${
|
|
100
|
-
}
|
|
101
|
-
if (value === true) {
|
|
102
|
-
value = (0, uuid_1.v4)();
|
|
99
|
+
const cli = ((_a = (_b = workspace.extensions)['cli']) !== null && _a !== void 0 ? _a : (_b['cli'] = {}));
|
|
100
|
+
if (!workspace || !core_1.json.isJsonObject(cli)) {
|
|
101
|
+
throw new Error(`Invalid config found at ${workspace.filePath}. CLI should be an object.`);
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
cli.analytics = value === true ? (0, uuid_1.v4)() : value;
|
|
104
|
+
await workspace.save();
|
|
106
105
|
analyticsDebug('done');
|
|
107
106
|
}
|
|
108
107
|
exports.setAnalyticsConfig = setAnalyticsConfig;
|
|
@@ -114,8 +113,8 @@ exports.setAnalyticsConfig = setAnalyticsConfig;
|
|
|
114
113
|
async function promptAnalytics(global, force = false) {
|
|
115
114
|
analyticsDebug('prompting user');
|
|
116
115
|
const level = global ? 'global' : 'local';
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
116
|
+
const workspace = await (0, config_1.getWorkspace)(level);
|
|
117
|
+
if (!workspace) {
|
|
119
118
|
throw new Error(`Could not find a ${level} workspace. Are you in a project?`);
|
|
120
119
|
}
|
|
121
120
|
if (force || (0, tty_1.isTTY)()) {
|
|
@@ -133,7 +132,7 @@ async function promptAnalytics(global, force = false) {
|
|
|
133
132
|
default: false,
|
|
134
133
|
},
|
|
135
134
|
]);
|
|
136
|
-
setAnalyticsConfig(global, answers.analytics);
|
|
135
|
+
await setAnalyticsConfig(global, answers.analytics);
|
|
137
136
|
if (answers.analytics) {
|
|
138
137
|
console.log('');
|
|
139
138
|
console.log(core_1.tags.stripIndent `
|
|
@@ -169,6 +168,7 @@ exports.promptAnalytics = promptAnalytics;
|
|
|
169
168
|
* - `undefined` when not configured.
|
|
170
169
|
*/
|
|
171
170
|
async function getAnalytics(level) {
|
|
171
|
+
var _a;
|
|
172
172
|
analyticsDebug('getAnalytics');
|
|
173
173
|
if (environment_options_1.analyticsDisabled) {
|
|
174
174
|
analyticsDebug('NG_CLI_ANALYTICS is false');
|
|
@@ -176,7 +176,7 @@ async function getAnalytics(level) {
|
|
|
176
176
|
}
|
|
177
177
|
try {
|
|
178
178
|
const workspace = await (0, config_1.getWorkspace)(level);
|
|
179
|
-
const analyticsConfig = workspace === null || workspace === void 0 ? void 0 : workspace.getCli()['analytics'];
|
|
179
|
+
const analyticsConfig = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.getCli()) === null || _a === void 0 ? void 0 : _a['analytics'];
|
|
180
180
|
analyticsDebug('Workspace Analytics config found: %j', analyticsConfig);
|
|
181
181
|
if (analyticsConfig === false) {
|
|
182
182
|
return new core_1.analytics.NoopAnalytics();
|
|
@@ -210,6 +210,7 @@ exports.getAnalytics = getAnalytics;
|
|
|
210
210
|
* or undefined if no sharing.
|
|
211
211
|
*/
|
|
212
212
|
async function getSharedAnalytics() {
|
|
213
|
+
var _a;
|
|
213
214
|
analyticsDebug('getSharedAnalytics');
|
|
214
215
|
if (environment_options_1.analyticsShareDisabled) {
|
|
215
216
|
analyticsDebug('NG_CLI_ANALYTICS is false');
|
|
@@ -218,7 +219,7 @@ async function getSharedAnalytics() {
|
|
|
218
219
|
// If anything happens we just keep the NOOP analytics.
|
|
219
220
|
try {
|
|
220
221
|
const globalWorkspace = await (0, config_1.getWorkspace)('global');
|
|
221
|
-
const analyticsConfig = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()['analyticsSharing'];
|
|
222
|
+
const analyticsConfig = (_a = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()) === null || _a === void 0 ? void 0 : _a['analyticsSharing'];
|
|
222
223
|
if (!analyticsConfig || !analyticsConfig.tracking || !analyticsConfig.uuid) {
|
|
223
224
|
return undefined;
|
|
224
225
|
}
|
|
@@ -288,10 +289,11 @@ function analyticsConfigValueToHumanFormat(value) {
|
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
291
|
async function getAnalyticsInfoString() {
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
const
|
|
294
|
-
const
|
|
292
|
+
var _a, _b;
|
|
293
|
+
const globalWorkspace = await (0, config_1.getWorkspace)('global');
|
|
294
|
+
const localWorkspace = await (0, config_1.getWorkspace)('local');
|
|
295
|
+
const globalSetting = (_a = globalWorkspace === null || globalWorkspace === void 0 ? void 0 : globalWorkspace.getCli()) === null || _a === void 0 ? void 0 : _a['analytics'];
|
|
296
|
+
const localSetting = (_b = localWorkspace === null || localWorkspace === void 0 ? void 0 : localWorkspace.getCli()) === null || _b === void 0 ? void 0 : _b['analytics'];
|
|
295
297
|
const analyticsInstance = await createAnalytics(!!localWorkspace /** workspace */, true /** skipPrompt */);
|
|
296
298
|
return (core_1.tags.stripIndents `
|
|
297
299
|
Global setting: ${analyticsConfigValueToHumanFormat(globalSetting)}
|
|
@@ -9,10 +9,14 @@ import { Architect, Target } from '@angular-devkit/architect';
|
|
|
9
9
|
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
|
|
10
10
|
import { CommandModule, CommandModuleImplementation, CommandScope, OtherOptions } from './command-module';
|
|
11
11
|
import { Option } from './utilities/json-schema';
|
|
12
|
-
export
|
|
12
|
+
export interface MissingTargetChoice {
|
|
13
|
+
name: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class ArchitectBaseCommandModule<T extends object> extends CommandModule<T> implements CommandModuleImplementation<T> {
|
|
13
17
|
static scope: CommandScope;
|
|
14
18
|
protected shouldReportAnalytics: boolean;
|
|
15
|
-
protected readonly
|
|
19
|
+
protected readonly missingTargetChoices: MissingTargetChoice[] | undefined;
|
|
16
20
|
protected runSingleTarget(target: Target, options: OtherOptions): Promise<number>;
|
|
17
21
|
private _architectHost;
|
|
18
22
|
protected getArchitectHost(): WorkspaceNodeModulesArchitectHost;
|
|
@@ -20,4 +24,7 @@ export declare abstract class ArchitectBaseCommandModule<T> extends CommandModul
|
|
|
20
24
|
protected getArchitect(): Architect;
|
|
21
25
|
protected getArchitectTargetOptions(target: Target): Promise<Option[]>;
|
|
22
26
|
private warnOnMissingNodeModules;
|
|
27
|
+
protected getArchitectTarget(): string;
|
|
28
|
+
protected onMissingTarget(defaultMessage: string): Promise<1>;
|
|
29
|
+
private getMissingTargetPackageToInstall;
|
|
23
30
|
}
|
|
@@ -11,9 +11,12 @@ exports.ArchitectBaseCommandModule = 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");
|
|
14
|
+
const child_process_1 = require("child_process");
|
|
14
15
|
const fs_1 = require("fs");
|
|
15
16
|
const path_1 = require("path");
|
|
16
17
|
const analytics_1 = require("../analytics/analytics");
|
|
18
|
+
const prompt_1 = require("../utilities/prompt");
|
|
19
|
+
const tty_1 = require("../utilities/tty");
|
|
17
20
|
const command_module_1 = require("./command-module");
|
|
18
21
|
const json_schema_1 = require("./utilities/json-schema");
|
|
19
22
|
class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
@@ -22,14 +25,13 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
|
22
25
|
this.shouldReportAnalytics = false;
|
|
23
26
|
}
|
|
24
27
|
async runSingleTarget(target, options) {
|
|
25
|
-
var _a;
|
|
26
28
|
const architectHost = await this.getArchitectHost();
|
|
27
29
|
let builderName;
|
|
28
30
|
try {
|
|
29
31
|
builderName = await architectHost.getBuilderNameForTarget(target);
|
|
30
32
|
}
|
|
31
33
|
catch (e) {
|
|
32
|
-
|
|
34
|
+
return this.onMissingTarget(e.message);
|
|
33
35
|
}
|
|
34
36
|
await this.reportAnalytics({
|
|
35
37
|
...(await architectHost.getOptionsForTarget(target)),
|
|
@@ -66,7 +68,13 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
|
66
68
|
}
|
|
67
69
|
async getArchitectTargetOptions(target) {
|
|
68
70
|
const architectHost = this.getArchitectHost();
|
|
69
|
-
|
|
71
|
+
let builderConf;
|
|
72
|
+
try {
|
|
73
|
+
builderConf = await architectHost.getBuilderNameForTarget(target);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
70
78
|
let builderDesc;
|
|
71
79
|
try {
|
|
72
80
|
builderDesc = await architectHost.resolveBuilder(builderConf);
|
|
@@ -98,6 +106,60 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
|
98
106
|
}
|
|
99
107
|
this.context.logger.warn(`Node packages may not be installed. Try installing with '${this.context.packageManager} install'.`);
|
|
100
108
|
}
|
|
109
|
+
getArchitectTarget() {
|
|
110
|
+
return this.commandName;
|
|
111
|
+
}
|
|
112
|
+
async onMissingTarget(defaultMessage) {
|
|
113
|
+
const { logger } = this.context;
|
|
114
|
+
const choices = this.missingTargetChoices;
|
|
115
|
+
if (!(choices === null || choices === void 0 ? void 0 : choices.length)) {
|
|
116
|
+
logger.error(defaultMessage);
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
const missingTargetMessage = `Cannot find "${this.getArchitectTarget()}" target for the specified project.\n` +
|
|
120
|
+
`You can add a package that implements these capabilities.\n\n` +
|
|
121
|
+
`For example:\n` +
|
|
122
|
+
choices.map(({ name, value }) => ` ${name}: ng add ${value}`).join('\n') +
|
|
123
|
+
'\n';
|
|
124
|
+
if ((0, tty_1.isTTY)()) {
|
|
125
|
+
// Use prompts to ask the user if they'd like to install a package.
|
|
126
|
+
logger.warn(missingTargetMessage);
|
|
127
|
+
const packageToInstall = await this.getMissingTargetPackageToInstall(choices);
|
|
128
|
+
if (packageToInstall) {
|
|
129
|
+
// Example run: `ng add @angular-eslint/schematics`.
|
|
130
|
+
const binPath = (0, path_1.resolve)(__dirname, '../../bin/ng.js');
|
|
131
|
+
const { error } = (0, child_process_1.spawnSync)(process.execPath, [binPath, 'add', packageToInstall], {
|
|
132
|
+
stdio: 'inherit',
|
|
133
|
+
});
|
|
134
|
+
if (error) {
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Non TTY display error message.
|
|
141
|
+
logger.error(missingTargetMessage);
|
|
142
|
+
}
|
|
143
|
+
return 1;
|
|
144
|
+
}
|
|
145
|
+
async getMissingTargetPackageToInstall(choices) {
|
|
146
|
+
if (choices.length === 1) {
|
|
147
|
+
// Single choice
|
|
148
|
+
const { name, value } = choices[0];
|
|
149
|
+
if (await (0, prompt_1.askConfirmation)(`Would you like to add ${name} now?`, true, false)) {
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
// Multiple choice
|
|
155
|
+
return (0, prompt_1.askQuestion)(`Would you like to add a package with "${this.getArchitectTarget()}" capabilities now?`, [
|
|
156
|
+
{
|
|
157
|
+
name: 'No',
|
|
158
|
+
value: null,
|
|
159
|
+
},
|
|
160
|
+
...choices,
|
|
161
|
+
], 0, null);
|
|
162
|
+
}
|
|
101
163
|
}
|
|
102
164
|
exports.ArchitectBaseCommandModule = ArchitectBaseCommandModule;
|
|
103
165
|
ArchitectBaseCommandModule.scope = command_module_1.CommandScope.In;
|
|
@@ -17,6 +17,9 @@ export declare abstract class ArchitectCommandModule extends ArchitectBaseComman
|
|
|
17
17
|
builder(argv: Argv): Promise<Argv<ArchitectCommandArgs>>;
|
|
18
18
|
run(options: Options<ArchitectCommandArgs> & OtherOptions): Promise<number | void>;
|
|
19
19
|
private getArchitectProject;
|
|
20
|
-
private getArchitectTarget;
|
|
21
20
|
private getProjectNamesByTarget;
|
|
21
|
+
/** @returns a sorted list of project names to be used for auto completion. */
|
|
22
|
+
private getProjectChoices;
|
|
23
|
+
/** @returns a sorted list of configuration names to be used for auto completion. */
|
|
24
|
+
private getConfigurationChoices;
|
|
22
25
|
}
|
|
@@ -6,17 +6,27 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
};
|
|
9
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
16
|
exports.ArchitectCommandModule = void 0;
|
|
11
17
|
const config_1 = require("../utilities/config");
|
|
18
|
+
const memoize_1 = require("../utilities/memoize");
|
|
12
19
|
const architect_base_command_module_1 = require("./architect-base-command-module");
|
|
13
|
-
const command_module_1 = require("./command-module");
|
|
14
20
|
class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
|
|
15
21
|
async builder(argv) {
|
|
22
|
+
const project = this.getArchitectProject();
|
|
23
|
+
const { jsonHelp, getYargsCompletions, help } = this.context.args.options;
|
|
16
24
|
const localYargs = argv
|
|
17
25
|
.positional('project', {
|
|
18
26
|
describe: 'The name of the project to build. Can be an application or a library.',
|
|
19
27
|
type: 'string',
|
|
28
|
+
// Hide choices from JSON help so that we don't display them in AIO.
|
|
29
|
+
choices: jsonHelp ? undefined : this.getProjectChoices(),
|
|
20
30
|
})
|
|
21
31
|
.option('configuration', {
|
|
22
32
|
describe: `One or more named builder configurations as a comma-separated ` +
|
|
@@ -25,9 +35,13 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
25
35
|
`For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.`,
|
|
26
36
|
alias: 'c',
|
|
27
37
|
type: 'string',
|
|
38
|
+
// Show only in when using --help and auto completion because otherwise comma seperated configuration values will be invalid.
|
|
39
|
+
// Also, hide choices from JSON help so that we don't display them in AIO.
|
|
40
|
+
choices: (getYargsCompletions || help) && !jsonHelp && project
|
|
41
|
+
? this.getConfigurationChoices(project)
|
|
42
|
+
: undefined,
|
|
28
43
|
})
|
|
29
44
|
.strict();
|
|
30
|
-
const project = this.getArchitectProject();
|
|
31
45
|
if (!project) {
|
|
32
46
|
return localYargs;
|
|
33
47
|
}
|
|
@@ -39,7 +53,6 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
39
53
|
return this.addSchemaOptionsToCommand(localYargs, schemaOptions);
|
|
40
54
|
}
|
|
41
55
|
async run(options) {
|
|
42
|
-
var _a;
|
|
43
56
|
const target = this.getArchitectTarget();
|
|
44
57
|
const { configuration = '', project, ...architectOptions } = options;
|
|
45
58
|
if (!project) {
|
|
@@ -48,7 +61,7 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
48
61
|
let result = 0;
|
|
49
62
|
const projectNames = this.getProjectNamesByTarget(target);
|
|
50
63
|
if (!projectNames) {
|
|
51
|
-
|
|
64
|
+
return this.onMissingTarget('Cannot determine project or target for command.');
|
|
52
65
|
}
|
|
53
66
|
for (const project of projectNames) {
|
|
54
67
|
result |= await this.runSingleTarget({ configuration, target, project }, architectOptions);
|
|
@@ -66,18 +79,12 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
66
79
|
}
|
|
67
80
|
const [, projectName] = this.context.args.positional;
|
|
68
81
|
if (projectName) {
|
|
69
|
-
|
|
70
|
-
throw new command_module_1.CommandModuleError(`Project '${projectName}' does not exist.`);
|
|
71
|
-
}
|
|
72
|
-
return projectName;
|
|
82
|
+
return workspace.projects.has(projectName) ? projectName : undefined;
|
|
73
83
|
}
|
|
74
84
|
const target = this.getArchitectTarget();
|
|
75
85
|
const projectFromTarget = this.getProjectNamesByTarget(target);
|
|
76
86
|
return (projectFromTarget === null || projectFromTarget === void 0 ? void 0 : projectFromTarget.length) ? projectFromTarget[0] : undefined;
|
|
77
87
|
}
|
|
78
|
-
getArchitectTarget() {
|
|
79
|
-
return this.commandName;
|
|
80
|
-
}
|
|
81
88
|
getProjectNamesByTarget(target) {
|
|
82
89
|
const workspace = this.getWorkspaceOrThrow();
|
|
83
90
|
const allProjectsForTargetName = [];
|
|
@@ -104,5 +111,24 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
104
111
|
}
|
|
105
112
|
return undefined;
|
|
106
113
|
}
|
|
114
|
+
/** @returns a sorted list of project names to be used for auto completion. */
|
|
115
|
+
getProjectChoices() {
|
|
116
|
+
const { workspace } = this.context;
|
|
117
|
+
return workspace ? [...workspace.projects.keys()].sort() : undefined;
|
|
118
|
+
}
|
|
119
|
+
/** @returns a sorted list of configuration names to be used for auto completion. */
|
|
120
|
+
getConfigurationChoices(project) {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
const projectDefinition = (_a = this.context.workspace) === null || _a === void 0 ? void 0 : _a.projects.get(project);
|
|
123
|
+
if (!projectDefinition) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const target = this.getArchitectTarget();
|
|
127
|
+
const configurations = (_b = projectDefinition.targets.get(target)) === null || _b === void 0 ? void 0 : _b.configurations;
|
|
128
|
+
return configurations ? Object.keys(configurations).sort() : undefined;
|
|
129
|
+
}
|
|
107
130
|
}
|
|
131
|
+
__decorate([
|
|
132
|
+
memoize_1.memoize
|
|
133
|
+
], ArchitectCommandModule.prototype, "getProjectNamesByTarget", null);
|
|
108
134
|
exports.ArchitectCommandModule = ArchitectCommandModule;
|
|
@@ -34,6 +34,7 @@ export interface CommandContext {
|
|
|
34
34
|
options: {
|
|
35
35
|
help: boolean;
|
|
36
36
|
jsonHelp: boolean;
|
|
37
|
+
getYargsCompletions: boolean;
|
|
37
38
|
} & Record<string, unknown>;
|
|
38
39
|
};
|
|
39
40
|
}
|
|
@@ -72,7 +73,6 @@ export declare abstract class CommandModule<T extends {} = {}> implements Comman
|
|
|
72
73
|
abstract run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
|
|
73
74
|
handler(args: ArgumentsCamelCase<T> & OtherOptions): Promise<void>;
|
|
74
75
|
reportAnalytics(options: (Options<T> & OtherOptions) | OtherOptions, paths?: string[], dimensions?: (boolean | number | string)[]): Promise<void>;
|
|
75
|
-
private _analytics;
|
|
76
76
|
protected getAnalytics(): Promise<analytics.Analytics>;
|
|
77
77
|
/**
|
|
78
78
|
* Adds schema options to a command also this keeps track of options that are required for analytics.
|
|
@@ -22,6 +22,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
26
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
+
};
|
|
25
31
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
32
|
if (mod && mod.__esModule) return mod;
|
|
27
33
|
var result = {};
|
|
@@ -36,6 +42,8 @@ const fs_1 = require("fs");
|
|
|
36
42
|
const path = __importStar(require("path"));
|
|
37
43
|
const helpers_1 = require("yargs/helpers");
|
|
38
44
|
const analytics_1 = require("../analytics/analytics");
|
|
45
|
+
const completion_1 = require("../utilities/completion");
|
|
46
|
+
const memoize_1 = require("../utilities/memoize");
|
|
39
47
|
var CommandScope;
|
|
40
48
|
(function (CommandScope) {
|
|
41
49
|
/** Command can only run inside an Angular workspace. */
|
|
@@ -82,6 +90,12 @@ class CommandModule {
|
|
|
82
90
|
for (const [key, value] of Object.entries(options)) {
|
|
83
91
|
camelCasedOptions[helpers_1.Parser.camelCase(key)] = value;
|
|
84
92
|
}
|
|
93
|
+
// Set up autocompletion if appropriate.
|
|
94
|
+
const autocompletionExitCode = await (0, completion_1.considerSettingUpAutocompletion)(this.commandName, this.context.logger);
|
|
95
|
+
if (autocompletionExitCode !== undefined) {
|
|
96
|
+
process.exitCode = autocompletionExitCode;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
85
99
|
// Gather and report analytics.
|
|
86
100
|
const analytics = await this.getAnalytics();
|
|
87
101
|
if (this.shouldReportAnalytics) {
|
|
@@ -124,13 +138,10 @@ class CommandModule {
|
|
|
124
138
|
metrics: [],
|
|
125
139
|
});
|
|
126
140
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return this._analytics;
|
|
130
|
-
}
|
|
131
|
-
return (this._analytics = await (0, analytics_1.createAnalytics)(!!this.context.workspace,
|
|
141
|
+
getAnalytics() {
|
|
142
|
+
return (0, analytics_1.createAnalytics)(!!this.context.workspace,
|
|
132
143
|
// Don't prompt for `ng update` and `ng analytics` commands.
|
|
133
|
-
['update', 'analytics'].includes(this.commandName))
|
|
144
|
+
['update', 'analytics'].includes(this.commandName));
|
|
134
145
|
}
|
|
135
146
|
/**
|
|
136
147
|
* Adds schema options to a command also this keeps track of options that are required for analytics.
|
|
@@ -180,8 +191,11 @@ class CommandModule {
|
|
|
180
191
|
return workspace;
|
|
181
192
|
}
|
|
182
193
|
}
|
|
183
|
-
exports.CommandModule = CommandModule;
|
|
184
194
|
CommandModule.scope = CommandScope.Both;
|
|
195
|
+
__decorate([
|
|
196
|
+
memoize_1.memoize
|
|
197
|
+
], CommandModule.prototype, "getAnalytics", null);
|
|
198
|
+
exports.CommandModule = CommandModule;
|
|
185
199
|
/**
|
|
186
200
|
* Creates an known command module error.
|
|
187
201
|
* This is used so during executation we can filter between known validation error and real non handled errors.
|