feat(cli): auto-update BC channel site URL on deploy#3001
Open
feat(cli): auto-update BC channel site URL on deploy#3001
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Contributor
Bundle Size ReportComparing against baseline from 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: LTRAC-446
What/Why?
After
catalyst deployfinishes, 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:
project.json.catalyst project linkandproject createnow 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-idflag →CATALYST_CHANNEL_IDenv →project.json. Pass--no-update-channelto opt out.catalyst auth loginhint instead of failing the deploy — the bundle is already live by the time we hit this step.store_channel_settingsis added toDEVICE_OAUTH_SCOPES. Existing logged-in users will need to re-runcatalyst auth loginto mint a token with the new scope; the soft-fail path catches the 401/403 they would otherwise hit.deployment_urldeprecation. The deployment-status SSE will eventually replacedeployment_urlwithdeployment_hostnames(string array). For this change we keep usingdeployment_urland leave thedeployment_hostnamesmigration as a commented TODO inDeploymentStatusSchema— separate follow-up.The two commits are split deliberately: implementation in
cce879a6f, tests inb4a274171.Testing
Unit tests:
pnpm --filter @bigcommerce/catalyst test— 156/156 passing (added 11 inchannels.spec.ts, 5 picker tests inproject.spec.ts, 6 channel-update tests indeploy.spec.ts).pnpm --filter @bigcommerce/catalyst typecheckandpnpm --filter @bigcommerce/catalyst lintclean.Manual end-to-end (requires a real store + at least one storefront channel):
catalyst auth login— pulls the newstore_channel_settingsscope.catalyst project link— confirm the channel picker appears with a "Skip" option, and selecting one writeschannelIdinto.bigcommerce/project.json.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.catalyst deploy --no-update-channel— confirm update is skipped.catalyst deploy --channel-id <other>— confirm flag overridesproject.json.channelIdfromproject.jsonand re-run deploy without flag/env — confirm soft warning, deploy still exits 0.store_channel_settings, run deploy and confirm the warning +catalyst auth loginhint.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) andcatalyst project link(to pick a channel and persist it). The new behavior is on by default once both are done; pass--no-update-channelto opt out of any single deploy.