npm-dependency-db

6.0.8 • Public • Published

npm-dependency-db

Use npm-dependency-db to list which npm packages depends on a given version (or version range) of a given npm package.

Build status js-standard-style

A hosted web version of this module exists at: dependency.land.

Installation

npm install npm-dependency-db -g

Upgrading from previous versions

If you are upgrading from versions older than v6.0.0, you need to completely purge the cache by deleting the entire ~/.npm-dependency-db directory and reimport everything by running npm-dependency-db --update.

CLI Usage

npm-dependency-db [<name> [range]] [options]

First time you use npm-dependency-db you need to sync the npm dependency tree to a local cache by running:

$ npm-dependency-db --update

Do this every time you want to get up-to-date with the latest changes from the npm database.

To perform a query, run:

$ npm-dependency-db <name> [range] [options]

Where <name> is a name of the module you want to query and [range] is an optional semver range similar to what you would write in a package.json file.

E.g. to ask who depends on bluebird within the 2.x version range, you could run:

$ npm-dependency-db bluebird 2.x

E.g. to ask who depends on standard as a dev-dependency within the 7.x version range, you could run:

$ npm-dependency-db --dev standard 7

Run with --help option to see a complete list of options.

Programmatic Usage

var Updater = require('npm-dependency-db/updater')
var level = require('level')
 
var db = level('./test.db')
 
var updater = new Updater(db, {live: true})
 
updater.on('processed', function (n) {
  console.log('processed npm change number %d', n)
})

API

Updater(db[, options])

Initialize the Updater with a LevelDB compatible database and an optional options object.

The following options are supported:

  • key - The hypercore key to create a feed from. Will default to a hard-coded key
  • live - If true, the feed will be kept open while waiting for new changes. Ignored if indexOnly is true. Defaults to false
  • hypercorePath - Path where to store the raw npm feed. Defaults to ./npm-dependency-db.core
  • indexOnly - Only build database index (do not download new blocks). Defaults to false

Event: init

Emitted when updater.processed, updater.startBlock and updater.currentBlock have been populated.

Event: running

Emitted when the updater.feed is ready.

Event: processed

Emitted when a change object have been completely processed.

The first argument is the hypercore block number containing the change that have been processed.

Event: end

Emitted when there is nothing more to process. Will not be emitted if options.live is true unless an error occurs.

Event: error

Emitted if an error occurs.

The first arguemnt is the error.

updater.feed

A hypercore feed. Contains all npm change objects. Each change is a block in the feed.

updater.startBlock

The change (i.e. hypercore block number) where the feed will start to process in this instance of the Updater.

updater.currentBlock

The change (i.e. hypercore block number) that is currently beeing processed.

updater.processed

The number of changes processed so far in the feed.

License

MIT

Package Sidebar

Install

npm i npm-dependency-db

Weekly Downloads

1

Version

6.0.8

License

MIT

Last publish

Collaborators

  • mafintosh
  • watson