Repository navigation
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2047 +/- ##
==========================================
+ Coverage 83.85% 84.18% +0.32%
==========================================
Files 56 56
Lines 2465 2491 +26
Branches 748 760 +12
==========================================
+ Hits 2067 2097 +30
+ Misses 392 388 -4
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
thanks for the PR! i have been considering rewriting the info fetching functionality to just use fetch to call the npm registry, as it should speed things up considerably to not have to start new processes for each call. however that would require us being able to know which registry to call for each package which is not the simplest thing... |
I looked into this when working on #1845 and just gave up. We could do this but it would require us to reverse-engineer quite a bit around how the CLIs handle |
|
Sounds like something a new package could do... |
mhmmm true that would be miles nicer that what I've whacked together 😅 I wonder whether something like https://github.com/npm/npm-registry-fetch would solve the problem 🤔 |
|
@zbrydon we plan to release v3 by the end of the month. I'm refactoring this stuff as we speak - and while it might not address everything yet... any further work should target that refactor. I'll open some PRs over the weekend and ping you for review/input. |
|
This is going to be superseded by #2097 where I'm working on a more holistic revamp of what package manager commands are invoked (and how). |
* chore(deps): update dependency node to v7 * go back to packageManager for now: changesets/changesets#2047 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Sam Chung <samchungy@gmail.com>
Issue
Resolves #965
Problem
The
getPackageInfofunction in the publish command always usesnpm infoto query package metadata, regardless of which package manager the project is configured to use.Projects can declare their package manager using either the
packageManagerfield or thedevEngines.packageManagerfield in package.json:{ "packageManager": "pnpm@10.12.1" } OR { "devEngines": { "packageManager": { "name": "pnpm", "version": ">=10", "onFail": "error" } } }The devEngines field is an OpenJS Foundation standard for declaring package manager and runtime requirements during development.
Because
npm infois always used, projects that rely on pnpm or Yarn-specific registry configuration and authentication may fail or behave incorrectly. Both pnpm and Yarn provide their own info commands that respect their configured registries and credentials.The publish workflow should use the project's configured package manager when querying package metadata.
What changed
Added
getInfoTool(cwd)to detect the project's package manager usingdetect({ cwd })and map it to:npmpnpmyarn-classicyarn-berryUpdated
getPackageInfoto use the appropriate package manager command:npm / pnpm
Yarn Berry
Registry configuration is read from
.yarnrc.yml.Yarn Classic
Handles Yarn v1's
{ type: "inspect", data }response format and treats{ type: "error" }as a package-not-found result.Extended
isEmptyResultto recognize Yarn Classic error responses, ensuring the existing two-query fallback and E404 normalization logic continue to work correctly.Threaded
cwdthrough:so package manager detection always runs relative to the project root.
Testing
New unit tests cover: