adio
v1.2.1
Published
Checks if the dependencies in package.json and in the actual code are synced.
Downloads
866
Maintainers
Readme
adio
adio
(all-dependencies-in-order) is a small library that checks your code
for dependencies that are not listed in the package.json and vice-versa,
checks package.json files for dependencies that are not used in code.
Install
npm install --save adio
Or if you prefer yarn:
yarn add adio
Basic usage
Once you've installed the library, you can run the adio
command like
so:
adio --packages "components/*" --packages "packages/*"
This will check all folders located in packages
folder, eg.
packages/something-1
and packages/something-2
. If all dependencies
are in order, the process will exit with the exit code 0
, and will
print a success message. Otherwise, the exit code 1
will be returned,
and a list of all issues will be printed in the console.
Configuration files
Even though it can be done via the CLI, parameters can also
be set via the .adiorc.js
or similar cosmiconfig supported config
types (eg. .adiorc.json
or even via the adio
key in package.json
),
placed in the current working directory. This is often a better
alternative to passing parameters inline via the CLI.
By just creating a following .adiorc.json
file in the current working
directory...
{
"packages": ["packages/*", "components/*", "..."]
}
and then running the adio
command in the same directory, we can
achieve the same effect as by manually running the previsuly shown
adio --packages "components/*" --packages "packages/*"
command.
This way will also make it easier to pass in additional config parameters.
Additional configuration parameters
- ignoreDirs: Array containing directories to ignore. By default,
adio
ignores['node_modules']
- ignore: Object containing dependencies for
adio
to ignore.- src: dependencies to ignore in source files. This can be an array of strings or simply
true
to ignore checking all deps in source files - dependencies: ignore
dependencies
inpackage.json
. This can be an array of strings, to ignore certain deps, or simplytrue
to ignore checking alldependencies
frompackage.json
- devDependencies: ignore
devDependencies
inpackage.json
. This can be an array of strings, to ignore certain deps, or simplytrue
to ignore checking alldevDependencies
frompackage.json
- peerDependencies: ignore
peerDependencies
inpackage.json
. This can be an array of strings, to ignore certain deps, or simplytrue
to ignore checking allpeerDependencies
frompackage.json
- src: dependencies to ignore in source files. This can be an array of strings or simply
- parser: any options to pass to
@babel/parser
see here for available options
A more comprehensive .adiorc
might look like this:
{
"packages": ["packages/*"],
"ignoreDirs": ["node_modules", "dist", "coverage"],
"ignore": {
"src": ["path", "url", "http"],
"devDependencies": true,
"peerDependencies": true
},
"parser": {
"plugins": ["typescript", "optionalChaining", "numericSeparator", "classProperties"]
}
}
Configuration Overriding
It is common to have an adio
configuration at the root of a monorepo. Then, say I did want adio
to check peerDependencies
usage in a particular package, I could extend the configuration above by adding a package local packages/*/.adiorc
like so:
{
"ignore": {
"peerDependencies": false
}
}