MCPcopy Index your code
hub / github.com/angular/angular-cli / main

Function main

packages/angular_devkit/schematics_cli/bin/schematics.ts:220–409  ·  view source on GitHub ↗
({
  args,
  stdout = process.stdout,
  stderr = process.stderr,
}: MainOptions)

Source from the content-addressed store, hash-verified

218}
219
220export async function main({
221 args,
222 stdout = process.stdout,
223 stderr = process.stderr,
224}: MainOptions): Promise<0 | 1> {
225 const { cliOptions, schematicOptions, _ } = parseOptions(args);
226
227 /** Create the DevKit Logger used through the CLI. */
228 const logger = createConsoleLogger(!!cliOptions.verbose, stdout, stderr, {
229 info: (s) => s,
230 debug: (s) => s,
231 warn: (s) => styleText(['bold', 'yellow'], s),
232 error: (s) => styleText(['bold', 'red'], s),
233 fatal: (s) => styleText(['bold', 'red'], s),
234 });
235
236 if (cliOptions.help) {
237 logger.info(getUsage());
238
239 return 0;
240 }
241
242 /** Get the collection an schematic name from the first argument. */
243 const { collection: collectionName, schematic: schematicName } = parseSchematicName(
244 _.shift() || null,
245 );
246
247 const isLocalCollection = collectionName.startsWith('.') || collectionName.startsWith('/');
248
249 /** Gather the arguments for later use. */
250 const debug = cliOptions.debug ?? isLocalCollection;
251 const dryRunPresent = cliOptions['dry-run'] != null;
252 const dryRun = cliOptions['dry-run'] ?? debug;
253 const force = !!cliOptions.force;
254 const allowPrivate = !!cliOptions['allow-private'];
255
256 /** Create the workflow scoped to the working directory that will be executed with this run. */
257 const workflow = new NodeWorkflow(process.cwd(), {
258 force,
259 dryRun,
260 resolvePaths: [process.cwd(), __dirname],
261 schemaValidation: true,
262 packageManager: getPackageManagerName(),
263 });
264
265 /** If the user wants to list schematics, we simply show all the schematic names. */
266 if (cliOptions['list-schematics']) {
267 return _listSchematics(workflow, collectionName, logger);
268 }
269
270 if (!schematicName) {
271 logger.info(getUsage());
272
273 return 1;
274 }
275
276 if (debug) {
277 logger.info(

Callers 2

schematics_spec.tsFile · 0.90
schematics.tsFile · 0.70

Calls 15

createConsoleLoggerFunction · 0.90
getUsageFunction · 0.85
parseSchematicNameFunction · 0.85
getPackageManagerNameFunction · 0.85
_listSchematicsFunction · 0.85
_createPromptProviderFunction · 0.85
subscribeMethod · 0.80
parseOptionsFunction · 0.70
removeLeadingSlashFunction · 0.70
isTTYFunction · 0.70
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected