Skip to content

Verify runtime version in fedify init - #981

Merged
2chanhaeng merged 13 commits into
fedify-dev:mainfrom
userjmmm:issue-964-verify-runtime-version
Aug 14, 2026
Merged

Verify runtime version in fedify init#981
2chanhaeng merged 13 commits into
fedify-dev:mainfrom
userjmmm:issue-964-verify-runtime-version

Conversation

@userjmmm

@userjmmm userjmmm commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Added runtime version verification to fedify init to enhance runtime safety by pre-checking minimum requirements.

Related issue

Changes

  • Added runtime minimum versions (minVersion) to json/rt.json, derived a RUNTIME list in const.ts, and added Runtime/Runtimes/RuntimeCheck types.
  • Added verifyRuntimeVersion, checkRuntimeVersion, resolveRequiredVersion, checkRuntimeRequirement, and checkAllRuntimes to lib.ts.
  • Added a minRuntimeVersions field to WebFrameworkDescription and set Astro's Node.js 22.12 requirement.
  • Updated ask/pm.ts to exit with an actionable error for an unsupported runtime in non-interactive mode, and to disable the affected package managers in the interactive menu.
  • Added tests for verifyRuntimeVersion and resolveRequiredVersion.

AI disclosure

Claude Code (claude-opus-4-8) assisted with this change: it proposed the design and drafted much of the implementation, tests, and this description. I reviewed and edited the work, made the design decisions, and verified the behaviour myself by running fedify init and the test suite.

@netlify

netlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

Name Link
🔨 Latest commit 766524b
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6a7e5bd827b60f0008b56f56

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c500b443-988b-4052-9016-a89e85b50877

📥 Commits

Reviewing files that changed from the base of the PR and between b3c248c and 766524b.

📒 Files selected for processing (1)
  • packages/init/src/types.ts

📝 Walkthrough

Walkthrough

fedify init now validates Deno, Bun, and Node.js versions before project generation. It applies framework-specific minimums, classifies runtime failures, and updates explicit and interactive package-manager selection.

Changes

Runtime verification

Layer / File(s) Summary
Runtime contracts and requirements
packages/init/src/const.ts, packages/init/src/types.ts, packages/init/src/json/rt.json, packages/init/src/webframeworks/astro.ts
Defines runtime identifiers, minimum versions, validation result types, and Astro’s stricter Node.js requirement.
Runtime validation engine
packages/init/src/lib.ts, packages/init/src/lib.test.ts, packages/init/src/utils.ts
Parses runtime command output, compares versions, resolves framework requirements, classifies failures, checks runtimes concurrently, and recognizes missing commands.
Initializer package-manager flow
packages/init/src/ask/pm.ts, CHANGES.md, changes.d/init/verify-runtime-version.md
Validates explicit and interactive package-manager choices and documents runtime verification behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to 76652

The runtime verification change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Possibly related PRs

Suggested labels: component/cli, runtime/node, runtime/bun

Suggested reviewers: dahlia, 2chanhaeng

Sequence Diagram(s)

