Giter Club home page Giter Club logo

npmvet's Introduction

Build status

NPM Vet is a simple CLI tool to help vet your npm package versions. NPM Vet can be used locally, or as a CI build-step to prevent builds passing with mismatched package versions. To read more about NPM Vet, visit the Hark website.

Installation

$ npm install npmvet -g

Usage

Usage: npmvet [options]

Options:

  -h, --help                 output usage information
  -V, --version              output the version number
  -p, --package <package>    package.json file location (Default: .)
  -m, --modules <modules>    node_modules folder location (Default: .)
  -r, --renderer <renderer>  Renderer to use (Default: inlinetable)
  -s, --strict               Using the CI renderer, fail build if any packages unlocked (Default: false, flag)

Strict Mode

If you're using the CI renderer (see below) the -s flag will enable strict mode. In which builds will fail if versions are unlocked, not just unmatching.

Renderers

Renderers are used to dictate how to output the data NPM Vet collects. The default is inlinetable.

Inline Table

$ npmvet -r inlinetable

The default renderer, inlinetable will print a table inline with your current process. You can use this locally to visualise package differences.

CI

$ npmvet -r ci

To prevent your CI builds passing with mismatched package versions, use the CI renderer. If any package version mismatches are found, the build will fail:

Or if there are no mismatching package versions, your build will continue (and hopefully pass!):

Blessed

The blessed renderer will render a table inside a screen, that has be exited by the user to escape.

$ npmvet -r blessed

JSON

The JSON renderer will print a JSON array with match information for each package.

$ npmvet -r json
[
  {
    "name": "blessed",
    "packageVersion": "0.1.81",
    "installedVersion": "0.1.81",
    "matches": true,
    "locked": false
  },
  {
    "name": "chalk",
    "packageVersion": "1.1.3",
    "installedVersion": "1.1.3",
    "matches": true,
    "locked": false
  },
  {
    "name": "jest",
    "packageVersion": "18.1.0",
    "installedVersion": "18.1.0",
    "matches": true,
    "locked": false
  }
]

Contributing

For information regarding contributing to this project, please read the Contributing document.

License

MIT License

npmvet's People

Contributors

andrewhathaway avatar slieschke avatar timjacobi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

npmvet's Issues

The JSON renderer

The document states that it can be displayed in JSON with npmvet - r json, but it can not be executed in 0.1.2. Do you still have an update plan?

Usage of typings for TS type management

I realise the types for this package are managed by typings. Since TypeScript 2 you can manage types using NPM and the @types organisation - see here.

I have tested this locally and am happy to submit a PR if this is of interest.

If package version is tgz it will be `Mismatch`

It seems that the installed version matches, but if package version is tgz it will be Mismatch.

example:
glob │ https://registry.npmjs.org/glob/-/glob-7.1.1.tgz │ 7.1.1   │  Mismatch  │  Unlocked

What does "Locked" mean?

Aren't you "locking" it when you use ~ or ^ ?

Or is it only supposed to represent if you use a static version?

Support for "latest" and "beta" matching

Currently you get a mismatch if you use things like "latest,beta,next,etc" in your package.json.

example:
║ mock-fs │ latest │ 3.12.1 │ Mismatch │ Unlocked ║

Is there a way to add support for this?

Display latest version

Hi, thank you, this project is quite useful!

I know its not it scope but it would be a nice addition to optionally display the latest available version. That way it would allow to make update decisions, eg. there is a minor update and decide to update, test and lock again.

Comparison with npm outdated

This isn't really an issue, but I think that it would be good to compare this package with the standard npm outdated -l command. Something else worth positioning as a comparison would be npm shrinkwrap as a way to lock dependencies (e.g. in a CI context, to ensure that all dependencies are locked).

This would help and figure out the added value of this package.

Thanks

Add switch for rendering JSON output

It would be great to have a JSON renderer so you can store or process the output. Instead of a table the output could be something like

[
  {
    "name": "blessed",
    "packageVersion": "0.1.81",
    "installedVersion": "0.1.81",
    "matches": true,
    "locked": false
  },
]

Handling sub-dependencies

How does this handle sub-dependencies (i.e. you're not locking downbabel if you remove the ^ in your project's package.json because that version of Babel still uses the caret to specify its dependencies) ?

And what benefit does this tool provide over using npm shrinkwrap?

[Suggestion] npmvet --lock command of some sort

I know sometimes even minor versions can result in fuckery, I'd wanted to use a --lock=installed command.
This would edit my package.json file with the specific versions that are surely to work.

This could be expanded if npmvet would display available version, so you could tell npmvet what version they should lock on (either package version, installed version or available version).

In that case a --lock=package|installed|available could be useful.

Auto exclude local file packages

In my situation it is necessary to have a local file package rather than an npm hosted package. I am not able to use npmvet in our build process as a final check due to it considering the local file package different than the installed version. It would be great to have an exclude package option, or a feature that auto excluded local file packages.

Strict mode doesn't check for mismatching

If package is locked, but mismatch, the npmvet -s -r ci exit without error.

This may happen in development, when you update your branch with the latest master, that brings new packages, and forget to run npm ci.

I made a PR with the fix.

version URL tag enhancement

In some repositories the version tags do not start with 'v'

