fix(core): forward args provided to the nx add command to the invoked init generator (#22855)

This commit is contained in:
Leosvel Pérez Espinosa 2024-04-18 09:55:20 +02:00 committed by GitHub
parent 7f0dc268a0
commit 125c1d2786
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -119,6 +119,10 @@ async function initializePlugin(
await runNxAsync(
`g ${pkgName}:${initGenerator} --keepExistingVersions${
updatePackageScripts ? ' --updatePackageScripts' : ''
}${
options.__overrides_unparsed__.length
? ' ' + options.__overrides_unparsed__.join(' ')
: ''
}`,
{
silent: !options.verbose,

View File

@ -1,9 +1,11 @@
import { CommandModule } from 'yargs';
import { withOverrides } from '../yargs-utils/shared-options';
export interface AddOptions {
packageSpecifier: string;
updatePackageScripts?: boolean;
verbose?: boolean;
__overrides_unparsed__: string[];
}
export const yargsAddCommand: CommandModule<
@ -14,6 +16,10 @@ export const yargsAddCommand: CommandModule<
describe: 'Install a plugin and initialize it.',
builder: (yargs) =>
yargs
.parserConfiguration({
'strip-dashed': true,
'unknown-options-as-args': true,
})
.positional('packageSpecifier', {
type: 'string',
description:
@ -41,5 +47,6 @@ export const yargsAddCommand: CommandModule<
'$0 add @nx/react@17.0.0',
'Install version `17.0.0` of the `@nx/react` package and run its `@nx/react:init` generator'
) as any,
handler: (args) => import('./add').then((m) => m.addHandler(args)),
handler: (args) =>
import('./add').then((m) => m.addHandler(withOverrides(args))),
};