Skip to content

fix(generate): place usage instructions directly after generator output - #29315

Open
Felipeness wants to merge 8 commits into
prisma:v7from
Felipeness:fix/generate-usage-hint-position
Open

Felipeness wants to merge 8 commits into
prisma:v7from
Felipeness:fix/generate-usage-hint-position

Conversation

@Felipeness

@Felipeness Felipeness commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When multiple generators are used, the usage instructions ("Start by importing your Prisma Client...") now appear directly after the corresponding generator's ✔ Generated message instead of at the very end of the output.

Before:

✔ Generated Prisma Client to .\node_modules\@prisma\client in 287ms

✔ Generated Custom Generator to .\prisma\node_modules\@generated\custom in 3.50s

Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)

After:

✔ Generated Prisma Client to .\node_modules\@prisma\client in 287ms

Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)

✔ Generated Custom Generator to .\prisma\node_modules\@generated\custom in 3.50s

Changes

  • packages/cli/src/Generate.ts: Restructured runGenerate to collect per-generator results with provider info, then insert the usage hint after the first prisma-client-js generator (only when no errors occurred). Moved hideHints extraction 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-hints still suppresses usage instructions
  • Watch mode unchanged (no hints)
  • Version mismatch warnings still appended at end
  • Hint suppressed when any generator errors (same as before)
  • Single-generator output is functionally identical

Fixes #1737

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
@CLAassistant

CLAassistant commented Mar 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The 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 --no-hints and watch mode, and appends global warnings only when eligible. CLI snapshots were updated for the revised per-generator output and spacing.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements #1737 by placing usage hints next to the generating client output and supporting generator-specific hints.
Out of Scope Changes check ✅ Passed The changed files are focused on the generate output flow, related tests, and the generator hint API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed It accurately summarizes the main user-visible change in generate output placement.
Description check ✅ Passed It clearly describes the output change, preserved behavior, and updated tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 77b2d811-9eaa-408e-88f4-75db2d292cc2

📥 Commits

Reviewing files that changed from the base of the PR and between 9fa295d and c1e1f68.

📒 Files selected for processing (2)
  • packages/cli/src/Generate.ts
  • packages/cli/src/__tests__/commands/Generate.test.ts

Comment thread packages/cli/src/Generate.ts Resolved
@Felipeness

Copy link
Copy Markdown
Contributor Author

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 7.5.0?) so the check can pass? Thanks!

Comment thread packages/cli/src/Generate.ts Outdated
private runGenerate = simpleDebounce(async ({ generators }: { generators: Generator[] }) => {
const message: string[] = []
private runGenerate = simpleDebounce(
async ({ generators, usageHint }: { generators: Generator[]; usageHint?: string }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 })[]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jacek-prisma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left 1 important comment

jacek-prisma pushed a commit that referenced this pull request Mar 17, 2026
…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 -->

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 55d60c41-11b3-4f02-b9cf-a61de71b7d04

📥 Commits

Reviewing files that changed from the base of the PR and between f56c5d9 and 3bb8448.

📒 Files selected for processing (1)
  • packages/cli/src/Generate.ts

Comment thread packages/cli/src/Generate.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3bb8448 and 091743d.

📒 Files selected for processing (1)
  • packages/cli/src/Generate.ts

Comment thread packages/cli/src/Generate.ts Resolved
Comment thread packages/cli/src/Generate.ts Outdated
private runGenerate = simpleDebounce(
async ({
generators,
jsClient,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rather than hardcoding the jsClient here, this should should accept a generic hint parameter that can be passed along with the generator

Comment thread packages/cli/src/Generate.ts Outdated
showHint: boolean
}) => {
const messages: string[] = []
const hints: Map<Generator, string> = new Map()

@jacek-prisma jacek-prisma Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@tensordreams
tensordreams changed the base branch from main to v7 July 21, 2026 12:08
@tensordreams
tensordreams changed the base branch from v7 to main July 21, 2026 15:13
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
@tensordreams

Copy link
Copy Markdown
Contributor

Merged latest main and resolved the conflict in Generate.ts against the new global/local version-mismatch warning (#29593): the per-generator usage hint is now printed after each generator's success message, while the breaking-changes / version-mismatch / global-local warnings remain at the end. Also applied the review feedback — the hint is supplied via an optional usageHint field on the Generator interface (both the JS and TS client generators set it) rather than a hardcoded prisma-client-js branch, threaded as a flat string[]. Local Generate suite passes (49/49, 35 snapshots) and the globalLocalVersionMismatch suite passes (9/9).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 091743d and 47316bb.

📒 Files selected for processing (5)
  • packages/cli/src/Generate.ts
  • packages/cli/src/__tests__/commands/Generate.test.ts
  • packages/client-generator-js/src/generator.ts
  • packages/client-generator-ts/src/generator.ts
  • packages/generator/src/generator.ts

Comment thread packages/cli/src/Generate.ts Resolved
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.
@wmadden-electric

Copy link
Copy Markdown
Contributor

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 git rebase --signoff origin/v7 (or git commit --amend --signoff for a single commit) and force-push your branch. We will take care of anything else the change still needs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate: Usage instructions should be directly below ✔ Generated ... of generator

5 participants