depy

Checks new or updated dependencies and install them if needed. Supports npm, yarn and inpack

Usage no npm install needed!

<script type="module">
  import depy from 'https://cdn.skypack.dev/depy';
</script>

README

depy

npm version Build Status XO code style

Depy is a small cli tool that watches your project dependencies and runs the appropriate package manager when it is needed. Depy tracks changes in package.json, npm-shrinkwrap.json, yarn.lock, inpack.json.

Screencast

asciicast

Install

npm install --save-dev depy

How it works

After the very first run, depy creates project confuguration files cache. From now on, when the tool is running, it will be comparing all the configuration files with the cache. If there are any inconsistencies, depy will run the appropriate tool to update dependecies.

Depy runs different commands for each type of config:

  • package.json and npm-shrinkwrap.json - npm install
  • yarn.lock - yarn install
  • inpack.json - inpack link

Also depy can detect yarn ("yarn install" will be executed instead of "npm install"). If npm-shrinkwrap.json exists and was changed, "npm install" will be executed in any case.

Usage

$ depy

Since depy is the tool for developers, you need to install it with --save-dev npm flag (or -D for yarn). You can run depy manually, but it might be annoying doing this every time. So, you can simply add depy to your npm-scripts.

Example

package.json before

...
"scripts": {
  "start": "webpack",
  "test": "ava"
},
...

package.json after

...
"scripts": {
  "start": "depy && webpack",
  "test": "depy && ava"
},
...

You can use depy cache to recreate the cache without any package manager. Makes sense to add this script to the "postinstall" section. It is a good way to avoid an unnecessary package manager launch after installing new dependencies.

In this case, your modified package.json will be:

...
"scripts": {
  "start": "depy && webpack",
  "test": "depy && ava"
},
"postinstsall": "depy cache",
...

Available flags

  • --dir - project directory (current directory by default)
  • --cache-dir - cache directory (depy installation directory by default)

Author

Dmitry Pavlovsky