-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat(cli): allow importing with file extension in generated schema #412
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
WalkthroughEnables CLI-level options (lite, liteOnly) to merge into per-plugin options for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code graph analysis (1)packages/cli/src/plugins/typescript.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (6)
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. Comment |
|
Claude finished @ymc9's task —— View job Code Review Complete ✅Reviewed PR #412 - feat(cli): allow importing with file extension in generated schema Review Tasks:
SummaryThis PR adds support for importing generated schema files with file extensions (e.g., ✅ Code Quality & Best Practices
✅ Implementation DetailsThe changes span three key files: packages/cli/src/actions/generate.ts:39 - Updates CLI help text to demonstrate usage 🟡 Areas for Improvement
✅ Security & Performance
🎯 Specific Code Commentstypescript.ts:26-29: Good validation, but consider checking for empty strings too. ts-schema-generator.ts:1462-1466: Smart handling of extensions with/without leading dot: importFrom += importWithFileExtension.startsWith('.')
? importWithFileExtension
: `.${importWithFileExtension}`;🏆 Overall AssessmentThis is a solid, focused PR that addresses a specific need (fixing #378). The implementation is clean, follows existing patterns, and maintains backward compatibility. The main area for improvement is adding test coverage to ensure the feature works correctly in various scenarios. Recommendation: ✅ Approve with suggestions - The core implementation is good, but adding tests would strengthen confidence in the feature. |
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.
Pull Request Overview
This PR adds the importWithFileExtension option to the TypeScript schema generator, allowing users to specify file extensions (e.g., .js, .mjs) for generated import statements. This is particularly useful for ESM projects that require explicit file extensions in import paths.
Key Changes:
- Added
importWithFileExtensionoption toTsSchemaGeneratorOptionstype - Modified
generateSchemaImportmethod to append the specified extension to relative imports - Added validation in the TypeScript plugin to ensure the option is a string when provided
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/sdk/src/ts-schema-generator.ts | Added importWithFileExtension option to the generator options and updated generateSchemaImport method to conditionally append file extensions to relative imports (./schema and ./schema-lite) |
| packages/cli/src/plugins/typescript.ts | Added validation for the importWithFileExtension plugin option and passed it through to the TsSchemaGenerator |
| packages/cli/src/actions/generate.ts | Refactored CLI option merging logic for the typescript plugin to be more explicit and maintainable (no functional changes related to the new feature) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fixes #378
Summary by CodeRabbit