dir2pkg
Small CLI to help to split big JS codebases into packages.
Moves dirs, creates boilerplate and creates the "dependencies" field of the new package with these benefits:
- 🧹 dependencies used in the code but missing from the package.json are added.
- ➕ only dependencies used in the code are listed.
- ➖ dependencies not used in the code are removed.
Install
Node.js v16.13 or newer is required.
Via the yarn client:
$ yarn global add dir2pkg
Via the npm client:
$ npm install -g dir2pkg
Usage
$ dir2pkg --in-dir some-dir --out-dir packages/some-dir --pkg-json-name "@org/new-pkg" --pkg-json-path ./package.json
--in-dir, -i
$ dir2pkg --in-dir some-dir
In directory
--out-dir, -o
$ dir2pkg --out-dir packages/some-dir
Out directory
--pkg-json-name, -n
$ dir2pkg --pkg-json-name "@org/new-pkg"
Package name
--pkg-json-path, -j
$ dir2pkg --pkg-json-path ./package.json
Host package.json path
--ignore, -d
$ dir2pkg --ignore "shared" --ignore "@org/internal-alias"
List of dependencies to ignore. Useful for ignoring internal alias that can't be resolved to one node_modules dep.
--force-peer-dep, -f
$ dir2pkg --force-peer-dep react --force-peer-dep react-dom
List of dependencies to force as peer dependencies. Useful for libraries like react.
Development
$ yarn
$ yarn build --watch
$ yarn link
$ dir2pkg --help