npm / npm/rfcs

[RRFC] Include gitHead when publishing from subdirectories

Open
#412 3 comments 0 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")

When publishing from workspaces, it is still desirable to have gitHead still set, for all the reasons it was desirable without them. (Specifically, that published packages can be correlated with a specific commit in the source repo.) This is described in terms of subdirectories and not workspaces because supporting this without requiring a workspace definition would allow monorepos that npm does not manage to still be published with gitHead. This is most commonly the case when pnpm is used as it calls npm publish from its own workspace folders under the hood.

Example
$ git init
$ mkdir packages
$ npm init -y
$ git add package.json
$ git commit -minitial
$ npm publish
How
Current Behaviour

Currently gitHead is read only if there is a .git folder in the same directory as the package.json

Desired Behaviour

npm should scan up the directory tree looking for a .git folder the same way git itself does.

References
  • n/a

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

Reproduce the example with npm publish from the packages subdirectory and inspect the publish path that currently checks for .git beside package.json. Compare the lookup with how Git finds a repository parent; done means publishing from a subdirectory records the repository commit in gitHead without requiring an npm workspace.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, javascript
Domain
cli, release, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.