Repository navigation
feat(cli): add project variable and project variable group commands - #395
Draft
clankergoose wants to merge 9 commits into
Draft
clankergoose wants to merge 9 commits into
clankergoose wants to merge 9 commits into
Conversation
Adds `prisma variable` with add/update/delete/list subcommands and `prisma variable group` with list/create/update/delete subcommands. Variables write to named groups (--group <name> or --role production|preview). --branch is rejected on write commands; use a variable group or send a service variable with the deploy. --role preview fails when the project has custom groups (Decided 37). New API endpoints (variable-groups, resolved-variables, groupId filter on environment-variables) are not in @prisma/management-api-sdk v1.80.0 so they are called through typed wrappers in lib/variable/api.ts that cast once to the raw client. Also: - Renames "Env map" column to "Variable group" in `branch list`. - Adds a deprecation warning to all `project env` write/list commands. - Adds the 8 new commands to the e2e-coverage exclusion list (endpoints not yet deployed to the standard CI environment) and to the mount-coverage snapshot. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
commit: |
…lint `variable update --file` looked each key up by role, so in a custom group it changed the preview group's row. It now looks keys up by group id, the same way the single-key path does. Also fixes lint: removes an unused import and test helper, a nested ternary and non-null assertions, and gives a reason for each remaining cast and sequential await. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…verrides Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xamples Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… override writes [skip ci] - Move `prisma variable` and `prisma variable group` to `prisma project variable` and `prisma project variable group`. Remove the top-level `variable` command. - Restore `prisma project env` to its main-branch behaviour. Remove the warning on every env command. Warn on stderr only when an env write sets a branch override (`--branch`, or a `Deprecation` header on the response). - Built-in groups are not stored: their id is `production` or `preview`, `builtIn` is true, and their variables have `groupId: null`. Update the typed wrappers and fixtures. `group update` and `group delete` refuse built-in groups. - `project variable list --branch` labels overrides as deprecated and `COMPOSER_` keys as "Managed by Prisma". - Add the `VARIABLE` codes to the error reference, and mention the new commands in the package READMEs and the platform skill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ne [skip ci] Every `prisma project env` command is now marked deprecated in its help, and each run prints one warning on stderr that names the matching `prisma project variable` command. Data on stdout is unchanged. This replaces the warning that only branch override writes printed. `prisma project variable` no longer imports any env module, so `env` can be removed later by deleting its files. Key and dotenv parsing moved to lib/variable/assignment.ts, and API errors use the variable library's own error. A test follows the imports and fails if an env module is reached. The variable commands now match what `env` can do, except overrides: - add and update check the group before writing, for one key and for --file, and write nothing when a key already exists or is missing - a failed --file write reports the keys already written - list accepts --role, shows ids, and fails on an unknown group or branch The error-code scanner now includes the VARIABLE namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…deprecated [skip ci] The VARIABLE.NO_BRANCH_WRITE error now says that overrides and `prisma project env` are deprecated, and recommends moving the value into a custom group. It still shows the `prisma project env --branch` command for changing an existing override. The platform skill, glossary, error reference, example README and command help now describe branch variables in groups, service variables, the order a deploy applies them in, and why branch variables are the recommended kind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing an override [skip ci] The steps for moving an override into a custom group now say that the new group does not include the preview group's values. Users must add every key the branch needs, or use the Console, which can copy them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Switch createEnvVarInGroup, findEnvVarInGroup, and listEnvVarsInGroup
from /v1/environment-variables to the new /v1/variable-groups/{groupId}/variables
routes, with groupId in the path instead of the query or body.
Add updateGroupVariable and deleteGroupVariable wrappers for
PATCH and DELETE /v1/variable-groups/{groupId}/variables/{variableId}.
update.ts and delete.ts now call these wrappers and no longer inline
the SDK calls.
Drop the groupId: null comment from RawGroupVariable; the new routes
always return groupId as a non-null string.
Update all test mocks and assertions to match the new paths and
path-param locations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Demo only. Not for merge. CLI side of the variable groups demo. Platform PRs: prisma/pdp-control-plane#6109 (API) and #6110 (Console). Spec: prisma/pdp-control-plane#5916. Review comments will not get replies.
Summary
Adds
prisma project variable(add / update / delete / list) andprisma project variable group(list / create / update / delete). There is no top-levelprisma variablecommand.All of
prisma project envis deprecated and will be removed in a later release. Its behaviour and its stdout are unchanged, so scripts keep working. Everyenvsubcommand says "Deprecated" in its help, and every run prints one warning on stderr that names the matchingprisma project variablecommand. This replaces the earlier warning that only branch override writes printed.prisma project variabledoes not depend on anyenvcode, soenvcan be removed by deleting its files only. A test follows the imports and fails if a variable file reaches an env module.Key design decisions
--group <name>or--role production|previewselects the target group, on writes and onlist. The two flags cannot be used together (VARIABLE.CONFLICTING_FLAGS).--branchon a write fails withVARIABLE.NO_BRANCH_WRITE. The error says that overrides andprisma project envare deprecated, and recommends moving the value into a custom group (prisma project variable group createandprisma project variable add, or "Move to a custom group" in Console). Its last next action is still the deprecatedprisma project env … --branchcommand, for changing an override that already exists.--role previewcheck. If the project has any custom group,--role previewfails withVARIABLE.CUSTOM_GROUP_CONFLICT. Use--group previewinstead.addfails withVARIABLE.ALREADY_EXISTSif a key exists;updatefails withVARIABLE.NOT_FOUNDif a key is missing. With--file, every key in the file is checked, all problem keys are listed, and nothing is written.--filewrite stops at that key and fails withVARIABLE.FILE_APPLY_FAILED, naming the keys already written.productionandpreview. The group list returns them withidequal to their name,builtIn: true, and no rule.group updateandgroup deleterefuse built-in groups. ThebuiltInhandling is unchanged in this round; the API contract is being finalised separately.project variable list --branch <name>shows the group the branch receives and each key's source. Overrides are labelled "Deprecated override", with a warning under the table. An unknown branch fails withVARIABLE.BRANCH_NOT_FOUND.envdeprecation warning in--jsonmode is a separatemessageframe in the output stream, as for every engine warning. Theresultframe is unchanged. The engine has no deprecation support for live commands (only redirects for removed ones), so the warning is one function inenv-shared.ts.@prisma/management-api-sdkv1.80.0.lib/variable/api.tsholds typed wrappers that cast once to the raw client.prisma deploy --variableto Composer.project variable list --branch <name> --service <name>only reads them. Known gap.Parity with
prisma project env(overrides excluded)prisma project envprisma project variableadd KEY=VALUE --role production|previewadd KEY=VALUE --role …or--group <name>add KEY(value from the shell)add KEYadd --file .envadd --file .envadd: fails if the key existsVARIABLE.ALREADY_EXISTS, single key and--fileupdate KEY=VALUE/KEY/--fileupdate: fails if a key is missingVARIABLE.NOT_FOUND, single key and--file--filepartial failure reportVARIABLE.FILE_APPLY_FAILEDdelete KEY --role …delete KEY --role …or--group <name>list(overview of every scope)list(every group)list --role …list --role …or--group <name>list --branch <name>(what a branch gets)list --branch <name>, plus--service--project,--json, stdout data lines--branchoverride writesCommands
prisma project variable add KEY=VALUE --group <name>prisma project variable update KEY=VALUE --group <name>prisma project variable delete KEY --group <name>prisma project variable list [--group <name> | --role …] [--branch <name>]prisma project variable group listprisma project variable group create <name> --equals|--starts-with <value>prisma project variable group update <name> [--name] [--equals|--starts-with]prisma project variable group delete <name> [--confirm <name>]Docs
docs/reference/error-reference.md:VARIABLEcodes, including the newALREADY_EXISTS,BRANCH_NOT_FOUND,FILE_APPLY_FAILED, andUSAGE_ERROR. A note marks thePROJECT.ENV_*codes as coming from the deprecated commands.scripts/list-error-codes.mjs:VARIABLEadded to the namespace list, socheck:error-referencenow verifies those codes.README.md,packages/cli/README.md,packages/prisma/README.md: examples useproject variable.skills/prisma-platform-core-concepts/SKILL.md: the "Environment variables" section is rewritten for the current model. It explains branch variables (in groups) and service variables, how a branch gets its one group, that groups do not inherit, the order a deploy applies groups, overrides and service variables, and why branch variables are recommended (a new branch gets the right configuration with no manual step). It says overrides andproject envare deprecated and how to move an override into a custom group. The resource model, preview database, promote, and stale-value entries are updated to match.docs/reference/glossary.md: new terms: variable group, branch variable, service variable, override (deprecated).examples/hello-world/README.md: usesproject variableinstead ofproject env.project variableexplains branch and service variables and that groups do not inherit;list --servicesays it shows service variables;project envhelp and its--branchflag say overrides are deprecated;--role previewinproject envno longer claims to reach every preview branch.Tests
tests/variable.test.ts(46 tests, one now checks the fullVARIABLE.NO_BRANCH_WRITEtext): flags, group resolution, add/update/delete/list, the checks before writing,--fileimport and partial failure, key validation,list --role, unknown group and branch, and the group commands.tests/variable-imports.test.ts: no file undercommands/project/variableorlib/variablereaches an env module, directly or through other modules. Verified to fail on a multi-line type import.tests/project.test.ts(7 tests): the warning on eachenvsubcommand (add, add--file, update, delete, list, and a failed run), with exact stdout checks, and the--jsonresult unchanged.Checks
pnpm format,pnpm lint: pass.pnpm typecheck: passes (9 of 9 tasks).pnpm --filter @prisma/cli test: 1275 passed, 2 skipped, 0 failed.pnpm check:error-reference: all 155 codes listed.pnpm check:skill-packaging,pnpm check:grammar: pass.🤖 Generated with Claude Code