Skip to content

feat: use active environment across commands#228

Open
angeloashmore wants to merge 3 commits into
aa/env-dot-envfrom
aa/env-dot-env-consume
Open

feat: use active environment across commands#228
angeloashmore wants to merge 3 commits into
aa/env-dot-envfrom
aa/env-dot-env-consume

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Jul 16, 2026

Copy link
Copy Markdown
Member

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: --env is deprecated in favor of the env commands. It is now treated as an alias to --repo. We previously validated that --env was valid for the repository. The CLI now simplifies that approach by treating --env as the repository name, falling back to normal 404 reporting if an invalid/incorrect environment name is given.

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1

npx prismic@pr-228 env set my-environment
npx prismic@pr-228 status                     # resolves to my-environment
npx prismic@pr-228 status --repo other-repo   # --repo still overrides

Note

Medium Risk
Broad CLI behavior change: default target repo/env and removal of --env validation can surprise scripts or users who relied on parent-repo + validated environment resolution.

Overview
CLI commands now default to the active environment (from .env.local via the framework adapter) when --repo is omitted, falling back to prismic.config.json through new getActiveRepositoryName().

--env is deprecated and treated as an alias for --repo (repository or environment domain). resolveEnvironment and its API-side validation against the parent repository are removed; invalid names surface as normal API errors instead of InvalidEnvironmentError.

pull / push / sync / status use the same resolution (--repo--env → active env → config repo). Onboarding and log output use the resolved domain. status still prints the config repository name and shows Environment only when it differs.

Tests that expected rejection of unknown --env values were removed.

Reviewed by Cursor Bugbot for commit 1fde0c6. Bugbot is set up for automated code reviews on this repo. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment.

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 angeloashmore changed the title refactor: consume active environment across commands feat: use active environment across commands Jul 16, 2026
@angeloashmore
angeloashmore marked this pull request as ready for review July 16, 2026 20:34

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1fde0c6. Configure here.

Comment thread src/adapters/index.ts
Comment thread src/commands/status.ts Outdated
angeloashmore and others added 2 commits July 16, 2026 22:29
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 lihbr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one suggestion if it makes sense

repo: { type: "string", short: "r", description: "Repository domain" },
env: { type: "string", short: "e", description: "Environment domain" },
repo: { type: "string", short: "r", description: "Repository or environment domain" },
env: { type: "string", short: "e", description: "(deprecated) Alias for --repo" },

@lihbr lihbr Jul 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 #idea: any thought on adding a deprecated: true property instead so that:

  1. the deprecated flag is not shown in --help anymore
  2. we can log the deprecation notice (description) if it is used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants