Skip to content

Conversation

@srod
Copy link
Owner

@srod srod commented Jan 16, 2026

Summary

  • Add daysUntilEOL property (days until EOL, negative if past)
  • Add toJSON() method for clean JSON serialization

Extracted from bot PRs #797 and #814, implemented cleanly.

Closes

Supersedes all 28 open bot PRs from google-labs-jules.


Summary by cubic

Adds daysUntilEOL to NodeVersion and a toJSON method for clean, data-only serialization. Improves EOL awareness and ensures JSON.stringify excludes methods.

  • New Features
    • daysUntilEOL: positive before EOL, negative after, undefined if unknown.
    • toJSON: returns only data fields; JSON.stringify now omits methods.
    • Exported NodeVersionJSON type and added tests for new fields and serialization.

Written for commit 39d7b0a. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added daysUntilEOL property to track days until a Node version reaches end-of-life.
    • Added toJSON() method to enable JSON serialization of version data.
    • Introduced NodeVersionJSON type for type-safe JSON representation.
  • Tests

    • Added test coverage for daysUntilEOL behavior and toJSON serialization.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2026

🦋 Changeset detected

Latest commit: 39d7b0a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
node-version Minor

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

The changes introduce a daysUntilEOL property and toJSON() method to the NodeVersion class, along with a new NodeVersionJSON type for serialization. The implementation refactors getVersion() to use a centralized data properties bundle. Tests verify the new functionality across scenarios.

Changes

Cohort / File(s) Summary
Type Definitions
src/types.ts
Added daysUntilEOL: number | undefined property and toJSON(): NodeVersionJSON method to NodeVersion interface. Introduced new exported NodeVersionJSON type as an Omit variant excluding methods and comparison operators.
Implementation
src/index.ts
Refactored getVersion() to centralize version metadata in dataProps bundle and spread it into the return object. Added computed daysUntilEOL property (calculated as days between EOL date and current time) and toJSON() method. Updated public exports to include NodeVersionJSON type.
Tests
src/index.test.ts
Added test cases for daysUntilEOL behavior across scenarios: positive before EOL, negative after EOL, undefined for unknown versions. Added toJSON test suite verifying it returns only data properties while excluding methods. Updated public property count assertion from 16 to 18.
Changelog
.changeset/tojson-and-daysuntileol.md
Documented minor version bump with descriptions of new daysUntilEOL property and toJSON() method.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through version trees,
With days until the end to see—
Now JSON sings each hoppy tale,
While toJSON() won't ever fail!
Serialization's here to stay,
Hop-hop-hooray! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding daysUntilEOL property and toJSON() method to NodeVersion, which are the primary features introduced across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

This was referenced Jan 16, 2026
@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ca5732e) to head (39d7b0a).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #826   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           46        55    +9     
  Branches        16        23    +7     
=========================================
+ Hits            46        55    +9     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@srod srod force-pushed the feat/tojson-and-daysuntileol branch from b4e370b to 5c30879 Compare January 16, 2026 21:37
srod pushed a commit that referenced this pull request Jan 16, 2026
Reverting local changes and closing task as PR #826 supersedes this work.
@greptile-apps
Copy link

greptile-apps bot commented Jan 16, 2026

Greptile Summary

Added two developer experience improvements to NodeVersion: a daysUntilEOL property (returning days until/past EOL) and a toJSON() method for clean JSON serialization.

  • daysUntilEOL: Calculates days until EOL using Math.ceil((eolDate - Date.now()) / ms_per_day). Returns positive values for future dates, negative for past dates, undefined for unknown versions. This eliminates the need for manual date math when checking EOL status.

  • toJSON(): Returns only data properties (excluding methods) by returning the dataProps object. This enables clean JSON.stringify() output for logging and debugging.

  • Implementation: Refactored getVersion() to extract data properties into a dataProps object that is spread into the returned object and reused by toJSON(). This avoids duplication and ensures consistency.

  • Tests: Added comprehensive test coverage for both features, including edge cases (positive/negative days, undefined values, JSON round-trip).

  • Type safety: Added NodeVersionJSON type that correctly omits all methods from NodeVersion.

