refactor(ngcc): update yargs and typings for yargs (#38470)
Updating yargs and typings for the updated yargs module. PR Close #38470
This commit is contained in:
parent
8373b720f3
commit
e472f5f688
|
@ -19,9 +19,10 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
alias: 'source',
|
alias: 'source',
|
||||||
describe:
|
describe:
|
||||||
'A path (relative to the working directory) of the `node_modules` folder to process.',
|
'A path (relative to the working directory) of the `node_modules` folder to process.',
|
||||||
default: './node_modules'
|
default: './node_modules',
|
||||||
|
type: 'string',
|
||||||
})
|
})
|
||||||
.option('f', {alias: 'formats', hidden: true, array: true})
|
.option('f', {alias: 'formats', hidden: true, array: true, type: 'string'})
|
||||||
.option('p', {
|
.option('p', {
|
||||||
alias: 'properties',
|
alias: 'properties',
|
||||||
array: true,
|
array: true,
|
||||||
|
@ -29,7 +30,8 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
'An array of names of properties in package.json to compile (e.g. `module` or `main`)\n' +
|
'An array of names of properties in package.json to compile (e.g. `module` or `main`)\n' +
|
||||||
'Each of these properties should hold the path to a bundle-format.\n' +
|
'Each of these properties should hold the path to a bundle-format.\n' +
|
||||||
'If provided, only the specified properties are considered for processing.\n' +
|
'If provided, only the specified properties are considered for processing.\n' +
|
||||||
'If not provided, all the supported format properties (e.g. fesm2015, fesm5, es2015, esm2015, esm5, main, module) in the package.json are considered.'
|
'If not provided, all the supported format properties (e.g. fesm2015, fesm5, es2015, esm2015, esm5, main, module) in the package.json are considered.',
|
||||||
|
type: 'string',
|
||||||
})
|
})
|
||||||
.option('t', {
|
.option('t', {
|
||||||
alias: 'target',
|
alias: 'target',
|
||||||
|
@ -37,6 +39,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
'A relative path (from the `source` path) to a single entry-point to process (plus its dependencies).\n' +
|
'A relative path (from the `source` path) to a single entry-point to process (plus its dependencies).\n' +
|
||||||
'If this property is provided then `error-on-failed-entry-point` is forced to true.\n' +
|
'If this property is provided then `error-on-failed-entry-point` is forced to true.\n' +
|
||||||
'This option overrides the `--use-program-dependencies` option.',
|
'This option overrides the `--use-program-dependencies` option.',
|
||||||
|
type: 'string',
|
||||||
})
|
})
|
||||||
.option('use-program-dependencies', {
|
.option('use-program-dependencies', {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -47,7 +50,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
.option('first-only', {
|
.option('first-only', {
|
||||||
describe:
|
describe:
|
||||||
'If specified then only the first matching package.json property will be compiled.',
|
'If specified then only the first matching package.json property will be compiled.',
|
||||||
type: 'boolean'
|
type: 'boolean',
|
||||||
})
|
})
|
||||||
.option('create-ivy-entry-points', {
|
.option('create-ivy-entry-points', {
|
||||||
describe:
|
describe:
|
||||||
|
@ -78,6 +81,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
alias: 'loglevel',
|
alias: 'loglevel',
|
||||||
describe: 'The lowest severity logging message that should be output.',
|
describe: 'The lowest severity logging message that should be output.',
|
||||||
choices: ['debug', 'info', 'warn', 'error'],
|
choices: ['debug', 'info', 'warn', 'error'],
|
||||||
|
type: 'string',
|
||||||
})
|
})
|
||||||
.option('invalidate-entry-point-manifest', {
|
.option('invalidate-entry-point-manifest', {
|
||||||
describe:
|
describe:
|
||||||
|
@ -105,7 +109,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
.help()
|
.help()
|
||||||
.parse(args);
|
.parse(args);
|
||||||
|
|
||||||
if (options['f'] && options['f'].length) {
|
if (options.f?.length) {
|
||||||
console.error(
|
console.error(
|
||||||
'The formats option (-f/--formats) has been removed. Consider the properties option (-p/--properties) instead.');
|
'The formats option (-f/--formats) has been removed. Consider the properties option (-p/--properties) instead.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -113,12 +117,12 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
|
|
||||||
setFileSystem(new NodeJSFileSystem());
|
setFileSystem(new NodeJSFileSystem());
|
||||||
|
|
||||||
const baseSourcePath = resolve(options['s'] || './node_modules');
|
const baseSourcePath = resolve(options.s || './node_modules');
|
||||||
const propertiesToConsider: string[] = options['p'];
|
const propertiesToConsider = options.p;
|
||||||
const targetEntryPointPath = options['t'] ? options['t'] : undefined;
|
const targetEntryPointPath = options.t;
|
||||||
const compileAllFormats = !options['first-only'];
|
const compileAllFormats = !options['first-only'];
|
||||||
const createNewEntryPointFormats = options['create-ivy-entry-points'];
|
const createNewEntryPointFormats = options['create-ivy-entry-points'];
|
||||||
const logLevel = options['l'] as keyof typeof LogLevel | undefined;
|
const logLevel = options.l as keyof typeof LogLevel | undefined;
|
||||||
const enableI18nLegacyMessageIdFormat = options['legacy-message-ids'];
|
const enableI18nLegacyMessageIdFormat = options['legacy-message-ids'];
|
||||||
const invalidateEntryPointManifest = options['invalidate-entry-point-manifest'];
|
const invalidateEntryPointManifest = options['invalidate-entry-point-manifest'];
|
||||||
const errorOnFailedEntryPoint = options['error-on-failed-entry-point'];
|
const errorOnFailedEntryPoint = options['error-on-failed-entry-point'];
|
||||||
|
@ -126,7 +130,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
// yargs is not so great at mixed string+boolean types, so we have to test tsconfig against a
|
// yargs is not so great at mixed string+boolean types, so we have to test tsconfig against a
|
||||||
// string "false" to capture the `tsconfig=false` option.
|
// string "false" to capture the `tsconfig=false` option.
|
||||||
// And we have to convert the option to a string to handle `no-tsconfig`, which will be `false`.
|
// And we have to convert the option to a string to handle `no-tsconfig`, which will be `false`.
|
||||||
const tsConfigPath = `${options['tsconfig']}` === 'false' ? null : options['tsconfig'];
|
const tsConfigPath = `${options.tsconfig}` === 'false' ? null : options.tsconfig;
|
||||||
|
|
||||||
const logger = logLevel && new ConsoleLogger(LogLevel[logLevel]);
|
const logger = logLevel && new ConsoleLogger(LogLevel[logLevel]);
|
||||||
|
|
||||||
|
@ -138,7 +142,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||||
createNewEntryPointFormats,
|
createNewEntryPointFormats,
|
||||||
logger,
|
logger,
|
||||||
enableI18nLegacyMessageIdFormat,
|
enableI18nLegacyMessageIdFormat,
|
||||||
async: options['async'],
|
async: options.async,
|
||||||
invalidateEntryPointManifest,
|
invalidateEntryPointManifest,
|
||||||
errorOnFailedEntryPoint,
|
errorOnFailedEntryPoint,
|
||||||
tsConfigPath,
|
tsConfigPath,
|
||||||
|
|
Loading…
Reference in New Issue