@angular/cli 14.0.0-next.4 → 14.0.0-next.7
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/bin/ng.js +3 -5
- package/lib/cli/index.d.ts +1 -2
- package/lib/cli/index.js +16 -45
- package/lib/config/schema.json +30 -15
- package/lib/config/workspace-schema.d.ts +6 -1
- package/lib/init.js +10 -9
- package/package.json +18 -20
- package/{models → src/analytics}/analytics-collector.d.ts +0 -0
- package/{models → src/analytics}/analytics-collector.js +8 -2
- package/src/analytics/analytics.d.ts +47 -0
- package/src/analytics/analytics.js +304 -0
- package/src/command-builder/architect-base-command-module.d.ts +23 -0
- package/src/command-builder/architect-base-command-module.js +103 -0
- package/src/command-builder/architect-command-module.d.ts +22 -0
- package/src/command-builder/architect-command-module.js +108 -0
- package/src/command-builder/command-module.d.ts +89 -0
- package/src/command-builder/command-module.js +191 -0
- package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
- package/src/command-builder/command-runner.js +152 -0
- package/src/command-builder/schematics-command-module.d.ts +46 -0
- package/src/command-builder/schematics-command-module.js +335 -0
- package/src/command-builder/utilities/command.d.ts +13 -0
- package/src/command-builder/utilities/command.js +27 -0
- package/src/command-builder/utilities/json-help.d.ts +36 -0
- package/src/command-builder/utilities/json-help.js +94 -0
- package/src/command-builder/utilities/json-schema.d.ts +40 -0
- package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
- package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
- package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
- package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
- package/src/command-builder/utilities/schematic-workflow.js +68 -0
- package/src/commands/add/cli.d.ts +33 -0
- package/{commands/add-impl.js → src/commands/add/cli.js} +108 -80
- package/src/commands/add/long-description.md +7 -0
- package/src/commands/analytics/cli.d.ts +16 -0
- package/src/commands/analytics/cli.js +35 -0
- package/src/commands/analytics/info/cli.d.ts +16 -0
- package/src/commands/analytics/info/cli.js +26 -0
- package/src/commands/analytics/settings/cli.d.ts +35 -0
- package/src/commands/analytics/settings/cli.js +61 -0
- package/src/commands/build/cli.d.ts +16 -0
- package/src/commands/build/cli.js +23 -0
- package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
- 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 +50 -0
- package/src/commands/config/cli.d.ts +24 -0
- package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
- package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
- package/src/commands/deploy/cli.d.ts +16 -0
- package/src/commands/deploy/cli.js +35 -0
- package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
- package/src/commands/doc/cli.d.ts +23 -0
- package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
- package/src/commands/e2e/cli.d.ts +17 -0
- package/src/commands/e2e/cli.js +34 -0
- package/src/commands/extract-i18n/cli.d.ts +15 -0
- package/src/commands/extract-i18n/cli.js +20 -0
- package/src/commands/generate/cli.d.ts +39 -0
- package/src/commands/generate/cli.js +145 -0
- package/src/commands/lint/cli.d.ts +16 -0
- package/src/commands/lint/cli.js +31 -0
- package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
- package/src/commands/make-this-awesome/cli.d.ts +17 -0
- package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
- package/src/commands/new/cli.d.ts +27 -0
- package/src/commands/new/cli.js +77 -0
- package/src/commands/run/cli.d.ts +23 -0
- package/src/commands/run/cli.js +59 -0
- package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
- package/src/commands/serve/cli.d.ts +16 -0
- package/src/commands/serve/cli.js +21 -0
- package/src/commands/test/cli.d.ts +16 -0
- package/src/commands/test/cli.js +23 -0
- package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
- package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +26 -9
- package/{commands/update-impl.js → src/commands/update/cli.js} +362 -316
- package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
- package/src/commands/update/schematic/index.js +33 -20
- package/src/commands/version/cli.d.ts +18 -0
- package/{commands/version-impl.js → src/commands/version/cli.js} +56 -74
- package/src/typings-bazel.d.ts +14 -0
- package/src/typings.d.ts +1 -14
- package/{utilities → src/utilities}/color.d.ts +0 -0
- package/{utilities → src/utilities}/color.js +5 -1
- package/{utilities → src/utilities}/config.d.ts +2 -2
- package/{utilities → src/utilities}/config.js +24 -16
- package/src/utilities/environment-options.d.ts +12 -0
- package/src/utilities/environment-options.js +24 -0
- package/{utilities → src/utilities}/find-up.d.ts +0 -0
- package/{utilities → src/utilities}/find-up.js +5 -1
- package/{utilities → src/utilities}/json-file.d.ts +0 -0
- package/{utilities → src/utilities}/json-file.js +0 -0
- package/{utilities → src/utilities}/log-file.d.ts +0 -0
- package/{utilities → src/utilities}/log-file.js +0 -0
- package/src/utilities/package-manager.d.ts +41 -0
- package/src/utilities/package-manager.js +276 -0
- package/{utilities → src/utilities}/package-metadata.d.ts +15 -37
- package/{utilities → src/utilities}/package-metadata.js +15 -27
- package/{utilities → src/utilities}/package-tree.d.ts +2 -2
- package/{utilities → src/utilities}/package-tree.js +5 -1
- package/{utilities → src/utilities}/project.d.ts +0 -0
- package/{utilities → src/utilities}/project.js +5 -1
- package/{utilities → src/utilities}/prompt.d.ts +0 -0
- package/{utilities → src/utilities}/prompt.js +7 -3
- package/{utilities → src/utilities}/spinner.d.ts +0 -0
- package/{utilities → src/utilities}/spinner.js +0 -0
- package/{utilities → src/utilities}/tty.d.ts +0 -0
- package/{utilities → src/utilities}/tty.js +0 -0
- package/{models → src/utilities}/version.d.ts +2 -1
- package/{models → src/utilities}/version.js +6 -6
- package/bin/postinstall/analytics-prompt.js +0 -27
- package/bin/postinstall/script.js +0 -16
- package/commands/add-impl.d.ts +0 -21
- package/commands/add.d.ts +0 -42
- package/commands/add.js +0 -10
- package/commands/add.json +0 -54
- package/commands/add.md +0 -10
- package/commands/analytics-impl.d.ts +0 -13
- package/commands/analytics-impl.js +0 -80
- package/commands/analytics-long.md +0 -8
- package/commands/analytics.d.ts +0 -46
- package/commands/analytics.js +0 -31
- package/commands/analytics.json +0 -37
- package/commands/build-impl.d.ts +0 -14
- package/commands/build-impl.js +0 -21
- package/commands/build.d.ts +0 -30
- package/commands/build.js +0 -10
- package/commands/build.json +0 -16
- package/commands/config-impl.d.ts +0 -15
- package/commands/config.d.ts +0 -34
- package/commands/config.js +0 -10
- package/commands/config.json +0 -43
- package/commands/definitions.json +0 -66
- package/commands/deploy-impl.d.ts +0 -15
- package/commands/deploy-impl.js +0 -36
- package/commands/deploy.d.ts +0 -30
- package/commands/deploy.js +0 -10
- package/commands/deploy.json +0 -34
- package/commands/doc-impl.d.ts +0 -13
- package/commands/doc.d.ts +0 -39
- package/commands/doc.js +0 -14
- package/commands/doc.json +0 -46
- package/commands/e2e-impl.d.ts +0 -16
- package/commands/e2e-impl.js +0 -36
- package/commands/e2e-long.md +0 -4
- package/commands/e2e.d.ts +0 -29
- package/commands/e2e.js +0 -10
- package/commands/e2e.json +0 -17
- package/commands/easter-egg-impl.d.ts +0 -12
- package/commands/easter-egg.d.ts +0 -14
- package/commands/easter-egg.js +0 -10
- package/commands/easter-egg.json +0 -12
- package/commands/extract-i18n-impl.d.ts +0 -14
- package/commands/extract-i18n-impl.js +0 -21
- package/commands/extract-i18n.d.ts +0 -29
- package/commands/extract-i18n.js +0 -10
- package/commands/extract-i18n.json +0 -15
- package/commands/generate-impl.d.ts +0 -18
- package/commands/generate-impl.js +0 -89
- package/commands/generate.d.ts +0 -37
- package/commands/generate.js +0 -10
- package/commands/generate.json +0 -31
- package/commands/help-impl.d.ts +0 -12
- package/commands/help-impl.js +0 -26
- package/commands/help-long.md +0 -7
- package/commands/help.d.ts +0 -17
- package/commands/help.js +0 -10
- package/commands/help.json +0 -13
- package/commands/lint-impl.d.ts +0 -16
- package/commands/lint-impl.js +0 -69
- package/commands/lint.d.ts +0 -29
- package/commands/lint.js +0 -10
- package/commands/lint.json +0 -36
- package/commands/new-impl.d.ts +0 -16
- package/commands/new-impl.js +0 -37
- package/commands/new.d.ts +0 -41
- package/commands/new.js +0 -10
- package/commands/new.json +0 -34
- package/commands/new.md +0 -16
- package/commands/run-impl.d.ts +0 -13
- package/commands/run-impl.js +0 -22
- package/commands/run.d.ts +0 -30
- package/commands/run.js +0 -10
- package/commands/run.json +0 -36
- package/commands/serve-impl.d.ts +0 -15
- package/commands/serve-impl.js +0 -24
- package/commands/serve.d.ts +0 -29
- package/commands/serve.js +0 -10
- package/commands/serve.json +0 -17
- package/commands/test-impl.d.ts +0 -15
- package/commands/test-impl.js +0 -22
- package/commands/test.d.ts +0 -29
- package/commands/test.js +0 -10
- package/commands/test.json +0 -17
- package/commands/update.d.ts +0 -61
- package/commands/update.js +0 -10
- package/commands/update.json +0 -78
- package/commands/version-impl.d.ts +0 -17
- package/commands/version.d.ts +0 -17
- package/commands/version.js +0 -10
- package/commands/version.json +0 -13
- package/commands.json +0 -20
- package/models/analytics.d.ts +0 -58
- package/models/analytics.js +0 -358
- package/models/architect-command.d.ts +0 -35
- package/models/architect-command.js +0 -364
- package/models/command-runner.d.ts +0 -24
- package/models/command-runner.js +0 -241
- package/models/command.d.ts +0 -34
- package/models/command.js +0 -143
- package/models/interface.d.ts +0 -196
- package/models/interface.js +0 -31
- package/models/parser.d.ts +0 -39
- package/models/parser.js +0 -349
- package/models/schematic-command.d.ts +0 -55
- package/models/schematic-command.js +0 -485
- package/utilities/install-package.d.ts +0 -16
- package/utilities/install-package.js +0 -193
- package/utilities/json-schema.d.ts +0 -17
- package/utilities/package-json.d.ts +0 -249
- package/utilities/package-manager.d.ts +0 -13
- package/utilities/package-manager.js +0 -106
|
@@ -0,0 +1,191 @@
|
|
|
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.CommandModuleError = exports.CommandModule = exports.CommandScope = void 0;
|
|
34
|
+
const core_1 = require("@angular-devkit/core");
|
|
35
|
+
const fs_1 = require("fs");
|
|
36
|
+
const path = __importStar(require("path"));
|
|
37
|
+
const helpers_1 = require("yargs/helpers");
|
|
38
|
+
const analytics_1 = require("../analytics/analytics");
|
|
39
|
+
var CommandScope;
|
|
40
|
+
(function (CommandScope) {
|
|
41
|
+
/** Command can only run inside an Angular workspace. */
|
|
42
|
+
CommandScope[CommandScope["In"] = 0] = "In";
|
|
43
|
+
/** Command can only run outside an Angular workspace. */
|
|
44
|
+
CommandScope[CommandScope["Out"] = 1] = "Out";
|
|
45
|
+
/** Command can run inside and outside an Angular workspace. */
|
|
46
|
+
CommandScope[CommandScope["Both"] = 2] = "Both";
|
|
47
|
+
})(CommandScope = exports.CommandScope || (exports.CommandScope = {}));
|
|
48
|
+
class CommandModule {
|
|
49
|
+
constructor(context) {
|
|
50
|
+
this.context = context;
|
|
51
|
+
this.shouldReportAnalytics = true;
|
|
52
|
+
this.optionsWithAnalytics = new Map();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Description object which contains the long command descroption.
|
|
56
|
+
* This is used to generate JSON help wich is used in AIO.
|
|
57
|
+
*
|
|
58
|
+
* `false` will result in a hidden command.
|
|
59
|
+
*/
|
|
60
|
+
get fullDescribe() {
|
|
61
|
+
return this.describe === false
|
|
62
|
+
? false
|
|
63
|
+
: {
|
|
64
|
+
describe: this.describe,
|
|
65
|
+
...(this.longDescriptionPath
|
|
66
|
+
? {
|
|
67
|
+
longDescriptionRelativePath: path
|
|
68
|
+
.relative(path.join(__dirname, '../../../../'), this.longDescriptionPath)
|
|
69
|
+
.replace(/\\/g, path.posix.sep),
|
|
70
|
+
longDescription: (0, fs_1.readFileSync)(this.longDescriptionPath, 'utf8').replace(/\r\n/g, '\n'),
|
|
71
|
+
}
|
|
72
|
+
: {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
get commandName() {
|
|
76
|
+
return this.command.split(' ', 1)[0];
|
|
77
|
+
}
|
|
78
|
+
async handler(args) {
|
|
79
|
+
const { _, $0, ...options } = args;
|
|
80
|
+
// Camelize options as yargs will return the object in kebab-case when camel casing is disabled.
|
|
81
|
+
const camelCasedOptions = {};
|
|
82
|
+
for (const [key, value] of Object.entries(options)) {
|
|
83
|
+
camelCasedOptions[helpers_1.Parser.camelCase(key)] = value;
|
|
84
|
+
}
|
|
85
|
+
// Gather and report analytics.
|
|
86
|
+
const analytics = await this.getAnalytics();
|
|
87
|
+
if (this.shouldReportAnalytics) {
|
|
88
|
+
await this.reportAnalytics(camelCasedOptions);
|
|
89
|
+
}
|
|
90
|
+
let exitCode;
|
|
91
|
+
try {
|
|
92
|
+
// Run and time command.
|
|
93
|
+
const startTime = Date.now();
|
|
94
|
+
exitCode = await this.run(camelCasedOptions);
|
|
95
|
+
const endTime = Date.now();
|
|
96
|
+
analytics.timing(this.commandName, 'duration', endTime - startTime);
|
|
97
|
+
await analytics.flush();
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
if (e instanceof core_1.schema.SchemaValidationException) {
|
|
101
|
+
this.context.logger.fatal(`Error: ${e.message}`);
|
|
102
|
+
exitCode = 1;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
if (typeof exitCode === 'number' && exitCode > 0) {
|
|
110
|
+
process.exitCode = exitCode;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async reportAnalytics(options, paths = [], dimensions = []) {
|
|
115
|
+
for (const [name, ua] of this.optionsWithAnalytics) {
|
|
116
|
+
const value = options[name];
|
|
117
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
118
|
+
dimensions[ua] = value;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const analytics = await this.getAnalytics();
|
|
122
|
+
analytics.pageview('/command/' + [this.commandName, ...paths].join('/'), {
|
|
123
|
+
dimensions,
|
|
124
|
+
metrics: [],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async getAnalytics() {
|
|
128
|
+
if (this._analytics) {
|
|
129
|
+
return this._analytics;
|
|
130
|
+
}
|
|
131
|
+
return (this._analytics = await (0, analytics_1.createAnalytics)(!!this.context.workspace,
|
|
132
|
+
// Don't prompt for `ng update` and `ng analytics` commands.
|
|
133
|
+
['update', 'analytics'].includes(this.commandName)));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Adds schema options to a command also this keeps track of options that are required for analytics.
|
|
137
|
+
* **Note:** This method should be called from the command bundler method.
|
|
138
|
+
*/
|
|
139
|
+
addSchemaOptionsToCommand(localYargs, options) {
|
|
140
|
+
const workingDir = (0, core_1.normalize)(path.relative(this.context.root, process.cwd()));
|
|
141
|
+
for (const option of options) {
|
|
142
|
+
const { default: defaultVal, positional, deprecated, description, alias, userAnalytics, type, hidden, name, choices, format, } = option;
|
|
143
|
+
const sharedOptions = {
|
|
144
|
+
alias,
|
|
145
|
+
hidden,
|
|
146
|
+
description,
|
|
147
|
+
deprecated,
|
|
148
|
+
choices,
|
|
149
|
+
// This should only be done when `--help` is used otherwise default will override options set in angular.json.
|
|
150
|
+
...(this.context.args.options.help ? { default: defaultVal } : {}),
|
|
151
|
+
};
|
|
152
|
+
// Special case for schematics
|
|
153
|
+
if (workingDir && format === 'path' && name === 'path' && hidden) {
|
|
154
|
+
sharedOptions.default = workingDir;
|
|
155
|
+
}
|
|
156
|
+
if (positional === undefined) {
|
|
157
|
+
localYargs = localYargs.option(core_1.strings.dasherize(name), {
|
|
158
|
+
type,
|
|
159
|
+
...sharedOptions,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
localYargs = localYargs.positional(core_1.strings.dasherize(name), {
|
|
164
|
+
type: type === 'array' || type === 'count' ? 'string' : type,
|
|
165
|
+
...sharedOptions,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
// Record option of analytics.
|
|
169
|
+
if (userAnalytics !== undefined) {
|
|
170
|
+
this.optionsWithAnalytics.set(name, userAnalytics);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return localYargs;
|
|
174
|
+
}
|
|
175
|
+
getWorkspaceOrThrow() {
|
|
176
|
+
const { workspace } = this.context;
|
|
177
|
+
if (!workspace) {
|
|
178
|
+
throw new CommandModuleError('A workspace is required for this command.');
|
|
179
|
+
}
|
|
180
|
+
return workspace;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.CommandModule = CommandModule;
|
|
184
|
+
CommandModule.scope = CommandScope.Both;
|
|
185
|
+
/**
|
|
186
|
+
* Creates an known command module error.
|
|
187
|
+
* This is used so during executation we can filter between known validation error and real non handled errors.
|
|
188
|
+
*/
|
|
189
|
+
class CommandModuleError extends Error {
|
|
190
|
+
}
|
|
191
|
+
exports.CommandModuleError = CommandModuleError;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @license
|
|
4
3
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -6,4 +5,5 @@
|
|
|
6
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
6
|
* found in the LICENSE file at https://angular.io/license
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
import { logging } from '@angular-devkit/core';
|
|
9
|
+
export declare function runCommand(args: string[], logger: logging.Logger): Promise<number>;
|
|
@@ -0,0 +1,152 @@
|
|
|
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.runCommand = void 0;
|
|
14
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
15
|
+
const helpers_1 = require("yargs/helpers");
|
|
16
|
+
const cli_1 = require("../commands/add/cli");
|
|
17
|
+
const cli_2 = require("../commands/analytics/cli");
|
|
18
|
+
const cli_3 = require("../commands/build/cli");
|
|
19
|
+
const cli_4 = require("../commands/cache/cli");
|
|
20
|
+
const cli_5 = require("../commands/config/cli");
|
|
21
|
+
const cli_6 = require("../commands/deploy/cli");
|
|
22
|
+
const cli_7 = require("../commands/doc/cli");
|
|
23
|
+
const cli_8 = require("../commands/e2e/cli");
|
|
24
|
+
const cli_9 = require("../commands/extract-i18n/cli");
|
|
25
|
+
const cli_10 = require("../commands/generate/cli");
|
|
26
|
+
const cli_11 = require("../commands/lint/cli");
|
|
27
|
+
const cli_12 = require("../commands/make-this-awesome/cli");
|
|
28
|
+
const cli_13 = require("../commands/new/cli");
|
|
29
|
+
const cli_14 = require("../commands/run/cli");
|
|
30
|
+
const cli_15 = require("../commands/serve/cli");
|
|
31
|
+
const cli_16 = require("../commands/test/cli");
|
|
32
|
+
const cli_17 = require("../commands/update/cli");
|
|
33
|
+
const cli_18 = require("../commands/version/cli");
|
|
34
|
+
const color_1 = require("../utilities/color");
|
|
35
|
+
const config_1 = require("../utilities/config");
|
|
36
|
+
const package_manager_1 = require("../utilities/package-manager");
|
|
37
|
+
const command_module_1 = require("./command-module");
|
|
38
|
+
const command_1 = require("./utilities/command");
|
|
39
|
+
const json_help_1 = require("./utilities/json-help");
|
|
40
|
+
const COMMANDS = [
|
|
41
|
+
cli_18.VersionCommandModule,
|
|
42
|
+
cli_7.DocCommandModule,
|
|
43
|
+
cli_12.AwesomeCommandModule,
|
|
44
|
+
cli_5.ConfigCommandModule,
|
|
45
|
+
cli_2.AnalyticsCommandModule,
|
|
46
|
+
cli_1.AddCommandModule,
|
|
47
|
+
cli_10.GenerateCommandModule,
|
|
48
|
+
cli_3.BuildCommandModule,
|
|
49
|
+
cli_8.E2eCommandModule,
|
|
50
|
+
cli_16.TestCommandModule,
|
|
51
|
+
cli_15.ServeCommandModule,
|
|
52
|
+
cli_9.ExtractI18nCommandModule,
|
|
53
|
+
cli_6.DeployCommandModule,
|
|
54
|
+
cli_11.LintCommandModule,
|
|
55
|
+
cli_13.NewCommandModule,
|
|
56
|
+
cli_17.UpdateCommandModule,
|
|
57
|
+
cli_14.RunCommandModule,
|
|
58
|
+
cli_4.CacheCommandModule,
|
|
59
|
+
].sort(); // Will be sorted by class name.
|
|
60
|
+
const yargsParser = helpers_1.Parser;
|
|
61
|
+
async function runCommand(args, logger) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const { $0, _: positional, help = false, jsonHelp = false, ...rest } = yargsParser(args, { boolean: ['help', 'json-help'], alias: { 'collection': 'c' } });
|
|
64
|
+
let workspace;
|
|
65
|
+
let globalConfiguration;
|
|
66
|
+
try {
|
|
67
|
+
[workspace, globalConfiguration] = await Promise.all([
|
|
68
|
+
(0, config_1.getWorkspace)('local'),
|
|
69
|
+
(0, config_1.getWorkspace)('global'),
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
logger.fatal(e.message);
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
const root = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.basePath) !== null && _a !== void 0 ? _a : process.cwd();
|
|
77
|
+
const context = {
|
|
78
|
+
globalConfiguration,
|
|
79
|
+
workspace,
|
|
80
|
+
logger,
|
|
81
|
+
currentDirectory: process.cwd(),
|
|
82
|
+
root,
|
|
83
|
+
packageManager: new package_manager_1.PackageManagerUtils({ globalConfiguration, workspace, root }),
|
|
84
|
+
args: {
|
|
85
|
+
positional: positional.map((v) => v.toString()),
|
|
86
|
+
options: {
|
|
87
|
+
help,
|
|
88
|
+
jsonHelp,
|
|
89
|
+
...rest,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
let localYargs = (0, yargs_1.default)(args);
|
|
94
|
+
for (const CommandModule of COMMANDS) {
|
|
95
|
+
if (!jsonHelp) {
|
|
96
|
+
// Skip scope validation when running with '--json-help' since it's easier to generate the output for all commands this way.
|
|
97
|
+
const scope = CommandModule.scope;
|
|
98
|
+
if ((scope === command_module_1.CommandScope.In && !workspace) || (scope === command_module_1.CommandScope.Out && workspace)) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
localYargs = (0, command_1.addCommandModuleToYargs)(localYargs, CommandModule, context);
|
|
103
|
+
}
|
|
104
|
+
if (jsonHelp) {
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
+
localYargs.getInternalMethods().getUsageInstance().help = () => (0, json_help_1.jsonHelpUsage)();
|
|
107
|
+
}
|
|
108
|
+
await localYargs
|
|
109
|
+
.scriptName('ng')
|
|
110
|
+
// https://github.com/yargs/yargs/blob/main/docs/advanced.md#customizing-yargs-parser
|
|
111
|
+
.parserConfiguration({
|
|
112
|
+
'populate--': true,
|
|
113
|
+
'unknown-options-as-args': false,
|
|
114
|
+
'dot-notation': false,
|
|
115
|
+
'boolean-negation': true,
|
|
116
|
+
'strip-aliased': true,
|
|
117
|
+
'strip-dashed': true,
|
|
118
|
+
'camel-case-expansion': false,
|
|
119
|
+
})
|
|
120
|
+
.option('json-help', {
|
|
121
|
+
describe: 'Show help in JSON format.',
|
|
122
|
+
implies: ['help'],
|
|
123
|
+
hidden: true,
|
|
124
|
+
type: 'boolean',
|
|
125
|
+
})
|
|
126
|
+
.help('help', 'Shows a help message for this command in the console.')
|
|
127
|
+
// A complete list of strings can be found: https://github.com/yargs/yargs/blob/main/locales/en.json
|
|
128
|
+
.updateStrings({
|
|
129
|
+
'Commands:': color_1.colors.cyan('Commands:'),
|
|
130
|
+
'Options:': color_1.colors.cyan('Options:'),
|
|
131
|
+
'Positionals:': color_1.colors.cyan('Arguments:'),
|
|
132
|
+
'deprecated': color_1.colors.yellow('deprecated'),
|
|
133
|
+
'deprecated: %s': color_1.colors.yellow('deprecated:') + ' %s',
|
|
134
|
+
'Did you mean %s?': 'Unknown command. Did you mean %s?',
|
|
135
|
+
})
|
|
136
|
+
.demandCommand(1, command_1.demandCommandFailureMessage)
|
|
137
|
+
.recommendCommands()
|
|
138
|
+
.version(false)
|
|
139
|
+
.showHelpOnFail(false)
|
|
140
|
+
.strict()
|
|
141
|
+
.fail((msg, err) => {
|
|
142
|
+
throw msg
|
|
143
|
+
? // Validation failed example: `Unknown argument:`
|
|
144
|
+
new command_module_1.CommandModuleError(msg)
|
|
145
|
+
: // Unknown exception, re-throw.
|
|
146
|
+
err;
|
|
147
|
+
})
|
|
148
|
+
.wrap(yargs_1.default.terminalWidth())
|
|
149
|
+
.parseAsync();
|
|
150
|
+
return (_b = process.exitCode) !== null && _b !== void 0 ? _b : 0;
|
|
151
|
+
}
|
|
152
|
+
exports.runCommand = runCommand;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { Collection } from '@angular-devkit/schematics';
|
|
9
|
+
import { FileSystemCollectionDescription, FileSystemSchematicDescription, NodeWorkflow } from '@angular-devkit/schematics/tools';
|
|
10
|
+
import { Argv } from 'yargs';
|
|
11
|
+
import { CommandModule, CommandModuleImplementation, CommandScope, Options, OtherOptions } from './command-module';
|
|
12
|
+
import { Option } from './utilities/json-schema';
|
|
13
|
+
export declare const DEFAULT_SCHEMATICS_COLLECTION = "@schematics/angular";
|
|
14
|
+
export interface SchematicsCommandArgs {
|
|
15
|
+
interactive: boolean;
|
|
16
|
+
force: boolean;
|
|
17
|
+
'dry-run': boolean;
|
|
18
|
+
defaults: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface SchematicsExecutionOptions extends Options<SchematicsCommandArgs> {
|
|
21
|
+
packageRegistry?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare abstract class SchematicsCommandModule extends CommandModule<SchematicsCommandArgs> implements CommandModuleImplementation<SchematicsCommandArgs> {
|
|
24
|
+
static scope: CommandScope;
|
|
25
|
+
protected readonly allowPrivateSchematics: boolean;
|
|
26
|
+
protected readonly shouldReportAnalytics = false;
|
|
27
|
+
builder(argv: Argv): Promise<Argv<SchematicsCommandArgs>>;
|
|
28
|
+
/** Get schematic schema options.*/
|
|
29
|
+
protected getSchematicOptions(collection: Collection<FileSystemCollectionDescription, FileSystemSchematicDescription>, schematicName: string, workflow: NodeWorkflow): Promise<Option[]>;
|
|
30
|
+
private _workflowForBuilder;
|
|
31
|
+
protected getOrCreateWorkflowForBuilder(collectionName: string): NodeWorkflow;
|
|
32
|
+
private _workflowForExecution;
|
|
33
|
+
protected getOrCreateWorkflowForExecution(collectionName: string, options: SchematicsExecutionOptions): Promise<NodeWorkflow>;
|
|
34
|
+
private _schematicCollections;
|
|
35
|
+
protected getSchematicCollections(): Promise<Set<string>>;
|
|
36
|
+
protected parseSchematicInfo(schematic: string | undefined): [collectionName: string | undefined, schematicName: string | undefined];
|
|
37
|
+
protected runSchematic(options: {
|
|
38
|
+
executionOptions: SchematicsExecutionOptions;
|
|
39
|
+
schematicOptions: OtherOptions;
|
|
40
|
+
collectionName: string;
|
|
41
|
+
schematicName: string;
|
|
42
|
+
}): Promise<number>;
|
|
43
|
+
private defaultProjectDeprecationWarningShown;
|
|
44
|
+
private getProjectName;
|
|
45
|
+
private getResolvePaths;
|
|
46
|
+
}
|