@angular-devkit/schematics-cli 13.3.3 → 14.0.0-next.10
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
|
@@ -30,9 +30,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
__setModuleDefault(result, mod);
|
|
31
31
|
return result;
|
|
32
32
|
};
|
|
33
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
|
-
};
|
|
36
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
34
|
exports.main = void 0;
|
|
38
35
|
// symbol polyfill must go first
|
|
@@ -43,7 +40,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
43
40
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
44
41
|
const ansiColors = __importStar(require("ansi-colors"));
|
|
45
42
|
const inquirer = __importStar(require("inquirer"));
|
|
46
|
-
const
|
|
43
|
+
const yargs_parser_1 = __importStar(require("yargs-parser"));
|
|
47
44
|
/**
|
|
48
45
|
* Parse the name of schematic passed in argument, and return a {collection, schematic} named
|
|
49
46
|
* tuple. The user can pass in `collection-name:schematic-name`, and this function will either
|
|
@@ -61,10 +58,11 @@ const minimist_1 = __importDefault(require("minimist"));
|
|
|
61
58
|
function parseSchematicName(str) {
|
|
62
59
|
let collection = '@angular-devkit/schematics-cli';
|
|
63
60
|
let schematic = str;
|
|
64
|
-
if (schematic
|
|
61
|
+
if (schematic === null || schematic === void 0 ? void 0 : schematic.includes(':')) {
|
|
62
|
+
const lastIndexOfColon = schematic.lastIndexOf(':');
|
|
65
63
|
[collection, schematic] = [
|
|
66
|
-
schematic.slice(0,
|
|
67
|
-
schematic.substring(
|
|
64
|
+
schematic.slice(0, lastIndexOfColon),
|
|
65
|
+
schematic.substring(lastIndexOfColon + 1),
|
|
68
66
|
];
|
|
69
67
|
}
|
|
70
68
|
return { collection, schematic };
|
|
@@ -121,32 +119,32 @@ function _createPromptProvider() {
|
|
|
121
119
|
}
|
|
122
120
|
// eslint-disable-next-line max-lines-per-function
|
|
123
121
|
async function main({ args, stdout = process.stdout, stderr = process.stderr, }) {
|
|
124
|
-
const
|
|
122
|
+
const { cliOptions, schematicOptions, _ } = parseArgs(args);
|
|
125
123
|
// Create a separate instance to prevent unintended global changes to the color configuration
|
|
126
124
|
// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
|
|
127
125
|
const colors = ansiColors.create();
|
|
128
126
|
/** Create the DevKit Logger used through the CLI. */
|
|
129
|
-
const logger = (0, node_1.createConsoleLogger)(
|
|
127
|
+
const logger = (0, node_1.createConsoleLogger)(!!cliOptions.verbose, stdout, stderr, {
|
|
130
128
|
info: (s) => s,
|
|
131
129
|
debug: (s) => s,
|
|
132
130
|
warn: (s) => colors.bold.yellow(s),
|
|
133
131
|
error: (s) => colors.bold.red(s),
|
|
134
132
|
fatal: (s) => colors.bold.red(s),
|
|
135
133
|
});
|
|
136
|
-
if (
|
|
134
|
+
if (cliOptions.help) {
|
|
137
135
|
logger.info(getUsage());
|
|
138
136
|
return 0;
|
|
139
137
|
}
|
|
140
138
|
/** Get the collection an schematic name from the first argument. */
|
|
141
|
-
const { collection: collectionName, schematic: schematicName } = parseSchematicName(
|
|
139
|
+
const { collection: collectionName, schematic: schematicName } = parseSchematicName(_.shift() || null);
|
|
142
140
|
const isLocalCollection = collectionName.startsWith('.') || collectionName.startsWith('/');
|
|
143
141
|
/** Gather the arguments for later use. */
|
|
144
|
-
const debugPresent =
|
|
145
|
-
const debug = debugPresent ? !!
|
|
146
|
-
const dryRunPresent =
|
|
147
|
-
const dryRun = dryRunPresent ? !!
|
|
148
|
-
const force =
|
|
149
|
-
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'];
|
|
150
148
|
/** Create the workflow scoped to the working directory that will be executed with this run. */
|
|
151
149
|
const workflow = new tools_1.NodeWorkflow(process.cwd(), {
|
|
152
150
|
force,
|
|
@@ -155,7 +153,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
155
153
|
schemaValidation: true,
|
|
156
154
|
});
|
|
157
155
|
/** If the user wants to list schematics, we simply show all the schematic names. */
|
|
158
|
-
if (
|
|
156
|
+
if (cliOptions['list-schematics']) {
|
|
159
157
|
return _listSchematics(workflow, collectionName, logger);
|
|
160
158
|
}
|
|
161
159
|
if (!schematicName) {
|
|
@@ -185,7 +183,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
185
183
|
workflow.reporter.subscribe((event) => {
|
|
186
184
|
nothingDone = false;
|
|
187
185
|
// Strip leading slash to prevent confusion.
|
|
188
|
-
const eventPath = event.path.startsWith('/') ? event.path.
|
|
186
|
+
const eventPath = event.path.startsWith('/') ? event.path.slice(1) : event.path;
|
|
189
187
|
switch (event.kind) {
|
|
190
188
|
case 'error':
|
|
191
189
|
error = true;
|
|
@@ -202,7 +200,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
202
200
|
loggingQueue.push(`${colors.yellow('DELETE')} ${eventPath}`);
|
|
203
201
|
break;
|
|
204
202
|
case 'rename':
|
|
205
|
-
const eventToPath = event.to.startsWith('/') ? event.to.
|
|
203
|
+
const eventToPath = event.to.startsWith('/') ? event.to.slice(1) : event.to;
|
|
206
204
|
loggingQueue.push(`${colors.blue('RENAME')} ${eventPath} => ${eventToPath}`);
|
|
207
205
|
break;
|
|
208
206
|
}
|
|
@@ -220,35 +218,12 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
220
218
|
error = false;
|
|
221
219
|
}
|
|
222
220
|
});
|
|
223
|
-
/**
|
|
224
|
-
* Remove every options from argv that we support in schematics itself.
|
|
225
|
-
*/
|
|
226
|
-
const parsedArgs = Object.assign({}, argv);
|
|
227
|
-
delete parsedArgs['--'];
|
|
228
|
-
for (const key of booleanArgs) {
|
|
229
|
-
delete parsedArgs[key];
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Add options from `--` to args.
|
|
233
|
-
*/
|
|
234
|
-
const argv2 = (0, minimist_1.default)(argv['--']);
|
|
235
|
-
for (const key of Object.keys(argv2)) {
|
|
236
|
-
parsedArgs[key] = argv2[key];
|
|
237
|
-
}
|
|
238
221
|
// Show usage of deprecated options
|
|
239
222
|
workflow.registry.useXDeprecatedProvider((msg) => logger.warn(msg));
|
|
240
223
|
// Pass the rest of the arguments as the smart default "argv". Then delete it.
|
|
241
|
-
workflow.registry.addSmartDefaultProvider('argv', (schema) =>
|
|
242
|
-
if ('index' in schema) {
|
|
243
|
-
return argv._[Number(schema['index'])];
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
return argv._;
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
delete parsedArgs._;
|
|
224
|
+
workflow.registry.addSmartDefaultProvider('argv', (schema) => 'index' in schema ? _[Number(schema['index'])] : _);
|
|
250
225
|
// Add prompts.
|
|
251
|
-
if (
|
|
226
|
+
if (cliOptions.interactive && isTTY()) {
|
|
252
227
|
workflow.registry.usePromptProvider(_createPromptProvider());
|
|
253
228
|
}
|
|
254
229
|
/**
|
|
@@ -264,7 +239,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
264
239
|
.execute({
|
|
265
240
|
collection: collectionName,
|
|
266
241
|
schematic: schematicName,
|
|
267
|
-
options:
|
|
242
|
+
options: schematicOptions,
|
|
268
243
|
allowPrivate: allowPrivate,
|
|
269
244
|
debug: debug,
|
|
270
245
|
logger: logger,
|
|
@@ -284,10 +259,10 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
284
259
|
logger.fatal('The Schematic workflow failed. See above.');
|
|
285
260
|
}
|
|
286
261
|
else if (debug) {
|
|
287
|
-
logger.fatal(
|
|
262
|
+
logger.fatal(`An error occured:\n${err.stack}`);
|
|
288
263
|
}
|
|
289
264
|
else {
|
|
290
|
-
logger.fatal(
|
|
265
|
+
logger.fatal(`Error: ${err.message}`);
|
|
291
266
|
}
|
|
292
267
|
return 1;
|
|
293
268
|
}
|
|
@@ -298,7 +273,7 @@ exports.main = main;
|
|
|
298
273
|
*/
|
|
299
274
|
function getUsage() {
|
|
300
275
|
return core_1.tags.stripIndent `
|
|
301
|
-
schematics [
|
|
276
|
+
schematics [collection-name:]schematic-name [options, ...]
|
|
302
277
|
|
|
303
278
|
By default, if the collection name is not specified, use the internal collection provided
|
|
304
279
|
by the Schematics CLI.
|
|
@@ -329,33 +304,51 @@ function getUsage() {
|
|
|
329
304
|
}
|
|
330
305
|
/** Parse the command line. */
|
|
331
306
|
const booleanArgs = [
|
|
332
|
-
'allowPrivate',
|
|
333
307
|
'allow-private',
|
|
334
308
|
'debug',
|
|
335
309
|
'dry-run',
|
|
336
|
-
'dryRun',
|
|
337
310
|
'force',
|
|
338
311
|
'help',
|
|
339
312
|
'list-schematics',
|
|
340
|
-
'listSchematics',
|
|
341
313
|
'verbose',
|
|
342
314
|
'interactive',
|
|
343
315
|
];
|
|
316
|
+
/** Parse the command line. */
|
|
344
317
|
function parseArgs(args) {
|
|
345
|
-
|
|
318
|
+
const { _, ...options } = (0, yargs_parser_1.default)(args, {
|
|
346
319
|
boolean: booleanArgs,
|
|
347
|
-
alias: {
|
|
348
|
-
'dryRun': 'dry-run',
|
|
349
|
-
'listSchematics': 'list-schematics',
|
|
350
|
-
'allowPrivate': 'allow-private',
|
|
351
|
-
},
|
|
352
320
|
default: {
|
|
353
321
|
'interactive': true,
|
|
354
322
|
'debug': null,
|
|
355
|
-
'
|
|
323
|
+
'dry-run': null,
|
|
324
|
+
},
|
|
325
|
+
configuration: {
|
|
326
|
+
'dot-notation': false,
|
|
327
|
+
'boolean-negation': true,
|
|
328
|
+
'strip-aliased': true,
|
|
329
|
+
'camel-case-expansion': false,
|
|
356
330
|
},
|
|
357
|
-
'--': true,
|
|
358
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
|
+
};
|
|
359
352
|
}
|
|
360
353
|
function isTTY() {
|
|
361
354
|
const isTruthy = (value) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/schematics-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0-next.10",
|
|
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": "
|
|
25
|
-
"@angular-devkit/schematics": "
|
|
24
|
+
"@angular-devkit/core": "14.0.0-next.10",
|
|
25
|
+
"@angular-devkit/schematics": "14.0.0-next.10",
|
|
26
26
|
"ansi-colors": "4.1.1",
|
|
27
|
-
"inquirer": "8.2.
|
|
28
|
-
"
|
|
29
|
-
"
|
|
27
|
+
"inquirer": "8.2.2",
|
|
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
|
},
|