Separate "version" and "publish" commands
See original GitHub issueLerna needs a separate version
command.
Why
Folks who use npm a lot are probably comfortable with the separation between the npm version
and npm publish
commands. For me, this separation is important because it allows me to double- and triple-check things before publishing. When versioning and publishing a monorepo with dozens of packages, the “publish anxiety” factor is even higher. I’ve worked through some of that anxiety with various permutations of --skip-git
and --skip-npm
then git diff
, but at some point you have to git reset
and just trust that Lerna is going to do the right thing.
The other problem is that Lerna doesn’t make it easy (possible?) to just publish all of the packages using the existing package.json
versions. AFAICT, it’s not possible to skip the increment step, which means that you have to run something like this instead:
lerna exec --bail=false npm publish
…which will output a lot of scary npm publish
error messages for any of your packages that haven’t been bumped since the last release.
We recently introduced a CI-driven automated publishing workflow in Primer, and to get around this we resorted to running a try-publish
script, which would only run npm publish
if the version in each module’s package.json
hadn’t already been published. Other teams that want to automate publishing will inevitably run into the same issue, and it would stink if they all ended up having to come up with their own solutions for it.
How
There are a couple of ways to go about this:
-
To maintain backwards compatibility with the current CLI API, the
publish
command could introduce two new options:- one that does everything but the git and npm steps, e.g.
lerna publish --skip-publish
- one that only publishes without touching any
package.json
files, e.g.lerna publish --skip-version
- one that does everything but the git and npm steps, e.g.
-
If you’re comfortable breaking the
publish
CLI for 2.x users, you could avoid adding any additional options topublish
and just move all of the versioning logic over to a newversion
command.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:49
- Comments:17 (10 by maintainers)
I agree that the two should be split. I got started on it a couple weeks ago, but then I stalled (pesky day job/infant son): https://github.com/lerna/lerna/compare/master...evocateur:split-version-from-publish
Historically, I’m fairly certain
lerna publish
conflatesnpm version
andnpm publish
because that’s exactly whatyarn publish
does, andlerna publish
was created by the creator ofyarn
. (Again, I disagree with that design decision, it’s just …a big piece of code…)I am certainly sympathetic to this request, though I’m not ready to do a breaking change for it…