Skip to content

LTRAC-444: fix(cli) - Read store hash and access token from project.json#2997

Merged
jorgemoya merged 2 commits intoalphafrom
jorgemoya/ltrac-444-cli-logs-tail-read-credentials-from-project-json
Apr 30, 2026
Merged

LTRAC-444: fix(cli) - Read store hash and access token from project.json#2997
jorgemoya merged 2 commits intoalphafrom
jorgemoya/ltrac-444-cli-logs-tail-read-credentials-from-project-json

Conversation

@jorgemoya
Copy link
Copy Markdown
Contributor

@jorgemoya jorgemoya commented Apr 28, 2026

Jira: LTRAC-444

What/Why?

catalyst logs tail and catalyst logs query previously required --store-hash and --access-token on every invocation (via .makeOptionMandatory()). After running catalyst project link / project create, those credentials are already persisted to .bigcommerce/project.json, but logs wasn't reading them.

This switches both subcommands to resolveCredentials(options, getProjectConfig()) — the same helper used by project, deploy, and build — so flags > CATALYST_* env vars > project.json.

While here, also migrates the shared --store-hash / --access-token / --project-uuid option helpers in lib/shared-options.ts from BIGCOMMERCE_* to CATALYST_* env var names. This was the env-var fallback the rest of the CLI moved to in the recent fix-env-var-names changeset; logs was the last command still on the legacy names.

Note the legacy BIGCOMMERCE_STORE_HASH / BIGCOMMERCE_ACCESS_TOKEN / BIGCOMMERCE_PROJECT_UUID env vars are no longer read by logs tail / logs query.

Fixes LTRAC-444

Testing

Unit tests added:

  • falls back to project.json for storeHash and accessToken — writes credentials to a tmp project.json and runs logs tail with no flags.
  • exits with error when no credentials are provided — asserts Missing credentials. and process.exit(1) for both tail and query.

Manual verification in a Catalyst project that's already run catalyst project link:

  • catalyst logs tail (no flags, no env vars) — connects and tails using project.json credentials.
  • catalyst logs tail --store-hash X --access-token Y — flag values override project.json.
  • CATALYST_STORE_HASH=X CATALYST_ACCESS_TOKEN=Y catalyst logs tail — env values used.
  • In a directory with no project.json and no flags/env — fails with the standard Missing credentials. message pointing at catalyst auth login.

pnpm --filter @bigcommerce/catalyst test, typecheck, and lint all clean.

Migration

The legacy BIGCOMMERCE_STORE_HASH / BIGCOMMERCE_ACCESS_TOKEN / BIGCOMMERCE_PROJECT_UUID env vars are no longer read by logs tail / logs query. Anyone relying on them needs to switch to CATALYST_STORE_HASH / CATALYST_ACCESS_TOKEN / CATALYST_PROJECT_UUID (or use catalyst project link to persist credentials). All other CLI commands already require the CATALYST_* names.

🤖 Generated with Claude Code

`catalyst logs tail` and `catalyst logs query` now resolve credentials via
`resolveCredentials`, falling back to `.bigcommerce/project.json` when
`--store-hash` / `--access-token` flags or `CATALYST_STORE_HASH` /
`CATALYST_ACCESS_TOKEN` env vars are not provided. This matches the
behavior already used by `project`, `deploy`, and `build`, and removes
the need to re-pass credentials after running `catalyst project link`.

Also migrates the shared `--store-hash` / `--access-token` option helpers
from the legacy `BIGCOMMERCE_*` env var names to `CATALYST_*` for
consistency with the rest of the CLI.

Fixes LTRAC-444
Co-Authored-By: Claude <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

⚠️ No Changeset found

Latest commit: abbf7b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview, Comment Apr 29, 2026 3:42pm

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Bundle Size Report

Comparing against baseline from 9f11983 (2026-04-29).

No bundle size changes detected.

@jorgemoya jorgemoya marked this pull request as ready for review April 28, 2026 22:23
@jorgemoya jorgemoya requested a review from a team as a code owner April 28, 2026 22:23
Comment thread packages/catalyst/src/cli/commands/logs.ts
'--store-hash <hash>',
'BigCommerce store hash. Can be found in the URL of your store Control Panel.',
).env('BIGCOMMERCE_STORE_HASH');
).env('CATALYST_STORE_HASH');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the other env vars in these options also be prefixed with CATALYST_?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Included CATALYST_PROJECT_UUID

…ROJECT_UUID

The shared `projectUuidOption()` helper was still using the legacy
`BIGCOMMERCE_PROJECT_UUID` env var name. It was missed in the earlier
`CATALYST_*` rename sweep because `logs` was the only consumer at the
time. The inline declarations in `build.ts` and `deploy.ts` already use
`CATALYST_PROJECT_UUID`, so this aligns the helper with the rest of the
CLI and the alpha.2 patch notes.

Refs LTRAC-444
Co-Authored-By: Claude <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 29, 2026

@jorgemoya jorgemoya merged commit 3ab3c67 into alpha Apr 30, 2026
15 of 16 checks passed
@jorgemoya jorgemoya deleted the jorgemoya/ltrac-444-cli-logs-tail-read-credentials-from-project-json branch April 30, 2026 02:47
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