The implementation is clean, well-tested, and follows the existing code patterns. The changeset correctly marks this as a minor version bump.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it adds well-tested, backward-compatible features with no breaking changes.
  • The implementation is clean and correct. The daysUntilEOL calculation uses proper date math with Math.ceil for appropriate rounding. The toJSON implementation leverages a shared dataProps object to avoid duplication. All changes are additive (no breaking changes), have comprehensive test coverage including edge cases, and follow existing code conventions. The refactoring improves code organization without changing behavior.
  • No files require special attention

Important Files Changed

Filename Overview
src/types.ts Added daysUntilEOL property and toJSON method to NodeVersion interface, plus NodeVersionJSON type definition. Clean type additions with proper documentation.
src/index.ts Implemented daysUntilEOL calculation and toJSON method. Refactored to extract dataProps for cleaner JSON serialization. Logic is correct with proper Math.ceil for day rounding.
src/index.test.ts Added comprehensive tests for daysUntilEOL (positive, negative, undefined cases) and toJSON (data-only serialization, JSON.stringify round-trip). Updated property count from 16 to 18. Import reordering per Biome config.
.changeset/tojson-and-daysuntileol.md Properly formatted changeset file marking this as a minor version bump with clear description of new features.

Sequence Diagram

sequenceDiagram
    participant User
    participant getVersion
    participant NodeVersion
    participant Date
    participant EOL_DATES

    User->>getVersion: Call getVersion()
    getVersion->>process: Read versions.node and release.lts
    getVersion->>EOL_DATES: Lookup major version
    EOL_DATES-->>getVersion: Return EOL date string or undefined
    
    alt EOL date exists
        getVersion->>Date: new Date(eolString)
        Date-->>getVersion: eolDate object
        getVersion->>Date: Date.now()
        Date-->>getVersion: Current timestamp
        getVersion->>getVersion: Calculate (eolDate - now) / ms_per_day
        getVersion->>Math: Math.ceil(daysDifference)
        Math-->>getVersion: daysUntilEOL (positive/negative)
    else No EOL date
        getVersion->>getVersion: Set daysUntilEOL = undefined
    end
    
    getVersion->>getVersion: Build dataProps object
    Note over getVersion: dataProps includes: original, short, long,<br/>major, minor, build, isLTS, ltsName,<br/>isEOL, eolDate, daysUntilEOL
    
    getVersion->>NodeVersion: Create NodeVersion object
    Note over NodeVersion: Spreads dataProps + adds methods:<br/>isAtLeast, is, isAbove, isBelow,<br/>isAtMost, toString, toJSON
    
    getVersion-->>User: Return NodeVersion
    
    alt User calls JSON.stringify
        User->>NodeVersion: JSON.stringify(version)
        NodeVersion->>NodeVersion: toJSON() called automatically
        NodeVersion-->>User: dataProps only (no methods)
    end
    
    alt User accesses daysUntilEOL
        User->>NodeVersion: version.daysUntilEOL
        NodeVersion-->>User: number (pos/neg) or undefined
    end
Loading

srod pushed a commit that referenced this pull request Jan 16, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/index.ts">

<violation number="1" location="src/index.ts:51">
P2: `Math.ceil` returns 0 for negative values between 0 and -1, so `daysUntilEOL` won’t be negative for up to 24 hours after EOL even though the version is already past EOL. Use a calculation that yields a negative value immediately after the date passes.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/index.ts">

<violation number="1" location="src/index.ts:52">
P2: Using Math.floor makes `daysUntilEOL` return 0 when less than 1 day remains before EOL, which contradicts the expectation that the value is positive for any pre‑EOL date. Use sign-aware rounding so values stay >0 before EOL and <0 after.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@srod srod merged commit 0000dfa into main Jan 16, 2026
13 checks passed
@srod srod deleted the feat/tojson-and-daysuntileol branch January 16, 2026 21:52
@greptile-apps greptile-apps bot mentioned this pull request Jan 16, 2026
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.

2 participants