Port the `init` command from create-catalyst into the catalyst CLI so it
connects an existing Catalyst project to a BigCommerce store and channel.
It resolves credentials from flags/env, the persisted project config, or an
interactive device-code login (persisting the result), then fetches available
channels, prompts for one, fetches its channel init data, and writes
.env.local in the current working directory.
Reuses the existing channels, login, project-config, telemetry, and
env-config libraries rather than porting create-catalyst's bespoke
Https/CliApi/Config utilities.
Refs LTRAC-908
Co-Authored-By: Claude <noreply@anthropic.com>
Linear: LTRAC-908
Part of LTRAC-138 — consolidating
create-catalystinto thecatalystCLI.What/Why?
Ports the
initcommand from@bigcommerce/create-catalystinto thecatalystCLI so it can connect an existing Catalyst project to a BigCommerce store and channel — one of the remaining gaps in the CLI consolidation.Rather than porting create-catalyst's bespoke
Https/CliApi/Configutilities, it reuses the catalyst CLI's existing libraries:.bigcommerce/project.json(getProjectConfig) → interactive device-codelogin(). Credentials obtained via login are persisted so later commands (deploy,project, …) don't re-prompt.fetchAvailableChannels+getChannelInit(already inlib/channels.ts)..env.localto the current working directory —initis expected to run from insidecore/, the same placedev/build/deployrun (unlikecreate, which scaffolds a sibling repo and targets<projectDir>/core/.env.local).--env KEY=VALUEoverrides are parsed via the existingparseEnvAssignmenthelper and win over channel-provided values.Testing
pnpm test,pnpm typecheck, andpnpm lintall pass inpackages/catalyst. Newinit.spec.tscovers credential resolution (flags, persisted config, interactive login + persistence, abort, non-abort error) and the--envmerge/validation paths.Manual:
catalyst init --store-hash <h> --access-token <t>(and interactivecatalyst init) connects a channel and writes.env.local.Migration
None. Purely additive — registers a new
initsubcommand;create-catalyst initis unaffected (the shim removal is tracked separately in LTRAC-910).