A CLI tool for removing unused dependencies, sorting the dependencies, locking the dependencies, and keeping a watch on the licenses.
$ npm install -g patroller
$ patroller COMMAND
running command...
$ patroller (-v|--version|version)
patroller/1.1.0 darwin-x64 node-v12.16.3
$ patroller --help [COMMAND]
USAGE
$ patroller COMMAND
...
-h | --help
: shows the CLI help-v | --version
: shows the CLI version-s | --sort
: sorts the dependencies in package.json-u | --unused
: removes the unused dependencies from node_modules and the package.json-l | --lock
: locks the dependencies in package.json and removes the wildcard ( ^ )--license
: checks the dependencies for difference in license from the root repository-a | --all
: performs all the actions above (except help and version)--yarn
: uses yarn instead of npm-f | --force
: forcefully removes unused dependencies
Use it in the package.json
for the CI CD to keep your dependencies clean.
{
...
"scripts": {
"patroller": "patroller --all --force"
}
}
Install husky
$ npm install husky --save-dev
Update the package.json
{
"scripts": {
"patroller": "patroller --all --force"
},
"husky": {
"hooks": {
"pre-commit" : "npm patroller"
}
}
}