Skip to content

Commit 6b36e0b

Browse files
Improve package manager detection using @antfu/ni (#85)
* feat: improved package manager detection using @antfu/ni `detect-package-manager` is too naive relates to: #38. * Create tall-pans-drive.md --------- Co-authored-by: Stefan E-K <stefan.eideloth@gmail.com>
1 parent 74dc9ed commit 6b36e0b

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

.changeset/tall-pans-drive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"solidui-cli": patch
3+
---
4+
5+
Improve package manager detection using @antfu/ni

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"pub:release": "pnpm build && pnpm publish --access public"
4141
},
4242
"dependencies": {
43+
"@antfu/ni": "^0.21.12",
4344
"@babel/core": "^7.22.20",
4445
"@babel/parser": "^7.22.16",
4546
"@babel/plugin-transform-typescript": "^7.22.15",
@@ -48,7 +49,6 @@
4849
"@types/babel__core": "^7.20.2",
4950
"chalk": "^5.3.0",
5051
"commander": "^11.0.0",
51-
"detect-package-manager": "^3.0.1",
5252
"json5": "^2.2.3",
5353
"prompts": "^2.4.2",
5454
"recast": "^0.23.4",

packages/cli/src/lib/utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { execSync } from "child_process"
22
import { readFile } from "fs"
33

4+
import { detect } from "@antfu/ni"
45
import { log, spinner } from "@clack/prompts"
5-
import { detect } from "detect-package-manager"
66
import JSON5 from "json5"
77

88
export function readJsonFile(
@@ -44,11 +44,14 @@ export function removeExtension(value: string) {
4444
}
4545

4646
export async function installPackages(...packages: string[]) {
47-
const packageManager = await detect()
47+
const packageManager = await detect({ programmatic: true })
4848

4949
switch (packageManager) {
50-
case "yarn":
50+
case "bun":
5151
case "pnpm":
52+
case "pnpm@6":
53+
case "yarn":
54+
case "yarn@berry":
5255
runCommand(`${packageManager} add ${packages.join(" ")}`, "Installing dependencies")
5356
break
5457
default:

pnpm-lock.yaml

Lines changed: 27 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)