feat: add env commands#227
Open
angeloashmore wants to merge 3 commits into
Open
Conversation
Add `prismic env` commands to manage a project's active environment. The active environment is stored in .env.local under a framework-specific variable name (e.g. NEXT_PUBLIC_PRISMIC_ENVIRONMENT), so the running site reads it automatically. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Register `prismic env` in the command router and update the generated prismic.io client templates to resolve repositoryName from the active environment variable, falling back to the configured repository name. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
prismic env commands backed by .env.local
This was referenced Jul 16, 2026
env commands
angeloashmore
marked this pull request as ready for review
July 16, 2026 20:34
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 6 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a222150. Configure here.
- getEnvironment surfaces corrupt .env.local instead of treating it as unset - env list marks the active environment only for the project's own repo - setEnvFileVar/unsetEnvFileVar update every occurrence of a key Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lihbr
approved these changes
Jul 17, 2026
| if (!hasFile) return; | ||
|
|
||
| let contents = await readFile(path, "utf8"); | ||
| parseEnv(contents); // Verify the format |
Member
There was a problem hiding this comment.
💡 #idea: do you think adding a test covering the behavior when this throws (malformed env) would be useful?
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.

Resolves:
Description
Adds
prismic envcommands to manage a project's active environment.The active environment is written to
.env.localunder a framework-specificvariable name, so the running site picks it up automatically:
# Next.js NEXT_PUBLIC_PRISMIC_ENVIRONMENT=my-environmentChecklist
Preview
How to QA 1
Note
Medium Risk
Changes which Prismic repository the dev site queries via
.env.localedits and client bootstrap; mistakes could point local builds at the wrong environment, though production defaults remain when unset.Overview
Adds
prismic envso developers can list, set, unset, and print the active Prismic environment for a project. The choice is persisted in.env.localvia a framework-specific public env var (NEXT_PUBLIC_PRISMIC_ENVIRONMENT,NUXT_PUBLIC_PRISMIC_ENVIRONMENT,PUBLIC_PRISMIC_ENVIRONMENT).env setvalidates the domain against environments the logged-in user can access (prod/stage), writes or updates the var, and treats the production repo domain as “unset” (remove override).env listsupports table or--jsonand marks the active env when listing the project repo;--repolists another repo without an active marker.Generated Next.js and SvelteKit
prismiciotemplates now resolverepositoryNamefrom that env var, falling back toprismic.config.json. Shared.env.localread/write helpers back the adaptergetEnvironment/setEnvironment/unsetEnvironmentAPIs.Reviewed by Cursor Bugbot for commit c74abb3. Bugbot is set up for automated code reviews on this repo. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