feat(analytics): add Node.js version check on package initialisation (closes #1014) - #1058
Open
Ranjeet2063 wants to merge 1 commit into
Open
Ranjeet2063 wants to merge 1 commit into
Ranjeet2063 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
packages/analytics/src/utils/node-check.ts):MIN_NODE_VERSION = 18.getNodeMajorVersionextracting Node major version.isSupportedNodeVersionwith fallback returningtruefor non-Node environments.warnIfUnsupportedNodeVersionlogging a formattedconsole.warnmessage when running on unsupported Node runtimes.packages/analytics/src/index.ts):warnIfUnsupportedNodeVersion()upon module import.MIN_NODE_VERSION.packages/analytics/src/utils/index.ts):node-checkhelpers from utils index.packages/analytics/tests/nodeCheck.test.ts):Verification
bun test tests/nodeCheck.test.ts: 11/11 passing tests.