-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: unpublish bugfixes #7039
fix: unpublish bugfixes #7039
Conversation
- Properly work in workspace mode. Previously setting the workspace meant the entire package was unpublished. Now it follows the convention of acting as if you were running from the workspace directory. - Better checking of when you are unpublishing the last version of a package. npm checks the actual manifest and compares it to the version you are asking to unpublish. - Error on ranges and tags. npm doesn't unpublish ranges or tags, and giving those as inputs would give unexepected results. - Proper output of what was unpublished. Previously the package (and sometimes version) displayed would not match what was actually unpublished. - Updated docs specifying that unpublishing with no parameters will only unpublish the version represented by the local package.json
3f47b3d
to
28536fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great tests and comments made this easy to follow along.
If you specify a package name but do not specify a version or if you | ||
remove all of a package's versions then the registry will remove the | ||
root package entry entirely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you specify a package name but do not specify a version or if you | |
remove all of a package's versions then the registry will remove the | |
root package entry entirely. | |
If you specify a package name but do not specify a version then the | |
registry will remove the root package entry entirely. The same applies | |
if you unpublish the last remaining version of a package. |
let spec | ||
if (args.length) { | ||
spec = npa(args[0]) | ||
if (spec.type !== 'version' && spec.rawSpec !== '*') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec.rawSpec !== '*'
💭 Looks like *
is a specific case of a range
spec. Would a isEntireRange
method on the npm-package-arg response be useful, particularly if there's ever another rawSpec value that also selects the entire range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*
is a special snowflake (no pun intended) within npm spec parsing and it always means "one version, the best version you can give me" npm 9 even had a breaking change where the few places we were NOT doing that (i.e. x
and x@
) now parse exactly as if you typed x@*
.
if (manifest?.name === spec.name && manifest.publishConfig) { | ||
flatten(manifest.publishConfig, opts) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Check pkgVersion
and throw the Refusing to delete entire project
usageError here, and get rid of the separate spec/non-spec checks above.
- Properly work in workspace mode. Previously setting the workspace meant the entire package was unpublished. Now it follows the convention of acting as if you were running from the workspace directory. - Better checking of when you are unpublishing the last version of a package. npm checks the actual manifest and compares it to the version you are asking to unpublish. - Error on ranges and tags. npm doesn't unpublish ranges or tags, and giving those as inputs would give unexepected results. - Proper output of what was unpublished. Previously the package (and sometimes version) displayed would not match what was actually unpublished. - Updated docs specifying that unpublishing with no parameters will only unpublish the version represented by the local package.json
- Properly work in workspace mode. Previously setting the workspace meant the entire package was unpublished. Now it follows the convention of acting as if you were running from the workspace directory. - Better checking of when you are unpublishing the last version of a package. npm checks the actual manifest and compares it to the version you are asking to unpublish. - Error on ranges and tags. npm doesn't unpublish ranges or tags, and giving those as inputs would give unexepected results. - Proper output of what was unpublished. Previously the package (and sometimes version) displayed would not match what was actually unpublished. - Updated docs specifying that unpublishing with no parameters will only unpublish the version represented by the local package.json
meant the entire package was unpublished. Now it follows the
convention of acting as if you were running from the workspace
directory.
package. npm checks the actual manifest and compares it to the
version you are asking to unpublish.
giving those as inputs would give unexepected results.
sometimes version) displayed would not match what was actually
unpublished.
only unpublish the version represented by the local package.json
Closes: #7015