Home / Function/ parseArgs() — react Function Reference

parseArgs() — react Function Reference

Architecture documentation for the parseArgs() function in args.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  e3408382_c967_e572_c032_b381d9017a3f["parseArgs()"]
  866d3017_4638_4c22_c8b5_0536c613669c["args.js"]
  e3408382_c967_e572_c032_b381d9017a3f -->|defined in| 866d3017_4638_4c22_c8b5_0536c613669c
  style e3408382_c967_e572_c032_b381d9017a3f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/tasks/generate-changelog/args.js lines 9–124

function parseArgs(argv) {
  const parser = yargs(argv)
    .usage(
      'Usage: yarn generate-changelog [--codex|--claude] [--debug] [--format <text|csv|json>] [<pkg@version> ...]'
    )
    .example(
      '$0 --codex eslint-plugin-react-hooks@7.0.1',
      'Generate changelog for a single package using Codex.'
    )
    .example(
      '$0 --claude react@19.3 react-dom@19.3',
      'Generate changelog entries for multiple packages using Claude.'
    )
    .example(
      '$0 --codex',
      'Generate changelog for all stable packages using recorded versions.'
    )
    .option('codex', {
      type: 'boolean',
      describe: 'Use Codex for commit summarization.',
    })
    .option('claude', {
      type: 'boolean',
      describe: 'Use Claude for commit summarization.',
    })
    .option('debug', {
      type: 'boolean',
      describe: 'Enable verbose debug logging.',
      default: false,
    })
    .option('format', {
      type: 'string',
      describe: 'Output format for the generated changelog.',
      choices: ['text', 'csv', 'json'],
      default: 'text',
    })
    .help('help')
    .alias('h', 'help')
    .version(false)
    .parserConfiguration({
      'parse-numbers': false,
      'parse-positional-numbers': false,
    });

  const args = parser.scriptName('generate-changelog').parse();
  const packageSpecs = [];
  const debug = !!args.debug;
  const format = args.format || 'text';
  let summarizer = null;

  if (args.codex && args.claude) {
    throw new Error('Choose either --codex or --claude, not both.');
  }
  if (args.codex) {
    summarizer = 'codex';
  } else if (args.claude) {
    summarizer = 'claude';
  }

  const positionalArgs = Array.isArray(args._) ? args._ : [];
  for (let i = 0; i < positionalArgs.length; i++) {
    const token = String(positionalArgs[i]).trim();
    if (!token) {
      continue;
    }

    const atIndex = token.lastIndexOf('@');
    if (atIndex <= 0 || atIndex === token.length - 1) {
      throw new Error(`Invalid package specification: ${token}`);
    }

    const packageName = token.slice(0, atIndex);
    const versionText = token.slice(atIndex + 1);
    const validVersion =
      semver.valid(versionText) || semver.valid(semver.coerce(versionText));
    if (!validVersion) {
      throw new Error(`Invalid version for ${packageName}: ${versionText}`);
    }

    packageSpecs.push({
      name: packageName,

Domain

Subdomains

Frequently Asked Questions

What does parseArgs() do?
parseArgs() is a function in the react codebase, defined in scripts/tasks/generate-changelog/args.js.
Where is parseArgs() defined?
parseArgs() is defined in scripts/tasks/generate-changelog/args.js at line 9.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free