A small wrapper around lerna that makes it easier to use in CI
yarn add --dev monodeploy
npm install --save-dev monodeploy
As a monorepo manager, lerna is a great tool, but it's not necessarily easy to use in CI if you want to publish all your packages every master build. Here are some problems you might encounter:
lerna publishin CI pushes back to your git repository, which may fail if commits have been pushed to your master branch in the meantime.
- lerna requires all package versions to be stored in your repository, in their respective package.json files, therefore it's not possible to simply skip pushing to git from CI by using the
--no-pushoption when publishing.
monodeploy allows you to publish NPM packages from a monorepo in CI, using lerna, on every single master build, without storing your version numbers in your package.json files and without having CI commit back to your repo.
We could argue back and forth about whether or not it's good idea to publish NPM packages every single build to master (maybe
--canary builds would be better), and we could certainly agree that not storing version numbers in package.json files is confusing, but in some cases the benefits of such a scheme outweigh the shortcomings, and monodeploy is intended to suit those scenarios.
How does monodeploy work?
monodeploy uses the registry as the single source of truth for package version numbers. At a high level, it does the following:
- Use lerna to determine which packages need to be published
- Retrieve the latest versions of these packages from the registry
- Update the package.json files for these packages with the latest version numbers from the registry
- Use lerna to bump the package versions and publish to the registry without commiting to the repo or pushing to the remote
- Create git tags for each newly published package
- Output a JSON list of all packages in your monorepo, including their latest version numbers.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Special thanks to Carol Skelly for donating the 'tophat' GitHub organization.