Repository navigation
feat(cloudflare): migrate deployments to Alchemy v2 - #1144
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (5)
packages/template-generator/src/processors/alchemy-plugins.ts (1)
84-95: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueBoth package.json edits bypass the
VirtualFileSystemJSON helpers. Each site callsreadFileandJSON.parsedirectly, which throws on malformed JSON.vfs.readJsonandvfs.writeJsonalready handle a missing file and a parse failure.
packages/template-generator/src/processors/alchemy-plugins.ts#L84-L95: replacereadFileplusJSON.parsewithvfs.readJson, and replace the manual stringify withvfs.writeJson.packages/template-generator/src/processors/alchemy-plugins.ts#L224-L233: apply the same replacement for thebuild:cloudflarescript write.packages/template-generator/templates/packages/infra/alchemy.run.ts.hbs (1)
79-133: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffConsider extracting the repeated
envbinding block into a partial.The
envmaps fornext,nuxt,svelte, andastrorepeat the same database, auth, AI, payments, and MySQL entries, and the same blocks repeat again in the non-self branches at Lines 333-530. A shared Handlebars partial would remove the duplication and keep the branches in sync when a binding is added.Also applies to: 134-179, 180-225, 226-271
packages/template-generator/src/post-process/package-configs.ts (1)
199-208: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winOne "local D1 fullstack" predicate is duplicated across three processors. Each site re-derives the same condition from
webDeploy,backend,dbSetup, and a hard-coded frontend list. The copies must stay in sync, otherwise the root script, the README step, and thewranglerdependency disagree for the same configuration.
packages/template-generator/src/post-process/package-configs.ts#L199-L208: replace the inlinehasLocalD1computation with a call to a shared helper.packages/template-generator/src/processors/readme-generator.ts#L607-L610: replace the inlineisFullstackStaticSitecomputation with the same shared helper.packages/template-generator/src/processors/deploy-deps.ts#L117-L120: deriveneedsLocalD1from the shared helper, and document whynextis excluded from the frontend list here.packages/template-generator/src/processors/deploy-deps.ts (1)
129-135: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSkip the dependency write when the list is empty.
When
isBackendSelfis false,addPackageDependencyreceives empty lists and rewritesapps/web/package.jsonwith no change. Guard the call instead.♻️ Proposed refactor
- } else if (frontend.includes("nuxt")) { + } else if (frontend.includes("nuxt") && isBackendSelf) { // wrangler powers the dev-time cloudflare:workers shim (getPlatformProxy) addPackageDependency({ vfs, packagePath: webPkgPath, - devDependencies: isBackendSelf ? ["nitro-cloudflare-dev", "wrangler"] : [], + devDependencies: ["nitro-cloudflare-dev", "wrangler"], }); } else if (frontend.includes("svelte")) {packages/template-generator/src/utils/add-deps.ts (1)
162-166: 🩺 Stability & Availability | 🔵 TrivialSchedule stable release pinning for the prerelease deps.
The pinned packages are published,
alchemy@2.0.0-beta.67acceptseffect@4.0.0-beta.101and the platform packages, andeffect@4.0.0-beta.101exposes theeffect/Configandeffect/Effectsubpaths consumed byalchemy.run.ts.hbs. The remaining concern is that these generated Cloudflare projects depend on beta tags; plan a follow-up to move to stable releases before betas disappear.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 55f2fa64-2533-4d38-8726-f42951039926
⛔ Files ignored due to path filters (1)
packages/template-generator/src/templates.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (44)
.codex/skills/openspec-apply-change/SKILL.md.codex/skills/openspec-archive-change/SKILL.md.codex/skills/openspec-explore/SKILL.md.codex/skills/openspec-propose/SKILL.md.codex/skills/openspec-sync-specs/SKILL.md.codex/skills/openspec-update-change/SKILL.mdapps/cli/src/helpers/core/post-installation.tsapps/cli/src/helpers/database-providers/d1-setup.tsapps/cli/src/utils/compatibility-rules.tsapps/cli/test/addons.test.tsapps/cli/test/cloudflare-db-clients.test.tsapps/cli/test/database-setup.test.tsapps/cli/test/deployment.test.tsapps/cli/test/post-installation.test.tsapps/cli/test/vite-plus-generator.test.tsdocs/alchemy-v2-beta-findings.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/.openspec.yamlopenspec/changes/formalize-alchemy-cloudflare-deployment/README.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/design.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/proposal.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/specs/alchemy-cloudflare-deployment/spec.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/tasks.mdopenspec/config.yamlpackages/template-generator/src/post-process/package-configs.tspackages/template-generator/src/processors/alchemy-plugins.tspackages/template-generator/src/processors/deploy-deps.tspackages/template-generator/src/processors/env-vars.tspackages/template-generator/src/processors/infra-deps.tspackages/template-generator/src/processors/readme-generator.tspackages/template-generator/src/processors/workspace-deps.tspackages/template-generator/src/template-handlers/packages.tspackages/template-generator/src/utils/add-deps.tspackages/template-generator/src/utils/generated-ignore-patterns.tspackages/template-generator/templates/api/orpc/server/src/context.ts.hbspackages/template-generator/templates/backend/server/base/tsdown.config.ts.hbspackages/template-generator/templates/extras/env.d.ts.hbspackages/template-generator/templates/frontend/astro/astro.config.mjs.hbspackages/template-generator/templates/frontend/nuxt/nuxt.config.ts.hbspackages/template-generator/templates/frontend/react/react-router/vite.config.ts.hbspackages/template-generator/templates/frontend/react/tanstack-start/vite.config.ts.hbspackages/template-generator/templates/frontend/svelte/svelte.config.js.hbspackages/template-generator/templates/packages/env/src/cloudflare-local.ts.hbspackages/template-generator/templates/packages/env/src/server.ts.hbspackages/template-generator/templates/packages/infra/alchemy.run.ts.hbs
💤 Files with no reviewable changes (3)
- packages/template-generator/templates/packages/env/src/cloudflare-local.ts.hbs
- packages/template-generator/src/template-handlers/packages.ts
- packages/template-generator/src/processors/env-vars.ts
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR adds six OpenSpec workflow skills and formalizes Alchemy v2 Cloudflare deployment generation. It updates infrastructure resources, framework templates, D1 setup, dependency pins, post-install instructions, documentation, and CLI verification tests. ChangesAlchemy Cloudflare deployment formalization
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
packages/template-generator/src/processors/alchemy-plugins.ts (1)
84-95: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse the virtual filesystem JSON helpers.
Both blocks call
JSON.parsedirectly onapps/web/package.json.VirtualFileSystemprovidesreadJsonandwriteJson, which returnundefinedon invalid JSON instead of throwing. Using them removes the duplicated read/parse/serialize code and removes the unguarded parse.Also applies to: 224-234
packages/template-generator/templates/packages/infra/alchemy.run.ts.hbs (1)
79-318: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffConsider extracting the repeated framework resource definitions.
Each framework resource is written twice: once at the top level for the
backend=selfpath (Lines 79-318) and once insideEffect.genfor the web-only path (Lines 330-531). Thecwd,command,memo,outdir,main,bundle,compatibility, anddevvalues are identical in both copies. A Handlebars partial per framework would keep the two paths in sync when a build path or compatibility flag changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 10166396-b084-4e10-8c26-a9c06963e8ae
⛔ Files ignored due to path filters (1)
packages/template-generator/src/templates.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (44)
.codex/skills/openspec-apply-change/SKILL.md.codex/skills/openspec-archive-change/SKILL.md.codex/skills/openspec-explore/SKILL.md.codex/skills/openspec-propose/SKILL.md.codex/skills/openspec-sync-specs/SKILL.md.codex/skills/openspec-update-change/SKILL.mdapps/cli/src/helpers/core/post-installation.tsapps/cli/src/helpers/database-providers/d1-setup.tsapps/cli/src/utils/compatibility-rules.tsapps/cli/test/addons.test.tsapps/cli/test/cloudflare-db-clients.test.tsapps/cli/test/database-setup.test.tsapps/cli/test/deployment.test.tsapps/cli/test/post-installation.test.tsapps/cli/test/vite-plus-generator.test.tsdocs/alchemy-v2-beta-findings.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/.openspec.yamlopenspec/changes/formalize-alchemy-cloudflare-deployment/README.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/design.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/proposal.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/specs/alchemy-cloudflare-deployment/spec.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/tasks.mdopenspec/config.yamlpackages/template-generator/src/post-process/package-configs.tspackages/template-generator/src/processors/alchemy-plugins.tspackages/template-generator/src/processors/deploy-deps.tspackages/template-generator/src/processors/env-vars.tspackages/template-generator/src/processors/infra-deps.tspackages/template-generator/src/processors/readme-generator.tspackages/template-generator/src/processors/workspace-deps.tspackages/template-generator/src/template-handlers/packages.tspackages/template-generator/src/utils/add-deps.tspackages/template-generator/src/utils/generated-ignore-patterns.tspackages/template-generator/templates/api/orpc/server/src/context.ts.hbspackages/template-generator/templates/backend/server/base/tsdown.config.ts.hbspackages/template-generator/templates/extras/env.d.ts.hbspackages/template-generator/templates/frontend/astro/astro.config.mjs.hbspackages/template-generator/templates/frontend/nuxt/nuxt.config.ts.hbspackages/template-generator/templates/frontend/react/react-router/vite.config.ts.hbspackages/template-generator/templates/frontend/react/tanstack-start/vite.config.ts.hbspackages/template-generator/templates/frontend/svelte/svelte.config.js.hbspackages/template-generator/templates/packages/env/src/cloudflare-local.ts.hbspackages/template-generator/templates/packages/env/src/server.ts.hbspackages/template-generator/templates/packages/infra/alchemy.run.ts.hbs
💤 Files with no reviewable changes (3)
- packages/template-generator/src/template-handlers/packages.ts
- packages/template-generator/templates/packages/env/src/cloudflare-local.ts.hbs
- packages/template-generator/src/processors/env-vars.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.codex/skills/openspec-propose/SKILL.md (2)
4-4: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winReplace unsupported tool calls in the Codex skill.
AskUserQuestionandTodoWriteare not Codex tools, andallowed-toolscannot authorize them. Replace these calls at lines 33-34, 60-63, and 89-91 with Codex-supported operations or runtime-neutral instructions.
25-25: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPass
--storeonly when a store is selected.When no store is selected, omit
--storefrom every affected command. Otherwise, the empty or undefined store ID overrides local root resolution and breaks the documented nearest-local-openspec/behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0640ce3f-4b3b-441b-8163-e20e9e680b5f
📒 Files selected for processing (7)
.codex/skills/openspec-apply-change/SKILL.md.codex/skills/openspec-archive-change/SKILL.md.codex/skills/openspec-explore/SKILL.md.codex/skills/openspec-propose/SKILL.md.codex/skills/openspec-sync-specs/SKILL.md.codex/skills/openspec-update-change/SKILL.mdopenspec/config.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
- .codex/skills/openspec-sync-specs/SKILL.md
- .codex/skills/openspec-apply-change/SKILL.md
- .codex/skills/openspec-explore/SKILL.md
- .codex/skills/openspec-update-change/SKILL.md
- .codex/skills/openspec-archive-change/SKILL.md
55bcc11 to
7223bc5
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
.codex/skills/openspec-propose/SKILL.md (3)
85-88: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAlign completion detection with the final status.
The loop stops when every artifact in
applyRequiresis done, but the output claimsAll artifacts created!. If other artifacts are not required byapplyRequires, the skill can report an incomplete proposal as complete. Continue until every artifact is done, or report the remaining artifacts and state only that the change is apply-ready.Also applies to: 101-106
44-45: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winMake
--storeconditional.If no store is selected, omit
--store "<store-id>"from the commands in Steps 2–5. An explicit--storeoverrides nearest-root discovery and can prevent use of the localopenspec/root. Add the flag only after selecting a store withopenspec store list --json.
41-48: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCheck for an existing change before creating it.
Before
openspec new change, runopenspec list --json, adding--store "<store-id>"for store-scoped work. If the name exists, ask whether to continue it or choose a new name because duplicate names are rejected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8938e6c8-6ba7-4afa-931f-fa1b278f8b58
📒 Files selected for processing (3)
.codex/skills/openspec-propose/SKILL.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/design.mdopenspec/changes/formalize-alchemy-cloudflare-deployment/tasks.md
🚧 Files skipped from review as they are similar to previous changes (2)
- openspec/changes/formalize-alchemy-cloudflare-deployment/tasks.md
- openspec/changes/formalize-alchemy-cloudflare-deployment/design.md
…Effects) - rewrite packages/infra/alchemy.run.ts to the v2 Alchemy.Stack pattern: Website.Vite for SSR vite frameworks, StaticSite for nuxt/svelte/astro/ next (OpenNext) and SPAs, Cloudflare.Worker for hono/elysia servers, Config.string/redacted for env, InferEnv-based typing via ServerEnv/WebEnv - pin alchemy 2.0.0-beta.61 + effect 4.0.0-beta.94 exactly (caret ranges resolve to a broken npm prerelease tag under bun) - drop the v1 alchemy/cloudflare/* plugin injection machinery and the cloudflare-local.ts shim; set framework adapters statically instead - react-router: generate workers/app.ts, edge entry.server.tsx, and the ssr rollup input wiring (RR8 server-build has no default export) - next: generate wrangler.jsonc + build:cloudflare script for OpenNext - astro: dist/server entry + dist/client assets + SESSION KV binding - svelte: bundle the adapter _worker.js shim; workerd-safe env layer - workarounds for upstream beta.61 bugs, documented with repros in https://github.com/AmanVarshney01/alchemy-v2-beta-repros Verified: 20,736-combo matrix sweep (8,436 valid, 892 unique infra renderings, all typecheck clean against the published beta), live smoke deploys of all 8 framework paths on Cloudflare (7/8 served 200; next build verified, upload needs paid plan for >3MiB workers), and alchemy dev for both the StaticSite and Website.Vite loops.
…PUBLISHABLE_KEY for self tanstack-start
…local D1 dev, svelte asset hygiene - nuxt/tanstack-start + self: externalize cloudflare:workers in node builds (nitro prerender dropped for self — it executes worker-only code in node) - local D1 for fullstack StaticSite frameworks: apps/web/wrangler.jsonc with a d1_databases binding + db:migrate:local scripts; next uses the existing initOpenNextCloudflareForDev, nuxt gains nitro-cloudflare-dev, svelte/astro adapters read the config natively (all four verified with live sign-up writes through framework dev servers) - svelte: ship static/.assetsignore so _worker.js/_routes.json stay out of the public asset upload - react-router: clerk worker credentials (CLERK_SECRET_KEY + VITE_CLERK_PUBLISHABLE_KEY) and isbot-aware entry.server - opennext wrangler config: compatibility_date 2025-05-05 + global_fetch_strictly_public - README: correct staged-deploy default (dev_$USER) with explicit production command; drop stale v1 guide link; local D1 migration note
… astro images - fix TS2345 in the three new frontend-array checks (as const); template generator typecheck is clean again - root db:migrate:local now filters the actual workspace name (web) - nuxt + self dev: page SSR runs under vite-node, which cannot resolve cloudflare:workers — alias it in $development to a getPlatformProxy shim (same miniflare state as nitro-cloudflare-dev); verified / and a sign-up write both 200 in dev - prisma + d1: local wrangler config gains migrations_pattern for prisma's nested <timestamp>_<name>/migration.sql layout - astro: bind IMAGES (adapter v14 defaults to the cloudflare-binding image service) alongside SESSION - opennext: global_fetch_strictly_public now set on the deployed worker (infra compatibility flags), not just the build-time wrangler config - orpc context: fix pre-existing ReferenceError for auth=none + cloudflare (destructured _env, returned env) - README/post-install: local D1 migration step ordered after generate
34bdff9 to
625cf67
Compare
Summary
Stack
Layer 1 of 8. Next: #1145.
The complete stack is verified at #1110.
Stack created with GitHub Stacks CLI • Give Feedback 💬
Summary by CodeRabbit
New Features
Bug Fixes
Documentation