npm / npm/cli

[FEATURE](libnpmversion) Preserve build metadata, and perhaps provide a way to set it

Open
#4,257 1 comment 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement Priority Backlog ws:libnpmversion
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

What / Why

Preserve semver build metadata if specified, rather than stripping it off.

It's perfectly safe to publish a package with build metadata in the package.json (since we strip it at every other place versions are consumed or analyzed).

Current Behavior
npm version 1.0.0+build.1

Writes "version": "1.0.0" to package.json.

How

  • If a version is specified, then do not strip build metadata from it.
  • Instead of passing the version through semver.valid() (which strips build metadata), use semver.parse() and stringify it in such a way that build metadata is preserved. (May benefit from an upgrade to node-semver to make a "blessed" way to do this, rather than sniffing the object and manually appending the string.)
  • Include build metadata in git tag/commit as well as package.json file.
  • (maybe?) add a buildMetadata field to the options this module accepts, so you could do something like npm version patch --build-metadata=foo.bar.1.3.0xCAFEBAD to append build metadata while programmatically bumping the version.

References

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 in libnpmversion and trace the handling of a specified version through semver.valid() and semver.parse(). Check how package.json versions and git tags or commits are written. Done means preserving build metadata in package.json and the related git tag/commit, with the optional buildMetadata setting considered separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, release
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.