Β§ Quick Take
lerna add
runs a whole chain of actions redundantly validating the packages and calling the internet.
We want the β npm i
but for packages within our monorepo!
That's what this CLI does:
deplink "detergent"
That's it. For example, symlink is created at "monorepo-root/packages/object-all-values-equal-to/node_modules/detergent" pointing to "monorepo-root/packages/detergent".
As you expect, package.json
is updated, CLI's are linked properly to bin/
and devDeps can be set via a flag:
deplink "detergent" -d
deplink "detergent" --dev
π»πΊπͺπΌπ₯π»ππ»
Β§ Supports CLI's
If your package ("b" from the example above) is a CLI, symlinks will be put one level deeper, instead of within node_modules
, for each entry in bin
from package.json, a symlink will be created in node_modules/.bin/
, pointing not to the root of the package "b" but straight to the file that bin
entry in package.json was pointing to.
For example, lerna-clean-changelogs-cli
of ours has the following bin
entry in its package.json
:
"bin": {
"lcc": "cli.js",
"lernacleanchangelog": "cli.js"
}
If you git-cloned our monorepo and wanted to link package lerna-clean-changelogs-cli
to another package, two symlinks would be created, one for lcc
and another for lernacleanchangelog
, both pointing to the same file, cli.js
.
PS. If you wonder, what happens if a package is both CLI and normal package (has both "main" and "bin" keys in package.json
)? It will still work β both sets of symlinks will be created.
π»πΊπͺπΌπ»πͺπΌπ»π₯
Β§ Against lerna link
According to lerna link documentation , lerna link
"symlinks together all packages that are dependencies of each other". But we want just to symlink one!
By the way, it's not just me, people complain about it at Lerna's issues board here , here and here .
Well, now those days are gone, we have a simple dependency linker at last.
πΊπ₯π»πͺπΌπ»π»πͺπΌπ»
Β§ The finest ingredients
Only the finest ~dependencies~ ingredients are used in this CLI:
fs-extra
- for promise-based I/Oexeca
- to run shell processes, theln -s
partmeow
- to bootstrap the CLIupdate-notifier
- to remind users if currently installed CLI is outdated
π»πͺπΌπ»π»πͺπΌπ»π₯
Β§ Changelog
See it in the monorepo , on GitHub.
Β§ Contributing
To report bugs or request features or assistance, raise an issue on GitHub .
Any code contributions welcome! All Pull Requests will be dealt promptly.
Β§ Licence
Copyright Β© 2010β2021 Roy Revelt and other contributors
Related packages:
npm-check-updates
but supports Lerna monorepos and enforces strict semver valuescommitizen
generated changelogs