-
Notifications
You must be signed in to change notification settings - Fork 239
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
[RRFC] npm publish --if-needed
#466
Comments
Maybe we should just compare the integrity values of the built artifact and the one on the registry, and if they're the same, always say it worked? If they differ, sure, failure. But I can't imagine why you would not want We could also potentially implement this on the registry, so if we get an artifact for a version we already have, and it's identical integrity, go "yep, we got it, thanks". |
Doing what I'm asking by default would be even better but i assumed it'd be simpler to start by asking for an option :-) Doing it on the registry is fine too, but wouldn't be as repeatable for private registries, such as the one my company uses, so it might be ideal to do it in both places. |
I created can-npm-publish for working similar workflow to this RFC.
📝 I've used I think it is very good that |
During the RFC call, it seems there was strong support for making the CLI do this by default, and anyone who wishes to contribute is invited to make a PR. |
This issue describes packing, then comparing the packed tarball's checksum against the version in the registry. The tarball checksum includes file metadata, so even changing files' timestamps will create a different checksum. If the package includes lifecycle scripts that generate code on pack it's almost guaranteed to have a different checksum. Then this proposal would publish the package with a different checksum and the registry will either error with Instead I recommend calling publish and exiting 0 if the error is Alternatively npm could introduce more deterministic checksums that only change when file content changes. Then as long as the package has deterministic builds the described workflow could work. |
That is currently the case. If the file contents are identical, you should always get an identical tarball, because we strip (or exclude) any platform, time, or OS specific data from the artifact, and explicitly specify all of the compression parameters to known values. |
This would be really useful, especially with workspaces. I'm in need for this since using release-please instead of lerna for releasing. pnpm does this by default, https://pnpm.io/cli/publish#--force |
Motivation ("The Why")
My company uses CD to publish our internal npm packages. However, the publish job, if ran twice, will error the second time, because the package is already published.
If we make the job never fail, then we might be hiding other issues.
Currently, our planned workaround is similar to:
npm pack
npm show @scope/package dist.shasum
Desired Behaviour
It would be great if we could do
npm publish --repeatable
(however it's spelled) that would not fail if i'm attempting to publish the same package contents over a matching version.Thoughts?
The text was updated successfully, but these errors were encountered: