Skip to content

feat: support PRISMIC_TOKEN env var to override stored token#191

Open
angeloashmore wants to merge 4 commits into
mainfrom
feat/prismic-token-env
Open

feat: support PRISMIC_TOKEN env var to override stored token#191
angeloashmore wants to merge 4 commits into
mainfrom
feat/prismic-token-env

Conversation

@angeloashmore
Copy link
Copy Markdown
Member

@angeloashmore angeloashmore commented Jun 2, 2026

Resolves:

Description

Adds a PRISMIC_TOKEN environment variable that takes priority over the token stored in the credentials file. Useful for CI, scripted use, and ephemeral environments where persisting a token to disk is undesirable.

The env value is kept in memory only — refreshToken() early-returns when PRISMIC_TOKEN is set so the value is never written to the credentials file.

Mirrors the existing PRISMIC_HOST pattern in src/auth.ts.

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. node --run build
  2. With no credentials file, run PRISMIC_TOKEN=<valid-token> ./dist/index.mjs whoami — should print the email associated with that token.
  3. With PRISMIC_TOKEN set, run any authenticated command and confirm the credentials file's token field is unchanged afterward.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Medium Risk
Changes how all authenticated commands resolve tokens and refresh behavior; mistakes could affect CI/scripts or leave users stuck on bad env tokens, but scope is small and mirrors PRISMIC_HOST.

Overview
Adds optional PRISMIC_TOKEN env support so authentication can use an in-memory token instead of the on-disk credentials file—aligned with the existing PRISMIC_HOST override pattern.

getToken() returns the env value when set; refreshToken() no-ops in that case so refreshed tokens are never persisted to the credentials file. prismic init surfaces a clear error when PRISMIC_TOKEN is set but invalid, instead of falling through to browser login. Coverage includes a whoami test that runs with PRISMIC_TOKEN after logout.

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

angeloashmore and others added 2 commits June 2, 2026 12:29
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 and found 1 potential issue.

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 c3e2a17. Configure here.

Comment thread src/auth.ts
angeloashmore and others added 2 commits June 2, 2026 12:41
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant