TRAC-137: Add native hosting option in catalyst CLI#3003
Open
jordanarldt wants to merge 1 commit intoalphafrom
Open
TRAC-137: Add native hosting option in catalyst CLI#3003jordanarldt wants to merge 1 commit intoalphafrom
jordanarldt wants to merge 1 commit intoalphafrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Contributor
Bundle Size ReportComparing against baseline from No bundle size changes detected. |
67f5265 to
8e3e01f
Compare
8e3e01f to
e13fec9
Compare
e13fec9 to
e4ae60e
Compare
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-137
What/Why?
Following review of #2995, the team agreed that hosting/deploy concerns belong in
catalyst(the CLI), notcreate-catalyst(the scaffolder). Since the broader plan is to absorbcreate-catalystintocatalystanyway, this PR ports the work directly intopackages/catalystas a newcatalyst createcommand, plus a few related improvements that fell out of building on that foundation.catalyst createNew command. Scaffold-only by default — no interactive hosting prompt, since most users will reach Commerce Hosting via
catalyst deploy.--hosting commerceopts into the full Commerce Hosting setup eagerly (proxy → middleware swap, OpenNext dep,.bigcommerce/project.json,core/.env.localsymlink). Reuses the existingcatalyst authdevice flow.setupCoreProjectruns unconditionally at create time, wiringcatalyst build/catalyst start/catalyst deployscripts and the@bigcommerce/catalystdep intocore/package.jsonregardless of hosting choice — the polymorphic dispatcher (below) makes this safe for self-hosted projects too.Polymorphic
catalyst build/catalyst startBoth commands dispatch via
lib/project-state.ts. Untransformed projects fall through topnpm exec next build/next start; transformed projects run the OpenNext pipeline. Lets the create-time scripts work end-to-end whether or not the user opts into Commerce Hosting.Shared
lib/commerce-hosting.tsSetup logic from #2995 extracted into a reusable module:
setupCommerceHosting,promptForCommerceHostingProject,selectOrCreateInfrastructureProject,runCommerceHostingSetup, plus aNoLinkedProjectErrorsentinel for graceful decline handling.selectOrCreateInfrastructureProjectis shared betweencatalyst project linkandcatalyst deploy, decorating the matching project with green[linked]and skipping the select prompt entirely on empty stores.catalyst project link/listlistandlink's select prompt now mark the currently linked project with green[linked]. After a successful link,linkoffers to run Commerce Hosting setup if the project isn't already transformed.catalyst deployVerifies the linked project still exists on the store before any build/upload work. If missing or 404, falls through to
selectOrCreateInfrastructureProject. Includes a transformation guard that prompts for Commerce Hosting setup when the project isn't transformed. Graceful info + exit on user decline.Misc / quality
.bigcommerce/cwd pollution. Telemetry moved to a user-scopedConf(lives in OS config dir undercatalyst-cli/); project state checks moved to a read-onlygetProjectState()helper that doesn't instantiateConf.core/package.jsonalways getsbuild: "npm run generate && catalyst build"/start: "catalyst start"/deploy: "npm run generate && catalyst deploy".package.jsonfield order (lib/sort-package-json.ts) applied whenever we mutate apackage.json.lib/shared-options.tsnow used acrossproject,create,deploy(each helper accepts an optional description override).lib/https.ts(stateful client class) andlib/user-agent.ts. All API code inlib/(project.ts, channels.ts, localization.ts) now follows the same pattern: positional(...data, storeHash, accessToken, host)args, schemas + parsing internal to the lib, throws on bad responses.lib/channels.tsnow owns all channel-related schemas/types (previously scattered acrosscommands/create.ts).--envand--channel-idvalidate at parse time. Custom argParsers throwInvalidArgumentErroron malformed input; values containing=in--envare preserved.buildWorkspacePackagesruns afterinstallDependenciesat create time when the cloned repo is the catalyst monorepo (core/,packages/catalyst,packages/clientall present), socorecan resolve workspace deps.Testing
228 unit tests, all passing. New:
commands/create.spec.ts(12 tests covering happy paths, parser validation, ordering invariants, failure handling,--hosting commerceprecondition),lib/project-state.spec.ts,lib/setup-core-project.spec.ts,lib/sort-package-json.spec.ts. Extended:commerce-hosting,project,deploy,build,startspecs.pnpm --filter @bigcommerce/catalyst test,typecheck,lint, andbuildall clean.Manually verified the major paths against a real store:
catalyst create(interactive,--hosting commerce,--hosting self-hosted),catalyst project link/listwith[linked]markers,catalyst deployfirst-run transformation prompt,catalyst deployagainst a deleted project (re-link prompt + graceful decline).Proof of life
catalyst_create.mov
catalyst_deploy.mov
Migration
packages/create-catalystis not modified in this PR — the staged #2995 changes there were reverted. A follow-up PR will updatecreate-catalyst createto shim intocatalyst createsopnpm create @bigcommerce/catalystkeeps working.External behavior changes:
BIGCOMMERCE_STOREFRONT_API_TOKENenv var (only ever written by the create flow, never read by the storefront) is now correctlyBIGCOMMERCE_STOREFRONT_TOKEN.User-Agentheader on requests to the cli-api gateway or BC store API. Server-side telemetry that buckets oncatalyst-cli/...UA will see the Node default UA instead.🤖 Generated with Claude Code