npm / npm/rfcs

[RRFC] `npm publish --if-needed`

Open
#466 7 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

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:

  1. npm pack
  2. npm show @scope/package dist.shasum
  3. if there is a version, confirm the tarball's shasum matches the published one and succeed, else fail
  4. else, publish (and fail if the publish fails)
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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed workflow in this issue: npm pack, npm show @scope/package dist.shasum, and npm publish. Clarify the RFC's command spelling and behavior for matching versus differing package contents, then document acceptance criteria for repeatable publishes and failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, release
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.