@angular/cli 14.0.0-next.8 → 14.0.0-next.9
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/package.json +15 -15
- package/src/analytics/analytics.d.ts +1 -1
- package/src/analytics/analytics.js +22 -20
- package/src/command-builder/architect-base-command-module.js +7 -1
- package/src/command-builder/architect-command-module.d.ts +4 -0
- package/src/command-builder/architect-command-module.js +26 -6
- package/src/command-builder/command-module.d.ts +1 -0
- package/src/command-builder/command-runner.js +47 -31
- 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 +30 -17
- 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 +31 -0
- package/src/commands/completion/long-description.md +1 -0
- package/src/commands/config/cli.js +14 -14
- package/src/commands/run/cli.d.ts +2 -0
- package/src/commands/run/cli.js +24 -0
- package/src/utilities/config.d.ts +4 -3
- package/src/utilities/config.js +11 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/cli",
|
|
3
|
-
"version": "14.0.0-next.
|
|
3
|
+
"version": "14.0.0-next.9",
|
|
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-next.
|
|
29
|
-
"@angular-devkit/core": "14.0.0-next.
|
|
30
|
-
"@angular-devkit/schematics": "14.0.0-next.
|
|
31
|
-
"@schematics/angular": "14.0.0-next.
|
|
28
|
+
"@angular-devkit/architect": "0.1400.0-next.9",
|
|
29
|
+
"@angular-devkit/core": "14.0.0-next.9",
|
|
30
|
+
"@angular-devkit/schematics": "14.0.0-next.9",
|
|
31
|
+
"@schematics/angular": "14.0.0-next.9",
|
|
32
32
|
"@yarnpkg/lockfile": "1.1.0",
|
|
33
33
|
"ansi-colors": "4.1.1",
|
|
34
34
|
"debug": "4.3.4",
|
|
35
|
-
"ini": "
|
|
35
|
+
"ini": "3.0.0",
|
|
36
36
|
"inquirer": "8.2.2",
|
|
37
37
|
"jsonc-parser": "3.0.0",
|
|
38
38
|
"npm-package-arg": "9.0.2",
|
|
39
39
|
"npm-pick-manifest": "7.0.1",
|
|
40
40
|
"open": "8.4.0",
|
|
41
41
|
"ora": "5.4.1",
|
|
42
|
-
"pacote": "13.1.
|
|
42
|
+
"pacote": "13.1.1",
|
|
43
43
|
"resolve": "1.22.0",
|
|
44
|
-
"semver": "7.3.
|
|
44
|
+
"semver": "7.3.6",
|
|
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-next.
|
|
53
|
-
"@angular-devkit/architect": "0.1400.0-next.
|
|
54
|
-
"@angular-devkit/build-angular": "14.0.0-next.
|
|
55
|
-
"@angular-devkit/build-webpack": "0.1400.0-next.
|
|
56
|
-
"@angular-devkit/core": "14.0.0-next.
|
|
57
|
-
"@angular-devkit/schematics": "14.0.0-next.
|
|
52
|
+
"@angular/cli": "14.0.0-next.9",
|
|
53
|
+
"@angular-devkit/architect": "0.1400.0-next.9",
|
|
54
|
+
"@angular-devkit/build-angular": "14.0.0-next.9",
|
|
55
|
+
"@angular-devkit/build-webpack": "0.1400.0-next.9",
|
|
56
|
+
"@angular-devkit/core": "14.0.0-next.9",
|
|
57
|
+
"@angular-devkit/schematics": "14.0.0-next.9"
|
|
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)}
|
|
@@ -68,7 +68,13 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
|
68
68
|
}
|
|
69
69
|
async getArchitectTargetOptions(target) {
|
|
70
70
|
const architectHost = this.getArchitectHost();
|
|
71
|
-
|
|
71
|
+
let builderConf;
|
|
72
|
+
try {
|
|
73
|
+
builderConf = await architectHost.getBuilderNameForTarget(target);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
72
78
|
let builderDesc;
|
|
73
79
|
try {
|
|
74
80
|
builderDesc = await architectHost.resolveBuilder(builderConf);
|
|
@@ -18,4 +18,8 @@ export declare abstract class ArchitectCommandModule extends ArchitectBaseComman
|
|
|
18
18
|
run(options: Options<ArchitectCommandArgs> & OtherOptions): Promise<number | void>;
|
|
19
19
|
private getArchitectProject;
|
|
20
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;
|
|
21
25
|
}
|
|
@@ -17,13 +17,16 @@ exports.ArchitectCommandModule = void 0;
|
|
|
17
17
|
const config_1 = require("../utilities/config");
|
|
18
18
|
const memoize_1 = require("../utilities/memoize");
|
|
19
19
|
const architect_base_command_module_1 = require("./architect-base-command-module");
|
|
20
|
-
const command_module_1 = require("./command-module");
|
|
21
20
|
class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBaseCommandModule {
|
|
22
21
|
async builder(argv) {
|
|
22
|
+
const project = this.getArchitectProject();
|
|
23
|
+
const { jsonHelp, getYargsCompletions, help } = this.context.args.options;
|
|
23
24
|
const localYargs = argv
|
|
24
25
|
.positional('project', {
|
|
25
26
|
describe: 'The name of the project to build. Can be an application or a library.',
|
|
26
27
|
type: 'string',
|
|
28
|
+
// Hide choices from JSON help so that we don't display them in AIO.
|
|
29
|
+
choices: jsonHelp ? undefined : this.getProjectChoices(),
|
|
27
30
|
})
|
|
28
31
|
.option('configuration', {
|
|
29
32
|
describe: `One or more named builder configurations as a comma-separated ` +
|
|
@@ -32,9 +35,13 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
32
35
|
`For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.`,
|
|
33
36
|
alias: 'c',
|
|
34
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,
|
|
35
43
|
})
|
|
36
44
|
.strict();
|
|
37
|
-
const project = this.getArchitectProject();
|
|
38
45
|
if (!project) {
|
|
39
46
|
return localYargs;
|
|
40
47
|
}
|
|
@@ -72,10 +79,7 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
72
79
|
}
|
|
73
80
|
const [, projectName] = this.context.args.positional;
|
|
74
81
|
if (projectName) {
|
|
75
|
-
|
|
76
|
-
throw new command_module_1.CommandModuleError(`Project '${projectName}' does not exist.`);
|
|
77
|
-
}
|
|
78
|
-
return projectName;
|
|
82
|
+
return workspace.projects.has(projectName) ? projectName : undefined;
|
|
79
83
|
}
|
|
80
84
|
const target = this.getArchitectTarget();
|
|
81
85
|
const projectFromTarget = this.getProjectNamesByTarget(target);
|
|
@@ -107,6 +111,22 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
107
111
|
}
|
|
108
112
|
return undefined;
|
|
109
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
|
+
}
|
|
110
130
|
}
|
|
111
131
|
__decorate([
|
|
112
132
|
memoize_1.memoize
|
|
@@ -17,50 +17,58 @@ const cli_1 = require("../commands/add/cli");
|
|
|
17
17
|
const cli_2 = require("../commands/analytics/cli");
|
|
18
18
|
const cli_3 = require("../commands/build/cli");
|
|
19
19
|
const cli_4 = require("../commands/cache/cli");
|
|
20
|
-
const cli_5 = require("../commands/
|
|
21
|
-
const cli_6 = require("../commands/
|
|
22
|
-
const cli_7 = require("../commands/
|
|
23
|
-
const cli_8 = require("../commands/
|
|
24
|
-
const cli_9 = require("../commands/
|
|
25
|
-
const cli_10 = require("../commands/
|
|
26
|
-
const cli_11 = require("../commands/
|
|
27
|
-
const cli_12 = require("../commands/
|
|
28
|
-
const cli_13 = require("../commands/
|
|
29
|
-
const cli_14 = require("../commands/
|
|
30
|
-
const cli_15 = require("../commands/
|
|
31
|
-
const cli_16 = require("../commands/
|
|
32
|
-
const cli_17 = require("../commands/
|
|
33
|
-
const cli_18 = require("../commands/
|
|
20
|
+
const cli_5 = require("../commands/completion/cli");
|
|
21
|
+
const cli_6 = require("../commands/config/cli");
|
|
22
|
+
const cli_7 = require("../commands/deploy/cli");
|
|
23
|
+
const cli_8 = require("../commands/doc/cli");
|
|
24
|
+
const cli_9 = require("../commands/e2e/cli");
|
|
25
|
+
const cli_10 = require("../commands/extract-i18n/cli");
|
|
26
|
+
const cli_11 = require("../commands/generate/cli");
|
|
27
|
+
const cli_12 = require("../commands/lint/cli");
|
|
28
|
+
const cli_13 = require("../commands/make-this-awesome/cli");
|
|
29
|
+
const cli_14 = require("../commands/new/cli");
|
|
30
|
+
const cli_15 = require("../commands/run/cli");
|
|
31
|
+
const cli_16 = require("../commands/serve/cli");
|
|
32
|
+
const cli_17 = require("../commands/test/cli");
|
|
33
|
+
const cli_18 = require("../commands/update/cli");
|
|
34
|
+
const cli_19 = require("../commands/version/cli");
|
|
34
35
|
const color_1 = require("../utilities/color");
|
|
35
36
|
const config_1 = require("../utilities/config");
|
|
36
37
|
const package_manager_1 = require("../utilities/package-manager");
|
|
37
38
|
const command_module_1 = require("./command-module");
|
|
38
39
|
const command_1 = require("./utilities/command");
|
|
39
40
|
const json_help_1 = require("./utilities/json-help");
|
|
41
|
+
const normalize_options_middleware_1 = require("./utilities/normalize-options-middleware");
|
|
40
42
|
const COMMANDS = [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
cli_19.VersionCommandModule,
|
|
44
|
+
cli_8.DocCommandModule,
|
|
45
|
+
cli_13.AwesomeCommandModule,
|
|
46
|
+
cli_6.ConfigCommandModule,
|
|
45
47
|
cli_2.AnalyticsCommandModule,
|
|
46
48
|
cli_1.AddCommandModule,
|
|
47
|
-
|
|
49
|
+
cli_11.GenerateCommandModule,
|
|
48
50
|
cli_3.BuildCommandModule,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
cli_9.E2eCommandModule,
|
|
52
|
+
cli_17.TestCommandModule,
|
|
53
|
+
cli_16.ServeCommandModule,
|
|
54
|
+
cli_10.ExtractI18nCommandModule,
|
|
55
|
+
cli_7.DeployCommandModule,
|
|
56
|
+
cli_12.LintCommandModule,
|
|
57
|
+
cli_14.NewCommandModule,
|
|
58
|
+
cli_18.UpdateCommandModule,
|
|
59
|
+
cli_15.RunCommandModule,
|
|
58
60
|
cli_4.CacheCommandModule,
|
|
61
|
+
cli_5.CompletionCommandModule,
|
|
59
62
|
].sort(); // Will be sorted by class name.
|
|
60
63
|
const yargsParser = helpers_1.Parser;
|
|
61
64
|
async function runCommand(args, logger) {
|
|
62
65
|
var _a, _b;
|
|
63
|
-
const { $0, _
|
|
66
|
+
const { $0, _, help = false, jsonHelp = false, getYargsCompletions = false, ...rest } = yargsParser(args, {
|
|
67
|
+
boolean: ['help', 'json-help', 'get-yargs-completions'],
|
|
68
|
+
alias: { 'collection': 'c' },
|
|
69
|
+
});
|
|
70
|
+
// When `getYargsCompletions` is true the scriptName 'ng' at index 0 is not removed.
|
|
71
|
+
const positional = getYargsCompletions ? _.slice(1) : _;
|
|
64
72
|
let workspace;
|
|
65
73
|
let globalConfiguration;
|
|
66
74
|
try {
|
|
@@ -86,6 +94,7 @@ async function runCommand(args, logger) {
|
|
|
86
94
|
options: {
|
|
87
95
|
help,
|
|
88
96
|
jsonHelp,
|
|
97
|
+
getYargsCompletions,
|
|
89
98
|
...rest,
|
|
90
99
|
},
|
|
91
100
|
},
|
|
@@ -101,9 +110,15 @@ async function runCommand(args, logger) {
|
|
|
101
110
|
}
|
|
102
111
|
localYargs = (0, command_1.addCommandModuleToYargs)(localYargs, CommandModule, context);
|
|
103
112
|
}
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const usageInstance = localYargs.getInternalMethods().getUsageInstance();
|
|
104
115
|
if (jsonHelp) {
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
usageInstance.help = () => (0, json_help_1.jsonHelpUsage)();
|
|
117
|
+
}
|
|
118
|
+
if (getYargsCompletions) {
|
|
119
|
+
// When in auto completion mode avoid printing description as it causes a slugish
|
|
120
|
+
// experience when there are a large set of options.
|
|
121
|
+
usageInstance.getDescriptions = () => ({});
|
|
107
122
|
}
|
|
108
123
|
await localYargs
|
|
109
124
|
.scriptName('ng')
|
|
@@ -135,6 +150,7 @@ async function runCommand(args, logger) {
|
|
|
135
150
|
})
|
|
136
151
|
.demandCommand(1, command_1.demandCommandFailureMessage)
|
|
137
152
|
.recommendCommands()
|
|
153
|
+
.middleware(normalize_options_middleware_1.normalizeOptionsMiddleware)
|
|
138
154
|
.version(false)
|
|
139
155
|
.showHelpOnFail(false)
|
|
140
156
|
.strict()
|
|
@@ -0,0 +1,18 @@
|
|
|
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 * as yargs from 'yargs';
|
|
9
|
+
/**
|
|
10
|
+
* A Yargs middleware that normalizes non Array options when the argument has been provided multiple times.
|
|
11
|
+
*
|
|
12
|
+
* By default, when an option is non array and it is provided multiple times in the command line, yargs
|
|
13
|
+
* will not override it's value but instead it will be changed to an array unless `duplicate-arguments-array` is disabled.
|
|
14
|
+
* But this option also have an effect on real array options which isn't desired.
|
|
15
|
+
*
|
|
16
|
+
* See: https://github.com/yargs/yargs-parser/pull/163#issuecomment-516566614
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeOptionsMiddleware(args: yargs.Arguments): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
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.normalizeOptionsMiddleware = void 0;
|
|
34
|
+
const yargs = __importStar(require("yargs"));
|
|
35
|
+
/**
|
|
36
|
+
* A Yargs middleware that normalizes non Array options when the argument has been provided multiple times.
|
|
37
|
+
*
|
|
38
|
+
* By default, when an option is non array and it is provided multiple times in the command line, yargs
|
|
39
|
+
* will not override it's value but instead it will be changed to an array unless `duplicate-arguments-array` is disabled.
|
|
40
|
+
* But this option also have an effect on real array options which isn't desired.
|
|
41
|
+
*
|
|
42
|
+
* See: https://github.com/yargs/yargs-parser/pull/163#issuecomment-516566614
|
|
43
|
+
*/
|
|
44
|
+
function normalizeOptionsMiddleware(args) {
|
|
45
|
+
// `getOptions` is not included in the types even though it's public API.
|
|
46
|
+
// https://github.com/yargs/yargs/issues/2098
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
const { array } = yargs.getOptions();
|
|
49
|
+
const arrayOptions = new Set(array);
|
|
50
|
+
for (const [key, value] of Object.entries(args)) {
|
|
51
|
+
if (key !== '_' && Array.isArray(value) && !arrayOptions.has(key)) {
|
|
52
|
+
const newValue = value.pop();
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.warn(`Option '${key}' has been specified multiple times. The value '${newValue}' will be used.`);
|
|
55
|
+
args[key] = newValue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.normalizeOptionsMiddleware = normalizeOptionsMiddleware;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { RuleFactory } from '@angular-devkit/schematics';
|
|
9
|
-
import { NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
|
|
9
|
+
import { FileSystemCollectionDesc, NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
|
|
10
10
|
export declare class SchematicEngineHost extends NodeModulesEngineHost {
|
|
11
|
-
protected _resolveReferenceString(refString: string, parentPath: string): {
|
|
11
|
+
protected _resolveReferenceString(refString: string, parentPath: string, collectionDescription?: FileSystemCollectionDesc): {
|
|
12
12
|
ref: RuleFactory<{}>;
|
|
13
13
|
path: string;
|
|
14
14
|
} | null;
|
|
@@ -21,21 +21,18 @@ const path_1 = require("path");
|
|
|
21
21
|
const vm_1 = require("vm");
|
|
22
22
|
/**
|
|
23
23
|
* Environment variable to control schematic package redirection
|
|
24
|
-
* Default: Angular schematics only
|
|
25
24
|
*/
|
|
26
25
|
const schematicRedirectVariable = (_a = process.env['NG_SCHEMATIC_REDIRECT']) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
27
|
-
function shouldWrapSchematic(schematicFile) {
|
|
26
|
+
function shouldWrapSchematic(schematicFile, schematicEncapsulation) {
|
|
28
27
|
// Check environment variable if present
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
28
|
+
switch (schematicRedirectVariable) {
|
|
29
|
+
case '0':
|
|
30
|
+
case 'false':
|
|
31
|
+
case 'off':
|
|
32
|
+
case 'none':
|
|
33
|
+
return false;
|
|
34
|
+
case 'all':
|
|
35
|
+
return true;
|
|
39
36
|
}
|
|
40
37
|
const normalizedSchematicFile = schematicFile.replace(/\\/g, '/');
|
|
41
38
|
// Never wrap the internal update schematic when executed directly
|
|
@@ -45,17 +42,21 @@ function shouldWrapSchematic(schematicFile) {
|
|
|
45
42
|
!normalizedSchematicFile.includes('node_modules/@angular/cli/node_modules/')) {
|
|
46
43
|
return false;
|
|
47
44
|
}
|
|
48
|
-
//
|
|
45
|
+
// Check for first-party Angular schematic packages
|
|
49
46
|
// Angular schematics are safe to use in the wrapped VM context
|
|
50
|
-
|
|
47
|
+
if (/\/node_modules\/@(?:angular|schematics|nguniversal)\//.test(normalizedSchematicFile)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// Otherwise use the value of the schematic collection's encapsulation option (current default of false)
|
|
51
|
+
return schematicEncapsulation;
|
|
51
52
|
}
|
|
52
53
|
class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
|
|
53
|
-
_resolveReferenceString(refString, parentPath) {
|
|
54
|
+
_resolveReferenceString(refString, parentPath, collectionDescription) {
|
|
54
55
|
const [path, name] = refString.split('#', 2);
|
|
55
56
|
// Mimic behavior of ExportStringRef class used in default behavior
|
|
56
57
|
const fullPath = path[0] === '.' ? (0, path_1.resolve)(parentPath !== null && parentPath !== void 0 ? parentPath : process.cwd(), path) : path;
|
|
57
58
|
const schematicFile = require.resolve(fullPath, { paths: [parentPath] });
|
|
58
|
-
if (shouldWrapSchematic(schematicFile)) {
|
|
59
|
+
if (shouldWrapSchematic(schematicFile, !!(collectionDescription === null || collectionDescription === void 0 ? void 0 : collectionDescription.encapsulation))) {
|
|
59
60
|
const schematicPath = (0, path_1.dirname)(schematicFile);
|
|
60
61
|
const moduleCache = new Map();
|
|
61
62
|
const factoryInitializer = wrap(schematicFile, schematicPath, moduleCache, name || 'default');
|
|
@@ -66,7 +67,7 @@ class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
|
|
|
66
67
|
return { ref: factory, path: schematicPath };
|
|
67
68
|
}
|
|
68
69
|
// All other schematics use default behavior
|
|
69
|
-
return super._resolveReferenceString(refString, parentPath);
|
|
70
|
+
return super._resolveReferenceString(refString, parentPath, collectionDescription);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
exports.SchematicEngineHost = SchematicEngineHost;
|
|
@@ -108,6 +109,15 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
|
108
109
|
// Provide compatibility modules for older versions of @angular/cdk
|
|
109
110
|
return legacyModules[id];
|
|
110
111
|
}
|
|
112
|
+
else if (id.startsWith('schematics:')) {
|
|
113
|
+
// Schematics built-in modules use the `schematics` scheme (similar to the Node.js `node` scheme)
|
|
114
|
+
const builtinId = id.slice(11);
|
|
115
|
+
const builtinModule = loadBuiltinModule(builtinId);
|
|
116
|
+
if (!builtinModule) {
|
|
117
|
+
throw new Error(`Unknown schematics built-in module '${id}' requested from schematic '${schematicFile}'`);
|
|
118
|
+
}
|
|
119
|
+
return builtinModule;
|
|
120
|
+
}
|
|
111
121
|
else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
|
|
112
122
|
// Files should not redirect `@angular/core` and instead use the direct
|
|
113
123
|
// dependency if available. This allows old major version migrations to continue to function
|
|
@@ -170,3 +180,6 @@ function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
|
170
180
|
const exportsFactory = script.runInNewContext(context);
|
|
171
181
|
return exportsFactory;
|
|
172
182
|
}
|
|
183
|
+
function loadBuiltinModule(id) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
@@ -30,7 +30,7 @@ class AnalyticsDisableModule extends AnalyticsSettingModule {
|
|
|
30
30
|
this.describe = 'Disables analytics gathering and reporting for the user.';
|
|
31
31
|
}
|
|
32
32
|
async run({ global }) {
|
|
33
|
-
(0, analytics_1.setAnalyticsConfig)(global, false);
|
|
33
|
+
await (0, analytics_1.setAnalyticsConfig)(global, false);
|
|
34
34
|
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -43,7 +43,7 @@ class AnalyticsEnableModule extends AnalyticsSettingModule {
|
|
|
43
43
|
this.describe = 'Enables analytics gathering and reporting for the user.';
|
|
44
44
|
}
|
|
45
45
|
async run({ global }) {
|
|
46
|
-
(0, analytics_1.setAnalyticsConfig)(global, true);
|
|
46
|
+
await (0, analytics_1.setAnalyticsConfig)(global, true);
|
|
47
47
|
process.stderr.write(await (0, analytics_1.getAnalyticsInfoString)());
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -14,7 +14,7 @@ export declare class CacheDisableModule extends CommandModule implements Command
|
|
|
14
14
|
longDescriptionPath: string | undefined;
|
|
15
15
|
static scope: CommandScope.In;
|
|
16
16
|
builder(localYargs: Argv): Argv;
|
|
17
|
-
run(): void
|
|
17
|
+
run(): Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
export declare class CacheEnableModule extends CommandModule implements CommandModuleImplementation {
|
|
20
20
|
command: string;
|
|
@@ -23,5 +23,5 @@ export declare class CacheEnableModule extends CommandModule implements CommandM
|
|
|
23
23
|
longDescriptionPath: string | undefined;
|
|
24
24
|
static scope: CommandScope.In;
|
|
25
25
|
builder(localYargs: Argv): Argv;
|
|
26
|
-
run(): void
|
|
26
|
+
run(): Promise<void>;
|
|
27
27
|
}
|
|
@@ -21,7 +21,7 @@ class CacheDisableModule extends command_module_1.CommandModule {
|
|
|
21
21
|
return localYargs;
|
|
22
22
|
}
|
|
23
23
|
run() {
|
|
24
|
-
(0, utilities_1.updateCacheConfig)('enabled', false);
|
|
24
|
+
return (0, utilities_1.updateCacheConfig)(this.getWorkspaceOrThrow(), 'enabled', false);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.CacheDisableModule = CacheDisableModule;
|
|
@@ -36,7 +36,7 @@ class CacheEnableModule extends command_module_1.CommandModule {
|
|
|
36
36
|
return localYargs;
|
|
37
37
|
}
|
|
38
38
|
run() {
|
|
39
|
-
(0, utilities_1.updateCacheConfig)('enabled', true);
|
|
39
|
+
return (0, utilities_1.updateCacheConfig)(this.getWorkspaceOrThrow(), 'enabled', true);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.CacheEnableModule = CacheEnableModule;
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Cache } from '../../../lib/config/workspace-schema';
|
|
9
9
|
import { AngularWorkspace } from '../../utilities/config';
|
|
10
|
-
export declare function updateCacheConfig<K extends keyof Cache>(key: K, value: Cache[K]): void
|
|
10
|
+
export declare function updateCacheConfig<K extends keyof Cache>(workspace: AngularWorkspace, key: K, value: Cache[K]): Promise<void>;
|
|
11
11
|
export declare function getCacheConfig(workspace: AngularWorkspace | undefined): Required<Cache>;
|
|
@@ -11,14 +11,13 @@ exports.getCacheConfig = exports.updateCacheConfig = void 0;
|
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const path_1 = require("path");
|
|
13
13
|
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
localWorkspace.save();
|
|
14
|
+
function updateCacheConfig(workspace, key, value) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
var _c;
|
|
17
|
+
const cli = ((_a = (_c = workspace.extensions)['cli']) !== null && _a !== void 0 ? _a : (_c['cli'] = {}));
|
|
18
|
+
const cache = ((_b = cli['cache']) !== null && _b !== void 0 ? _b : (cli['cache'] = {}));
|
|
19
|
+
cache[key] = value;
|
|
20
|
+
return workspace.save();
|
|
22
21
|
}
|
|
23
22
|
exports.updateCacheConfig = updateCacheConfig;
|
|
24
23
|
function getCacheConfig(workspace) {
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { Argv } from 'yargs';
|
|
9
|
+
import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
|
|
10
|
+
export declare class CompletionCommandModule extends CommandModule implements CommandModuleImplementation {
|
|
11
|
+
command: string;
|
|
12
|
+
describe: string;
|
|
13
|
+
longDescriptionPath: string;
|
|
14
|
+
builder(localYargs: Argv): Argv;
|
|
15
|
+
run(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CompletionCommandModule = void 0;
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
16
|
+
const command_module_1 = require("../../command-builder/command-module");
|
|
17
|
+
class CompletionCommandModule extends command_module_1.CommandModule {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.command = 'completion';
|
|
21
|
+
this.describe = 'Generate a bash and zsh real-time type-ahead autocompletion script.';
|
|
22
|
+
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
23
|
+
}
|
|
24
|
+
builder(localYargs) {
|
|
25
|
+
return localYargs;
|
|
26
|
+
}
|
|
27
|
+
run() {
|
|
28
|
+
yargs_1.default.showCompletionScript();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.CompletionCommandModule = CompletionCommandModule;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
To enable bash and zsh real-time type-ahead autocompletion, copy and paste the generated script to your `.bashrc`, `.bash_profile`, `.zshrc` or `.zsh_profile`.
|
|
@@ -71,25 +71,22 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
71
71
|
return 0;
|
|
72
72
|
}
|
|
73
73
|
async set(options) {
|
|
74
|
-
var _a
|
|
74
|
+
var _a;
|
|
75
75
|
if (!((_a = options.jsonPath) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
76
76
|
throw new command_module_1.CommandModuleError('Invalid Path.');
|
|
77
77
|
}
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
['cli.cache.enabled', undefined],
|
|
87
|
-
['cli.cache.environment', undefined],
|
|
88
|
-
['cli.cache.path', undefined],
|
|
78
|
+
const validGlobalCliPaths = new Set([
|
|
79
|
+
'cli.warnings.versionMismatch',
|
|
80
|
+
'cli.defaultCollection',
|
|
81
|
+
'cli.schematicCollections',
|
|
82
|
+
'cli.packageManager',
|
|
83
|
+
'cli.analytics',
|
|
84
|
+
'cli.analyticsSharing.tracking',
|
|
85
|
+
'cli.analyticsSharing.uuid',
|
|
89
86
|
]);
|
|
90
87
|
if (options.global &&
|
|
91
88
|
!options.jsonPath.startsWith('schematics.') &&
|
|
92
|
-
!
|
|
89
|
+
!validGlobalCliPaths.has(options.jsonPath)) {
|
|
93
90
|
throw new command_module_1.CommandModuleError('Invalid Path.');
|
|
94
91
|
}
|
|
95
92
|
const [config, configPath] = (0, config_1.getWorkspaceRaw)(options.global ? 'global' : 'local');
|
|
@@ -97,7 +94,10 @@ class ConfigCommandModule extends command_module_1.CommandModule {
|
|
|
97
94
|
if (!config || !configPath) {
|
|
98
95
|
throw new command_module_1.CommandModuleError('Confguration file cannot be found.');
|
|
99
96
|
}
|
|
100
|
-
const
|
|
97
|
+
const normalizeUUIDValue = (v) => (v === '' ? (0, uuid_1.v4)() : `${v}`);
|
|
98
|
+
const value = options.jsonPath === 'cli.analyticsSharing.uuid'
|
|
99
|
+
? normalizeUUIDValue(options.value)
|
|
100
|
+
: options.value;
|
|
101
101
|
const modified = config.modify(parseJsonPath(options.jsonPath), normalizeValue(value));
|
|
102
102
|
if (!modified) {
|
|
103
103
|
logger.error('Value cannot be found.');
|
|
@@ -20,4 +20,6 @@ export declare class RunCommandModule extends ArchitectBaseCommandModule<RunComm
|
|
|
20
20
|
builder(argv: Argv): Promise<Argv<RunCommandArgs>>;
|
|
21
21
|
run(options: Options<RunCommandArgs> & OtherOptions): Promise<number>;
|
|
22
22
|
protected makeTargetSpecifier(options?: Options<RunCommandArgs>): Target | undefined;
|
|
23
|
+
/** @returns a sorted list of target specifiers to be used for auto completion. */
|
|
24
|
+
private getTargetChoices;
|
|
23
25
|
}
|
package/src/commands/run/cli.js
CHANGED
|
@@ -19,11 +19,15 @@ class RunCommandModule extends architect_base_command_module_1.ArchitectBaseComm
|
|
|
19
19
|
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
20
20
|
}
|
|
21
21
|
async builder(argv) {
|
|
22
|
+
const { jsonHelp, getYargsCompletions, help } = this.context.args.options;
|
|
22
23
|
const localYargs = argv
|
|
23
24
|
.positional('target', {
|
|
24
25
|
describe: 'The Architect target to run.',
|
|
25
26
|
type: 'string',
|
|
26
27
|
demandOption: true,
|
|
28
|
+
// Show only in when using --help and auto completion because otherwise comma seperated configuration values will be invalid.
|
|
29
|
+
// Also, hide choices from JSON help so that we don't display them in AIO.
|
|
30
|
+
choices: (getYargsCompletions || help) && !jsonHelp ? this.getTargetChoices() : undefined,
|
|
27
31
|
})
|
|
28
32
|
.strict();
|
|
29
33
|
const target = this.makeTargetSpecifier();
|
|
@@ -54,6 +58,26 @@ class RunCommandModule extends architect_base_command_module_1.ArchitectBaseComm
|
|
|
54
58
|
configuration,
|
|
55
59
|
};
|
|
56
60
|
}
|
|
61
|
+
/** @returns a sorted list of target specifiers to be used for auto completion. */
|
|
62
|
+
getTargetChoices() {
|
|
63
|
+
if (!this.context.workspace) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const targets = [];
|
|
67
|
+
for (const [projectName, project] of this.context.workspace.projects) {
|
|
68
|
+
for (const [targetName, target] of project.targets) {
|
|
69
|
+
const currentTarget = `${projectName}:${targetName}`;
|
|
70
|
+
targets.push(currentTarget);
|
|
71
|
+
if (!target.configurations) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
for (const configName of Object.keys(target.configurations)) {
|
|
75
|
+
targets.push(`${currentTarget}:${configName}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return targets.sort();
|
|
80
|
+
}
|
|
57
81
|
}
|
|
58
82
|
exports.RunCommandModule = RunCommandModule;
|
|
59
83
|
RunCommandModule.scope = command_module_1.CommandScope.In;
|
|
@@ -10,14 +10,15 @@ import { PackageManager } from '../../lib/config/workspace-schema';
|
|
|
10
10
|
import { JSONFile } from './json-file';
|
|
11
11
|
export declare const workspaceSchemaPath: string;
|
|
12
12
|
export declare class AngularWorkspace {
|
|
13
|
-
private workspace;
|
|
13
|
+
private readonly workspace;
|
|
14
14
|
readonly filePath: string;
|
|
15
15
|
readonly basePath: string;
|
|
16
16
|
constructor(workspace: workspaces.WorkspaceDefinition, filePath: string);
|
|
17
17
|
get extensions(): Record<string, json.JsonValue | undefined>;
|
|
18
18
|
get projects(): workspaces.ProjectDefinitionCollection;
|
|
19
|
-
getCli(): Record<string, any
|
|
20
|
-
getProjectCli(projectName: string): Record<string, any
|
|
19
|
+
getCli(): Record<string, any> | undefined;
|
|
20
|
+
getProjectCli(projectName: string): Record<string, any> | undefined;
|
|
21
|
+
save(): Promise<void>;
|
|
21
22
|
static load(workspaceFilePath: string): Promise<AngularWorkspace>;
|
|
22
23
|
}
|
|
23
24
|
export declare function getWorkspace(level?: 'local' | 'global'): Promise<AngularWorkspace | undefined>;
|
package/src/utilities/config.js
CHANGED
|
@@ -134,12 +134,15 @@ class AngularWorkspace {
|
|
|
134
134
|
// Temporary helper functions to support refactoring
|
|
135
135
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
136
|
getCli() {
|
|
137
|
-
return this.workspace.extensions['cli']
|
|
137
|
+
return this.workspace.extensions['cli'];
|
|
138
138
|
}
|
|
139
139
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
140
|
getProjectCli(projectName) {
|
|
141
141
|
const project = this.workspace.projects.get(projectName);
|
|
142
|
-
return
|
|
142
|
+
return project === null || project === void 0 ? void 0 : project.extensions['cli'];
|
|
143
|
+
}
|
|
144
|
+
save() {
|
|
145
|
+
return core_1.workspaces.writeWorkspace(this.workspace, createWorkspaceHost(), this.filePath);
|
|
143
146
|
}
|
|
144
147
|
static async load(workspaceFilePath) {
|
|
145
148
|
const result = await core_1.workspaces.readWorkspace(workspaceFilePath, createWorkspaceHost(), core_1.workspaces.WorkspaceFormat.JSON);
|
|
@@ -152,10 +155,13 @@ async function getWorkspace(level = 'local') {
|
|
|
152
155
|
if (cachedWorkspaces.has(level)) {
|
|
153
156
|
return cachedWorkspaces.get(level);
|
|
154
157
|
}
|
|
155
|
-
|
|
158
|
+
let configPath = level === 'local' ? projectFilePath() : globalFilePath();
|
|
156
159
|
if (!configPath) {
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
if (level === 'local') {
|
|
161
|
+
cachedWorkspaces.set(level, undefined);
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
configPath = createGlobalSettings();
|
|
159
165
|
}
|
|
160
166
|
try {
|
|
161
167
|
const workspace = await AngularWorkspace.load(configPath);
|