Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Dec 11, 2025

Summary

This PR fixes issue #13 where the makeConfig function failed to parse custom --version and --help options because yargs' built-in flags overrode user-defined options.

Fixes #13

Problem

The makeConfig function was returning false instead of the provided value when users defined custom --version or --help options. This caused release scripts to fail in CI/CD pipelines.

Root Cause: The final yargs instance (src/index.js:360-364) was missing .help(false) and .version(false) calls, while the initial parse (lines 337-345) correctly disabled these built-in flags.

Solution

Added .help(false) and .version(false) to the final yargs instance to maintain consistency with the initial parse and allow user-defined options.

Changes

  • src/index.js:360-367: Added .help(false) and .version(false) to final yargs instance
  • tests/index.test.js:644-786: Added 7 comprehensive tests for custom --version and --help options
  • experiments/: Added minimal reproduction scripts for testing
  • docs/case-studies/issue-13/: Added comprehensive case study analysis and data
  • .changeset/: Added changeset for patch release

Code Change

  // Step 5: Configure yargs with user options + getenv helper
- const yargsInstance = yargs(hideBin(argv)).option('configuration', {
-   type: 'string',
-   describe: 'Path to configuration .lenv file',
-   alias: 'c',
- });
+ const yargsInstance = yargs(hideBin(argv))
+   .help(false)     // Disable built-in help to allow custom --help option
+   .version(false)  // Disable built-in version to allow custom --version option
+   .option('configuration', {
+     type: 'string',
+     describe: 'Path to configuration .lenv file',
+     alias: 'c',
+   });

Testing

Test Coverage

✅ All 54 tests pass (including 7 new tests)

  • Custom --version option with value
  • Custom --version option without value (uses default)
  • Custom --version option from environment via getenv
  • Custom --help option with value
  • Custom --help option without value (uses default)
  • Custom --help option from environment via getenv
  • Both --version and --help custom options simultaneously

Before Fix

$ node experiments/minimal-repro-version.mjs --version "1.0.0"
config.version: false
❌ BUG REPRODUCED: --version returned false instead of the value

After Fix

$ node experiments/minimal-repro-version.mjs --version "1.0.0"
config.version: "1.0.0"
✅ PASS: --version parsed correctly: 1.0.0

CI Status

✅ All checks pass:

  • Lint: Passed
  • Format: Passed
  • File size: Passed
  • Tests on Node.js: Passed (54/54)
  • Tests on Bun: Passed
  • Tests on Deno: Passed

Case Study

A comprehensive case study has been created at docs/case-studies/issue-13/case-study-analysis.md that includes:

  • Timeline of events
  • Root cause deep dive
  • Solution analysis
  • Testing evidence
  • Impact assessment
  • References and external resources

This analysis was requested by @konard to ensure thorough understanding and documentation of the issue.

Backwards Compatibility

✅ No breaking changes - users who weren't using --version or --help as custom options are unaffected.


🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #13
@konard konard self-assigned this Dec 11, 2025
konard and others added 2 commits December 11, 2025 10:19
## Problem
The makeConfig function failed to parse custom --version and --help options
because yargs' built-in flags overrode user-defined options, returning false
instead of the provided value.

## Root Cause
The final yargs instance (src/index.js:360-364) was missing .help(false) and
.version(false) calls, while the initial parse (lines 337-345) correctly
disabled these built-in flags.

## Solution
Added .help(false) and .version(false) to the final yargs instance to maintain
consistency with the initial parse and allow user-defined options.

## Changes
- src/index.js: Added .help(false) and .version(false) to final yargs instance
- tests/index.test.js: Added 7 comprehensive tests for custom --version and --help options
- experiments/: Added minimal reproduction scripts for testing
- docs/case-studies/issue-13/: Added comprehensive case study analysis and data

## Testing
- All 54 tests pass (including 7 new tests)
- Minimal reproduction scripts verified
- No regressions in existing functionality
- All CI checks pass (lint, format, file size)

Fixes #13

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Bug: --version flag conflicts with custom options in makeConfig Fix: Disable built-in --version and --help flags to allow custom options Dec 11, 2025
@konard konard marked this pull request as ready for review December 11, 2025 09:22
@konard
Copy link
Member Author

konard commented Dec 11, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.917041 USD
  • Calculated by Anthropic: $1.632610 USD
  • Difference: $-1.284432 (-44.03%)
    📎 Log file uploaded as GitHub Gist (565KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: --version flag conflicts with custom options in makeConfig

2 participants