feat(cli): add init command for Stripe Projects handoff#535
Closed
moranshe-max wants to merge 1 commit into
Closed
feat(cli): add init command for Stripe Projects handoff#535moranshe-max wants to merge 1 commit into
init command for Stripe Projects handoff#535moranshe-max wants to merge 1 commit into
Conversation
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) <noreply@anthropic.com>
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.0.54-pr.535.dfef860Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.0.54-pr.535.dfef860"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.0.54-pr.535.dfef860"
}
}
Preview published to npm registry — try new features instantly! |
Collaborator
Author
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.
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 afterstripe projects add base44_projects.Changes
initcommand (cli/commands/project/init.ts, registered inprogram.ts): resolves the app id from--app-idorBASE44_APP_ID, scaffolds the template against the existing id (nocreateProject()call), defaults path to the current dir.core/auth/config.ts,core/clients/base44-client.ts):BASE44_ACCESS_TOKENis used verbatim as the bearer token, taking precedence over~/.base44/auth.jsonand bypassing OAuth refresh (provider-issued tokens can't refresh via/oauth/token).isLoggedIn()honors it sorequireAuthcommands run without login..envauto-load + normalization (core/utils/env.ts+cli/bootstrap-env.tsas the first import): loads.env/.env.localbefore 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 bareBASE44_*names (prefix-agnostic; ambiguous matches left unset).core/project/template.ts):renderTemplategains askipExistingmode soinitnever clobbers existing files (e.g. a Stripe-managed.gitignore).cli/commands/project/scaffold-shared.ts):create's post-scaffold logic (push/deploy/skills/output +getTemplateById) is extracted and reused by bothcreateandinit(create.tsshrank ~138 lines).Verification
typecheck✓,lint✓, 520 tests ✓ (new specs:init,env-token-auth, coreenv; adds agivenEnvtestkit helper).stripe projects env --pull→base44 init(scaffolded the real appId via prefix-normalization) →entities push→deploy --yes, all authenticated by the Stripe env token; test artifacts cleaned up afterward. (This e2e is what surfaced the prefix-normalization requirement.)entities push(anddeploy) is a full reconcile — the remote is made to matchbase44/entities/exactly, so entities present remotely but absent locally are deleted.initcurrently scaffolds a fresh template and does not pull the existing app's resources, so runningpush/deployafterinitagainst an app that already has data models can delete them (including the defaultUserentity). There is also noentities pullcommand today.Recommended follow-up before this is used for non-empty apps: have
initmirror the existing app's resources (pull entities —GET /entity-schemasalready exists — plus functions/agents/connectors) so the first push is non-destructive. Tracking this separately.🤖 Generated with Claude Code