-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: do without yargs #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replaced yargs-based argument parsing with native `parseArgs` API, improving performance and reducing dependencies. Simplified the codebase by removing unused modules and adopting a more streamlined configuration setup. (This commit message was AI-generated.) Signed-off-by: Jens Oliver Meiert <[email protected]>
Removed "yargs" from dependencies, marked several packages as dev dependencies, and updated the package version to 4.2.0 in package.json and package-lock.json. This change ensures cleaner dependency management and alignment with intended usage. (This commit message was AI-generated.) Signed-off-by: Jens Oliver Meiert <[email protected]>
WalkthroughThe update removes the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI_Script
participant NodeUtil as parseArgs
User->>CLI_Script: Execute command
CLI_Script->>CLI_Script: Define options {dry, ignore, staged}
CLI_Script->>NodeUtil: Call parseArgs with process.argv and options
NodeUtil-->>CLI_Script: Return parsed arguments (argv)
CLI_Script->>CLI_Script: Process arguments based on returned argv
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/index.js (1)
9-14
: LGTM! Clean implementation of parseArgs.The migration from yargs to Node's built-in parseArgs is well-structured:
- Clear type definitions for each option
- Maintains the same functionality as before
- Reduces external dependencies
Consider documenting these CLI options in the README to help users transition from yargs to the new implementation.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (2)
package.json
(2 hunks)src/index.js
(1 hunks)
🔇 Additional comments (3)
package.json (2)
43-43
: LGTM! Version bump follows semver.The version bump from 4.1.4 to 4.2.0 correctly follows semantic versioning for feature changes (removing a dependency).
12-12
:✅ Verification successful
Verify the simple-git version for security advisories.
Let's ensure the fixed version of
simple-git
is secure and up-to-date.
🏁 Script executed:
#!/bin/bash # Description: Check for security advisories and latest versions of the simple-git library. # Check npm for latest versions curl -s https://registry.npmjs.org/simple-git | jq '.["dist-tags"].latest' # Check for security advisories gh api graphql -f query=' { securityVulnerabilities(first: 5, ecosystem: NPM, package: "simple-git") { nodes { advisory { summary severity publishedAt } vulnerableVersionRange firstPatchedVersion { identifier } } } }'Length of output: 1272
Security Verification Complete: simple-git Version 3.27.0 is Secure
- The npm registry confirms we are using simple-git version 3.27.0.
- All reported vulnerabilities (affecting versions below 3.5.0, 3.15.0, 3.16.0, and 3.3.0) have been patched above our current version.
No changes are needed regarding the simple-git version.
src/index.js (1)
5-5
:❓ Verification inconclusive
Verify Node.js version compatibility for parseArgs.
The
parseArgs
function was introduced in Node.js v16.17.0. Let's ensure the project's minimum Node.js version is compatible.
🌐 Web query:
When was node:util parseArgs introduced and what is its current status?
💡 Result:
The
node:util
module'sparseArgs
function was introduced in Node.js v18.3.0 (released June 2022)[2][7]. Initially marked as experimental[2][7], it has since evolved into a stable feature for parsing command-line arguments without requiring external dependencies[1][5].As of Node.js v23.8.0 (current documentation):
- It supports boolean and string option types with short/long aliases[1][4]
- Handles positional arguments and option terminators (
--
)[4]- Provides tokenized parsing details when using
tokens: true
[1]- Supports default values and multiple occurrences[3][4]
- Is considered a core utility for CLI development[5][7]
Key milestones:
- v18.11.0 (2022): Added default value support[10]
- v18.7.0: Introduced token tracking[10]
- Current implementation shows no experimental warnings in official docs[1], indicating full stability.
Example from current implementation:
import { parseArgs } from 'node:util'; const options = { verbose: { type: 'boolean', short: 'v' }, file: { type: 'string' } }; const { values } = parseArgs({ options }); console.log(values); // { verbose: true, file: 'data.txt' }Citations:
- 1: https://nodejs.org/api/util.html
- 2: https://www.kevincunningham.co.uk/posts/using-parseargs-in-node/
- 3: nodejs/node#53095
- 4: https://2ality.com/2022/08/node-util-parseargs.html
- 5: https://blog.platformatic.dev/nodejs-is-here-to-stay
- 6: https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V22.md
- 7: https://www.matthinchliffe.dev/2023/07/19/shedding-node-project-dependencies.html
- 8: nodejs/node#44564
- 9: https://bun.sh/docs/api/utils
- 10: https://github.com/pkgjs/parseargs
Ensure Project Uses Node.js v18.3.0 or Later for parseArgs
Our investigation confirms that the
parseArgs
function in thenode:util
module was introduced in Node.js v18.3.0 and is now stable. If your project’s minimum Node.js version is below v18.3.0, please update the required version (e.g., in thepackage.json
engines
field) to prevent potential runtime issues. Also, if supporting older versions is necessary, consider alternative approaches or polyfills.
- File: src/index.js, Line 5
- Action: Verify and update the Node.js version requirement if necessary.
Summary by CodeRabbit