feat: add prompt to update npm publish config#103
feat: add prompt to update npm publish config#103zcf0508 wants to merge 7 commits intoantfu-collective:mainfrom
Conversation
| if (newTag === 'latest') { | ||
| if (currentTag) { | ||
| if (Object.keys((file.data as any).publishConfig).length === 1) { | ||
| file.modified.push([['publishConfig'], undefined]) |
There was a problem hiding this comment.
I am not so sure if we should write the tag into the package.json
| registry: string | ||
| }> | ||
|
|
||
| export async function resolvePublishTag(operation: Operation) { |
There was a problem hiding this comment.
While I love this idea, I am a bit worried this could be a bit too annoying as I see 95% of the time I would want to publish to latest and in very rare cases I need to publish to a different tag (for example, when doing beta releases in another branch, I would only publish packages to the beta tag, and I could configure or update the command for a specific branch, prompting everytime can also increse the chance of mistakes).
There was a problem hiding this comment.
I have an idea that we could add a command parameter like --change-publish-tag or something.
By default, this parameter is false, and the publish tag prompt will not be shown. If mantainer wants to publish the current version to another tag like beta, he can run bumpp --chang-publish-tag locally and then the publish tag prompt will be shown to confirm the tag name.
|
Also noting that even with So my main concern is that if this would create more trouble than it would help. |
|
I just realized that adding the |
cfc7fee to
4b71649
Compare
xbetween the brackts.Description
This PR introduces a new CLI option
--npm-tagto manage the npm publish tag (e.g.,latest,beta,next) during the release process.Why?
Previously,
bumppdid not offer a built-in way to modify thepublishConfig.tagduring the version bump process. Users who needed to publish to a specific tag (common for prereleases likev1.0.0-beta.1) had to manually editpackage.jsonor rely on external scripts.When you publish a prerelease version, npm will throw an error :
npm error You must specify a tag with --tag when publishing a prerelease version.Key Changes:
New
--npm-tagOption:publishConfiginpackage.jsonis left untouched. This preserves the existing behavior and avoids accidental changes.--npm-tag): Prompts the user to confirm or input the publish tag. The default value is intelligently inferred (e.g.,betafor1.0.0-beta.1,latestfor1.0.0).--npm-tag <tag>): Directly sets the tag (e.g.,bumpp --npm-tag beta) without prompting, ideal for CI/CD or scripts.Smart Manifest Updates:
publishConfig.taginpackage.jsononly when explicitly requested via the new flag.latest, it automatically removes thetagfield frompackage.json(aslatestis the default). IfpublishConfigbecomes empty, the entire object is removed to keep the file clean.publishConfig(likeaccess: "public"), ensuring no configuration is lost.Monorepo Support:
Linked Issues
N/A
Additional context
I have added new test cases in
test/publish-tag.test.tscovering:--npm-tag.package.jsonupdate scenarios (add, update, remove tag).publishConfig(e.g.,access).