diff --git a/docs/generated/cli/graph.md b/docs/generated/cli/graph.md index 4dd438d168..cd34855c57 100644 --- a/docs/generated/cli/graph.md +++ b/docs/generated/cli/graph.md @@ -159,6 +159,12 @@ Type: `boolean` Untracked changes +### verbose + +Type: `boolean` + +Prints additional information about the commands (e.g., stack traces) + ### version Type: `boolean` diff --git a/docs/generated/packages/nx/documents/dep-graph.md b/docs/generated/packages/nx/documents/dep-graph.md index 4dd438d168..cd34855c57 100644 --- a/docs/generated/packages/nx/documents/dep-graph.md +++ b/docs/generated/packages/nx/documents/dep-graph.md @@ -159,6 +159,12 @@ Type: `boolean` Untracked changes +### verbose + +Type: `boolean` + +Prints additional information about the commands (e.g., stack traces) + ### version Type: `boolean` diff --git a/packages/nx/src/command-line/graph/command-object.ts b/packages/nx/src/command-line/graph/command-object.ts index f2c5fc6339..d63e80b3dd 100644 --- a/packages/nx/src/command-line/graph/command-object.ts +++ b/packages/nx/src/command-line/graph/command-object.ts @@ -3,6 +3,7 @@ import { linkToNxDevAndExamples } from '../yargs-utils/documentation'; import { withAffectedOptions, withDepGraphOptions, + withVerbose, } from '../yargs-utils/shared-options'; export const yargsDepGraphCommand: CommandModule = { @@ -11,7 +12,7 @@ export const yargsDepGraphCommand: CommandModule = { aliases: ['dep-graph'], builder: (yargs) => linkToNxDevAndExamples( - withAffectedOptions(withDepGraphOptions(yargs)), + withVerbose(withAffectedOptions(withDepGraphOptions(yargs))), 'dep-graph' ) .option('affected', { diff --git a/packages/nx/src/command-line/show/command-object.ts b/packages/nx/src/command-line/show/command-object.ts index 387c15e959..7567f9f464 100644 --- a/packages/nx/src/command-line/show/command-object.ts +++ b/packages/nx/src/command-line/show/command-object.ts @@ -1,6 +1,10 @@ import type { ProjectGraphProjectNode } from '../../config/project-graph'; import { CommandModule, showHelp } from 'yargs'; -import { parseCSV, withAffectedOptions } from '../yargs-utils/shared-options'; +import { + parseCSV, + withAffectedOptions, + withVerbose, +} from '../yargs-utils/shared-options'; import { handleErrors } from '../../utils/params'; export interface NxShowArgs { @@ -64,7 +68,7 @@ const showProjectsCommand: CommandModule = { command: 'projects', describe: 'Show a list of projects in the workspace', builder: (yargs) => - withAffectedOptions(yargs) + withVerbose(withAffectedOptions(yargs)) .option('affected', { type: 'boolean', description: 'Show only affected projects', @@ -86,11 +90,6 @@ const showProjectsCommand: CommandModule = { description: 'Select only projects of the given type', choices: ['app', 'lib', 'e2e'], }) - .option('verbose', { - type: 'boolean', - description: - 'Prints additional information about the commands (e.g., stack traces)', - }) .implies('untracked', 'affected') .implies('uncommitted', 'affected') .implies('files', 'affected') diff --git a/packages/nx/src/command-line/yargs-utils/shared-options.ts b/packages/nx/src/command-line/yargs-utils/shared-options.ts index 22f2982371..c7187b1ba2 100644 --- a/packages/nx/src/command-line/yargs-utils/shared-options.ts +++ b/packages/nx/src/command-line/yargs-utils/shared-options.ts @@ -30,7 +30,7 @@ export interface RunOptions { } export function withRunOptions(yargs: Argv): Argv { - return withExcludeOption(yargs) + return withVerbose(withExcludeOption(yargs)) .option('parallel', { describe: 'Max number of parallel processes [default is 3]', type: 'string', @@ -63,11 +63,6 @@ export function withRunOptions(yargs: Argv): Argv { ? false : value, }) - .option('verbose', { - type: 'boolean', - describe: - 'Prints additional information about the commands (e.g., stack traces)', - }) .option('nxBail', { describe: 'Stop command execution after the first failed task', type: 'boolean', @@ -123,6 +118,20 @@ export function withConfiguration(yargs: Argv) { }); } +export function withVerbose(yargs: Argv) { + return yargs + .option('verbose', { + describe: + 'Prints additional information about the commands (e.g., stack traces)', + type: 'boolean', + }) + .middleware((args) => { + if (args.verbose) { + process.env.NX_VERBOSE_LOGGING = 'true'; + } + }); +} + export function withBatch(yargs: Argv) { return yargs.options('batch', { type: 'boolean',