Workflow for test-publishing to a local registry, e.g. Verdaccio
See original GitHub issueAs discussed on https://github.com/lerna/lerna/issues/805 there’s no Lerna “unpublish” command or general support for overwriting an existing published version because lerna publish
is intended for best-practice publication to a public registry like NPM.
I’m wondering what would be a good approach for test-publishing to a local registry, such as Verdaccio running on http://localhost:4873
, where you might want to repeatedly publish locally to the same version number, until the published version works as intended and you are ready to publish a real new version to the public repository.
Is there an intended approach for this? There are lots of good pointers on using things like from-git
and from-package
with CI but I can’t see anything clean for this case.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7
Top GitHub Comments
lerna publish
was meant to do a lot. And that’s OK. Personally, I think it’s an unnecessary risk having to add several flags to suppress “production” behaviors (I could end up publishing git tags to remote unknowingly).I’d rather play on the safe side, using
lerna exec "npm publish …"
It executes commands in a bottom-up way, so leaf packages are executed first, which is perfect for my use case. Below is a pretty much generic solution, that publishes all packages to Verdaccio, then unpublishes them. You can use additional heuristics for version numbers and all.
@gaurav5430 so you can simply run:
Currently I’m experimenting with something like this, which seems to work reasonably well for my case (several prepublish and postpublish scripts, plus a
create-*
package intended to be used from the registry withnpm init
oryarn create
). I’ve also seen similar scripts to mylocal-unpublish-all
in the wild:local-publish
puts all packages on the local registry without changing tags (bumps versions by default but that can be undone with a hard git reset), andlocal-unpublish
removes the latest version of each package from the local registry.local-unpublish-all
nukes all the packages on the local registry in case something went wrong.So the usual workflow to test that everything in a branch works correctly when published and pulled from a registry is:
npm run local-unpublish
, unless there’s nothing on the local registry (e.g. if this is the first time this has been done orlocal-unpublish-all
has been done to start again after something went wrong)npm run local-publish
, optionally passing a version number if all packages are intended to be locally published to the same version, e.g.npm run local-publish 0.0.1
Is there anything existing or in the roadmap that fits this kind of local testing better than the above?