o-rango / update-notify

Update your node-js libraries inspired by `update-notifier`. but works with custom registries and under proxy
MIT License
0 stars 1 forks source link
latest-version npm npm-check npm-ping package-json update-checker update-notifier version-update

@o-rango/update-notify

Build Status codecov

Inspired in update-notifier but using the default npm api that way is working behind proxy or any other config reflected in .npmrc.

It only has programmatic api and can be easily attached to your workflow.

Install

npm i --save @o-rango/updatet-notify

Usage

const { updateNotify } = require('@o-rango/update-notify');

const notifier = updateNotify({
      pkg: {
        version: '0.0.1',
        name: 'react'
      },
      updateCheckInterval: 0
    });

console.log(notifier);
// Output =>  

API

notify = updateNotify(options)

Checks if there is an available update. Accepts options defined below. Returns { updateAvailable: true , name: 'react' , latest: '16.11.0', 'current': '0.0.1' } if there is any update.

options

Type: object

pkg

Type: object

name

Required
Type: string

version

Required
Type: string

updateCheckInterval

Type: number
Default: 1000 * 60 * 60 * 24 (1 day)

How often to check for updates.

distTag

Type: string
Default: latest

Which dist-tag to use to find the latest version.

Extra

ping = pingRegistry()

Easter egg method that pings registry defined in your .npmrc;

const { pingRegistry } = require('@o-rango/update-notify');

const online = await pingRegistry();
// Output online => :{ isOnline : true }