feat(publish): add --include-private option for testing private packages #3503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds an option
--include-private
tolerna publish
. This allows packages marked as"private": true
in package.json to be published. Since npm does not allow publishing packages with"private": true
, lerna will strip out the property before the publish.The option accepts a list of package names to be included in the publish. The packages provided are only published if those packages are deemed necessary to publish, as is consistent with lerna's existing publish behavior. Alternatively, a "*" can be provided, telling lerna to allow any private package to be published.
$ lerna publish from-git --include-private my-private-package my-other-private-package $ lerna publish from-git --include-private "*"
Motivation and Context
This allows for the ability to publish packages that are currently private, but will be public in the future. This is useful for end to end testing. These packages can now be published to a locally hosted npm repository and downloaded for real in the end to end tests, all before the package is ready for publishing on the public npm repository.
Lerna's official stance on publishing private packages (and that you shouldn't do it) wouldn't change with this PR. If a package is meant to be published, then it is by definition "public", which means it should not have
"private": true
in package.json (as described in the npm docs). However, this strict implementation by lerna leaves no room for the specific use case outlined above - for packages that will be public, but aren't yet.Therefore, this option is meant to be used as a workaround in CI pipelines for testing purposes, not for consistently publishing private packages to actual public repos.
Note that this PR is talking about packages with
"private": true
in package.json, which is different than npm's idea of scoped private packages.How Has This Been Tested?
This has been tested manually and covered by e2e tests.
Types of changes
Checklist: