Skip to content

feat: better environment support #209

Description

@angeloashmore

Is your feature request related to a problem? Please describe.

Environments only have low-level controls. --env exists, but nothing persists it, so a developer has to pass it on every command and remember which environment they're in. That is easy to forget, and easy to target the wrong one.

The Type Builder has an environment dropdown, but it is specific to that UI. It has no connection to the CLI or the running website. There is no shared, persisted "active environment" that the CLI, the site, and the developer all agree on.

We want a persisted active environment, defaulting to production, that:

  • the developer can select, clear, and inspect from the CLI, so they set it once instead of repeating --env;
  • the running website resolves without the CLI at runtime, including in client-side bundles, which have no filesystem;
  • works the same in CI, where the pipeline sets the environment;
  • is scoped per project (per working copy), not per machine, so multiple projects or git worktrees do not collide;
  • has one source of truth, so a manual change and a CLI change cannot silently drift apart.

Describe the solution you'd like

A persisted active environment managed through the CLI, defaulting to production, that the website reads natively at build time and that CI can set through the pipeline. The existing --env <name> per-command override stays for one-off targeting.

Concrete approaches are proposed and compared in the comments rather than fixed here.

Describe alternatives you've considered

Directions that are ruled out, to bound the solution:

  • Injecting the value inline in package.json scripts (for example, command substitution). Not cross-platform, since npm runs scripts under cmd.exe on Windows.
  • A wrapper run command (for example, prismic env exec -- next dev). Cross-platform, but intrusive, and it does not fit a developer's existing setup.
  • Reading machine-global state at runtime. Not portable to client-side bundles, and machine scope is wrong for a per-project setting.
  • A server-side active environment. Environments are for local development.

Additional context

The Type Builder shows an npx prismic pull command. When a non-production environment is active, that command should reflect it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions