diff --git a/docs/generated/cli/print-affected.md b/docs/generated/cli/print-affected.md index 6c33c6bbeab2e..d834298a43a0e 100644 --- a/docs/generated/cli/print-affected.md +++ b/docs/generated/cli/print-affected.md @@ -61,6 +61,12 @@ Type: `string` Base of the current branch (usually main) +### configuration + +Type: `string` + +This is the configuration to use when performing tasks on projects + ### exclude Type: `array` diff --git a/docs/generated/packages/nx.json b/docs/generated/packages/nx.json index 45a73fd7032c8..ec5a6c8ffff6d 100644 --- a/docs/generated/packages/nx.json +++ b/docs/generated/packages/nx.json @@ -81,7 +81,7 @@ "name": "print-affected", "id": "print-affected", "file": "generated/cli/print-affected", - "content": "---\ntitle: 'print-affected - CLI command'\ndescription: 'Prints information about the projects and targets affected by changes'\n---\n\n# print-affected\n\nPrints information about the projects and targets affected by changes\n\n## Usage\n\n```terminal\nnx print-affected\n```\n\nInstall `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`.\n\n### Examples\n\nPrint information about affected projects and the project graph:\n\n```terminal\n nx print-affected\n```\n\nPrint information about the projects affected by the changes between main and HEAD (e.g,. PR):\n\n```terminal\n nx print-affected --base=main --head=HEAD\n```\n\nPrints information about the affected projects and a list of tasks to test them:\n\n```terminal\n nx print-affected --target=test\n```\n\nPrints the projects property from the print-affected output:\n\n```terminal\n nx print-affected --target=build --select=projects\n```\n\nPrints the tasks.target.project property from the print-affected output:\n\n```terminal\n nx print-affected --target=build --select=tasks.target.project\n```\n\n## Options\n\n### all\n\nType: `boolean`\n\nAll projects\n\n### base\n\nType: `string`\n\nBase of the current branch (usually main)\n\n### exclude\n\nType: `array`\n\nDefault: `[]`\n\nExclude certain projects from being processed\n\n### files\n\nType: `array`\n\nChange the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas\n\n### head\n\nType: `string`\n\nLatest commit of the current branch (usually HEAD)\n\n### help\n\nType: `boolean`\n\nShow help\n\n### select\n\nType: `string`\n\nSelect the subset of the returned json document (e.g., --select=projects)\n\n### target\n\nType: `string`\n\nTask to run for affected projects\n\n### type\n\nType: `string`\n\nChoices: [app, lib]\n\nSelect the type of projects to be returned (e.g., --type=app)\n\n### uncommitted\n\nType: `boolean`\n\nUncommitted changes\n\n### untracked\n\nType: `boolean`\n\nUntracked changes\n\n### version\n\nType: `boolean`\n\nShow version number\n" + "content": "---\ntitle: 'print-affected - CLI command'\ndescription: 'Prints information about the projects and targets affected by changes'\n---\n\n# print-affected\n\nPrints information about the projects and targets affected by changes\n\n## Usage\n\n```terminal\nnx print-affected\n```\n\nInstall `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`.\n\n### Examples\n\nPrint information about affected projects and the project graph:\n\n```terminal\n nx print-affected\n```\n\nPrint information about the projects affected by the changes between main and HEAD (e.g,. PR):\n\n```terminal\n nx print-affected --base=main --head=HEAD\n```\n\nPrints information about the affected projects and a list of tasks to test them:\n\n```terminal\n nx print-affected --target=test\n```\n\nPrints the projects property from the print-affected output:\n\n```terminal\n nx print-affected --target=build --select=projects\n```\n\nPrints the tasks.target.project property from the print-affected output:\n\n```terminal\n nx print-affected --target=build --select=tasks.target.project\n```\n\n## Options\n\n### all\n\nType: `boolean`\n\nAll projects\n\n### base\n\nType: `string`\n\nBase of the current branch (usually main)\n\n### configuration\n\nType: `string`\n\nThis is the configuration to use when performing tasks on projects\n\n### exclude\n\nType: `array`\n\nDefault: `[]`\n\nExclude certain projects from being processed\n\n### files\n\nType: `array`\n\nChange the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas\n\n### head\n\nType: `string`\n\nLatest commit of the current branch (usually HEAD)\n\n### help\n\nType: `boolean`\n\nShow help\n\n### select\n\nType: `string`\n\nSelect the subset of the returned json document (e.g., --select=projects)\n\n### target\n\nType: `string`\n\nTask to run for affected projects\n\n### type\n\nType: `string`\n\nChoices: [app, lib]\n\nSelect the type of projects to be returned (e.g., --type=app)\n\n### uncommitted\n\nType: `boolean`\n\nUncommitted changes\n\n### untracked\n\nType: `boolean`\n\nUntracked changes\n\n### version\n\nType: `boolean`\n\nShow version number\n" }, { "name": "format:check", diff --git a/packages/nx/bin/init-local.ts b/packages/nx/bin/init-local.ts index b53f2d929a3c0..f2af46855cf81 100644 --- a/packages/nx/bin/init-local.ts +++ b/packages/nx/bin/init-local.ts @@ -68,6 +68,7 @@ function isKnownCommand() { 'affected:dep-graph', 'format', 'workspace-schematic', + 'connect-to-nx-cloud', 'clear-cache', 'help', ]; diff --git a/packages/nx/src/command-line/nx-commands.ts b/packages/nx/src/command-line/nx-commands.ts index 99b2dd6abfc8c..c75f240b6f2c9 100644 --- a/packages/nx/src/command-line/nx-commands.ts +++ b/packages/nx/src/command-line/nx-commands.ts @@ -58,7 +58,9 @@ export const commandsObject = yargs describe: 'Run target for multiple listed projects', builder: (yargs) => linkToNxDevAndExamples( - withRunManyOptions(withOutputStyleOption(withTargetOption(yargs))), + withRunManyOptions( + withOutputStyleOption(withTargetAndConfigurationOption(yargs)) + ), 'run-many' ), handler: async (args) => @@ -70,7 +72,9 @@ export const commandsObject = yargs builder: (yargs) => linkToNxDevAndExamples( withAffectedOptions( - withRunOptions(withOutputStyleOption(withTargetOption(yargs))) + withRunOptions( + withOutputStyleOption(withTargetAndConfigurationOption(yargs)) + ) ), 'affected' ), @@ -190,7 +194,10 @@ export const commandsObject = yargs builder: (yargs) => linkToNxDevAndExamples( withAffectedOptions( - withTargetOption(withPrintAffectedOptions(yargs), false) + withTargetAndConfigurationOption( + withPrintAffectedOptions(yargs), + false + ) ), 'print-affected' ), @@ -443,12 +450,6 @@ function withRunOptions(yargs: yargs.Argv): yargs.Argv { describe: 'This is the name of the tasks runner configured in nx.json', type: 'string', }) - .options('configuration', { - describe: - 'This is the configuration to use when performing tasks on projects', - type: 'string', - alias: 'c', - }) .option('prod', { describe: 'Use the production configuration', type: 'boolean', @@ -626,14 +627,24 @@ function withOutputStyleOption( }); } -function withTargetOption(yargs: yargs.Argv, demandOption = true): yargs.Argv { - return yargs.option('target', { - describe: 'Task to run for affected projects', - type: 'string', - requiresArg: true, - demandOption, - global: false, - }); +function withTargetAndConfigurationOption( + yargs: yargs.Argv, + demandOption = true +): yargs.Argv { + return yargs + .option('target', { + describe: 'Task to run for affected projects', + type: 'string', + requiresArg: true, + demandOption, + global: false, + }) + .options('configuration', { + describe: + 'This is the configuration to use when performing tasks on projects', + type: 'string', + alias: 'c', + }); } function withNewOptions(yargs: yargs.Argv) { @@ -692,7 +703,7 @@ function withRunOneOptions(yargs: yargs.Argv) { ); const res = withRunOptions( - withOutputStyleOption(withTargetOption(yargs, false), [ + withOutputStyleOption(withTargetAndConfigurationOption(yargs, false), [ 'dynamic', 'static', 'stream',