Skip to content

feat(cli): scaffold migrated sites fast-deploy-ready - #550

Open
JonasJesus42 wants to merge 1 commit into
mainfrom
feat/scaffold-fast-deploy
Open

JonasJesus42 wants to merge 1 commit into
mainfrom
feat/scaffold-fast-deploy

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Problema

Um site migrado não conseguia usar fast-deploy sem edição manual:

  • generateWranglerConfig emitia um wrangler.jsonc sem vars, sem observabilidade, e com um único binding KV: SITES_KV com o id literal "dev-sites-kv" — que não resolve em ambiente nenhum.
  • O setup.ts scaffoldado nunca chamava setupTanstackFastDeploy(), então mesmo com o wrangler corrigido na mão o write-through do publish do Studio no-opava em silêncio (o blocks-admin não pode importar o @decocms/tanstack — direção errada no grafo de pacotes — então quem entrega o resolver de KV é o site).

Mudanças

  • wrangler.jsonc declara DECO_KV e DECO_FAST_DEPLOY: "1" juntos, mais version_metadata e tail_consumers: deco-otel-tail. O tail consumer não é enfeite: a Cloudflare mata o isolate acima do teto de 128 MB antes de qualquer código in-worker conseguir reportar, então sem ele um exceededMemory é invisível (docs/runbooks/tail-exception-spike.md). Emitido como JSONC de verdade em vez de JSON.stringify, pra os porquês ficarem ao lado dos campos.
  • Ids de namespace ficam vazios de propósito. O control-plane provisiona os namespaces próprios do site (ensureSiteKvNamespace) e o builder re-força os ids a cada build via CF_KV_NAMESPACE_ID, então id errado no repo nunca chega em produção — e um id falso com cara de real é pior que um branco.
  • setup.ts chama setupTanstackFastDeploy(), espelhando examples/tanstack-smoke.
  • Check novo no phase-verify, severidade error, exigindo os três juntos. Dois de três é o pior estado possível: parece configurado, o publish reporta sucesso, e nada chega no KV.

Testes

fast-deploy-scaffold.test.ts — 8 casos. O wrangler gerado é parseado, não grepado (um vírgula solta desliga fast-deploy em todo lugar de uma vez: builder, control-plane e o próprio check lêem esse arquivo por um parser JSONC). O check de verify é exercitado nos quatro estados parciais.

Parte da pilha: #548 → #549 → este.

🤖 Generated with Claude Code


Summary by cubic

Makes migrated sites fast-deploy-ready without hand edits. Previously the scaffolded wrangler.jsonc carried no vars, no observability, and a SITES_KV binding with a dummy id, and the scaffolded setup.ts never called setupTanstackFastDeploy(), so Studio publishes would silently no-op.

  • The generated wrangler.jsonc now declares DECO_KV and DECO_FAST_DEPLOY: "1" together, plus version_metadata and a deco-otel-tail tail consumer; it's emitted as JSONC so the comments explaining each field survive.
  • Namespace ids stay empty on purpose: the control-plane provisions the site's own namespaces and re-forces the ids on every build, so a wrong id in the repo can never reach production.
  • setup.ts now calls setupTanstackFastDeploy(), handing the KV resolver to @decocms/blocks-admin, which can't import @decocms/tanstack itself.
  • A new phase-verify check (severity error) requires all three pieces together, since two of three looks configured but writes nothing to KV.
  • The scaffold tests parse the generated JSONC rather than grep it, covering the partial-config failure states.

Written for commit edbb911. Summary will update on new commits.

Review in cubic

A migrated site could not fast-deploy without hand edits. The scaffold
emitted a wrangler.jsonc with no `vars`, no observability, and a single KV
binding — `SITES_KV` with the literal id "dev-sites-kv", which resolves to
nothing anywhere — and a setup.ts that never called
`setupTanstackFastDeploy()`, so even a hand-fixed wrangler would leave the
Studio publish write-through silently no-opping.

Now:

- wrangler.jsonc declares the `DECO_KV` binding and `DECO_FAST_DEPLOY: "1"`
  together, plus `version_metadata` and a `deco-otel-tail` consumer. The
  tail consumer is not decoration: Cloudflare kills an isolate over the
  128MB cap before any in-worker code can report it, so without it an
  exceededMemory incident is invisible. Emitted as real JSONC rather than
  JSON.stringify so the reasons survive next to the fields.
- Namespace ids are left empty on purpose. The control-plane provisions
  the site's OWN namespaces and re-forces the ids at build time, so a
  wrong id in the repo can never reach production — and a plausible-looking
  fake id is worse than a blank.
- setup.ts calls `setupTanstackFastDeploy()`, mirroring the smoke example.
- A verify check asserts all three together. Two of three is the worst
  state: it looks configured, the publish reports success, and nothing
  reaches KV.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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