hyperinstall v1.3.0
Hyperinstall
Hyperinstall is a program that runs yarn or npm install in multiple directories. Most companies have several npm packages in a project. Whenever you update your local copy of the code, you need to run npm install in case any of these packages has different dependencies since the last time you ran npm install. Hyperinstall automates and accelerates this with one command.
Hyperinstall automatically runs yarn and npm install
$ ./npm-hyperinstall
Package "a" has been updated; installing...
...
Finished installing "a"
Package "b" has been updated; installing...
...
Finished installing "b"
Updated 2 packages:
a
bHyperinstall is efficient when your dependencies haven't changed
$ time ./npm-hyperinstall
real 0m0.232s
user 0m0.206s
sys 0m0.032sInstallation
The only prerequisite is Node.js 4.0 or newer. The best way to install Node.js is with nvm.
- Install Hyperinstall globally:
npm install -g hyperinstall. Now thehyperinstallcommand is in your path. Everyone on your team must do this. - Run
hyperinstall initin the root directory of your project, or wherever your project scripts are stored. Make sure this is a directory that is under version control and is shared with your teammates. Hyperinstall creates two files: hyperinstall.json and npm-hyperinstall. - hyperinstall.json is a configuration file containing a JSON object.
- The keys of the object are paths to npm packages in which you want Hyperinstall to run
npm install. Both absolute and relative paths are supported; relative paths are resolved relative to hyperinstall.json. - The values of the object are cache breakers. Start with 0 and bump it to 1, 2, 3, etc. if you need to force Hyperinstall to run
npm installin the respective package. This usually isn't necessary since Hyperinstall tracks whether each package's dependencies have changed since the last time it ran, but the cache breakers serve as an escape hatch if necessary. For example, if your repository were to look like this:
. ├── hyperinstall.json ├── npm-hyperinstall ├── server │ ├── index.js │ ├── node_modules │ └── package.json └── website ├── index.js ├── node_modules └── package.jsonThen to run
npm installin your server and website packages, hyperinstall.json should look like this:{ "server": 0, "website": 0 }
- npm-hyperinstall is a script that runs
yarnornpm installin each of your npm packages and can be run from anywhere. It is a shortcut forcd your/project/root && hyperinstall install. - Add
/.hyperinstall-state.jsonto your .gitignore file. This file is created by npm-hyperinstall and records the dependencies that are installed in each npm package. - After testing Hyperinstall (see the Usage section), commit hyperinstall.json, npm-hyperinstall, and .gitignore to your repository.
Usage
Run npm-hyperinstall. It will run yarn or npm install in each of your npm packages and create a file called .hyperinstall-state.json that records the dependencies that were installed.
The next time you run npm-hyperinstall, it will check if any of the packages' dependencies have changed since the last time you ran Hyperinstall. It will run npm install in each package with different dependencies. When the dependencies haven't changed at all, Hyperinstall is very fast and exits quickly.
Options
To locally force Hyperinstall to reinstall all of your npm packages, run it with -f (short for --force). Hyperinstall will first delete each package's node_modules directory before running npm install in each one.
Contributions
Contributions are welcome. We're most interested in improving the workflow so feedback in that vein is especially interesting to us. Also bug fixes are appreciated. We might be more selective with diffs that add a fair bit of complexity since we generally want Hyperinstall to be a simple script on top of yarn and npm install.
