- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 107
fix(cli): enhancer code fails to compile when generated into a custom folder #1678
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
… folder Fixes #1667
WalkthroughWalkthroughThe changes introduce new functionality for handling Zod imports and custom output folders in the schema enhancement process. A private method, Changes
Assessment against linked issues
Possibly related issues
Tip Early access features: disabledWe are currently testing the following features in early access:
Note:
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: 1
Outside diff range, codebase verification and nitpick comments (1)
packages/schema/src/plugins/plugin-utils.ts (1)
122-132
: LGTM! Consider adding JSDoc comments.The code changes are approved. The
getPluginCustomOutputFolder
function is well-structured and follows the Single Responsibility Principle. It uses appropriate type guards and checks to ensure the correctness of the returned value.To improve the maintainability and readability of the code, consider adding JSDoc comments to document the function's purpose, parameters, and return value. Here's an example:
/** * Retrieves the custom output folder for a specified plugin based on its model and provider. * @param zmodel - The model to search for the plugin. * @param provider - The provider string of the plugin. * @returns The custom output folder if found, otherwise `undefined`. */ export function getPluginCustomOutputFolder(zmodel: Model, provider: string) { // ... }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- packages/schema/src/plugins/enhancer/enhance/index.ts (3 hunks)
- packages/schema/src/plugins/plugin-utils.ts (2 hunks)
- packages/testtools/src/schema.ts (3 hunks)
- tests/regression/tests/issue-1667.test.ts (1 hunks)
Additional context used
GitHub Check: CodeQL
packages/testtools/src/schema.ts
[warning] 237-237: Unsafe shell command constructed from library input
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
[warning] 243-243: Unsafe shell command constructed from library input
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
Additional comments not posted (8)
tests/regression/tests/issue-1667.test.ts (2)
4-28
: LGTM!The test case is well-structured and properly configures the schema with the enhancer plugin using a custom output folder. The
loadSchema
function is called with suitable options to focus on the generated Prisma schema and preserve TypeScript files for analysis. The lack of assertions is acceptable for a regression test that verifies the successful completion of the schema loading and code generation process.
30-59
: LGTM!The test case is well-structured and properly configures the schema with the enhancer plugin and the zod plugin using custom output folders. The
loadSchema
function is called with suitable options to focus on the generated Prisma schema, generate code without compilation, and then compile the generated code. The lack of assertions is acceptable for a regression test that verifies the successful completion of the schema loading, code generation, and compilation process.packages/schema/src/plugins/plugin-utils.ts (1)
2-2
: LGTM!The import changes are approved as they are consistent with the new
getPluginCustomOutputFolder
function.Also applies to: 6-6
packages/testtools/src/schema.ts (2)
138-138
: LGTM!The code change is approved.
150-150
: LGTM!The code change is approved.
packages/schema/src/plugins/enhancer/enhance/index.ts (3)
41-41
: LGTM!The import statement is approved.
134-153
: LGTM!The new private method
getZodImport
looks good. It correctly determines the appropriate import path for Zod based on the presence of custom output options.
104-108
: LGTM!The changes to the import statement for Zod schemas are approved. The dynamic import based on the
withZodSchemas
option and the path returned bygetZodImport()
enhances the flexibility of the import mechanism.
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/integration/tests/plugins/zod.test.ts (5 hunks)
Additional comments not posted (3)
tests/integration/tests/plugins/zod.test.ts (3)
500-500
: LGTM!The code changes are approved.
791-794
: LGTM!The code changes are approved.
809-809
: LGTM!The code changes are approved.
plugin enhancer { | ||
provider = '@core/enhancer' | ||
output = "$projectRoot/enhance" | ||
} |
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.
Consider merging the duplicate enhancer
plugin configurations.
The enhancer
plugin is configured twice with the same options. Consider merging them into a single configuration to improve maintainability and reduce duplication.
plugin enhancer {
provider = '@core/enhancer'
output = "$projectRoot/enhance"
}
-
-plugin enhancer {
- provider = '@core/enhancer'
- output = "$projectRoot/enhance"
-}
Also applies to: 831-834
Fixes #1667