Repository navigation
fix(generate): place usage instructions directly after generator output - #29315
Felipeness wants to merge 8 commits into
Conversation
When multiple generators are used, the usage instructions ("Start by
importing your Prisma Client...") now appear directly after the
corresponding generator's success message instead of at the very end
of the output. This makes the output more intuitive when using custom
generators alongside Prisma Client.
Fixes prisma#1737
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe generator contract now supports optional usage hints, and Prisma Client generators provide importing instructions. The generate command collects per-generator messages and hints, handles non-Error throws, suppresses hints for 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 77b2d811-9eaa-408e-88f4-75db2d292cc2
📒 Files selected for processing (2)
packages/cli/src/Generate.tspackages/cli/src/__tests__/commands/Generate.test.ts
|
Hi! The "Milestone Check" is currently pending on this PR since no milestone is set, and it looks like only maintainers have permission to assign one. Could someone set the appropriate milestone (perhaps |
| private runGenerate = simpleDebounce(async ({ generators }: { generators: Generator[] }) => { | ||
| const message: string[] = [] | ||
| private runGenerate = simpleDebounce( | ||
| async ({ generators, usageHint }: { generators: Generator[]; usageHint?: string }) => { |
There was a problem hiding this comment.
I think it might be cleaner to extend the interface passed in here to allow generators to have hints in order to avoid the generator specific logic here:
generators: (Generator & { usageHint?: string })[]
There was a problem hiding this comment.
Implemented your suggestion — generators now carry an optional usageHint, and runGenerate just checks for it instead of hardcoding provider logic. Thanks for the clean approach!
jacek-prisma
left a comment
There was a problem hiding this comment.
Left 1 important comment
…onstant (#29317) ## Summary Closes #29316 Extracts the hardcoded `'prisma-client-js'` string literal into a shared `PRISMA_CLIENT_JS_PROVIDER` constant defined in `@prisma/internals`, replacing all occurrences across the codebase. ### Changes - **New**: `packages/internals/src/prisma-client-js-provider.ts` — single source of truth for the constant - **Modified** (8 files across 4 packages): - `packages/internals/src/index.ts` — export the constant - `packages/internals/src/cli/getGeneratorSuccessMessage.ts` — use constant - `packages/internals/src/utils/extractPreviewFeatures.ts` — use constant - `packages/cli/src/Generate.ts` — use constant (2 occurrences) - `packages/cli/src/utils/checkpoint.ts` — use constant - `packages/client-generator-js/src/generator.ts` — use constant - `packages/client-generator-js/src/utils/types/dmmfToTypes.ts` — use constant (2 occurrences) - `packages/client/src/utils/getTestClient.ts` — use constant ### Motivation This was identified during the review of #29315 by @coderabbitai. Having a single constant: - Eliminates risk of typos in the provider string - Makes it easy to find all usages via "Find References" - Provides a single place to update if the value ever changes ## Test plan - [x] `pnpm build` passes (43 tasks) - [x] `getGenerators` tests pass (40/40, 33 snapshots) - [x] No behavioral changes — pure mechanical refactor <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Standardized provider identifiers across internal modules using a centralized constant. * No changes to behavior or public APIs; end-user experience remains unchanged. * Improved internal consistency and reliability of provider detection and generator selection logic. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 55d60c41-11b3-4f02-b9cf-a61de71b7d04
📒 Files selected for processing (1)
packages/cli/src/Generate.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cli/src/Generate.ts`:
- Around line 93-97: Extract the inline object type for the parameter into a
named interface (e.g., GenerateOptions) and replace the inline annotation with
that interface; the interface should declare generators: Generator[], optional
jsClient?: Generator, and showHint: boolean so it can be reused across the file.
Locate the function in Generate.ts that currently types its parameter as {
generators: Generator[]; jsClient?: Generator; showHint: boolean } and update
its signature to use the new interface name, and export the interface if it may
be reused elsewhere.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ccc2c456-628a-4e2d-80c5-0a7700bec2ec
📒 Files selected for processing (1)
packages/cli/src/Generate.ts
| private runGenerate = simpleDebounce( | ||
| async ({ | ||
| generators, | ||
| jsClient, |
There was a problem hiding this comment.
I think rather than hardcoding the jsClient here, this should should accept a generic hint parameter that can be passed along with the generator
| showHint: boolean | ||
| }) => { | ||
| const messages: string[] = [] | ||
| const hints: Map<Generator, string> = new Map() |
There was a problem hiding this comment.
There's no need to use a Map here, since this is processed in the same order as the generators array,
It could either be a string[][] or flattened (by just concating the strings) string[] or even string (by joining the strings with newlines)
Add an optional usageHint to the Generator interface so each generator declares its own post-generation usage instructions, instead of the CLI hardcoding a prisma-client-js branch. Both the JS and TS client generators supply the import hint, and Generate.ts prints each generator's hint after its success message using a flat string list aligned by index.
…nt-position # Conflicts: # packages/cli/src/Generate.ts
|
Merged latest |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/Generate.ts`:
- Around line 275-277: Update the breakingChangesStr construction in the
jsClient generation path to require logger.should.warn() in addition to
printBreakingChangesMessage before appending breakingChangesMessage. Preserve
the existing warning-suppressed behavior by leaving breakingChangesStr empty
when warnings are disabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c274c7d4-3853-49bc-8734-61e66d5c8138
📒 Files selected for processing (5)
packages/cli/src/Generate.tspackages/cli/src/__tests__/commands/Generate.test.tspackages/client-generator-js/src/generator.tspackages/client-generator-ts/src/generator.tspackages/generator/src/generator.ts
Reaching the breaking-change output path implies logger.should.warn() is false (otherwise the earlier guard returns early), so the message must not be appended when warnings are suppressed, matching the sibling version mismatch warning.
|
Thank you for this, and sorry for the long wait. We want this change and are getting it ready to merge. One thing only you can do: the repository now requires a Developer Certificate of Origin sign-off on every commit (see CONTRIBUTING), and the commits on this branch have none. Please add it with |
Summary
When multiple generators are used, the usage instructions ("Start by importing your Prisma Client...") now appear directly after the corresponding generator's
✔ Generatedmessage instead of at the very end of the output.Before:
After:
Changes
packages/cli/src/Generate.ts: RestructuredrunGenerateto collect per-generator results with provider info, then insert the usage hint after the firstprisma-client-jsgenerator (only when no errors occurred). MovedhideHintsextraction earlier. Separated the import guide (per-generator) from global warnings like version mismatches (still appended at end).packages/cli/src/__tests__/commands/Generate.test.ts: Updated inline snapshots to reflect new hint positioning.Behavior preserved
--no-hintsstill suppresses usage instructionsFixes #1737