- Update the library.
- Commit your work, but do not push to Github.
changedcommand to verify changes to packages.
versioncommand to amend last commit.
publishcommand to publish updated packages to npmjs.com.
- Push latest commits to Github.
When you're done making changes to a library, you can commit your changes as usual. DO NOT push changes to Github yet.
Once that's done, check for packages that Lerna can publish new versions of:
yarn run lerna changed
This command will show all the packages that have changed since the last release. You can also use the
diff command to
see the diff between current version and the last published version.
Once you've confirmed the changes, you can use the
version command to amend the last commit, to include version bumps.
yarn run lerna version --amend
This command will ask you how to change the version of changed packages. It'll then update the last commit, changing versions as per your instruction and also tagging the commit.
Once the commit is ready, you can use it to publish updated packages to npmjs.com. If you haven't logged into npmjs.com
prior to this, you'll need to login with the
npm login command before publishing.
yarn run lerna publish from-git
This command will read the version info from the repo, and publish packages.
Don't forget to push the commit to Github as well!
Why use the version command?
Why bother with
version? Why not just run
publish and allow it to set the version?
publish [bump] after committing your changes will cause lerna to create a new commit which includes the
version bump and the git tags. Using the
version command allows us to avoid this extra commit which lets the git
history be just a little bit less noisy.