Skip to content

Commit

Permalink
switch from preferred-pm to package-manager-detector (changesets#…
Browse files Browse the repository at this point in the history
…1446)

* chore: switch from preferred-pm to package-manager-detector

* avoid subpath import

* Update .changeset/slow-avocados-promise.md

---------

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
benmccann and Andarist authored Aug 28, 2024
1 parent 4efc038 commit 5150fc1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-avocados-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/cli": patch
---

Switched from `preferred-pm` to `package-manager-detector` in order to reduce installation size
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"mri": "^1.2.0",
"outdent": "^0.5.0",
"p-limit": "^2.2.0",
"preferred-pm": "^3.0.0",
"package-manager-detector": "^0.2.0",
"resolve-from": "^5.0.0",
"semver": "^7.5.3",
"spawndamnit": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/publish/npm-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExitError } from "@changesets/errors";
import { error, info, warn } from "@changesets/logger";
import { AccessType, PackageJSON } from "@changesets/types";
import pLimit from "p-limit";
import preferredPM from "preferred-pm";
import { detect } from "package-manager-detector";
import chalk from "chalk";
import spawn from "spawndamnit";
import semverParse from "semver/functions/parse";
Expand Down Expand Up @@ -44,7 +44,7 @@ function getCorrectRegistry(packageJson?: PackageJSON): string {
async function getPublishTool(
cwd: string
): Promise<{ name: "npm" } | { name: "pnpm"; shouldAddNoGitChecks: boolean }> {
const pm = await preferredPM(cwd);
const pm = await detect({ cwd });
if (!pm || pm.name !== "pnpm") return { name: "npm" };
try {
let result = await spawn("pnpm", ["--version"], { cwd });
Expand Down
43 changes: 6 additions & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3655,14 +3655,6 @@ find-up@^5.0.0:
locate-path "^6.0.0"
path-exists "^4.0.0"

find-yarn-workspace-root2@^1.2.11:
version "1.2.11"
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root2/-/find-yarn-workspace-root2-1.2.11.tgz#b14a8be43503ec8c0cdf7f5923a3534860bdd92e"
integrity sha512-TkwH3kDD1Z8X9LnrU3gbyYw8KtLZZjsym6c2YIRFCDIMJD1JL9+Blkzpm07db+Q6ZVLISqrW9cN0CvXN4rr5ag==
dependencies:
micromatch "^4.0.2"
pkg-dir "^4.2.0"

fixturez@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fixturez/-/fixturez-1.1.0.tgz#37d5ecc830c9513907d8fdafb774751acf74db1a"
Expand Down Expand Up @@ -5046,7 +5038,7 @@ js-tokens@^4.0.0:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.6.1:
js-yaml@^3.13.1, js-yaml@^3.6.1:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
Expand Down Expand Up @@ -5195,16 +5187,6 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

load-yaml-file@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/load-yaml-file/-/load-yaml-file-0.2.0.tgz#af854edaf2bea89346c07549122753c07372f64d"
integrity sha512-OfCBkGEw4nN6JLtgRidPX6QxjBQGQf72q3si2uvqyFEMbycSFFHwAZeXx6cJgFM9wmLrf9zBwCP3Ivqa+LLZPw==
dependencies:
graceful-fs "^4.1.5"
js-yaml "^3.13.0"
pify "^4.0.1"
strip-bom "^3.0.0"

locate-path@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
Expand Down Expand Up @@ -5799,6 +5781,11 @@ package-json@^6.5.0:
registry-url "^5.0.0"
semver "^6.2.0"

package-manager-detector@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/package-manager-detector/-/package-manager-detector-0.2.0.tgz#160395cd5809181f5a047222319262b8c2d8aaea"
integrity sha512-E385OSk9qDcXhcM9LNSe4sdhx8a9mAPrZ4sMLW+tmxl5ZuGtPUcdFu+MPP2jbgiWAZ6Pfe5soGFMd+0Db5Vrog==

parent-module@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
Expand Down Expand Up @@ -5969,16 +5956,6 @@ posix-character-classes@^0.1.0:
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=

preferred-pm@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/preferred-pm/-/preferred-pm-3.0.0.tgz#26cc7fbbfc1815e4cb8272d5fdde15dc96220fb8"
integrity sha512-NbN+2UuqjakJpyHamsuIWyeFdQcFUQHF9nkw16hpFE++z3px+/KDsj+AF1h0BlnsBJi1Z5U4EKBW7XnHriny8g==
dependencies:
find-up "^4.1.0"
find-yarn-workspace-root2 "^1.2.11"
path-exists "^4.0.0"
which-pm "2.0.0"

prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
Expand Down Expand Up @@ -7275,14 +7252,6 @@ which-boxed-primitive@^1.0.2:
is-string "^1.0.5"
is-symbol "^1.0.3"

which-pm@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/which-pm/-/which-pm-2.0.0.tgz#8245609ecfe64bf751d0eef2f376d83bf1ddb7ae"
integrity sha512-Lhs9Pmyph0p5n5Z3mVnN0yWcbQYUAD7rbQUiMsQxOJ3T57k7RFe35SUwWMf7dsbDZks1uOmw4AecB/JMDj3v/w==
dependencies:
load-yaml-file "^0.2.0"
path-exists "^4.0.0"

which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
Expand Down

0 comments on commit 5150fc1

Please sign in to comment.