"ng-uikit-pro-standard": "git+https://oauth2:[email protected]/mdb/angular/ng-uikit-pro-standard.git#8.5.0"

This is a slight variant on the fix in issue #2

Will submit a PR.

Pipeline does not fail with ci renderer when there is a mismatch

Hey,

First of all, thanks for amazing project!

I have added npmvet -r ci to pipeline hoping it would start failing the pipeline if there is a version mismatch. There is a new mismatch, but the pipeline does not fail and the command has exited with 0 error code.

Am I using it not in a proper way?

Thanks for your answer!

Provide Similar functionality to yarn outdated

It would be great to add

  • what the current package.json says (i.e Current column).
  • What the resolution of things like ~ or ^ wants (i.e Wanted column) and maybe state that in the output?
  • then a 3rd column for how far behind you are (i.e. Latest).
  • Then you can have your mismatch logic be behind current and wanted.

Posted what yarn outdated would look like for reference.

yarn outdated v0.17.10
Package                        Current Wanted  Latest Package Type
autoprefixer                   6.5.4   6.5.4   6.7.2  devDependencies
babel-cli                      6.14.0  6.14.0  6.22.2 devDependencies
babel-eslint                   6.1.2   6.1.2   7.1.1  devDependencies
babel-istanbul                 0.11.0  0.11.0  0.12.1 devDependencies
babel-plugin-webpack-loaders   0.7.1   0.7.1   0.8.0  devDependencies
babel-polyfill                 6.6.1   6.6.1   6.22.0 devDependencies
babel-runtime                  6.6.1   6.6.1   6.22.0 devDependencies
bluebird                       3.3.3   3.3.3   3.4.7  devDependencies
concurrently                   2.2.0   2.2.0   3.1.0  devDependencies
cross-env                      2.0.1   2.0.1   3.1.4  devDependencies
css-loader                     0.24.0  0.24.0  0.26.1 devDependencies
enzyme                         2.4.2   2.4.2   2.7.1  devDependencies
es6-promisify                  4.1.0   4.1.0   5.0.0  devDependencies
esdoc                          0.4.8   0.4.8   0.5.2  devDependencies
eslint-config-airbnb           10.0.1  10.0.1  14.0.0 devDependencies
eslint-config-standard         6.0.1   6.0.1   6.2.1  devDependencies
eslint-import-resolver-webpack 0.5.1   0.5.1   0.8.1  devDependencies
eslint-plugin-import           1.16.0  1.16.0  2.2.0  devDependencies
eslint-plugin-jsx-a11y         2.2.3   2.2.3   4.0.0  devDependencies
eslint-plugin-promise          2.0.1   2.0.1   3.4.0  devDependencies
eventemitter3                  1.1.1   1.1.1   2.0.2  devDependencies
expand-tilde                   1.2.2   1.2.2   2.0.2  devDependencies
fix-path                       2.0.0   2.0.0   2.1.0  devDependencies
fs-extra                       1.0.0   1.0.0   2.0.0  devDependencies
github                         5.2.3   5.2.3   8.1.1  dependencies
history                        2.0.1   2.0.1   4.5.1  devDependencies
http-status-codes              1.0.6   1.0.6   1.1.6  devDependencies
husky                          0.11.9  0.11.9  0.13.1 devDependencies
isomorphic-style-loader        1.0.0   1.0.0   1.1.0  devDependencies
jquery                         2.2.4   2.2.4   3.1.1  devDependencies
lodash                         4.11.2  4.11.2  4.17.4 devDependencies
mocha-multi                    0.9.1   0.9.1   0.10.0 devDependencies
node-fetch                     1.3.3   1.3.3   1.6.3  devDependencies
normalize.css                  3.0.3   3.0.3   5.0.0  devDependencies
npm                            3.10.10 3.10.10 4.1.2  devDependencies
path-to-regexp                 1.6.0   1.6.0   1.7.0  devDependencies
postcss-import                 8.2.0   8.2.0   9.1.0  devDependencies
postcss-loader                 0.8.2   0.8.2   1.2.2  devDependencies
postcss-scss                   0.1.9   0.1.9   0.4.0  devDependencies
prettyjson                     1.1.3   1.1.3   1.2.1  devDependencies
react                          15.4.0  15.4.0  15.4.2 devDependencies
react-dom                      15.4.0  15.4.0  15.4.2 devDependencies
react-dropzone                 3.6.0   3.6.0   3.9.2  devDependencies
react-notification-system      0.2.7   0.2.7   0.2.11 devDependencies
react-redux                    4.4.6   4.4.6   5.0.2  devDependencies
redux                          3.5.2   3.5.2   3.6.0  devDependencies
redux-logger                   2.6.1   2.6.1   2.8.1  devDependencies
redux-thunk                    2.0.1   2.0.1   2.2.0  devDependencies
request                        2.78.0  2.78.0  2.79.0 devDependencies
sort-package-json              1.4.0   1.4.0   1.5.0  devDependencies
sync-request                   3.0.1   3.0.1   4.0.1  devDependencies
webpack                        1.12.15 1.12.15 2.2.1  devDependencies
webpack-merge                  0.14.1  0.14.1  2.6.1  devDependencies
whatwg-fetch                   0.11.0  0.11.0  2.0.2  devDependencies 

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.