dir2pkg

1.0.0-beta.2 • Public • Published

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.

demo of dir2pkg

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

# install deps
$ yarn
# build and watch for changes
$ yarn build --watch
# link dir2pkg globally
$ yarn link
# enjoy!
$ dir2pkg --help

Readme

Keywords

none

Package Sidebar

Install

npm i dir2pkg

Weekly Downloads

0

Version

1.0.0-beta.2

License

MIT

Unpacked Size

36.7 kB

Total Files

10

Last publish

Collaborators

  • ramasilveyra