Skip to content

feat(cli): add init command for Stripe Projects handoff#535

Closed
moranshe-max wants to merge 1 commit into
mainfrom
feature/init-stripe-projects-handoff
Closed

feat(cli): add init command for Stripe Projects handoff#535
moranshe-max wants to merge 1 commit into
mainfrom
feature/init-stripe-projects-handoff

Conversation

@moranshe-max

@moranshe-max moranshe-max commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

What & why

Adds base44 init — scaffolds a local project for an already-existing Base44 app (e.g. one provisioned by the Stripe Projects CLI), using the app id and access token supplied via the environment, without creating a new app or requiring an interactive login. This is the local-dev handoff after stripe projects add base44_projects.

Changes

  • init command (cli/commands/project/init.ts, registered in program.ts): resolves the app id from --app-id or BASE44_APP_ID, scaffolds the template against the existing id (no createProject() call), defaults path to the current dir.
  • Env-token auth (core/auth/config.ts, core/clients/base44-client.ts): BASE44_ACCESS_TOKEN is used verbatim as the bearer token, taking precedence over ~/.base44/auth.json and bypassing OAuth refresh (provider-issued tokens can't refresh via /oauth/token). isLoggedIn() honors it so requireAuth commands run without login.
  • .env auto-load + normalization (core/utils/env.ts + cli/bootstrap-env.ts as the first import): loads .env/.env.local before the HTTP clients capture the API URL, and normalizes the Stripe CLI's resource-prefixed vars (e.g. BASE44_PROJECTS_BASE44_APP_ID) to the bare BASE44_* names (prefix-agnostic; ambiguous matches left unset).
  • Non-destructive scaffolding (core/project/template.ts): renderTemplate gains a skipExisting mode so init never clobbers existing files (e.g. a Stripe-managed .gitignore).
  • Shared internals (cli/commands/project/scaffold-shared.ts): create's post-scaffold logic (push/deploy/skills/output + getTemplateById) is extracted and reused by both create and init (create.ts shrank ~138 lines).

Verification

  • typecheck ✓, lint ✓, 520 tests ✓ (new specs: init, env-token-auth, core env; adds a givenEnv testkit helper).
  • Real Stripe e2e against a live provisioned app: stripe projects env --pullbase44 init (scaffolded the real appId via prefix-normalization) → entities pushdeploy --yes, all authenticated by the Stripe env token; test artifacts cleaned up afterward. (This e2e is what surfaced the prefix-normalization requirement.)

⚠️ Known limitation / follow-up

entities push (and deploy) is a full reconcile — the remote is made to match base44/entities/ exactly, so entities present remotely but absent locally are deleted. init currently scaffolds a fresh template and does not pull the existing app's resources, so running push/deploy after init against an app that already has data models can delete them (including the default User entity). There is also no entities pull command today.

Recommended follow-up before this is used for non-empty apps: have init mirror the existing app's resources (pull entities — GET /entity-schemas already exists — plus functions/agents/connectors) so the first push is non-destructive. Tracking this separately.

🤖 Generated with Claude Code

Adds `base44 init` to scaffold a local project for an already-existing
Base44 app (e.g. one provisioned by the Stripe Projects CLI), using the
app id and access token supplied via the environment — without creating
a new app or requiring an interactive login.

- `init` resolves the app id from `--app-id` or `BASE44_APP_ID` and
  scaffolds the template against the existing id (no `createProject()`
  API call). Defaults the path to the current directory.
- `base44Client` uses `BASE44_ACCESS_TOKEN` from the environment verbatim,
  taking precedence over `~/.base44/auth.json` and bypassing the OAuth
  refresh (these are provider-issued tokens). `isLoggedIn()` honors it so
  `requireAuth` commands run without an interactive login.
- Load `.env`/`.env.local` at startup (via `cli/bootstrap-env.ts`, first
  import) and normalize the Stripe Projects CLI's resource-prefixed vars
  (e.g. `BASE44_PROJECTS_BASE44_APP_ID`) to the bare `BASE44_*` names.
- `renderTemplate` gains a non-destructive `skipExisting` mode so `init`
  never clobbers existing files (e.g. a Stripe-managed `.gitignore`).
- Extract `create`'s post-scaffold logic into `scaffold-shared.ts`, reused
  by both `create` and `init`.

Tests: `init`, env-token auth, and `.env` normalization specs; adds a
`givenEnv` testkit helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/[email protected]

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/[email protected]"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/[email protected]"
  }
}

Preview published to npm registry — try new features instantly!

@moranshe-max

Copy link
Copy Markdown
Collaborator Author

Superseded by a 3-PR stack: #536 (scaffold-shared) → #537 (env-token auth) → init (3/3). Same final diff, split for review.

@moranshe-max moranshe-max deleted the feature/init-stripe-projects-handoff branch June 9, 2026 11:09
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