npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dep-validate

v1.2.0

Published

Dependency verification for npm packages with Gulp support

Downloads

6

Readme

dep-validate

dep-validate is a tool used to verify the ranges on your npm dependencies. It can be used from the command line, from JavaScript, or from Gulp. It's available on npm, so just install it via:

# for gulp/node usage
$ npm install --save-dev dep-validate

# for command line usage
$ npm install -g dep-validate

Command Line Usage

Super easy, it's just the same interface as the JavaScript library (read up).

$ dep-validate --dependencies '~' --devDependencies '^' --exclude pkg1 --exclude pkg2 --hardcoded=allow --only production --only development --packageFile ./package.json

The exit code will be a 1 in case of error, with a chart displaying errors. It'll be 0 on success with no output.

Library Usages

You can use the JavaScript library either directly in Node.js or via Gulp:

JavaScript Interface

All options are shown below and are the defaults (so they're used if not provided). The only exception is file, which will resolve the current package.json (by reading upwards in directory).

var dv = require('dep-validate');

// available options
var opts = {
  dependencies: '~',                      // the range to enforce on all "dependencies"
  devDependencies: '^',                   // the range to enforce on all "devDependencies"
  exluded: [ 'my-package' ],              // packages to exclude from validation
  hardcoded: 'allow|force',               // allow or force hardcoded versions
  packageFile: './package.json',          // the package.json file to read and validate
  only: [ 'production', 'development' ]   // only check prod/dev dependencies
}

// `validate()` results a results object
var results = dv.validate(opts);

// which can be printed using `log()`
if (dv.hasErrors(results)) {
  dv.log(results);
}

// or use `pipe()` for a callback-style interface (it's still synchronous)
dv.pipe(opts, function (err) {
  // err contains a `meta` field containing information about failures
  // you can either inspect this manually, or log the entire error using `log(err)`
})
Gulp
var dv = require('dep-validate');
var gulp = require('gulp');

gulp.task('deps:validate', function () {
	gulp.src('./package.json', { read: false })
		.pipe(dv.gulp());
})

In addition to the options accepted by the JavaScript interface, .gulp() can also accept a failOnError option which will cause your Gulp task to cause an error if your dependencies do not satisfy your rules.