[create-cloudflare] Add Node.js version check before loading CLI#13243
[create-cloudflare] Add Node.js version check before loading CLI#13243petebacondarwin wants to merge 2 commits intomainfrom
Conversation
Add a bin shim (bin/c3.js) that checks the Node.js version before requiring the bundled CLI. This gives users a clear error message when running on unsupported Node.js versions instead of a cryptic syntax error. Also updates the engines field to require Node.js >= 20.0.0. Co-Authored-By: pbacondarwin <pete@bacondarwin.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: eb534ac The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
✅ All changesets look good |
|
Now let me also verify how Let me also check whether the changeset should be Now let me check the second test — if Let me also check if there's a Now let me think about the actual issues:
Actually, wait — the second test catches the error but doesn't fail if Let me focus on the most actionable issue: the changeset version type. Actually, re-reading the changeset rules more carefully — the Let me reconsider if there are any actual bugs:
I think this PR is actually clean. Let me look one more time at whether there's anything actionable... One issue: the Actually, I realize this PR is well-done and doesn't have actionable issues. The approach is sound, mirrors wrangler's pattern, the test is reasonable, and the changeset is appropriate. LGTM |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
|
Codeowners approval required for this PR:
Show detailed file reviewers |
There was a problem hiding this comment.
Devin Review found 1 potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ C3 AGENTS.md not updated to reflect new bin shim architecture (packages/create-cloudflare/AGENTS.md:16-17)
The PR introduces a separate bin/c3.js shim and changes package.json's bin field from ./dist/cli.js to ./bin/c3.js, but packages/create-cloudflare/AGENTS.md:16-17 still states:
- "
package.jsonmain,exports["."], andbinall point atdist/cli.js" - "No separate bin shim — the built output IS the bin"
Both statements are now factually incorrect. AI agents relying on AGENTS.md for project context will receive wrong information about the package's entry point architecture, potentially making incorrect changes (e.g., removing the bin shim or re-pointing bin back to dist/cli.js).
View 3 additional findings in Devin Review.
packages/create-cloudflare/bin/c3.js
Outdated
| @@ -0,0 +1,51 @@ | |||
| #!/usr/bin/env node | |||
|
|
|||
| const MIN_NODE_VERSION = "20.0.0"; | |||
There was a problem hiding this comment.
Suggestion: Would it be better if this was imported from the package.json instead? That way there is a single source for the minimum Node.js version.
There was a problem hiding this comment.
Good call - let's try...
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
…e AGENTS.md - bin/c3.js now reads the minimum Node.js version from package.json engines.node instead of hardcoding it - Updated AGENTS.md to reflect the new bin shim architecture - Updated test to also read expected version from package.json Co-Authored-By: pbacondarwin <pete@bacondarwin.com>
Fixes #13237.
Adds a lightweight bin shim (
bin/c3.js) that checks the Node.js version before loading the bundled CLI. Previously, runningcreate-cloudflareon an older Node.js version (e.g. v18) would fail with a confusing syntax error. Now users get a clear message explaining the minimum version and suggesting version managers (Volta/nvm).This mirrors the existing pattern used by wrangler's
bin/wrangler.js.Changes:
bin/c3.js— plain CommonJS bin shim with embedded semiver for version comparison; reads the minimum version frompackage.jsonengines.nodeso there's a single source of truthpackage.json:binnow points to./bin/c3.jsinstead of./dist/cli.js;bindir added tofiles;engines.nodebumped from>=18.14.1to>=20.0.0AGENTS.mdto reflect the new bin shim architectureHuman review checklist
engines.nodeparsing (replace(">=", "")) assumes the format is always>=X.Y.Z— if the format ever changes (e.g.^20or>=20 <22), the bin shim would need updatingengines.nodebump from>=18.14.1→>=20.0.0codifies what was already true in practice (the bundled code doesn't run on Node 18), but is technically a breaking change for theenginesfieldrequire("../dist/cli.js")relies on the bundled output auto-executingmain(process.argv)at module load — programmatic consumers viamain/exports(still pointing atdist/cli.js) bypass the version check, which is intentionalLink to Devin session: https://app.devin.ai/sessions/fa8fa0b8995c42c1a0cb41d27f7de3d6
Requested by: @petebacondarwin