nw / node-release-lines

API for Node.js release metadata
MIT License
59 stars 2 forks source link

Node Release Lines

Introspection API for Node.js release metadata. Provides information about release lines, their relative status along with details of each release.

See how release lines work for more context.

Currently optimized for offline mode. Release schedule has apis to support both online & offline mode.

Installation

npm install node-release-lines

Outline

Usage

const { ReleaseLines } = require('node-release-lines')

const releases = ReleaseLines.load('2018-09-15') // state of release lines at a point in time

if (releases.getLTS().length === 4 && // LTS release lines
    releases.getEOL().length === 6 && // release lines that have reached EOL (end of life)
    releases.getEOL().getModern().length === 4 && // "modern" EOL release lines
    releases.getEOL().getLTS().length === 1) { // LTS release lines that are EOL
  // examine supported release lines

  releases.getSupported().forEach(line => {
    let stats = line.getStats()
    console.log({
      version: line.version,
      daysToEOL: stats.days.until.eol,
      progress: `${stats.percent.total}%`,
      state: {
        lts: line.isLTS,
        isCurrent: line.isCurrent,
        isActive: line.isActive,
        isMaintenance: line.isMaintenance
      },
      releases: {
        total: line.releases.length,
        safe: line.releases.getSafe().length,
        latest: line.releases[0].version
      }
    })
  })
}

Output

{ version: 'v6',
  daysToEOL: 198,
  progress: '81%',
  state:
   { lts: true,
     isCurrent: false,
     isActive: false,
     isMaintenance: true },
  releases: { total: 39, safe: 1, latest: 'v6.14.3' } }
{ version: 'v8',
  daysToEOL: 472,
  progress: '50%',
  state:
   { lts: true,
     isCurrent: false,
     isActive: true,
     isMaintenance: false },
  releases: { total: 26, safe: 2, latest: 'v8.11.4' } }
{ version: 'v10',
  daysToEOL: 929,
  progress: '13%',
  state:
   { lts: true,
     isCurrent: true,
     isActive: false,
     isMaintenance: false },
  releases: { total: 12, safe: 6, latest: 'v10.9.0' } }

Command Line

The node-release-lines CLI options can be used globally or via npx.

Globally, where <command> is the command you'd like to use:

npm install node-release-lines -g
<command> [options]

Via npx, where <command> is the command you'd like to use:

npx node-release-lines <command> [options]

Command: isnodesafe [options]

isnodesafe is a CLI utility to check if Node.js is safe. The CLI defaults to checking system version, but can also check user-specified versions.

isnodesafe Options

isnodesafe Examples

$ isnodesafe
$ isnodesafe --ci
$ isnodesafe --release 10.2.0
$ isnodesafe -rc 6.9.5

Command: amisafe

This command is deprecated in favor of isnodesafe. It will work as an alias of isnodesafe until node-release-lines@2.0.0, at which point it will be removed.

Command: nodetimeline [options]

nodetimeline is a CLI tool to understand Node.js release lines lifespans.

nodetimeline Options

nodetimeline Examples

$ nodetimeline
$ nodetimeline -c
$ nodetimeline --lts

API

Terminology

ReleaseLine class

Instance properties:

Instance getters:

see terminology

setDate(date)

Changes the date for calculating stats in getStats

Params:

Returns: this

getStats(precision)

Params:

Stats about the relative timeline of the release based on the current setDate.

Notes:

Returns:

{ days: { 
    total: 1073, // total days release is supported
    current: 160, // days in `current` mode
    lts: 548, // days in `active` LTS
    maintenance: 365, // days in maintenance
    completed: { 
        total: 144, 
        current: 144, 
        lts: 0, 
        maintenance: 0 },
    remaining: { 
        total: 929, 
        current: 16, 
        lts: 548, 
        maintenance: 365 },
    until: { 
        start: 0, // already started
        lts: 16, 
        maintenance: 564, 
        eol: 929 } 
    },
  percent: { 
      total: 13, // complete
      current: 90, 
      lts: 0, 
      maintenance: 0 } 
}

ReleaseLines extends Array class

An array of ReleaseLine instances. Provides helper methods for updating, filtering and querying release lines.

ReleaseLines.load(schedule, date) static

Hydrates a schedule. If a schedule is not defined then the internal cached copy is automatically used.

Params:

Returns: ReleaseLines instance

ReleaseLines.fetch(date) static

Params:

Returns: Promise - resolves to ReleaseLines instance

ReleaseLines.scheduleUrl (string) static

The url to the offical release schedule.

get(version, resetDate)

Params:

Returns: ReleaseLine or undefined

setDate(date)

Params:

Returns: this

getSupported(resetDate)

Filters ReleaseLine items by isSupported

Params:

Returns: ReleaseLines instance with only supported release lines.

getCurrent(resetDate)

Filters ReleaseLine items by isCurrent

Params:

Returns: ReleaseLines instance with only current release lines.

getMaintenance(resetDate)

Filters ReleaseLine items by isMaintenance

Params:

Returns: ReleaseLines instance with only release lines in maintenance mode.

getFuture(resetDate)

Filters ReleaseLine items by isFuture

Params:

Returns: ReleaseLines instance with only release lines that have yet to start.

getActive(resetDate)

Filters ReleaseLine items by isActive

Params:

Returns: ReleaseLines instance with only release lines that are in LTS, excluding maintenance window.

getEOL(resetDate)

Filters ReleaseLine items by isEOL

Params:

Returns: ReleaseLines instance with only release lines that have hit EOL

getModern(resetDate)

Filters ReleaseLine items by isModern

Params:

Returns: ReleaseLines instance with only modern release lines.

getLTS(resetDate)

Filters ReleaseLine items by isLTS

Params:

Returns: ReleaseLines instance with only release lines that have an LTS active mode in their lifecycle. Note: It does not neccessarily mean it is an active LTS (see getActive()).

Release class

Instance properties:

Instance getters:

Release.load(version) static

options:

Returns: Release or null if version does not exist

download(arch, type)

If arch is omitted returns directory to all download resources for release version.

Currently arch and type are not implemented

options:

Returns: String url of download resource

Releases extends Array class

An array of Release instances. Provides helper methods for updating, filtering and querying release lines.

Releases.load(version) static

Params:

Returns: Releases instance

getSafe()

Filters Release items by isSafe

Returns: Releases instance with only releases that have no known vulnerabilities.

Vulnerability class

Instance properties:

Instance getters:

ChangeLog class

Currently deprecations and notable changes are not fully supported.

Instance properties:

load(version) static

options:

Returns: ChangeLog instance or null

Commit class

Instance properties:

Instance getters:

Acknowledgements

Thank you Node.js Release Team and all the contributors to the Node.js project, without you none of this is possible. Special thanks goes out to Tierney Cyren. His relentless desire to improve accessibility, visibility and communication inspired this project.

Contributing

To submit a bug report, please create an issue on GitHub.

If you'd like to contribute code to this project, please read the CONTRIBUTING.md document.

License & Copyright

node-release-lines is Copyright (c) 2018 Nathan White and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.