Skip to content

feat(analytics): add Node.js version check on package initialisation (closes #1014) - #1058

Open
Ranjeet2063 wants to merge 1 commit into
StellarCommons:mainfrom
Ranjeet2063:feat/node-version-check-on-init
Open

Ranjeet2063 wants to merge 1 commit into
StellarCommons:mainfrom
Ranjeet2063:feat/node-version-check-on-init

Conversation

@Ranjeet2063

Copy link
Copy Markdown

Summary

Closes #1014

Adds a Node.js minimum version check (v18+) executed automatically on package initialisation within @stellar-explain/analytics, warning developers if the runtime does not satisfy version requirements.

Key Changes

  • Node Version Verification Utility (packages/analytics/src/utils/node-check.ts):
    • Defined MIN_NODE_VERSION = 18.
    • Implemented getNodeMajorVersion extracting Node major version.
    • Implemented isSupportedNodeVersion with fallback returning true for non-Node environments.
    • Implemented warnIfUnsupportedNodeVersion logging a formatted console.warn message when running on unsupported Node runtimes.
  • Package Initialisation (packages/analytics/src/index.ts):
    • Invokes warnIfUnsupportedNodeVersion() upon module import.
    • Re-exports version checking utilities and MIN_NODE_VERSION.
  • Re-exports (packages/analytics/src/utils/index.ts):
    • Exported node-check helpers from utils index.
  • Unit Testing (packages/analytics/tests/nodeCheck.test.ts):
    • 11 unit tests covering version parsing, supported/unsupported boundaries, and console warning emissions.

Verification

  • bun test tests/nodeCheck.test.ts: 11/11 passing tests.

…loses StellarCommons#1014)

- Implements `MIN_NODE_VERSION` (18), `getNodeMajorVersion`, `isSupportedNodeVersion`, and `warnIfUnsupportedNodeVersion` in `packages/analytics/src/utils/node-check.ts`.
- Invokes `warnIfUnsupportedNodeVersion` automatically on package initialisation in `packages/analytics/src/index.ts`.
- Safely handles non-Node / browser environments without emitting false positive warnings.
- Adds comprehensive unit test suite in `packages/analytics/tests/nodeCheck.test.ts` verifying major version parsing, threshold checking, and console.warn behavior.
Copilot AI lite review requested due to automatic review settings September 11, 2026 22:46

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Analytics #125 — Add Node.js version check on package import

2 participants