Coder Social home page Coder Social logo

version-notifier's Introduction

version-notifier

Let developers know when there is a new release of your package in their next development runtime.

Out-of-the-box providers will only send you version notifications from your application's dependencies, and not from dependencies of your dependencies. Notifications can be disabled in production environments by using the environment variable NODE_ENV=production or NODE_ENV=prod.

You can also specify custom resolvers, so you don't have to rely on NPM's availability.

Install

This is a Node.js module. Therefore, beforehand, you need to download and install Node.js.

Assuming that you have already used the npm init command, run:

$ npm install version-notifier --save

Getting started

You can call version-notifier anytime on your runtime, but it is recommended to call it as soon as your app starts. For example, in your index.js, in your root directory:

ES6+

import checkVersion from 'version-notifier'
checkVersion(__dirname)

ES5

var checkVersion = require('version-notifier')
checkVersion(__dirname)

The first argument must always be the root directory of your app.

How to configure

package.json

You can specify a different provider through versionNotifier.provider on your package.json. Out-of-the-box providers: npm.

{
    "name": "myPackage",
    "version": "1.0.0",
    "versionNotifier": {
        "provider": "npm"
    }
}

Or you can create your very own version provider by the time you call version-notifier:

Custom version providers
checkVersion(__dirname, function (packageName, currentVersion, log) {
    // your magic
    log('I have just checked my custom provider for a new version of ' + packageName + '.')
})

Function Parameters

checkVersion(appRootDirectory, customProvider, log)

appRootDirectory

Type: string

The root directory of your application. If your main file is already in the root directory, just use __dirname here. Otherwise, you must use specify how to go to your root directory still using __dirname. For example, if you are calling version-notifier inside a subfolder of your root directory, you must use path.join(__dirname, '..') to get the relative path of your root directory.

I used root directory here multiples times because getting the right directory for your app is a must for a fully working environment. Using __dirname, your project can be used as a dependency in other projects.

customProvider

Type: function or object

You can use version-notifier with totally different environments from NPM, with support for alternative dependency checking:

{
    isDependency: function (parentDependenciesJson: JSON, dependencyName: string) : boolean,
    resolver: function (packageName: string, currentVersion: string, log: function) : void
}

Or if you are still using package.json for your project, you can just use a function:

function (packageName: string, currentVersion: string, log: function) : void

Versions ideally follow semver, but it is not a rule since you can create your own custom providers.

log

Type: function

Custom logging function for the results.

function (err?: Error, message?: string) : void

Team

Created and developed by Arthur Arioli Bergamaschi.


License

Licensed under MIT.


Disclaimer: version-notifier is an experiment to improve development environments and it is still in alpha. Methods and behavior can change along the way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.