feat: use active environment across commands#228
Merged
Conversation
Migrate the existing commands (locale, preview, token, webhook, pull, push, status, sync) to resolve the target repository from the persisted active environment. Deprecate the per-command --env flag, making it an alias for --repo, and remove resolveEnvironment along with its API-side validation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
angeloashmore
marked this pull request as ready for review
July 16, 2026 20:34
Show an explicit --repo target on the status Environment line, not just --env or the active environment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lihbr
approved these changes
Jul 17, 2026
lihbr
left a comment
Member
There was a problem hiding this comment.
LGTM, just one suggestion if it makes sense
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # test/push.serial.test.ts # test/status.serial.test.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 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 93b9b66. Configure here.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
angeloashmore
added a commit
that referenced
this pull request
Jul 24, 2026
* feat: add prismic env commands backed by .env.local 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> * feat: wire env command and read active environment in clients 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> * fix: address env review feedback - 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> * feat: hide env commands from help and mark them experimental Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor: remove env file format checks that can never throw Node's util.parseEnv is a best-effort parser with no error path for string input, so the "verify the format" calls were dead code. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: use active environment across commands (#228) * refactor: consume active environment across commands Migrate the existing commands (locale, preview, token, webhook, pull, push, status, sync) to resolve the target repository from the persisted active environment. Deprecate the per-command --env flag, making it an alias for --repo, and remove resolveEnvironment along with its API-side validation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: label status Environment line from the resolved repo Show an explicit --repo target on the status Environment line, not just --env or the active environment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat: hide deprecated options from help and warn on use Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: record onboarding steps on the production repository Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: resolve the repository lazily so --repo works without a framework Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: fall back to config repository name when environment variable is empty Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <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:
Description
This PR is a follow-up to #227. #227 gives a way to set the active environment, while this PR connects the active environment to the commands.
Note:
--envis deprecated in favor of theenvcommands. It is now treated as an alias to--repo. We previously validated that--envwas valid for the repository. The CLI now simplifies that approach by treating--envas the repository name, falling back to normal 404 reporting if an invalid/incorrect environment name is given.Checklist
Preview
How to QA 1
Note
Medium Risk
Wide CLI behavior change: default targets may shift to a configured environment, and
--envno longer validates against the parent repo’s environment list before API calls.Overview
Commands that talk to Prismic now default to the project’s active environment (from
prismic env set/ the framework adapter), falling back toprismic.config.jsonwhen none is set.getActiveRepositoryName()centralizes that default for locale, preview, token, and webhook commands; pull, push, sync, and status use the same idea viaadapter.getEnvironment().--envis deprecated: it is treated as an alias for--repo(repository or environment domain), with a runtime warning and omission from help.resolveEnvironmentand API-side validation of environment names are removed—invalid domains surface as normal API errors instead.prismic statusprints the config repository separately and shows Environment only when the resolved target differs. Onboarding completion still uses the parent repository from config, not the active environment. Tests that expected--envvalidation failures were removed.Reviewed by Cursor Bugbot for commit 01d3d8b. 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. ↩