@angular/cli 14.0.0-next.6 → 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/lib/cli/index.d.ts +0 -1
- package/lib/cli/index.js +3 -30
- package/lib/config/schema.json +22 -3
- package/lib/config/workspace-schema.d.ts +5 -0
- package/lib/init.js +2 -5
- package/package.json +19 -22
- package/src/analytics/analytics-collector.js +2 -0
- package/src/analytics/analytics.d.ts +1 -1
- package/src/analytics/analytics.js +39 -36
- package/src/command-builder/architect-base-command-module.d.ts +8 -1
- 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 +40 -14
- package/src/command-builder/command-module.d.ts +4 -3
- package/src/command-builder/command-module.js +14 -7
- package/src/command-builder/command-runner.d.ts +1 -2
- package/src/command-builder/command-runner.js +69 -36
- package/src/command-builder/schematics-command-module.d.ts +3 -4
- package/src/command-builder/schematics-command-module.js +88 -48
- 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/add/cli.js +14 -14
- package/src/commands/add/long-description.md +1 -4
- package/src/commands/analytics/cli.d.ts +1 -1
- package/src/commands/analytics/info/cli.d.ts +1 -1
- package/src/commands/analytics/settings/cli.d.ts +1 -1
- package/src/commands/analytics/settings/cli.js +2 -2
- package/src/commands/cache/clean/cli.d.ts +17 -0
- package/src/commands/cache/clean/cli.js +32 -0
- package/src/commands/cache/cli.d.ts +17 -0
- package/src/commands/cache/cli.js +38 -0
- package/src/commands/cache/info/cli.d.ts +20 -0
- package/src/commands/cache/info/cli.js +82 -0
- package/src/commands/cache/long-description.md +53 -0
- package/src/commands/cache/settings/cli.d.ts +27 -0
- package/src/commands/cache/settings/cli.js +42 -0
- package/src/commands/cache/utilities.d.ts +11 -0
- package/src/commands/cache/utilities.js +49 -0
- 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.d.ts +1 -1
- package/src/commands/config/cli.js +15 -15
- package/src/commands/deploy/cli.d.ts +2 -1
- package/src/commands/deploy/cli.js +27 -13
- package/src/commands/doc/cli.d.ts +1 -1
- package/src/commands/e2e/cli.d.ts +3 -2
- package/src/commands/e2e/cli.js +14 -13
- package/src/commands/generate/cli.d.ts +11 -1
- package/src/commands/generate/cli.js +54 -23
- package/src/commands/lint/cli.d.ts +2 -1
- package/src/commands/lint/cli.js +6 -9
- package/src/commands/new/cli.d.ts +2 -0
- package/src/commands/new/cli.js +22 -6
- package/src/commands/run/cli.d.ts +2 -0
- package/src/commands/run/cli.js +24 -0
- package/src/commands/update/cli.d.ts +1 -0
- package/src/commands/update/cli.js +53 -23
- package/src/commands/update/schematic/index.js +27 -18
- package/src/commands/version/cli.d.ts +0 -1
- package/src/commands/version/cli.js +4 -23
- package/src/typings-bazel.d.ts +14 -0
- package/src/typings.d.ts +0 -13
- package/src/utilities/config.d.ts +5 -5
- package/src/utilities/config.js +27 -44
- package/src/{analytics/analytics-environment-options.d.ts → utilities/environment-options.d.ts} +3 -0
- package/src/utilities/environment-options.js +24 -0
- package/src/utilities/memoize.d.ts +15 -0
- package/src/utilities/memoize.js +69 -0
- package/src/utilities/package-manager.d.ts +33 -5
- package/src/utilities/package-manager.js +252 -71
- package/src/utilities/package-metadata.d.ts +15 -37
- package/src/utilities/package-metadata.js +10 -26
- package/src/utilities/package-tree.d.ts +2 -2
- package/src/utilities/prompt.d.ts +2 -0
- package/src/utilities/prompt.js +20 -3
- package/bin/postinstall/analytics-prompt.js +0 -27
- package/bin/postinstall/script.js +0 -16
- package/src/analytics/analytics-environment-options.js +0 -20
- package/src/utilities/install-package.d.ts +0 -16
- package/src/utilities/install-package.js +0 -193
- package/src/utilities/package-json.d.ts +0 -249
- package/src/utilities/package-json.js +0 -9
|
@@ -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 = [];
|
|
@@ -94,15 +101,34 @@ class ArchitectCommandModule extends architect_base_command_module_1.ArchitectBa
|
|
|
94
101
|
return allProjectsForTargetName;
|
|
95
102
|
}
|
|
96
103
|
else {
|
|
104
|
+
if (allProjectsForTargetName.length === 1) {
|
|
105
|
+
return allProjectsForTargetName;
|
|
106
|
+
}
|
|
97
107
|
const maybeProject = (0, config_1.getProjectByCwd)(workspace);
|
|
98
108
|
if (maybeProject && allProjectsForTargetName.includes(maybeProject)) {
|
|
99
109
|
return [maybeProject];
|
|
100
110
|
}
|
|
101
|
-
if (allProjectsForTargetName.length === 1) {
|
|
102
|
-
return allProjectsForTargetName;
|
|
103
|
-
}
|
|
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;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { analytics, logging } from '@angular-devkit/core';
|
|
9
9
|
import { ArgumentsCamelCase, Argv, CamelCaseKey, CommandModule as YargsCommandModule } from 'yargs';
|
|
10
|
-
import { PackageManager } from '../../lib/config/workspace-schema';
|
|
11
10
|
import { AngularWorkspace } from '../utilities/config';
|
|
11
|
+
import { PackageManagerUtils } from '../utilities/package-manager';
|
|
12
12
|
import { Option } from './utilities/json-schema';
|
|
13
13
|
export declare type Options<T> = {
|
|
14
14
|
[key in keyof T as CamelCaseKey<key>]: T[key];
|
|
@@ -25,14 +25,16 @@ export interface CommandContext {
|
|
|
25
25
|
currentDirectory: string;
|
|
26
26
|
root: string;
|
|
27
27
|
workspace?: AngularWorkspace;
|
|
28
|
+
globalConfiguration?: AngularWorkspace;
|
|
28
29
|
logger: logging.Logger;
|
|
29
|
-
packageManager:
|
|
30
|
+
packageManager: PackageManagerUtils;
|
|
30
31
|
/** Arguments parsed in free-from without parser configuration. */
|
|
31
32
|
args: {
|
|
32
33
|
positional: string[];
|
|
33
34
|
options: {
|
|
34
35
|
help: boolean;
|
|
35
36
|
jsonHelp: boolean;
|
|
37
|
+
getYargsCompletions: boolean;
|
|
36
38
|
} & Record<string, unknown>;
|
|
37
39
|
};
|
|
38
40
|
}
|
|
@@ -71,7 +73,6 @@ export declare abstract class CommandModule<T extends {} = {}> implements Comman
|
|
|
71
73
|
abstract run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
|
|
72
74
|
handler(args: ArgumentsCamelCase<T> & OtherOptions): Promise<void>;
|
|
73
75
|
reportAnalytics(options: (Options<T> & OtherOptions) | OtherOptions, paths?: string[], dimensions?: (boolean | number | string)[]): Promise<void>;
|
|
74
|
-
private _analytics;
|
|
75
76
|
protected getAnalytics(): Promise<analytics.Analytics>;
|
|
76
77
|
/**
|
|
77
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,7 @@ 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 memoize_1 = require("../utilities/memoize");
|
|
39
46
|
var CommandScope;
|
|
40
47
|
(function (CommandScope) {
|
|
41
48
|
/** Command can only run inside an Angular workspace. */
|
|
@@ -124,13 +131,10 @@ class CommandModule {
|
|
|
124
131
|
metrics: [],
|
|
125
132
|
});
|
|
126
133
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return this._analytics;
|
|
130
|
-
}
|
|
131
|
-
return (this._analytics = await (0, analytics_1.createAnalytics)(!!this.context.workspace,
|
|
134
|
+
getAnalytics() {
|
|
135
|
+
return (0, analytics_1.createAnalytics)(!!this.context.workspace,
|
|
132
136
|
// Don't prompt for `ng update` and `ng analytics` commands.
|
|
133
|
-
['update', 'analytics'].includes(this.commandName))
|
|
137
|
+
['update', 'analytics'].includes(this.commandName));
|
|
134
138
|
}
|
|
135
139
|
/**
|
|
136
140
|
* Adds schema options to a command also this keeps track of options that are required for analytics.
|
|
@@ -180,8 +184,11 @@ class CommandModule {
|
|
|
180
184
|
return workspace;
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
|
-
exports.CommandModule = CommandModule;
|
|
184
187
|
CommandModule.scope = CommandScope.Both;
|
|
188
|
+
__decorate([
|
|
189
|
+
memoize_1.memoize
|
|
190
|
+
], CommandModule.prototype, "getAnalytics", null);
|
|
191
|
+
exports.CommandModule = CommandModule;
|
|
185
192
|
/**
|
|
186
193
|
* Creates an known command module error.
|
|
187
194
|
* This is used so during executation we can filter between known validation error and real non handled errors.
|
|
@@ -6,5 +6,4 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { logging } from '@angular-devkit/core';
|
|
9
|
-
|
|
10
|
-
export declare function runCommand(args: string[], logger: logging.Logger, workspace: AngularWorkspace | undefined): Promise<number>;
|
|
9
|
+
export declare function runCommand(args: string[], logger: logging.Logger): Promise<number>;
|
|
@@ -16,59 +16,85 @@ const helpers_1 = require("yargs/helpers");
|
|
|
16
16
|
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
|
-
const cli_4 = require("../commands/
|
|
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/
|
|
19
|
+
const cli_4 = require("../commands/cache/cli");
|
|
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");
|
|
33
35
|
const color_1 = require("../utilities/color");
|
|
36
|
+
const config_1 = require("../utilities/config");
|
|
34
37
|
const package_manager_1 = require("../utilities/package-manager");
|
|
35
38
|
const command_module_1 = require("./command-module");
|
|
36
39
|
const command_1 = require("./utilities/command");
|
|
37
40
|
const json_help_1 = require("./utilities/json-help");
|
|
41
|
+
const normalize_options_middleware_1 = require("./utilities/normalize-options-middleware");
|
|
38
42
|
const COMMANDS = [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
cli_19.VersionCommandModule,
|
|
44
|
+
cli_8.DocCommandModule,
|
|
45
|
+
cli_13.AwesomeCommandModule,
|
|
46
|
+
cli_6.ConfigCommandModule,
|
|
43
47
|
cli_2.AnalyticsCommandModule,
|
|
44
48
|
cli_1.AddCommandModule,
|
|
45
|
-
|
|
49
|
+
cli_11.GenerateCommandModule,
|
|
46
50
|
cli_3.BuildCommandModule,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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,
|
|
60
|
+
cli_4.CacheCommandModule,
|
|
61
|
+
cli_5.CompletionCommandModule,
|
|
56
62
|
].sort(); // Will be sorted by class name.
|
|
57
63
|
const yargsParser = helpers_1.Parser;
|
|
58
|
-
async function runCommand(args, logger
|
|
59
|
-
var _a, _b
|
|
60
|
-
const { $0, _
|
|
64
|
+
async function runCommand(args, logger) {
|
|
65
|
+
var _a, _b;
|
|
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) : _;
|
|
72
|
+
let workspace;
|
|
73
|
+
let globalConfiguration;
|
|
74
|
+
try {
|
|
75
|
+
[workspace, globalConfiguration] = await Promise.all([
|
|
76
|
+
(0, config_1.getWorkspace)('local'),
|
|
77
|
+
(0, config_1.getWorkspace)('global'),
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
logger.fatal(e.message);
|
|
82
|
+
return 1;
|
|
83
|
+
}
|
|
84
|
+
const root = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.basePath) !== null && _a !== void 0 ? _a : process.cwd();
|
|
61
85
|
const context = {
|
|
86
|
+
globalConfiguration,
|
|
62
87
|
workspace,
|
|
63
88
|
logger,
|
|
64
89
|
currentDirectory: process.cwd(),
|
|
65
|
-
root
|
|
66
|
-
packageManager:
|
|
90
|
+
root,
|
|
91
|
+
packageManager: new package_manager_1.PackageManagerUtils({ globalConfiguration, workspace, root }),
|
|
67
92
|
args: {
|
|
68
93
|
positional: positional.map((v) => v.toString()),
|
|
69
94
|
options: {
|
|
70
95
|
help,
|
|
71
96
|
jsonHelp,
|
|
97
|
+
getYargsCompletions,
|
|
72
98
|
...rest,
|
|
73
99
|
},
|
|
74
100
|
},
|
|
@@ -84,9 +110,15 @@ async function runCommand(args, logger, workspace) {
|
|
|
84
110
|
}
|
|
85
111
|
localYargs = (0, command_1.addCommandModuleToYargs)(localYargs, CommandModule, context);
|
|
86
112
|
}
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const usageInstance = localYargs.getInternalMethods().getUsageInstance();
|
|
87
115
|
if (jsonHelp) {
|
|
88
|
-
|
|
89
|
-
|
|
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 = () => ({});
|
|
90
122
|
}
|
|
91
123
|
await localYargs
|
|
92
124
|
.scriptName('ng')
|
|
@@ -118,6 +150,7 @@ async function runCommand(args, logger, workspace) {
|
|
|
118
150
|
})
|
|
119
151
|
.demandCommand(1, command_1.demandCommandFailureMessage)
|
|
120
152
|
.recommendCommands()
|
|
153
|
+
.middleware(normalize_options_middleware_1.normalizeOptionsMiddleware)
|
|
121
154
|
.version(false)
|
|
122
155
|
.showHelpOnFail(false)
|
|
123
156
|
.strict()
|
|
@@ -130,6 +163,6 @@ async function runCommand(args, logger, workspace) {
|
|
|
130
163
|
})
|
|
131
164
|
.wrap(yargs_1.default.terminalWidth())
|
|
132
165
|
.parseAsync();
|
|
133
|
-
return (
|
|
166
|
+
return (_b = process.exitCode) !== null && _b !== void 0 ? _b : 0;
|
|
134
167
|
}
|
|
135
168
|
exports.runCommand = runCommand;
|
|
@@ -10,6 +10,7 @@ import { FileSystemCollectionDescription, FileSystemSchematicDescription, NodeWo
|
|
|
10
10
|
import { Argv } from 'yargs';
|
|
11
11
|
import { CommandModule, CommandModuleImplementation, CommandScope, Options, OtherOptions } from './command-module';
|
|
12
12
|
import { Option } from './utilities/json-schema';
|
|
13
|
+
export declare const DEFAULT_SCHEMATICS_COLLECTION = "@schematics/angular";
|
|
13
14
|
export interface SchematicsCommandArgs {
|
|
14
15
|
interactive: boolean;
|
|
15
16
|
force: boolean;
|
|
@@ -26,12 +27,9 @@ export declare abstract class SchematicsCommandModule extends CommandModule<Sche
|
|
|
26
27
|
builder(argv: Argv): Promise<Argv<SchematicsCommandArgs>>;
|
|
27
28
|
/** Get schematic schema options.*/
|
|
28
29
|
protected getSchematicOptions(collection: Collection<FileSystemCollectionDescription, FileSystemSchematicDescription>, schematicName: string, workflow: NodeWorkflow): Promise<Option[]>;
|
|
29
|
-
private _workflowForBuilder;
|
|
30
30
|
protected getOrCreateWorkflowForBuilder(collectionName: string): NodeWorkflow;
|
|
31
|
-
private _workflowForExecution;
|
|
32
31
|
protected getOrCreateWorkflowForExecution(collectionName: string, options: SchematicsExecutionOptions): Promise<NodeWorkflow>;
|
|
33
|
-
|
|
34
|
-
protected getDefaultSchematicCollection(): Promise<string>;
|
|
32
|
+
protected getSchematicCollections(): Promise<Set<string>>;
|
|
35
33
|
protected parseSchematicInfo(schematic: string | undefined): [collectionName: string | undefined, schematicName: string | undefined];
|
|
36
34
|
protected runSchematic(options: {
|
|
37
35
|
executionOptions: SchematicsExecutionOptions;
|
|
@@ -39,6 +37,7 @@ export declare abstract class SchematicsCommandModule extends CommandModule<Sche
|
|
|
39
37
|
collectionName: string;
|
|
40
38
|
schematicName: string;
|
|
41
39
|
}): Promise<number>;
|
|
40
|
+
private defaultProjectDeprecationWarningShown;
|
|
42
41
|
private getProjectName;
|
|
43
42
|
private getResolvePaths;
|
|
44
43
|
}
|
|
@@ -6,27 +6,54 @@
|
|
|
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
|
|
10
|
-
|
|
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 __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
|
+
};
|
|
31
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
11
37
|
};
|
|
12
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.SchematicsCommandModule = void 0;
|
|
39
|
+
exports.SchematicsCommandModule = exports.DEFAULT_SCHEMATICS_COLLECTION = void 0;
|
|
14
40
|
const core_1 = require("@angular-devkit/core");
|
|
15
41
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
16
42
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
17
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
18
43
|
const config_1 = require("../utilities/config");
|
|
44
|
+
const memoize_1 = require("../utilities/memoize");
|
|
19
45
|
const tty_1 = require("../utilities/tty");
|
|
20
46
|
const command_module_1 = require("./command-module");
|
|
21
47
|
const json_schema_1 = require("./utilities/json-schema");
|
|
22
48
|
const schematic_engine_host_1 = require("./utilities/schematic-engine-host");
|
|
23
49
|
const schematic_workflow_1 = require("./utilities/schematic-workflow");
|
|
24
|
-
|
|
50
|
+
exports.DEFAULT_SCHEMATICS_COLLECTION = '@schematics/angular';
|
|
25
51
|
class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
26
52
|
constructor() {
|
|
27
53
|
super(...arguments);
|
|
28
54
|
this.allowPrivateSchematics = false;
|
|
29
55
|
this.shouldReportAnalytics = false;
|
|
56
|
+
this.defaultProjectDeprecationWarningShown = false;
|
|
30
57
|
}
|
|
31
58
|
async builder(argv) {
|
|
32
59
|
return argv
|
|
@@ -62,24 +89,18 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
62
89
|
return (0, json_schema_1.parseJsonSchemaToOptions)(workflow.registry, schemaJson);
|
|
63
90
|
}
|
|
64
91
|
getOrCreateWorkflowForBuilder(collectionName) {
|
|
65
|
-
|
|
66
|
-
return this._workflowForBuilder;
|
|
67
|
-
}
|
|
68
|
-
return (this._workflowForBuilder = new tools_1.NodeWorkflow(this.context.root, {
|
|
92
|
+
return new tools_1.NodeWorkflow(this.context.root, {
|
|
69
93
|
resolvePaths: this.getResolvePaths(collectionName),
|
|
70
94
|
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
71
|
-
})
|
|
95
|
+
});
|
|
72
96
|
}
|
|
73
97
|
async getOrCreateWorkflowForExecution(collectionName, options) {
|
|
74
|
-
if (this._workflowForExecution) {
|
|
75
|
-
return this._workflowForExecution;
|
|
76
|
-
}
|
|
77
98
|
const { logger, root, packageManager } = this.context;
|
|
78
99
|
const { force, dryRun, packageRegistry } = options;
|
|
79
100
|
const workflow = new tools_1.NodeWorkflow(root, {
|
|
80
101
|
force,
|
|
81
102
|
dryRun,
|
|
82
|
-
packageManager,
|
|
103
|
+
packageManager: packageManager.name,
|
|
83
104
|
// A schema registry is required to allow customizing addUndefinedDefaults
|
|
84
105
|
registry: new core_1.schema.CoreSchemaRegistry(schematics_1.formats.standardFormats),
|
|
85
106
|
packageRegistry,
|
|
@@ -118,7 +139,7 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
118
139
|
return options;
|
|
119
140
|
});
|
|
120
141
|
if (options.interactive !== false && (0, tty_1.isTTY)()) {
|
|
121
|
-
workflow.registry.usePromptProvider((definitions) => {
|
|
142
|
+
workflow.registry.usePromptProvider(async (definitions) => {
|
|
122
143
|
const questions = definitions
|
|
123
144
|
.filter((definition) => !options.defaults || definition.default === undefined)
|
|
124
145
|
.map((definition) => {
|
|
@@ -177,35 +198,47 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
177
198
|
}
|
|
178
199
|
return question;
|
|
179
200
|
});
|
|
180
|
-
|
|
201
|
+
if (questions.length) {
|
|
202
|
+
const { prompt } = await Promise.resolve().then(() => __importStar(require('inquirer')));
|
|
203
|
+
return prompt(questions);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return {};
|
|
207
|
+
}
|
|
181
208
|
});
|
|
182
209
|
}
|
|
183
|
-
return
|
|
210
|
+
return workflow;
|
|
184
211
|
}
|
|
185
|
-
async
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
async getSchematicCollections() {
|
|
213
|
+
var _a;
|
|
214
|
+
const getSchematicCollections = (configSection) => {
|
|
215
|
+
if (!configSection) {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
const { schematicCollections, defaultCollection } = configSection;
|
|
219
|
+
if (Array.isArray(schematicCollections)) {
|
|
220
|
+
return new Set(schematicCollections);
|
|
221
|
+
}
|
|
222
|
+
else if (typeof defaultCollection === 'string') {
|
|
223
|
+
return new Set([defaultCollection]);
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
};
|
|
227
|
+
const { workspace, globalConfiguration } = this.context;
|
|
190
228
|
if (workspace) {
|
|
191
229
|
const project = (0, config_1.getProjectByCwd)(workspace);
|
|
192
230
|
if (project) {
|
|
193
|
-
const value = workspace.getProjectCli(project)
|
|
194
|
-
if (
|
|
195
|
-
return
|
|
231
|
+
const value = getSchematicCollections(workspace.getProjectCli(project));
|
|
232
|
+
if (value) {
|
|
233
|
+
return value;
|
|
196
234
|
}
|
|
197
235
|
}
|
|
198
|
-
const value = workspace.getCli()['defaultCollection'];
|
|
199
|
-
if (typeof value === 'string') {
|
|
200
|
-
return (this._defaultSchematicCollection = value);
|
|
201
|
-
}
|
|
202
236
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return (this._defaultSchematicCollection = value);
|
|
237
|
+
const value = (_a = getSchematicCollections(workspace === null || workspace === void 0 ? void 0 : workspace.getCli())) !== null && _a !== void 0 ? _a : getSchematicCollections(globalConfiguration === null || globalConfiguration === void 0 ? void 0 : globalConfiguration.getCli());
|
|
238
|
+
if (value) {
|
|
239
|
+
return value;
|
|
207
240
|
}
|
|
208
|
-
return (
|
|
241
|
+
return new Set([exports.DEFAULT_SCHEMATICS_COLLECTION]);
|
|
209
242
|
}
|
|
210
243
|
parseSchematicInfo(schematic) {
|
|
211
244
|
if (schematic === null || schematic === void 0 ? void 0 : schematic.includes(':')) {
|
|
@@ -260,22 +293,20 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
260
293
|
if (!workspace) {
|
|
261
294
|
return undefined;
|
|
262
295
|
}
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
265
|
-
return
|
|
296
|
+
const projectName = (0, config_1.getProjectByCwd)(workspace);
|
|
297
|
+
if (projectName) {
|
|
298
|
+
return projectName;
|
|
266
299
|
}
|
|
267
|
-
|
|
268
|
-
|
|
300
|
+
const defaultProjectName = workspace.extensions['defaultProject'];
|
|
301
|
+
if (typeof defaultProjectName === 'string' && defaultProjectName) {
|
|
302
|
+
if (!this.defaultProjectDeprecationWarningShown) {
|
|
269
303
|
logger.warn(core_1.tags.oneLine `
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
Using default workspace project instead.
|
|
304
|
+
DEPRECATED: The 'defaultProject' workspace option has been deprecated.
|
|
305
|
+
The project to use will be determined from the current working directory.
|
|
273
306
|
`);
|
|
307
|
+
this.defaultProjectDeprecationWarningShown = true;
|
|
274
308
|
}
|
|
275
|
-
|
|
276
|
-
if (typeof defaultProjectName === 'string' && defaultProjectName) {
|
|
277
|
-
return defaultProjectName;
|
|
278
|
-
}
|
|
309
|
+
return defaultProjectName;
|
|
279
310
|
}
|
|
280
311
|
return undefined;
|
|
281
312
|
}
|
|
@@ -283,7 +314,7 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
283
314
|
const { workspace, root } = this.context;
|
|
284
315
|
return workspace
|
|
285
316
|
? // Workspace
|
|
286
|
-
collectionName === DEFAULT_SCHEMATICS_COLLECTION
|
|
317
|
+
collectionName === exports.DEFAULT_SCHEMATICS_COLLECTION
|
|
287
318
|
? // Favor __dirname for @schematics/angular to use the build-in version
|
|
288
319
|
[__dirname, process.cwd(), root]
|
|
289
320
|
: [process.cwd(), root, __dirname]
|
|
@@ -291,5 +322,14 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
291
322
|
[__dirname, process.cwd()];
|
|
292
323
|
}
|
|
293
324
|
}
|
|
294
|
-
exports.SchematicsCommandModule = SchematicsCommandModule;
|
|
295
325
|
SchematicsCommandModule.scope = command_module_1.CommandScope.In;
|
|
326
|
+
__decorate([
|
|
327
|
+
memoize_1.memoize
|
|
328
|
+
], SchematicsCommandModule.prototype, "getOrCreateWorkflowForBuilder", null);
|
|
329
|
+
__decorate([
|
|
330
|
+
memoize_1.memoize
|
|
331
|
+
], SchematicsCommandModule.prototype, "getOrCreateWorkflowForExecution", null);
|
|
332
|
+
__decorate([
|
|
333
|
+
memoize_1.memoize
|
|
334
|
+
], SchematicsCommandModule.prototype, "getSchematicCollections", null);
|
|
335
|
+
exports.SchematicsCommandModule = SchematicsCommandModule;
|
|
@@ -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;
|