Skip to content

Create cli#10

Merged
cavewebs merged 2 commits intomainfrom
create-cli
Apr 20, 2026
Merged

Create cli#10
cavewebs merged 2 commits intomainfrom
create-cli

Conversation

@cavewebs
Copy link
Copy Markdown
Contributor

No description provided.

Template needs to stay multi-tenant — you can't commit D1/KV ids into a starter that other people also deploy. Instead: each deployer sets their binding ids as environment variables on their Worker project, and a small build-time script injects them into the adapter-generated dist/server/wrangler.json before wrangler deploy reads it.

- scripts/patch-wrangler-config.mjs reads CF_D1_DATABASE_ID, CF_KV_SESSION_ID, CF_R2_BUCKET, CF_R2_PUBLIC_URL from env and writes them into d1_databases[].database_id / kv_namespaces[].id / r2_buckets[].bucket_name in dist/server/wrangler.json. Runs chained into build:cf so the output artifact is always deploy-ready.
- build:cf now: 'DEPLOY_TARGET=cloudflare astro build && node scripts/patch-wrangler-config.mjs'
- README Cloudflare section rewritten: explicit env var table + deploy-command guidance for the CF dashboard.

Verified locally: CF_D1_DATABASE_ID=test-uuid CF_KV_SESSION_ID=test-kv bun run build:cf emits dist/server/wrangler.json with those ids patched in. Empty env vars → patch script warns + leaves placeholders in, so the failure mode is loud.
Three strict-null errors the monorepo root's tsconfig catches on CI but my local build didn't because the create package was still typecheck-clean against the older strict settings:

- parseArgs: argv[i] is string | undefined under noUncheckedIndexedAccess. Added an early 'if (a === undefined) continue;' guard so the subsequent .startsWith() and equality checks see a narrowed string.
- main: TEMPLATES[templateKey] is TemplateDef | undefined. Added an explicit error-out if the registry lookup misses (shouldn't happen in practice since --template is validated upstream and the prompts menu only offers registered keys, but closes the type hole and gives a clearer message than 'cannot read properties of undefined').

Verified: 'bun run --filter *' typecheck' clean across all three packages.
@cavewebs cavewebs merged commit d193955 into main Apr 20, 2026
1 check passed
@cavewebs cavewebs deleted the create-cli branch April 22, 2026 06:59
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