sequenceDiagram
  participant FedifyInit
  participant fillPackageManager
  participant checkAllRuntimes
  participant RuntimeCommands
  FedifyInit->>fillPackageManager: resolve package manager
  fillPackageManager->>checkAllRuntimes: validate runtime requirements
  checkAllRuntimes->>RuntimeCommands: execute version commands
  RuntimeCommands-->>checkAllRuntimes: return runtime statuses
  checkAllRuntimes-->>fillPackageManager: return compatible options
  fillPackageManager-->>FedifyInit: continue or exit
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The changes address the main issue requirements, but the provided summaries do not confirm continued support for Deno Temporal before version 2.7. Provide evidence or tests confirming that existing Deno Temporal configuration remains supported on versions earlier than 2.7.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: runtime version verification in fedify init.
Description check ✅ Passed The description directly explains the runtime verification changes, framework requirements, package-manager behavior, tests, and linked issue.
Out of Scope Changes check ✅ Passed The runtime metadata, validation utilities, package-manager behavior, tests, error handling, and changelog entries are related to the linked issue.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/init/src/ask/pm.ts`:
- Around line 40-64: Update the explicit package-manager branch before its
availability/runtime checks to validate isWfSupportsPm(options.webFramework,
pm), matching the interactive selection path. Reject unsupported combinations
using the existing error/exit behavior, while preserving the current checks and
successful return for compatible package managers.
- Around line 53-55: Update the result.status === "missing" branch to include
actionable runtime installation guidance, using runtimes[pmToRt(pm)].label and
an install URL. Extend the installer metadata or add a runtime helper to support
the getInstallUrl signature needed for this path, while preserving the existing
missing-runtime error message.

In `@packages/init/src/lib.ts`:
- Around line 221-224: Update the return type of checkRuntimeVersion to use the
imported RuntimeCheck type instead of redeclaring the equivalent union, matching
checkRuntimeRequirement and keeping the shared contract centralized.
- Around line 239-249: Update checkRuntimeVersion so unexpected runtime-check
errors are converted into the same result shape used for missing, unsupported,
and malformed runtimes instead of being rethrown. Ensure checkAllRuntimes and
askPackageManager handle that result by printing an actionable CLI message and
exiting cleanly, while preserving the existing not-found behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6e67122f-54e4-4ac4-a1fb-5b08cbe4b156

📥 Commits

Reviewing files that changed from the base of the PR and between a681e1f and c4cdc1c.

📒 Files selected for processing (9)
  • CHANGES.md
  • changes.d/init/verify-runtime-version.md
  • packages/init/src/ask/pm.ts
  • packages/init/src/const.ts
  • packages/init/src/json/rt.json
  • packages/init/src/lib.test.ts
  • packages/init/src/lib.ts
  • packages/init/src/types.ts
  • packages/init/src/webframeworks/astro.ts

Comment thread packages/init/src/ask/pm.ts Outdated
Comment thread packages/init/src/ask/pm.ts Outdated
Comment thread packages/init/src/lib.ts Outdated
Comment thread packages/init/src/lib.ts

@2chanhaeng 2chanhaeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for your contribution to Fedify. Before merging this PR, some changes are needed, and I have left suggestions to make your PR better. Please read them and consider applying them!

Comment thread CHANGES.md Outdated
Comment thread packages/init/src/lib.ts Outdated
Comment thread packages/init/src/lib.ts Outdated
Comment thread packages/init/src/ask/pm.ts Outdated
Comment thread packages/init/src/ask/pm.ts
Comment thread packages/init/src/ask/pm.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CHANGES.md (1)

183-195: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Correct the PR reference.

Line 183 escapes the closing citation bracket. Line 195 links PR #981 as an issue. Remove the escape and change the reference URL to https://github.com/fedify-dev/fedify/pull/981.

Based on PR objectives: this change is PR #981.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGES.md` around lines 183 - 195, In CHANGES.md, correct the PR `#981`
citation by removing the unnecessary escape from its closing bracket, and update
the `#981` reference URL from the issues endpoint to the pull endpoint. Leave the
other changelog references unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@CHANGES.md`:
- Around line 183-195: In CHANGES.md, correct the PR `#981` citation by removing
the unnecessary escape from its closing bracket, and update the `#981` reference
URL from the issues endpoint to the pull endpoint. Leave the other changelog
references unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 408742d3-7138-47d9-9b17-033403cf539d

📥 Commits

Reviewing files that changed from the base of the PR and between c4cdc1c and 1dd33c5.

📒 Files selected for processing (4)
  • CHANGES.md
  • changes.d/init/verify-runtime-version.md
  • packages/init/src/ask/pm.ts
  • packages/init/src/lib.ts

@userjmmm

userjmmm commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

