@angular-devkit/schematics-cli 14.0.0-next.3 → 14.0.0-next.6
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/schematics.js
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
|
@@ -26,9 +30,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
30
|
__setModuleDefault(result, mod);
|
|
27
31
|
return result;
|
|
28
32
|
};
|
|
29
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
-
};
|
|
32
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
34
|
exports.main = void 0;
|
|
34
35
|
// symbol polyfill must go first
|
|
@@ -39,7 +40,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
39
40
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
40
41
|
const ansiColors = __importStar(require("ansi-colors"));
|
|
41
42
|
const inquirer = __importStar(require("inquirer"));
|
|
42
|
-
const
|
|
43
|
+
const yargs_parser_1 = __importStar(require("yargs-parser"));
|
|
43
44
|
/**
|
|
44
45
|
* Parse the name of schematic passed in argument, and return a {collection, schematic} named
|
|
45
46
|
* tuple. The user can pass in `collection-name:schematic-name`, and this function will either
|
|
@@ -57,10 +58,11 @@ const minimist_1 = __importDefault(require("minimist"));
|
|
|
57
58
|
function parseSchematicName(str) {
|
|
58
59
|
let collection = '@angular-devkit/schematics-cli';
|
|
59
60
|
let schematic = str;
|
|
60
|
-
if (schematic
|
|
61
|
+
if (schematic === null || schematic === void 0 ? void 0 : schematic.includes(':')) {
|
|
62
|
+
const lastIndexOfColon = schematic.lastIndexOf(':');
|
|
61
63
|
[collection, schematic] = [
|
|
62
|
-
schematic.slice(0,
|
|
63
|
-
schematic.substring(
|
|
64
|
+
schematic.slice(0, lastIndexOfColon),
|
|
65
|
+
schematic.substring(lastIndexOfColon + 1),
|
|
64
66
|
];
|
|
65
67
|
}
|
|
66
68
|
return { collection, schematic };
|
|
@@ -117,32 +119,32 @@ function _createPromptProvider() {
|
|
|
117
119
|
}
|
|
118
120
|
// eslint-disable-next-line max-lines-per-function
|
|
119
121
|
async function main({ args, stdout = process.stdout, stderr = process.stderr, }) {
|
|
120
|
-
const
|
|
122
|
+
const { cliOptions, schematicOptions, _ } = parseArgs(args);
|
|
121
123
|
// Create a separate instance to prevent unintended global changes to the color configuration
|
|
122
124
|
// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
|
|
123
125
|
const colors = ansiColors.create();
|
|
124
126
|
/** Create the DevKit Logger used through the CLI. */
|
|
125
|
-
const logger = (0, node_1.createConsoleLogger)(
|
|
127
|
+
const logger = (0, node_1.createConsoleLogger)(!!cliOptions.verbose, stdout, stderr, {
|
|
126
128
|
info: (s) => s,
|
|
127
129
|
debug: (s) => s,
|
|
128
130
|
warn: (s) => colors.bold.yellow(s),
|
|
129
131
|
error: (s) => colors.bold.red(s),
|
|
130
132
|
fatal: (s) => colors.bold.red(s),
|
|
131
133
|
});
|
|
132
|
-
if (
|
|
134
|
+
if (cliOptions.help) {
|
|
133
135
|
logger.info(getUsage());
|
|
134
136
|
return 0;
|
|
135
137
|
}
|
|
136
138
|
/** Get the collection an schematic name from the first argument. */
|
|
137
|
-
const { collection: collectionName, schematic: schematicName } = parseSchematicName(
|
|
139
|
+
const { collection: collectionName, schematic: schematicName } = parseSchematicName(_.shift() || null);
|
|
138
140
|
const isLocalCollection = collectionName.startsWith('.') || collectionName.startsWith('/');
|
|
139
141
|
/** Gather the arguments for later use. */
|
|
140
|
-
const debugPresent =
|
|
141
|
-
const debug = debugPresent ? !!
|
|
142
|
-
const dryRunPresent =
|
|
143
|
-
const dryRun = dryRunPresent ? !!
|
|
144
|
-
const force =
|
|
145
|
-
const allowPrivate =
|
|
142
|
+
const debugPresent = cliOptions.debug !== null;
|
|
143
|
+
const debug = debugPresent ? !!cliOptions.debug : isLocalCollection;
|
|
144
|
+
const dryRunPresent = cliOptions['dry-run'] !== null;
|
|
145
|
+
const dryRun = dryRunPresent ? !!cliOptions['dry-run'] : debug;
|
|
146
|
+
const force = !!cliOptions.force;
|
|
147
|
+
const allowPrivate = !!cliOptions['allow-private'];
|
|
146
148
|
/** Create the workflow scoped to the working directory that will be executed with this run. */
|
|
147
149
|
const workflow = new tools_1.NodeWorkflow(process.cwd(), {
|
|
148
150
|
force,
|
|
@@ -151,7 +153,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
151
153
|
schemaValidation: true,
|
|
152
154
|
});
|
|
153
155
|
/** If the user wants to list schematics, we simply show all the schematic names. */
|
|
154
|
-
if (
|
|
156
|
+
if (cliOptions['list-schematics']) {
|
|
155
157
|
return _listSchematics(workflow, collectionName, logger);
|
|
156
158
|
}
|
|
157
159
|
if (!schematicName) {
|
|
@@ -216,35 +218,12 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
216
218
|
error = false;
|
|
217
219
|
}
|
|
218
220
|
});
|
|
219
|
-
/**
|
|
220
|
-
* Remove every options from argv that we support in schematics itself.
|
|
221
|
-
*/
|
|
222
|
-
const parsedArgs = Object.assign({}, argv);
|
|
223
|
-
delete parsedArgs['--'];
|
|
224
|
-
for (const key of booleanArgs) {
|
|
225
|
-
delete parsedArgs[key];
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Add options from `--` to args.
|
|
229
|
-
*/
|
|
230
|
-
const argv2 = (0, minimist_1.default)(argv['--']);
|
|
231
|
-
for (const key of Object.keys(argv2)) {
|
|
232
|
-
parsedArgs[key] = argv2[key];
|
|
233
|
-
}
|
|
234
221
|
// Show usage of deprecated options
|
|
235
222
|
workflow.registry.useXDeprecatedProvider((msg) => logger.warn(msg));
|
|
236
223
|
// Pass the rest of the arguments as the smart default "argv". Then delete it.
|
|
237
|
-
workflow.registry.addSmartDefaultProvider('argv', (schema) =>
|
|
238
|
-
if ('index' in schema) {
|
|
239
|
-
return argv._[Number(schema['index'])];
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
return argv._;
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
delete parsedArgs._;
|
|
224
|
+
workflow.registry.addSmartDefaultProvider('argv', (schema) => 'index' in schema ? _[Number(schema['index'])] : _);
|
|
246
225
|
// Add prompts.
|
|
247
|
-
if (
|
|
226
|
+
if (cliOptions.interactive && isTTY()) {
|
|
248
227
|
workflow.registry.usePromptProvider(_createPromptProvider());
|
|
249
228
|
}
|
|
250
229
|
/**
|
|
@@ -260,7 +239,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
260
239
|
.execute({
|
|
261
240
|
collection: collectionName,
|
|
262
241
|
schematic: schematicName,
|
|
263
|
-
options:
|
|
242
|
+
options: schematicOptions,
|
|
264
243
|
allowPrivate: allowPrivate,
|
|
265
244
|
debug: debug,
|
|
266
245
|
logger: logger,
|
|
@@ -280,10 +259,10 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
280
259
|
logger.fatal('The Schematic workflow failed. See above.');
|
|
281
260
|
}
|
|
282
261
|
else if (debug) {
|
|
283
|
-
logger.fatal(
|
|
262
|
+
logger.fatal(`An error occured:\n${err.stack}`);
|
|
284
263
|
}
|
|
285
264
|
else {
|
|
286
|
-
logger.fatal(
|
|
265
|
+
logger.fatal(`Error: ${err.message}`);
|
|
287
266
|
}
|
|
288
267
|
return 1;
|
|
289
268
|
}
|
|
@@ -294,7 +273,7 @@ exports.main = main;
|
|
|
294
273
|
*/
|
|
295
274
|
function getUsage() {
|
|
296
275
|
return core_1.tags.stripIndent `
|
|
297
|
-
schematics [
|
|
276
|
+
schematics [collection-name:]schematic-name [options, ...]
|
|
298
277
|
|
|
299
278
|
By default, if the collection name is not specified, use the internal collection provided
|
|
300
279
|
by the Schematics CLI.
|
|
@@ -325,33 +304,51 @@ function getUsage() {
|
|
|
325
304
|
}
|
|
326
305
|
/** Parse the command line. */
|
|
327
306
|
const booleanArgs = [
|
|
328
|
-
'allowPrivate',
|
|
329
307
|
'allow-private',
|
|
330
308
|
'debug',
|
|
331
309
|
'dry-run',
|
|
332
|
-
'dryRun',
|
|
333
310
|
'force',
|
|
334
311
|
'help',
|
|
335
312
|
'list-schematics',
|
|
336
|
-
'listSchematics',
|
|
337
313
|
'verbose',
|
|
338
314
|
'interactive',
|
|
339
315
|
];
|
|
316
|
+
/** Parse the command line. */
|
|
340
317
|
function parseArgs(args) {
|
|
341
|
-
|
|
318
|
+
const { _, ...options } = (0, yargs_parser_1.default)(args, {
|
|
342
319
|
boolean: booleanArgs,
|
|
343
|
-
alias: {
|
|
344
|
-
'dryRun': 'dry-run',
|
|
345
|
-
'listSchematics': 'list-schematics',
|
|
346
|
-
'allowPrivate': 'allow-private',
|
|
347
|
-
},
|
|
348
320
|
default: {
|
|
349
321
|
'interactive': true,
|
|
350
322
|
'debug': null,
|
|
351
|
-
'
|
|
323
|
+
'dry-run': null,
|
|
324
|
+
},
|
|
325
|
+
configuration: {
|
|
326
|
+
'dot-notation': false,
|
|
327
|
+
'boolean-negation': true,
|
|
328
|
+
'strip-aliased': true,
|
|
329
|
+
'camel-case-expansion': false,
|
|
352
330
|
},
|
|
353
|
-
'--': true,
|
|
354
331
|
});
|
|
332
|
+
// Camelize options as yargs will return the object in kebab-case when camel casing is disabled.
|
|
333
|
+
const schematicOptions = {};
|
|
334
|
+
const cliOptions = {};
|
|
335
|
+
const isCliOptions = (key) => booleanArgs.includes(key);
|
|
336
|
+
for (const [key, value] of Object.entries(options)) {
|
|
337
|
+
if (/[A-Z]/.test(key)) {
|
|
338
|
+
throw new Error(`Unknown argument ${key}. Did you mean ${(0, yargs_parser_1.decamelize)(key)}?`);
|
|
339
|
+
}
|
|
340
|
+
if (isCliOptions(key)) {
|
|
341
|
+
cliOptions[key] = value;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
schematicOptions[(0, yargs_parser_1.camelCase)(key)] = value;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
_: _.map((v) => v.toString()),
|
|
349
|
+
schematicOptions,
|
|
350
|
+
cliOptions,
|
|
351
|
+
};
|
|
355
352
|
}
|
|
356
353
|
function isTTY() {
|
|
357
354
|
const isTruthy = (value) => {
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@angular-devkit/core": "^<%= coreVersion %>",
|
|
17
17
|
"@angular-devkit/schematics": "^<%= schematicsVersion %>",
|
|
18
|
-
"typescript": "~4.
|
|
18
|
+
"typescript": "~4.6.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/node": "^
|
|
21
|
+
"@types/node": "^14.15.0",
|
|
22
22
|
"@types/jasmine": "~3.10.0",
|
|
23
23
|
"jasmine": "^4.0.0"
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/schematics-cli",
|
|
3
|
-
"version": "14.0.0-next.
|
|
3
|
+
"version": "14.0.0-next.6",
|
|
4
4
|
"description": "Angular Schematics - CLI",
|
|
5
5
|
"homepage": "https://github.com/angular/angular-cli",
|
|
6
6
|
"bin": {
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
],
|
|
22
22
|
"schematics": "./collection.json",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@angular-devkit/core": "14.0.0-next.
|
|
25
|
-
"@angular-devkit/schematics": "14.0.0-next.
|
|
24
|
+
"@angular-devkit/core": "14.0.0-next.6",
|
|
25
|
+
"@angular-devkit/schematics": "14.0.0-next.6",
|
|
26
26
|
"ansi-colors": "4.1.1",
|
|
27
|
-
"inquirer": "8.2.
|
|
28
|
-
"
|
|
29
|
-
"
|
|
27
|
+
"inquirer": "8.2.1",
|
|
28
|
+
"symbol-observable": "4.0.0",
|
|
29
|
+
"yargs-parser": "21.0.1"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
33
|
"url": "https://github.com/angular/angular-cli.git"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
|
-
"node": "^
|
|
36
|
+
"node": "^14.15.0 || >=16.10.0",
|
|
37
37
|
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
|
38
38
|
"yarn": ">= 1.13.0"
|
|
39
39
|
},
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@angular-devkit/core": "^<%= coreVersion %>",
|
|
17
17
|
"@angular-devkit/schematics": "^<%= schematicsVersion %>",
|
|
18
|
-
"typescript": "~4.
|
|
18
|
+
"typescript": "~4.6.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/node": "^
|
|
21
|
+
"@types/node": "^14.15.0",
|
|
22
22
|
"@types/jasmine": "~3.10.0",
|
|
23
23
|
"jasmine": "~4.0.0"
|
|
24
24
|
}
|