question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Separate "version" and "publish" commands

See original GitHub issue

Lerna 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:

  1. 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
  2. If you’re comfortable breaking the publish CLI for 2.x users, you could avoid adding any additional options to publish and just move all of the versioning logic over to a new version command.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:49
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

15reactions
evocateurcommented, May 11, 2018

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 conflates npm version and npm publish because that’s exactly what yarn publish does, and lerna publish was created by the creator of yarn. (Again, I disagree with that design decision, it’s just …a big piece of code…)

15reactions
evocateurcommented, Aug 23, 2017

I am certainly sympathetic to this request, though I’m not ready to do a breaking change for it…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version and Publish - Lerna
Versioning​. Lerna comes with a version command that allows you to increment your package's version number, commit the changes and tag them accordingly....
Read more >
JS monorepos in prod 2: project versioning and publishing
Prompts the user a choice of version for each package since those are managed independently. · Saves the version inside the package.json files....
Read more >
Bump version and publish packages from one branch but ...
publish command does two things: updates versions in package.json files of changed packages, in root package.json and lerna.json and commits ...
Read more >
How to Publish an Updated Version of an npm Package
The publish command will add the updated package to the npm registry. ... so if you ever migrate to another version control provider, ......
Read more >
dotnet publish command - .NET CLI | Microsoft Learn
To make publish output go to separate folders for each project, specify a relative path by using the msbuild PublishDir property instead of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found