feat: add prismic env commands and CLI-owned active environment#211
Draft
angeloashmore wants to merge 5 commits into
Draft
feat: add prismic env commands and CLI-owned active environment#211angeloashmore wants to merge 5 commits into
prismic env commands and CLI-owned active environment#211angeloashmore wants to merge 5 commits into
Conversation
Add `prismic env set/unset/active/list` to pick a project's active environment. The choice lives in CLI state keyed by project, so nothing lands in the repo. `getRepositoryName` resolves it, so every command honors it. Sites read it at build time via the `prismic/env` and `prismic/env/register` exports; `prismic init` wires the register import into the framework config and generated `prismicio` file for Next.js and SvelteKit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
angeloashmore
commented
Jul 3, 2026
angeloashmore
left a comment
Member
Author
There was a problem hiding this comment.
It looks like we're missing the update-notifier message change where if we detect the user has the prismic cli installed as a dependency, we print instructions on how to update it. If it's being used via npx without an installation instead, we keep the current message.
- update-notifier: when the CLI is installed as a project dependency, suggest the package manager's add command instead of the npx message - rename `listAvailableEnvironments` to `getEnvironments` - reuse a shared `findUpwardSync` helper in `active-environment` Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Makes it clear at the call site that the function returns the prod/stage environments the logged-in user can access, not the raw client list. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rename addRegisterImport to addEnvRegisterImport and activeDomain to activeEnvironment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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: #209
Description
Adds
prismic env set/unset/active/listto pick a project's active environment. The choice lives in CLI-owned state keyed by project, so nothing lands in the repo.getRepositoryNameresolves it, so every command honors it (--env/--repostill override).Sites read the active environment at build time via two exports:
prismic/env— a syncgetActiveEnvironment()prismic/env/register— a side-effect import that sets the framework's environment variableprismic initwires theregisterimport into the framework config and updates the generatedprismiciofile for Next.js and SvelteKit, and addsprismicas a project dependency. Nuxt is out of scope here —@nuxtjs/prismicwill read the state itself.This implements the approach from the last comment on #209 (CLI-owned state), not the
.env.localapproach from #210.Not included, by design: stripping the stale Slice Machine
NEXT_PUBLIC_PRISMIC_ENVIRONMENTfrom existing projects'.env.local.Checklist
Preview
How to QA 1
In a Next.js or SvelteKit project:
prismic env listshows the environments; production is marked(active).prismic env set <staging-domain>thenprismic env activeprints the staging domain, and CLI commands (e.g.prismic pull) target it.prismiciofile.prismic env unsetreturns everything to production.🤖 Generated with Claude Code
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. ↩