I applied changes. Could you take another look?

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.03125% with 87 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/init/src/ask/pm.ts 11.32% 47 Missing ⚠️
packages/init/src/lib.ts 41.79% 39 Missing ⚠️
packages/init/src/utils.ts 80.00% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
packages/init/src/const.ts 100.00% <100.00%> (ø)
packages/init/src/webframeworks/astro.ts 100.00% <100.00%> (ø)
packages/init/src/utils.ts 89.33% <80.00%> (-0.47%) ⬇️
packages/init/src/lib.ts 61.89% <41.79%> (-4.78%) ⬇️
packages/init/src/ask/pm.ts 27.02% <11.32%> (-23.86%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2chanhaeng 2chanhaeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, you've addressed my comments well, but it seems there are still some areas for improvement. Could you take a look at these points?

Comment thread packages/init/src/ask/pm.ts Outdated
Comment thread packages/init/src/ask/pm.ts Outdated
Comment thread packages/init/src/ask/pm.ts Outdated
Comment thread packages/init/src/ask/pm.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (1)
packages/init/src/ask/pm.ts (1)

61-68: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Report the runtime failure details when all choices are disabled.

The error only states that no supported package manager is available. It omits the disabled reasons already computed for each choice. A user cannot identify the missing runtime, malformed version output, or required minimum version.

Include the relevant disabled reason or reasons in this exit path. The PR requires clear errors for missing, malformed, and unsupported runtimes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/init/src/ask/pm.ts` around lines 61 - 68, Update the all-disabled
branch after the PACKAGE_MANAGER choices are computed to include each disabled
choice’s existing reason in the printErrorMessage output. Preserve the current
package-manager availability message while reporting missing, malformed, and
unsupported runtime details from the choice objects before exiting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/init/src/ask/pm.ts`:
- Around line 42-52: The explicit disabled package-manager path in the async
package-manager prompt must terminate after printing the error, regardless of
test mode. Update the branch handling choice.disabled in the packageManager
selection flow to exit unconditionally, while preserving the existing successful
return and interactive prompt behavior.

---

Outside diff comments:
In `@packages/init/src/ask/pm.ts`:
- Around line 61-68: Update the all-disabled branch after the PACKAGE_MANAGER
choices are computed to include each disabled choice’s existing reason in the
printErrorMessage output. Preserve the current package-manager availability
message while reporting missing, malformed, and unsupported runtime details from
the choice objects before exiting.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 02b29fbf-5fc3-4845-abb8-1beb9e08cfb3

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd33c5 and 3c2ae4e.

📒 Files selected for processing (2)
  • packages/init/src/ask/pm.ts
  • packages/init/src/lib.ts

Comment thread packages/init/src/ask/pm.ts
@userjmmm
userjmmm requested a review from 2chanhaeng August 12, 2026 15:52

@2chanhaeng 2chanhaeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your hard work! I'm really sorry that this PR is dragging on, but I still see a few spots that need some fixing. Hang in there, we're almost there!

Comment thread packages/init/src/json/rt.json Outdated
Comment thread packages/init/src/json/rt.json Outdated
Comment thread packages/init/src/lib.ts
Comment thread changes.d/init/verify-runtime-version.md
Comment thread packages/init/src/ask/pm.ts Outdated
@userjmmm
userjmmm requested a review from 2chanhaeng August 13, 2026 09:40

@2chanhaeng 2chanhaeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Before merging this PR, please rebase from main branch.

Fedify has minimum runtime versions, and some frameworks require even
newer ones.  `fedify init` did not check this, so it could scaffold a
project on a runtime below the minimum, which can then fail at runtime.
Verify the selected runtime version before creating any files.

The base minimums (Deno 2.0.0, Node.js 22.0.0, Bun 1.1.0) mirror the
values declared by `@fedify/fedify` and are defined directly in
`rt.json`.  Frameworks with stricter requirements, such as Astro's
Node.js 22.12, raise the minimum through `minRuntimeVersions`.

Assisted-by: Claude Code:claude-opus-4-8
Cover `verifyRuntimeVersion` for versions below, equal to, and above the
minimum, and `resolveRequiredVersion` for framework overrides that raise
the base minimum.

Assisted-by: Claude Code:claude-opus-4-8
Assisted-by: Claude Code:claude-opus-4-8
`askPackageManager` recomputed the runtime checks through
`checkAllRuntimes` every time it built the prompt.  Following the
review, that computation was separated into `calculateChoices` to run
once.  When `fillPackageManager` already has a `packageManager`, it now
looks the value up in `choices` instead of calling
`checkRuntimeRequirement` again.

`checkRuntimeRequirement` is no longer used outside `lib.ts`, so its
export was removed.

Assisted-by: Claude Code:claude-opus-4-8
When the chosen package manager was not installed, `fillPackageManager`
recursed to prompt again, recomputing `calculateChoices` on every retry,
so replace the recursion with a loop that reuses the `choices` computed
once at the start.

Assisted-by: Claude Code:claude-opus-4-8
`checkRuntimeRequirement` only forwarded to `checkRuntimeVersion`, so it
was inlined into `checkAllRuntimes` to make the chain simpler.

Assisted-by: Claude Code:claude-opus-4-8
`choices` recorded each runtime's version but not whether a package
manager's binary was installed, so `fillPackageManager` checked the
binary separately and looped to retry.

Move that check into `choicePackageManager` so `choices` also reflects
binary availability.  `fillPackageManager` then trusts `choices` and
drops the re-check, the retry `while` loop, and the `pm` alias.  A
disabled choice falls back to `askPackageManager` instead of exiting.

Assisted-by: Claude Code:claude-opus-4-8
When a command is not installed, dax throws a ShellError with exit code 127.  `isNotFoundError` only checked `ENOENT`, so it missed the error and init crashed.  Recognize exit code 127 as well.

Assisted-by: Claude Code:claude-opus-4-8
The `outputPattern` for bun and node was anchored to the end of the
string with `$`, so it only matched a bare `major.minor.patch`.  That
missed pre-release versions such as bun's `1.2.14-canary.96` or Node.js
nightly builds.  Replace the trailing `$` with a word boundary (`\b`) so
the pattern still captures the `major.minor.patch` core while allowing a
pre-release or build-metadata suffix to follow.

Assisted-by: Claude Code:claude-opus-4-8
@userjmmm
userjmmm force-pushed the issue-964-verify-runtime-version branch from b3c248c to 766524b Compare August 14, 2026 00:05
@2chanhaeng
2chanhaeng enabled auto-merge August 14, 2026 05:30
@2chanhaeng
2chanhaeng merged commit 2ca4f0a into fedify-dev:main Aug 14, 2026
18 checks passed
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.

Verify runtime is supported version when fedify init

2 participants