Skip to content

feat(cli): auto-update BC channel site URL on deploy#3001

Open
jorgemoya wants to merge 3 commits intoalphafrom
jorgemoya/ltrac-446-cli-auto-update-bc-channel-site-url-on-deploy
Open

feat(cli): auto-update BC channel site URL on deploy#3001
jorgemoya wants to merge 3 commits intoalphafrom
jorgemoya/ltrac-446-cli-auto-update-bc-channel-site-url-on-deploy

Conversation

@jorgemoya
Copy link
Copy Markdown
Contributor

Jira: LTRAC-446

What/Why?

After catalyst deploy finishes, the CLI now PUTs the new deployment URL onto the linked BigCommerce channel's site (PUT /v3/channels/{id}/site), so merchants no longer have to remember to copy the URL into the control panel after every deploy.

A few decisions worth flagging for review:

  • Channel ID lives in project.json. catalyst project link and project create now show a channel picker (storefront-type only) right after writing the project UUID, with a "Skip" option for users who don't want to link one. At deploy time the resolution order is --channel-id flag → CATALYST_CHANNEL_ID env → project.json. Pass --no-update-channel to opt out.
  • Soft-fail on update errors. The deploy first GETs the current channel site and skips the PUT when the URL already matches; on any other error (401 missing scope, 404, 5xx, etc.) we log a warning + a catalyst auth login hint instead of failing the deploy — the bundle is already live by the time we hit this step.
  • OAuth scope. store_channel_settings is added to DEVICE_OAUTH_SCOPES. Existing logged-in users will need to re-run catalyst auth login to mint a token with the new scope; the soft-fail path catches the 401/403 they would otherwise hit.
  • deployment_url deprecation. The deployment-status SSE will eventually replace deployment_url with deployment_hostnames (string array). For this change we keep using deployment_url and leave the deployment_hostnames migration as a commented TODO in DeploymentStatusSchema — separate follow-up.

The two commits are split deliberately: implementation in cce879a6f, tests in b4a274171.

Testing

Unit tests:

  • pnpm --filter @bigcommerce/catalyst test — 156/156 passing (added 11 in channels.spec.ts, 5 picker tests in project.spec.ts, 6 channel-update tests in deploy.spec.ts).
  • pnpm --filter @bigcommerce/catalyst typecheck and pnpm --filter @bigcommerce/catalyst lint clean.

Manual end-to-end (requires a real store + at least one storefront channel):

  1. catalyst auth login — pulls the new store_channel_settings scope.
  2. catalyst project link — confirm the channel picker appears with a "Skip" option, and selecting one writes channelId into .bigcommerce/project.json.
  3. catalyst deploy — confirm the post-deploy line: Updated channel <id> site URL to https://... (or ... already up to date. on a re-deploy of the same hostname). Verify in the BC control panel.
  4. catalyst deploy --no-update-channel — confirm update is skipped.
  5. catalyst deploy --channel-id <other> — confirm flag overrides project.json.
  6. Delete channelId from project.json and re-run deploy without flag/env — confirm soft warning, deploy still exits 0.
  7. With a token missing store_channel_settings, run deploy and confirm the warning + catalyst auth login hint.

Migration

None for users continuing to set channel URLs by hand. Users who want the auto-update should re-run catalyst auth login (new OAuth scope) and catalyst project link (to pick a channel and persist it). The new behavior is on by default once both are done; pass --no-update-channel to opt out of any single deploy.

jorgemoya and others added 2 commits May 1, 2026 21:00
After a successful `catalyst deploy`, automatically update the linked
BigCommerce channel's site URL to the new deployment URL so merchants no
longer have to remember to do it manually in the control panel.

The channel ID is selected interactively at `catalyst project link` /
`project create` time (with a "skip" option for users who don't want to
link a channel) and persisted to `.bigcommerce/project.json`. At deploy
time the resolution order is `--channel-id` flag, then
`CATALYST_CHANNEL_ID`, then project.json. Pass `--no-update-channel` to
opt out of the auto-update.

The deploy first GETs the current channel site and skips the PUT when
the URL already matches, and any failure during the update is treated as
a soft warning so the deploy itself remains successful — the bundle is
already live by the time we hit this step.

Adds the `store_channel_settings` scope to the device-OAuth flow;
existing logged-in users will need to re-run `catalyst auth login` to
pick it up. The new endpoint also requires that scope, so the soft-fail
path points users at `catalyst auth login` if they hit a 401/403.

Refs LTRAC-446
Co-Authored-By: Claude <noreply@anthropic.com>
Add coverage for the post-deploy channel site URL auto-update introduced
in cce879a:

- channels.spec.ts: unit tests for fetchChannels, fetchChannelSite (incl.
  404→null), and updateChannelSiteUrl, asserting that 401/403 responses
  surface the re-auth hint.
- project.spec.ts: tests the new channel picker in `project link` and
  `project create` — a selection writes channelId to project.json, the
  Skip option leaves it untouched, an empty storefront list is handled,
  and a 403 from the channels API soft-fails so users can still proceed.
- deploy.spec.ts: tests the post-deploy update path — successful update,
  channelId resolution from project.json, the GET-and-skip-when-equal
  optimization, --no-update-channel as a hard skip, the no-channel-id
  warning, and the 401 soft-fail with re-auth hint.
- tests/mocks/handlers.ts: default `/v3/channels` handler returns an
  empty list so unrelated tests no longer hit the unhandled-request
  warning while still exercising the soft-fail path.

Refs LTRAC-446
Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 2, 2026

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

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview, Comment May 2, 2026 2:23am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

⚠️ No Changeset found

Latest commit: c3a4536

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

@jorgemoya jorgemoya changed the title LTRAC-446: feat(cli) - Auto-update BC channel site URL on deploy feat(cli): auto-update BC channel site URL on deploy May 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Bundle Size Report

Comparing against baseline from ec92930 (2026-05-02).

No bundle size changes detected.

The channel picker added in cce879a filtered to type=storefront, which
still surfaces non-Catalyst storefronts (Stencil, headless, etc.) that
the user can't meaningfully target with `catalyst deploy`. Narrow the
filter to platform=catalyst so the picker only shows channels actually
backed by Catalyst.

Refs LTRAC-446
Co-Authored-By: Claude <noreply@anthropic.com>
@jorgemoya jorgemoya marked this pull request as ready for review May 2, 2026 02:38
@jorgemoya jorgemoya requested a review from a team as a code owner May 2, 2026 02:38
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