feat: support custom type - #141
Conversation
WalkthroughThis update introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant CustomParser
participant ZodSchema
User->>CLI: Run command with custom argument(s)
CLI->>CustomParser: Invoke parse function with input
CustomParser->>ZodSchema: (Optional) Validate input
ZodSchema-->>CustomParser: Return validated value or throw error
CustomParser-->>CLI: Return parsed value or error
CLI-->>User: Output result or display validation error
Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
Deploying gunshi with
|
| Latest commit: |
11e875d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5947ce05.gunshi.pages.dev |
| Branch Preview URL: | https://feat-custom.gunshi.pages.dev |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/cli.test.ts (1)
969-971: Consider using numeric separators for better readability.Instead of disabling the eslint rule, consider using numeric separators for the port range constants:
- // eslint-disable-next-line unicorn/numeric-separators-style - if (Number.isNaN(port) || port < 1024 || port > 65535) { + if (Number.isNaN(port) || port < 1_024 || port > 65_535) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (4)
docs/guide/essentials/declarative-configuration.md(2 hunks)package.json(1 hunks)src/cli.test.ts(2 hunks)src/renderer/usage.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
package.json (1)
159-160:Details
✅ Verification successful
Verify the zod library version for security and compatibility.
Please ensure that version
^3.25.28is the latest stable release and check for any known security vulnerabilities.
🌐 Web query:
What is the latest stable version of zod npm package and are there any known security vulnerabilities in version 3.25.28?💡 Result:
The latest stable version of Zod npm package is 3.25.28, which was released on May 23, 2025, just 2-3 days ago[1][6]. This version is currently tagged as "latest" in the npm registry and has been downloaded over 30 million times in the past week[6].
Regarding security vulnerabilities in version 3.25.28, no direct vulnerabilities have been found for this package according to Snyk's vulnerability database[9]. This means that the core package itself doesn't have any known security issues, though this assessment doesn't include potential vulnerabilities in its dependencies.
It's worth noting that Zod is a TypeScript-first schema declaration and validation library with static type inference[1]. It's widely used for data validation across various projects, particularly in backend development where it helps ensure data contracts are predictable, validated, and fully type-safe[8].
While the stable release is at version 3.25.28, Zod is also working on version 4.0, which is currently in beta. The beta versions include significant changes such as splitting the package into three separate packages:
zod,@zod/mini(a tree-shakable variant), and@zod/core(shared logic and parsers)[7]. These beta versions can be installed using the "next" tag.For developers concerned about security, it's always good practice to regularly update to the latest stable versions and monitor security advisories for any packages used in your projects.
Citations:
- 1: https://www.npmjs.com/package/zod
- 2: https://github.com/colinhacks/zod
- 3: https://deps.dev/npm/zod/3.23.2
- 4: https://socket.dev/npm/package/zod
- 5: https://www.npmjs.com/package/nestjs-zod
- 6: https://www.npmjs.com/package/zod?activeTab=versions
- 7: https://github.com/colinhacks/zod/releases
- 8: https://themobilereality.com/blog/javascript/top-5-node-js-packages-2025
- 9: https://security.snyk.io/package/npm/zod/3.25.28
- 10: https://bundlephobia.com/package/zod
Zod version 3.25.28 is the latest stable release with no known security vulnerabilities
- package.json (lines 159–160)
No upgrade or remediation needed at this time. Continue to monitor the Zod changelog and security advisories for future updates.
src/renderer/usage.ts (1)
315-319: LGTM! Consistent default value display for custom types.The addition of
'custom'to the type check ensures that custom argument types with default values are properly displayed in the usage output, maintaining consistency with other argument types.docs/guide/essentials/declarative-configuration.md (2)
166-166: Good addition to the command options documentation.The
parseproperty is correctly documented as required for custom types, providing clear guidance for users.
200-267: Excellent documentation for custom type arguments!The section provides comprehensive examples covering various use cases:
- CSV parsing with array output
- JSON validation using zod schemas
- Custom numeric validation with range checking
- Clear error handling patterns
The examples are practical and demonstrate best practices for implementing custom argument parsers.
src/cli.test.ts (2)
889-1017: Well-structured test suite for custom type arguments!The test suite comprehensively covers the new custom type functionality with good test cases for CSV parsing, JSON validation with zod, default values, error handling, and multiple values.
2-2:Details
❓ Verification inconclusive
Verify the zod import path.
The import path
'zod/v4-mini'seems unusual. Typically, zod is imported directly as'zod'.Please verify that this specific import path exists and is the intended way to import zod:
Consider using the standard import if the v4-mini path doesn't exist:
-import { z } from 'zod/v4-mini' +import { z } from 'zod'
🏁 Script executed:
#!/bin/bash # Description: Check if the zod/v4-mini import path exists in node_modules # Check if the path exists fd -t f "v4-mini" node_modules/zod --exec ls -la {} \; # Check package.json for any exports configuration cat node_modules/zod/package.json | jq '.exports'Length of output: 273
Verify zod import path
I wasn’t able to locate a
v4-minisubpath in your zod installation—there’s nonode_modules/zodfolder to confirm an exportedv4-mini. Please manually verify that your installed zod package exports"./v4-mini"(e.g. checknode_modules/zod/package.jsonunder itsexportsfield). If it’s not present, update the import to the standard entry point:-import { z } from 'zod/v4-mini' +import { z } from 'zod'
Description
Linked Issues
kazupon/args-tokens#101
Additional context
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores