mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 18:13:38 +08:00
This update addresses an issue where an older version of the CLI tarball was mistakenly employed in creating a new application via `yarn admin create`. Additionally, `yarn admin create` now accommodates extra options that can be utilized with `ng new`. Example: ``` yarn admin create my-app --ssr ```
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
#!/usr/bin/env node
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import colors from 'ansi-colors';
|
|
import path, { dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import yargsParser from 'yargs-parser';
|
|
|
|
const args = yargsParser(process.argv.slice(2), {
|
|
boolean: ['verbose'],
|
|
configuration: {
|
|
'camel-case-expansion': false,
|
|
},
|
|
});
|
|
const scriptName = args._.shift();
|
|
|
|
const cwd = process.cwd();
|
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
process.chdir(path.join(scriptDir, '..'));
|
|
|
|
const originalConsole = { ...console };
|
|
console.warn = function (...args) {
|
|
const [m, ...rest] = args;
|
|
originalConsole.warn(colors.yellow(m), ...rest);
|
|
};
|
|
console.error = function (...args) {
|
|
const [m, ...rest] = args;
|
|
originalConsole.error(colors.red(m), ...rest);
|
|
};
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
(async () => {
|
|
// code goes here
|
|
try {
|
|
const script = await import(`./${scriptName}.mjs`);
|
|
const exitCode = await script.default(args, cwd);
|
|
process.exitCode = exitCode || 0;
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
} catch (err: any) {
|
|
console.error(err.stack);
|
|
process.exitCode = 99;
|
|
}
|
|
})();
|