TRAC-137: Add native hosting option to create-catalyst#2995
TRAC-137: Add native hosting option to create-catalyst#2995jordanarldt wants to merge 1 commit intocanaryfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Bundle Size ReportComparing against baseline from No bundle size changes detected. |
Unlighthouse Performance Comparison — VercelComparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores. Summary ScoreAggregate score across all categories as reported by Unlighthouse.
Category Scores
Core Web Vitals
|
6015097 to
2c61f68
Compare
2c61f68 to
819c3c2
Compare
819c3c2 to
1ef5123
Compare
1ef5123 to
119cc17
Compare
119cc17 to
e478678
Compare
e478678 to
45d5dbf
Compare
45d5dbf to
b6fb183
Compare
chanceaclark
left a comment
There was a problem hiding this comment.
Overall LGTM. I'd let a second opinion from @bigcommerce/team-trac have some input before merging though.
| .addOption( | ||
| new Option( | ||
| '--hosting <mode>', | ||
| 'Hosting mode: "self-hosted" for Next.js or "commerce" for Commerce-hosted', |
There was a problem hiding this comment.
⛏️ I'd like to think a bit more about these hosting flags, same with the help message.
Is the logic here: "self-hosted" == Vercel right now, but in theory can be any hosting provider (including self-hosted), and "commerce" == Native Hosting on CF?
I guess my question here is: why not put "vercel" and "commerce" as the options?
There was a problem hiding this comment.
@parthshahp I think self-hosted makes the most sense, because it doesn't necessarily mean Vercel. When not using Native Hosting, the consumer can host their NextJS app anywhere that supports hosting NextJS (heroku, vercel, google cloud, etc)
There was a problem hiding this comment.
That makes sense. I think the message "self-hosted" for Next.js is a bit confusing here, because technically it's Next.js either way, right? If I saw this message, I would think:
If "self-hosted" is how I use Next.js, what framework is "commerce"?
There was a problem hiding this comment.
@parthshahp Yeah good point, let me fix that!
There was a problem hiding this comment.
I think that self-hosted here means that it's hosted elsewhere. We have merchants hosting on Vercel, but also in AWS or other hosting providers right now. The point of self-hosted here is more on the path that we ship default Next.js commands, not our Native Hosting specific setup. self-hosted also opens up the door that we can support aws as an option and tweak what the command ships to be aligned with AWS.
I'm not married to the name, but we should probably avoid "framework" here. I think of "framework" as Next.js, Vue, or React, but not a "hosting framework". If we wanted to remove self-hosted we could say the flag follows this logic:
- Only provide
commerce(or whatever we want to name it) as the only option. - If
--hosting commerceis provided, ship with Native Hosting augments - If no flag is provided or option selected, ship with default Next.js
- If invalid flag name, error.
I really want Catalyst to lean into this "composability" aspect, and this flag is probably one of those design choices. I want developers to have the option of taking a base output and being able to change what they need to fit their needs. If they want to ship it to AWS, they can; Vercel, easy; etc....
b6fb183 to
2ec2b73
Compare
2ec2b73 to
f02c21e
Compare
f02c21e to
dd7aee1
Compare
dd7aee1 to
db3f606
Compare
db3f606 to
31cea39
Compare
31cea39 to
8dfb70c
Compare
8dfb70c to
f69ce47
Compare
|
I feel like we're mixing concerns here. I'm not sure that we should have this option on the We're adding a ton of logic to An example of where decoupling |
Jira: TRAC-137
What/Why?
Adds a
--hostingflag and prompt tocreate-catalystso merchants can scaffold a project pre-wired for Commerce Hosting in one step instead of runningcatalyst project create/linkthemselves.The hosting prompt is gated on
GET /v3/infrastructure/projects(200 → prompt, 403 → silent self-hosted default, other failures → warn and fall back). When Commerce Hosting is selected, the user can pick an existing Commerce Hosting project or create a new one; the resulting UUID is wired into the scaffold automatically. New-project names are checked against existing projects on the store (case-insensitive, matching API behavior) before submission so name collisions surface as a friendly validator error instead of a server roundtrip.--hostingaccepts:self-hosted— Next.js (default if omitted)commerce— Commerce Hosting (Native)--project-name <name>, when passed alongside--hosting commerce, skips the Commerce Hosting project selection prompts and auto-creates a project with that name. If a project with that name already exists on the store, the user is asked Yes/No whether to reuse it (in non-interactive environments / with--use-existing, the answer is automatic).--use-existing— only used with--hosting commerceand--project-name. When the named project already exists on the store, reuse it instead of prompting. Has no effect without--hosting commerce(a warning is logged if it's set in another mode).Native-mode post-clone mutations (
setupCommerceHosting):core/package.json:next build→catalyst build, adddeploy, dropstart, add@bigcommerce/catalyst@1.0.0-alpha.3+@opennextjs/cloudflare@1.17.3(per the Native Hosting docs)core/.bigcommerce/project.json: written withprojectUuid,framework, plusstoreHash/accessTokenwhen availablecore/.env.local: symlinked to../.env.local(warns and continues if symlinks aren't permitted; tagged withTODO(LTRAC-409): remove this symlink)core/proxy.ts→core/middleware.tswith the edge runtime injection (Next.js 16 migration note)Versions are pinned exactly — these need a deliberate bump alongside
@bigcommerce/catalystreleases.User-facing terminology
To keep the two "project" concepts distinct, the CLI distinguishes:
--project-name/--project-dir; the interactive prompt is"What is the name of your project directory?".Files and functions touching the user-facing flow were renamed to match:
setup-native-hosting.ts→setup-commerce-hosting.ts(setupNativeHosting→setupCommerceHosting)prompt-infrastructure-project.ts→prompt-commerce-hosting-project.ts(promptForInfrastructureProject→promptForCommerceHostingProject)listInfrastructureProjects,createInfrastructureProject,InfrastructureProjectValidationError) keep the "infrastructure" name since they map directly to/v3/infrastructure/projects.Error handling
API methods now wrap fetch / parse / non-OK-status failures in a single friendly Error (
Could not load Commerce Hosting projects: ...,Could not create Commerce Hosting project: ...) with the original error preserved ascause.InfrastructureProjectValidationErroris intentionally re-thrown unwrapped so consumerinstanceofchecks still work.Rollout/Rollback
Behind the existing Infrastructure Projects API feature flag — merchants without access keep the current self-hosted scaffold unchanged. Rollback is a code revert; no migrations or runtime changes.
Testing
71 unit tests across the API client, hosting-mode resolution, the prompt + retry / auto-create / collision flow, the
--use-existingflag (TTY and non-TTY paths), and the file mutations.Manual end-to-end:
Scaffolding works end-to-end against a store with infrastructure access.
pnpm build/pnpm deployon the resulting project are blocked on a separate downstream issue, out of scope for this PR.Proof of life
Screen.Recording.2026-04-29.at.4.55.12.PM.mov