Skip to content

Add node preFlight checks to CLI - #2892

Merged
gerteck merged 3 commits into
MarkBind:masterfrom
Harjun751:node-preflight
Apr 16, 2026
Merged

Add node preFlight checks to CLI#2892
gerteck merged 3 commits into
MarkBind:masterfrom
Harjun751:node-preflight

Conversation

@Harjun751

@Harjun751Harjun751 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Resolves#2886

Overview of changes:
Adds a pre-flight check that ensures that Node version is >=22.12.0.

Anything you'd like to highlight/discuss:
Here's what it looks like:

image

Testing instructions:

Use nvm/whatever your environment uses to install and use a version of node that is incompatible, and see that building a site or any command fails. Switch back to a compatible version and see that it works.

Proposed commit message: (wrap lines at 72 characters)

Add node preflight checks to CLI


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

MarkBind requires some checks to improve
UX.
Let's
* Add a new file preFlightChecks to contain all
of these checks
* Add a preAction hook to run the checks before
invoking any command

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a CLI pre-flight check that blocks command execution when the running Node.js version is below the minimum supported version (>= 22.12.0), resolving #2890.

Changes:

  • Introduce preFlightChecks() with a Node version gate using semver.
  • Register a Commander preAction hook to run pre-flight checks before executing commands.
  • Add semver and its TypeScript types to the CLI package dependencies.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

FileDescription
packages/cli/src/util/preFlightChecks.tsImplements Node version validation and error/exit behavior.
packages/cli/index.tsHooks pre-flight checks into Commander’s preAction lifecycle.
packages/cli/package.jsonAdds semver runtime dependency and @types/semver for typing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/cli/src/util/preFlightChecks.ts
Comment threadpackages/cli/src/util/preFlightChecks.ts Outdated
Comment on lines +12 to +16
logger.error(
`Markbind ${CLI_VERSION} requires Node >=22.12.0. `
+ 'Please update Node or use an older version of MarkBind!'
);
process.exit(1);

CopilotAIApr 16, 2026

Copy link

Choose a reason for hiding this comment

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

Calling process.exit(1) inside a utility invoked from Commander hooks makes this harder to test and can bypass any centralized error handling/cleanup. Prefer throwing an error (or a Commander-specific error type) and letting the CLI entrypoint decide the exit code.

Suggested change
logger.error(
`Markbind ${CLI_VERSION} requires Node >=22.12.0. `
+'Please update Node or use an older version of MarkBind!'
);
process.exit(1);
constmessage=`Markbind ${CLI_VERSION} requires Node >=22.12.0. `
+'Please update Node or use an older version of MarkBind!';
logger.error(message);
thrownewError(message);

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'm thinking to leave this in. Throwing an error will print the whole stack trace to the user, it's ugly and less helpful from the user's standpoint IMO.

Instead I've added some explicit documentation through jsDoc that says calling the function may exit the process if checks fail.

Comment threadpackages/cli/src/util/preFlightChecks.ts Outdated
@codecov

codecovBot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.35%. Comparing base (b3b90c8) to head (19d2be6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #2892 +/- ##
========================================
Coverage 71.35% 71.35% ========================================
Files 133 133 Lines 7229 7229 Branches 1611 1712 +101 ========================================
Hits 5158 5158 + Misses 2065 1970 -95 - Partials 6 101 +95 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gerteckgerteck 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.

LGTM

@gerteck
gerteck merged commit 29efca4 into MarkBind:masterApr 16, 2026
11 checks passed
@github-actionsgithub-actionsBot added the r.Minor Version resolver: increment by 0.1.0 label Apr 16, 2026
@gerteckgerteck added r.Patch Version resolver: increment by 0.0.1 and removed r.Minor Version resolver: increment by 0.1.0 labels Apr 16, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

r.PatchVersion resolver: increment by 0.0.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add preflight check for Node v22.12 and above (alongside other checks In future)

3 participants

@Harjun751@gerteck