Repository navigation
TML-2616 Add --format <pretty|json> framework-wide (--json alias preserved) - #571
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces a new ChangesFormat Option Implementation and Validation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Agents can opt into pretty output on non-TTY stdout via --format pretty; --json remains a zero-break alias for --format json with mutual-exclusion when the two flags disagree. Signed-off-by: Will Madden <[email protected]>
435ce5b to
68fe15b
Compare
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/extension-cipherstash
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
Explicit --format pretty now enables TerminalUI decoration on non-TTY via forcePretty, and invalid/mutex format flags surface as PN-CLI-4014/4015 envelopes instead of uncaught stack traces. Signed-off-by: Will Madden <[email protected]>
Signed-off-by: Will Madden <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/1-framework/1-core/errors/test/control.test.ts (1)
427-442: ⚡ Quick winPrefer object matcher for related assertions in the new test cases.
These two tests assert several related fields one-by-one; consolidating the structural checks with
toMatchObjectwill keep failures more readable and consistent with the suite’s matcher style.As per coding guidelines: "Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests".
🤖 Prompt for 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. In `@packages/1-framework/1-core/errors/test/control.test.ts` around lines 427 - 442, Update the two tests to use object matchers instead of multiple individual expects: for errorInvalidOutputFormat and errorOutputFormatMutex, replace the separate assertions on error.code/envelope.code and message contents with a single toMatchObject-style assertion that checks the relevant fields (e.g., envelope.code and error.code) and use one matcher for message content (or include message snippets in the object) so the tests for errorInvalidOutputFormat and errorOutputFormatMutex become consolidated, clearer, and consistent with the suite’s toMatchObject style.
🤖 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/1-framework/3-tooling/cli/src/commands/contract-infer.ts`:
- Around line 45-46: The command currently calls parseGlobalFlagsOrExit twice
causing duplicate parsing and potential process exits; remove the early call at
the top-level and instead parse flags once inside the action handler, then pass
the resulting flags into executeContractInferCommand (and subsequently into
inspectLiveSchema) so that parseGlobalFlagsOrExit is only invoked in the action
handler and internal helpers like executeContractInferCommand and
inspectLiveSchema accept a flags parameter rather than re-parsing.
In `@packages/1-framework/3-tooling/cli/test/utils/global-flags.test.ts`:
- Around line 138-140: The test is passing an async callback to expect().rejects
instead of a Promise; change the assertion to pass the Promise returned by
calling parseGlobalFlagsOrExit directly (i.e., await
expect(parseGlobalFlagsOrExit({ format: 'pretty', json: true
})).rejects.toThrow('process.exit called') or simply return the Promise to the
matcher) so that expect().rejects receives the actual Promise from
parseGlobalFlagsOrExit and correctly asserts the thrown error; update the
assertion that references parseGlobalFlagsOrExit accordingly.
---
Nitpick comments:
In `@packages/1-framework/1-core/errors/test/control.test.ts`:
- Around line 427-442: Update the two tests to use object matchers instead of
multiple individual expects: for errorInvalidOutputFormat and
errorOutputFormatMutex, replace the separate assertions on
error.code/envelope.code and message contents with a single toMatchObject-style
assertion that checks the relevant fields (e.g., envelope.code and error.code)
and use one matcher for message content (or include message snippets in the
object) so the tests for errorInvalidOutputFormat and errorOutputFormatMutex
become consolidated, clearer, and consistent with the suite’s toMatchObject
style.
🪄 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: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: af4aeae9-05e9-4c2e-b1ff-a05a8e02cbcd
⛔ Files ignored due to path filters (1)
packages/1-framework/3-tooling/cli/test/__snapshots__/help.snapshot.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (34)
packages/1-framework/1-core/errors/src/control.tspackages/1-framework/1-core/errors/src/exports/control.tspackages/1-framework/1-core/errors/test/control.test.tspackages/1-framework/3-tooling/cli/src/commands/contract-emit.tspackages/1-framework/3-tooling/cli/src/commands/contract-infer.tspackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/1-framework/3-tooling/cli/src/commands/db-schema.tspackages/1-framework/3-tooling/cli/src/commands/db-sign.tspackages/1-framework/3-tooling/cli/src/commands/db-update.tspackages/1-framework/3-tooling/cli/src/commands/db-verify.tspackages/1-framework/3-tooling/cli/src/commands/init/index.tspackages/1-framework/3-tooling/cli/src/commands/init/init.tspackages/1-framework/3-tooling/cli/src/commands/migrate.tspackages/1-framework/3-tooling/cli/src/commands/migration-check.tspackages/1-framework/3-tooling/cli/src/commands/migration-graph.tspackages/1-framework/3-tooling/cli/src/commands/migration-list.tspackages/1-framework/3-tooling/cli/src/commands/migration-log.tspackages/1-framework/3-tooling/cli/src/commands/migration-new.tspackages/1-framework/3-tooling/cli/src/commands/migration-plan.tspackages/1-framework/3-tooling/cli/src/commands/migration-show.tspackages/1-framework/3-tooling/cli/src/commands/migration-status.tspackages/1-framework/3-tooling/cli/src/commands/ref.tspackages/1-framework/3-tooling/cli/src/utils/cli-errors.tspackages/1-framework/3-tooling/cli/src/utils/command-helpers.tspackages/1-framework/3-tooling/cli/src/utils/global-flags.tspackages/1-framework/3-tooling/cli/src/utils/terminal-ui.tspackages/1-framework/3-tooling/cli/test/commands/contract-emit.command.test.tspackages/1-framework/3-tooling/cli/test/commands/init/consent-prompt.test.tspackages/1-framework/3-tooling/cli/test/commands/init/init.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-plan-renderer.test.tspackages/1-framework/3-tooling/cli/test/utils/global-flags.test.tspackages/1-framework/3-tooling/cli/test/utils/progress-adapter.test.tspackages/1-framework/3-tooling/cli/test/utils/result-handler.test.tstest/integration/test/cli.init-skill-distribution.integration.test.ts
Signed-off-by: Will Madden <[email protected]>
Summary
--format <pretty|json>on every command that already exposes--json, with defaultprettyon a TTY andjsonwhen stdout is not a TTY (unchanged auto-detection).--jsonas a zero-break alias for--format json; rejects--format prettytogether with--json, while allowing redundant--format json --json.parseGlobalFlagsunit tests.fixes TML-2616
Test plan
pnpm lint@prisma-next/cliunit tests (including newglobal-flags.test.tsand updated help snapshots)test/integrationsample:cli.emit-command.e2e.test.ts(existing--jsonpaths)pnpm test:packages/pnpm test:integrationon CISummary by CodeRabbit
Release Notes
New Features
--format <pretty|json>flag across CLI commands for explicit output formatting control--format prettyis explicitly requestedBug Fixes
--format prettyand--jsonflags with clear error messages