feat(build): add base44 build — site buildCommand with the app id injected - #586
Conversation
…p id injected Deployed bundles built with a bare `npm run build` carry no app id (the template no longer bakes it into source), so their API calls fail once deployed. `base44 build` runs the configured site.buildCommand from the project root with VITE_BASE44_APP_ID set to the linked app's id. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.7-pr.586.967fb6fPrefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.7-pr.586.967fb6f"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.7-pr.586.967fb6f"
}
}
Preview published to npm registry — try new features instantly! |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
runSiteBuild is about to gain a second consumer (the deploy build step); giving it its own module now keeps that PR from touching this command. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
|
||
| export async function runSiteBuild( | ||
| { runTask }: Pick<CLIContext, "runTask">, | ||
| { root, buildCommand, appId }: SiteBuildTarget, |
There was a problem hiding this comment.
in case of editor app => github clone => base44 build, what is the source of the app id? the user should use the --app-id flag?
There was a problem hiding this comment.
The id comes from base44 link, not a flag. An editor-app clone ships base44/config.jsonc but deliberately no .app.jsonc (the platform git-ignores it), so the first base44 build fails pointing at base44 link; link lists editor-created apps since #577 and writes .app.jsonc, and build resolves the id from there like every project command. --app-id/BASE44_APP_ID intentionally don't work here: they carry an id without a project root, and build requires a linked project — injecting app X's id into app Y's checkout is exactly the mistake that guard blocks. If we ever want --app-id to override in unlinked checkouts, that's a product decision to take deliberately, not a gap.
Note
Description
Adds a new
base44 buildcommand that runs the site's configuredbuildCommandwith the linked app's id injected asVITE_BASE44_APP_ID. This makes it possible to produce a production bundle that always carries the correct app id, without developers having to remember to export the env var themselves. The build runner lives in its own module (site-build.ts) so it can be reused by other commands later.Related Issue
None
Type of Change
Changes Made
base44 buildcommand (packages/cli/src/cli/commands/project/build.ts): requires a linked local project, reads the project config, runs the site build, and reports the injected app id in its outro message.runSiteBuild()helper (packages/cli/src/cli/commands/project/site-build.ts): executes thebuildCommandviaexeca(shell, project root as cwd) insiderunTask, withVITE_BASE44_APP_IDset to the app id.ConfigNotFoundErrorwith a hint to addsite.buildCommandwhen no build command is configured, andConfigInvalidErrorwhen run outside a linked project.packages/cli/src/cli/program.ts(beforedeploy).packages/cli/tests/cli/build.spec.tscovering: successful build with the app id injected, missingsite.buildCommand, a failing build command, and running outside a project.with-buildable-siteandwith-failing-build.### Added.Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
Base44Command+getXCommand()), usesrunTaskfor progress/error reporting, and throws typed core errors rather than callingprocess.exit— consistent withdocs/commands.mdanddocs/error-handling.md.runSiteBuild()takes onlyPick<CLIContext, "runTask">, so it is straightforward to call fromdeployif the site build should become part of the deploy flow.VITE_BASE44_APP_IDname matches what the scaffolded templates andbase44 dev/ejectalready use.🤖 Generated by Claude | 2026-08-03 07:42 UTC | 967fb6f