@angular/cli 14.0.0-next.1 → 14.0.0-next.12
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 +48 -15
- package/lib/config/workspace-schema.d.ts +18 -1
- package/lib/init.js +10 -9
- package/package.json +21 -23
- 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 +306 -0
- package/src/command-builder/architect-base-command-module.d.ts +30 -0
- package/src/command-builder/architect-base-command-module.js +165 -0
- package/src/command-builder/architect-command-module.d.ts +25 -0
- package/src/command-builder/architect-command-module.js +134 -0
- package/src/command-builder/command-module.d.ts +89 -0
- package/src/command-builder/command-module.js +198 -0
- package/{utilities/package-json.js → src/command-builder/command-runner.d.ts} +2 -2
- package/src/command-builder/command-runner.js +168 -0
- package/src/command-builder/schematics-command-module.d.ts +43 -0
- package/src/command-builder/schematics-command-module.js +333 -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/src/command-builder/utilities/normalize-options-middleware.d.ts +18 -0
- package/src/command-builder/utilities/normalize-options-middleware.js +59 -0
- package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +2 -2
- package/{models → src/command-builder/utilities}/schematic-engine-host.js +33 -18
- 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 +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 +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 +17 -0
- package/src/commands/deploy/cli.js +49 -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 +18 -0
- package/src/commands/e2e/cli.js +35 -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 +17 -0
- package/src/commands/lint/cli.js +28 -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 +82 -0
- package/src/commands/run/cli.d.ts +25 -0
- package/src/commands/run/cli.js +83 -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} +363 -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 +6 -5
- package/{utilities → src/utilities}/config.js +33 -19
- 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 +1 -0
- package/{utilities → src/utilities}/log-file.d.ts +0 -0
- package/{utilities → src/utilities}/log-file.js +0 -0
- package/src/utilities/memoize.d.ts +15 -0
- package/src/utilities/memoize.js +69 -0
- package/src/utilities/package-manager.d.ts +41 -0
- package/src/utilities/package-manager.js +287 -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 +2 -0
- package/{utilities → src/utilities}/prompt.js +25 -4
- 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 -32
- package/commands/extract-i18n.d.ts +0 -29
- package/commands/extract-i18n.js +0 -10
- package/commands/extract-i18n.json +0 -17
- 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/INITIAL_COMMIT_MESSAGE.txt +0 -8
- 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,333 @@
|
|
|
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 __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;
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.SchematicsCommandModule = exports.DEFAULT_SCHEMATICS_COLLECTION = void 0;
|
|
40
|
+
const core_1 = require("@angular-devkit/core");
|
|
41
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
42
|
+
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
43
|
+
const config_1 = require("../utilities/config");
|
|
44
|
+
const memoize_1 = require("../utilities/memoize");
|
|
45
|
+
const tty_1 = require("../utilities/tty");
|
|
46
|
+
const command_module_1 = require("./command-module");
|
|
47
|
+
const json_schema_1 = require("./utilities/json-schema");
|
|
48
|
+
const schematic_engine_host_1 = require("./utilities/schematic-engine-host");
|
|
49
|
+
const schematic_workflow_1 = require("./utilities/schematic-workflow");
|
|
50
|
+
exports.DEFAULT_SCHEMATICS_COLLECTION = '@schematics/angular';
|
|
51
|
+
class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
this.allowPrivateSchematics = false;
|
|
55
|
+
this.shouldReportAnalytics = false;
|
|
56
|
+
this.defaultProjectDeprecationWarningShown = false;
|
|
57
|
+
}
|
|
58
|
+
async builder(argv) {
|
|
59
|
+
return argv
|
|
60
|
+
.option('interactive', {
|
|
61
|
+
describe: 'Enable interactive input prompts.',
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
default: true,
|
|
64
|
+
})
|
|
65
|
+
.option('dry-run', {
|
|
66
|
+
describe: 'Run through and reports activity without writing out results.',
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
default: false,
|
|
69
|
+
})
|
|
70
|
+
.option('defaults', {
|
|
71
|
+
describe: 'Disable interactive input prompts for options with a default.',
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
default: false,
|
|
74
|
+
})
|
|
75
|
+
.option('force', {
|
|
76
|
+
describe: 'Force overwriting of existing files.',
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
default: false,
|
|
79
|
+
})
|
|
80
|
+
.strict();
|
|
81
|
+
}
|
|
82
|
+
/** Get schematic schema options.*/
|
|
83
|
+
async getSchematicOptions(collection, schematicName, workflow) {
|
|
84
|
+
const schematic = collection.createSchematic(schematicName, true);
|
|
85
|
+
const { schemaJson } = schematic.description;
|
|
86
|
+
if (!schemaJson) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
return (0, json_schema_1.parseJsonSchemaToOptions)(workflow.registry, schemaJson);
|
|
90
|
+
}
|
|
91
|
+
getOrCreateWorkflowForBuilder(collectionName) {
|
|
92
|
+
return new tools_1.NodeWorkflow(this.context.root, {
|
|
93
|
+
resolvePaths: this.getResolvePaths(collectionName),
|
|
94
|
+
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async getOrCreateWorkflowForExecution(collectionName, options) {
|
|
98
|
+
const { logger, root, packageManager } = this.context;
|
|
99
|
+
const { force, dryRun, packageRegistry } = options;
|
|
100
|
+
const workflow = new tools_1.NodeWorkflow(root, {
|
|
101
|
+
force,
|
|
102
|
+
dryRun,
|
|
103
|
+
packageManager: packageManager.name,
|
|
104
|
+
// A schema registry is required to allow customizing addUndefinedDefaults
|
|
105
|
+
registry: new core_1.schema.CoreSchemaRegistry(schematics_1.formats.standardFormats),
|
|
106
|
+
packageRegistry,
|
|
107
|
+
resolvePaths: this.getResolvePaths(collectionName),
|
|
108
|
+
schemaValidation: true,
|
|
109
|
+
optionTransforms: [
|
|
110
|
+
// Add configuration file defaults
|
|
111
|
+
async (schematic, current) => {
|
|
112
|
+
const projectName = typeof (current === null || current === void 0 ? void 0 : current.project) === 'string' ? current.project : this.getProjectName();
|
|
113
|
+
return {
|
|
114
|
+
...(await (0, config_1.getSchematicDefaults)(schematic.collection.name, schematic.name, projectName)),
|
|
115
|
+
...current,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
120
|
+
});
|
|
121
|
+
workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
|
|
122
|
+
workflow.registry.addSmartDefaultProvider('projectName', () => this.getProjectName());
|
|
123
|
+
workflow.registry.useXDeprecatedProvider((msg) => logger.warn(msg));
|
|
124
|
+
let shouldReportAnalytics = true;
|
|
125
|
+
workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
|
|
126
|
+
var _a;
|
|
127
|
+
if (shouldReportAnalytics) {
|
|
128
|
+
shouldReportAnalytics = false;
|
|
129
|
+
// ng generate lib -> ng generate
|
|
130
|
+
const commandName = (_a = this.command) === null || _a === void 0 ? void 0 : _a.split(' ', 1)[0];
|
|
131
|
+
await this.reportAnalytics(options, [
|
|
132
|
+
commandName,
|
|
133
|
+
schematic.collection.name.replace(/\//g, '_'),
|
|
134
|
+
schematic.name.replace(/\//g, '_'),
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
return options;
|
|
138
|
+
});
|
|
139
|
+
if (options.interactive !== false && (0, tty_1.isTTY)()) {
|
|
140
|
+
workflow.registry.usePromptProvider(async (definitions) => {
|
|
141
|
+
const questions = definitions
|
|
142
|
+
.filter((definition) => !options.defaults || definition.default === undefined)
|
|
143
|
+
.map((definition) => {
|
|
144
|
+
var _a;
|
|
145
|
+
const question = {
|
|
146
|
+
name: definition.id,
|
|
147
|
+
message: definition.message,
|
|
148
|
+
default: definition.default,
|
|
149
|
+
};
|
|
150
|
+
const validator = definition.validator;
|
|
151
|
+
if (validator) {
|
|
152
|
+
question.validate = (input) => validator(input);
|
|
153
|
+
// Filter allows transformation of the value prior to validation
|
|
154
|
+
question.filter = async (input) => {
|
|
155
|
+
for (const type of definition.propertyTypes) {
|
|
156
|
+
let value;
|
|
157
|
+
switch (type) {
|
|
158
|
+
case 'string':
|
|
159
|
+
value = String(input);
|
|
160
|
+
break;
|
|
161
|
+
case 'integer':
|
|
162
|
+
case 'number':
|
|
163
|
+
value = Number(input);
|
|
164
|
+
break;
|
|
165
|
+
default:
|
|
166
|
+
value = input;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
// Can be a string if validation fails
|
|
170
|
+
const isValid = (await validator(value)) === true;
|
|
171
|
+
if (isValid) {
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return input;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
switch (definition.type) {
|
|
179
|
+
case 'confirmation':
|
|
180
|
+
question.type = 'confirm';
|
|
181
|
+
break;
|
|
182
|
+
case 'list':
|
|
183
|
+
question.type = definition.multiselect ? 'checkbox' : 'list';
|
|
184
|
+
question.choices = (_a = definition.items) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
185
|
+
return typeof item == 'string'
|
|
186
|
+
? item
|
|
187
|
+
: {
|
|
188
|
+
name: item.label,
|
|
189
|
+
value: item.value,
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
break;
|
|
193
|
+
default:
|
|
194
|
+
question.type = definition.type;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
return question;
|
|
198
|
+
});
|
|
199
|
+
if (questions.length) {
|
|
200
|
+
const { prompt } = await Promise.resolve().then(() => __importStar(require('inquirer')));
|
|
201
|
+
return prompt(questions);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
return {};
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return workflow;
|
|
209
|
+
}
|
|
210
|
+
async getSchematicCollections() {
|
|
211
|
+
var _a;
|
|
212
|
+
const getSchematicCollections = (configSection) => {
|
|
213
|
+
if (!configSection) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
const { schematicCollections, defaultCollection } = configSection;
|
|
217
|
+
if (Array.isArray(schematicCollections)) {
|
|
218
|
+
return new Set(schematicCollections);
|
|
219
|
+
}
|
|
220
|
+
else if (typeof defaultCollection === 'string') {
|
|
221
|
+
return new Set([defaultCollection]);
|
|
222
|
+
}
|
|
223
|
+
return undefined;
|
|
224
|
+
};
|
|
225
|
+
const { workspace, globalConfiguration } = this.context;
|
|
226
|
+
if (workspace) {
|
|
227
|
+
const project = (0, config_1.getProjectByCwd)(workspace);
|
|
228
|
+
if (project) {
|
|
229
|
+
const value = getSchematicCollections(workspace.getProjectCli(project));
|
|
230
|
+
if (value) {
|
|
231
|
+
return value;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
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());
|
|
236
|
+
if (value) {
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
return new Set([exports.DEFAULT_SCHEMATICS_COLLECTION]);
|
|
240
|
+
}
|
|
241
|
+
parseSchematicInfo(schematic) {
|
|
242
|
+
if (schematic === null || schematic === void 0 ? void 0 : schematic.includes(':')) {
|
|
243
|
+
const [collectionName, schematicName] = schematic.split(':', 2);
|
|
244
|
+
return [collectionName, schematicName];
|
|
245
|
+
}
|
|
246
|
+
return [undefined, schematic];
|
|
247
|
+
}
|
|
248
|
+
async runSchematic(options) {
|
|
249
|
+
const { logger } = this.context;
|
|
250
|
+
const { schematicOptions, executionOptions, collectionName, schematicName } = options;
|
|
251
|
+
const workflow = await this.getOrCreateWorkflowForExecution(collectionName, executionOptions);
|
|
252
|
+
if (!schematicName) {
|
|
253
|
+
throw new Error('schematicName cannot be undefined.');
|
|
254
|
+
}
|
|
255
|
+
const { unsubscribe, files } = (0, schematic_workflow_1.subscribeToWorkflow)(workflow, logger);
|
|
256
|
+
try {
|
|
257
|
+
await workflow
|
|
258
|
+
.execute({
|
|
259
|
+
collection: collectionName,
|
|
260
|
+
schematic: schematicName,
|
|
261
|
+
options: schematicOptions,
|
|
262
|
+
logger,
|
|
263
|
+
allowPrivate: this.allowPrivateSchematics,
|
|
264
|
+
})
|
|
265
|
+
.toPromise();
|
|
266
|
+
if (!files.size) {
|
|
267
|
+
logger.info('Nothing to be done.');
|
|
268
|
+
}
|
|
269
|
+
if (executionOptions.dryRun) {
|
|
270
|
+
logger.warn(`\nNOTE: The "--dry-run" option means no changes were made.`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
// In case the workflow was not successful, show an appropriate error message.
|
|
275
|
+
if (err instanceof schematics_1.UnsuccessfulWorkflowExecution) {
|
|
276
|
+
// "See above" because we already printed the error.
|
|
277
|
+
logger.fatal('The Schematic workflow failed. See above.');
|
|
278
|
+
return 1;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
throw err;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
unsubscribe();
|
|
286
|
+
}
|
|
287
|
+
return 0;
|
|
288
|
+
}
|
|
289
|
+
getProjectName() {
|
|
290
|
+
const { workspace, logger } = this.context;
|
|
291
|
+
if (!workspace) {
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
const projectName = (0, config_1.getProjectByCwd)(workspace);
|
|
295
|
+
if (projectName) {
|
|
296
|
+
return projectName;
|
|
297
|
+
}
|
|
298
|
+
const defaultProjectName = workspace.extensions['defaultProject'];
|
|
299
|
+
if (typeof defaultProjectName === 'string' && defaultProjectName) {
|
|
300
|
+
if (!this.defaultProjectDeprecationWarningShown) {
|
|
301
|
+
logger.warn(core_1.tags.oneLine `
|
|
302
|
+
DEPRECATED: The 'defaultProject' workspace option has been deprecated.
|
|
303
|
+
The project to use will be determined from the current working directory.
|
|
304
|
+
`);
|
|
305
|
+
this.defaultProjectDeprecationWarningShown = true;
|
|
306
|
+
}
|
|
307
|
+
return defaultProjectName;
|
|
308
|
+
}
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
getResolvePaths(collectionName) {
|
|
312
|
+
const { workspace, root } = this.context;
|
|
313
|
+
return workspace
|
|
314
|
+
? // Workspace
|
|
315
|
+
collectionName === exports.DEFAULT_SCHEMATICS_COLLECTION
|
|
316
|
+
? // Favor __dirname for @schematics/angular to use the build-in version
|
|
317
|
+
[__dirname, process.cwd(), root]
|
|
318
|
+
: [process.cwd(), root, __dirname]
|
|
319
|
+
: // Global
|
|
320
|
+
[__dirname, process.cwd()];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
SchematicsCommandModule.scope = command_module_1.CommandScope.In;
|
|
324
|
+
__decorate([
|
|
325
|
+
memoize_1.memoize
|
|
326
|
+
], SchematicsCommandModule.prototype, "getOrCreateWorkflowForBuilder", null);
|
|
327
|
+
__decorate([
|
|
328
|
+
memoize_1.memoize
|
|
329
|
+
], SchematicsCommandModule.prototype, "getOrCreateWorkflowForExecution", null);
|
|
330
|
+
__decorate([
|
|
331
|
+
memoize_1.memoize
|
|
332
|
+
], SchematicsCommandModule.prototype, "getSchematicCollections", null);
|
|
333
|
+
exports.SchematicsCommandModule = SchematicsCommandModule;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { CommandContext, CommandModule, CommandModuleImplementation } from '../command-module';
|
|
10
|
+
export declare const demandCommandFailureMessage = "You need to specify a command before moving on. Use '--help' to view the available commands.";
|
|
11
|
+
export declare function addCommandModuleToYargs<T, U extends Partial<CommandModuleImplementation> & {
|
|
12
|
+
new (context: CommandContext): Partial<CommandModuleImplementation> & CommandModule;
|
|
13
|
+
}>(localYargs: Argv<T>, commandModule: U, context: CommandContext): Argv<T>;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.addCommandModuleToYargs = exports.demandCommandFailureMessage = void 0;
|
|
11
|
+
exports.demandCommandFailureMessage = `You need to specify a command before moving on. Use '--help' to view the available commands.`;
|
|
12
|
+
function addCommandModuleToYargs(localYargs, commandModule, context) {
|
|
13
|
+
const cmd = new commandModule(context);
|
|
14
|
+
const describe = context.args.options.jsonHelp ? cmd.fullDescribe : cmd.describe;
|
|
15
|
+
return localYargs.command({
|
|
16
|
+
command: cmd.command,
|
|
17
|
+
aliases: cmd.aliases,
|
|
18
|
+
describe:
|
|
19
|
+
// We cannot add custom fields in help, such as long command description which is used in AIO.
|
|
20
|
+
// Therefore, we get around this by adding a complex object as a string which we later parse when generating the help files.
|
|
21
|
+
typeof describe === 'object' ? JSON.stringify(describe) : describe,
|
|
22
|
+
deprecated: cmd.deprecated,
|
|
23
|
+
builder: (argv) => cmd.builder(argv),
|
|
24
|
+
handler: (args) => cmd.handler(args),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.addCommandModuleToYargs = addCommandModuleToYargs;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
interface JsonHelpOption {
|
|
9
|
+
name: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
deprecated: boolean | string;
|
|
12
|
+
aliases?: string[];
|
|
13
|
+
default?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
positional?: number;
|
|
16
|
+
enum?: string[];
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
19
|
+
interface JsonHelpDescription {
|
|
20
|
+
shortDescription?: string;
|
|
21
|
+
longDescription?: string;
|
|
22
|
+
longDescriptionRelativePath?: string;
|
|
23
|
+
}
|
|
24
|
+
interface JsonHelpSubcommand extends JsonHelpDescription {
|
|
25
|
+
name: string;
|
|
26
|
+
aliases: string[];
|
|
27
|
+
deprecated: string | boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface JsonHelp extends JsonHelpDescription {
|
|
30
|
+
name: string;
|
|
31
|
+
command: string;
|
|
32
|
+
options: JsonHelpOption[];
|
|
33
|
+
subcommands?: JsonHelpSubcommand[];
|
|
34
|
+
}
|
|
35
|
+
export declare function jsonHelpUsage(): string;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
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.jsonHelpUsage = void 0;
|
|
14
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
15
|
+
const yargsDefaultCommandRegExp = /^\$0|\*/;
|
|
16
|
+
function jsonHelpUsage() {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
const localYargs = yargs_1.default;
|
|
20
|
+
const { deprecatedOptions, alias: aliases, array, string, boolean, number, choices, demandedOptions, default: defaultVal, hiddenOptions = [], } = localYargs.getOptions();
|
|
21
|
+
const internalMethods = localYargs.getInternalMethods();
|
|
22
|
+
const usageInstance = internalMethods.getUsageInstance();
|
|
23
|
+
const context = internalMethods.getContext();
|
|
24
|
+
const descriptions = usageInstance.getDescriptions();
|
|
25
|
+
const groups = localYargs.getGroups();
|
|
26
|
+
const positional = groups[usageInstance.getPositionalGroupName()];
|
|
27
|
+
const hidden = new Set(hiddenOptions);
|
|
28
|
+
const normalizeOptions = [];
|
|
29
|
+
const allAliases = new Set([...Object.values(aliases).flat()]);
|
|
30
|
+
for (const [names, type] of [
|
|
31
|
+
[array, 'array'],
|
|
32
|
+
[string, 'string'],
|
|
33
|
+
[boolean, 'boolean'],
|
|
34
|
+
[number, 'number'],
|
|
35
|
+
]) {
|
|
36
|
+
for (const name of names) {
|
|
37
|
+
if (allAliases.has(name) || hidden.has(name)) {
|
|
38
|
+
// Ignore hidden, aliases and already visited option.
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const positionalIndex = (_a = positional === null || positional === void 0 ? void 0 : positional.indexOf(name)) !== null && _a !== void 0 ? _a : -1;
|
|
42
|
+
const alias = aliases[name];
|
|
43
|
+
normalizeOptions.push({
|
|
44
|
+
name,
|
|
45
|
+
type,
|
|
46
|
+
deprecated: deprecatedOptions[name],
|
|
47
|
+
aliases: (alias === null || alias === void 0 ? void 0 : alias.length) > 0 ? alias : undefined,
|
|
48
|
+
default: defaultVal[name],
|
|
49
|
+
required: demandedOptions[name],
|
|
50
|
+
enum: choices[name],
|
|
51
|
+
description: (_b = descriptions[name]) === null || _b === void 0 ? void 0 : _b.replace('__yargsString__:', ''),
|
|
52
|
+
positional: positionalIndex >= 0 ? positionalIndex : undefined,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// https://github.com/yargs/yargs/blob/00e4ebbe3acd438e73fdb101e75b4f879eb6d345/lib/usage.ts#L124
|
|
57
|
+
const subcommands = usageInstance.getCommands()
|
|
58
|
+
.map(([name, rawDescription, isDefault, aliases, deprecated]) => ({
|
|
59
|
+
name: name.split(' ', 1)[0].replace(yargsDefaultCommandRegExp, ''),
|
|
60
|
+
command: name.replace(yargsDefaultCommandRegExp, ''),
|
|
61
|
+
default: isDefault || undefined,
|
|
62
|
+
...parseDescription(rawDescription),
|
|
63
|
+
aliases,
|
|
64
|
+
deprecated,
|
|
65
|
+
}))
|
|
66
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
67
|
+
const [command, rawDescription] = (_c = usageInstance.getUsage()[0]) !== null && _c !== void 0 ? _c : [];
|
|
68
|
+
const defaultSubCommand = (_e = (_d = subcommands.find((x) => x.default)) === null || _d === void 0 ? void 0 : _d.command) !== null && _e !== void 0 ? _e : '';
|
|
69
|
+
const otherSubcommands = subcommands.filter((s) => !s.default);
|
|
70
|
+
const output = {
|
|
71
|
+
name: [...context.commands].pop(),
|
|
72
|
+
command: `${command === null || command === void 0 ? void 0 : command.replace(yargsDefaultCommandRegExp, localYargs['$0'])}${defaultSubCommand}`,
|
|
73
|
+
...parseDescription(rawDescription),
|
|
74
|
+
options: normalizeOptions.sort((a, b) => a.name.localeCompare(b.name)),
|
|
75
|
+
subcommands: otherSubcommands.length ? otherSubcommands : undefined,
|
|
76
|
+
};
|
|
77
|
+
return JSON.stringify(output, undefined, 2);
|
|
78
|
+
}
|
|
79
|
+
exports.jsonHelpUsage = jsonHelpUsage;
|
|
80
|
+
function parseDescription(rawDescription) {
|
|
81
|
+
try {
|
|
82
|
+
const { longDescription, describe: shortDescription, longDescriptionRelativePath, } = JSON.parse(rawDescription);
|
|
83
|
+
return {
|
|
84
|
+
shortDescription,
|
|
85
|
+
longDescriptionRelativePath,
|
|
86
|
+
longDescription,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return {
|
|
91
|
+
shortDescription: rawDescription,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { json } from '@angular-devkit/core';
|
|
9
|
+
import yargs from 'yargs';
|
|
10
|
+
/**
|
|
11
|
+
* An option description.
|
|
12
|
+
*/
|
|
13
|
+
export interface Option extends yargs.Options {
|
|
14
|
+
/**
|
|
15
|
+
* The name of the option.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether this option is required or not.
|
|
20
|
+
*/
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Format field of this option.
|
|
24
|
+
*/
|
|
25
|
+
format?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this option should be hidden from the help output. It will still show up in JSON help.
|
|
28
|
+
*/
|
|
29
|
+
hidden?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If this option can be used as an argument, the position of the argument. Otherwise omitted.
|
|
32
|
+
*/
|
|
33
|
+
positional?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not to report this option to the Angular Team, and which custom field to use.
|
|
36
|
+
* If this is falsey, do not report this option.
|
|
37
|
+
*/
|
|
38
|
+
userAnalytics?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare function parseJsonSchemaToOptions(registry: json.schema.SchemaRegistry, schema: json.JsonObject, interactive?: boolean): Promise<Option[]>;
|