diff --git a/.changeset/tall-pans-drive.md b/.changeset/tall-pans-drive.md new file mode 100644 index 00000000..ce495691 --- /dev/null +++ b/.changeset/tall-pans-drive.md @@ -0,0 +1,5 @@ +--- +"solidui-cli": patch +--- + +Improve package manager detection using @antfu/ni diff --git a/packages/cli/package.json b/packages/cli/package.json index d350a27e..25386b53 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -40,6 +40,7 @@ "pub:release": "pnpm build && pnpm publish --access public" }, "dependencies": { + "@antfu/ni": "^0.21.12", "@babel/core": "^7.22.20", "@babel/parser": "^7.22.16", "@babel/plugin-transform-typescript": "^7.22.15", @@ -48,7 +49,6 @@ "@types/babel__core": "^7.20.2", "chalk": "^5.3.0", "commander": "^11.0.0", - "detect-package-manager": "^3.0.1", "json5": "^2.2.3", "prompts": "^2.4.2", "recast": "^0.23.4", diff --git a/packages/cli/src/lib/utils.ts b/packages/cli/src/lib/utils.ts index ec8ebfe8..b67a9378 100644 --- a/packages/cli/src/lib/utils.ts +++ b/packages/cli/src/lib/utils.ts @@ -1,8 +1,8 @@ import { execSync } from "child_process" import { readFile } from "fs" +import { detect } from "@antfu/ni" import { log, spinner } from "@clack/prompts" -import { detect } from "detect-package-manager" import JSON5 from "json5" export function readJsonFile( @@ -44,11 +44,14 @@ export function removeExtension(value: string) { } export async function installPackages(...packages: string[]) { - const packageManager = await detect() + const packageManager = await detect({ programmatic: true }) switch (packageManager) { - case "yarn": + case "bun": case "pnpm": + case "pnpm@6": + case "yarn": + case "yarn@berry": runCommand(`${packageManager} add ${packages.join(" ")}`, "Installing dependencies") break default: diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 82452af6..f83ea7d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -178,6 +178,9 @@ importers: packages/cli: dependencies: + '@antfu/ni': + specifier: ^0.21.12 + version: 0.21.12 '@babel/core': specifier: ^7.22.20 version: 7.23.0 @@ -202,9 +205,6 @@ importers: commander: specifier: ^11.0.0 version: 11.0.0 - detect-package-manager: - specifier: ^3.0.1 - version: 3.0.1 json5: specifier: ^2.2.3 version: 2.2.3 @@ -226,7 +226,7 @@ importers: version: 2.4.5 tsup: specifier: ^7.2.0 - version: 7.2.0(postcss@8.4.38)(typescript@5.1.6) + version: 7.2.0(typescript@5.1.6) typescript: specifier: ^5.1.6 version: 5.1.6 @@ -248,6 +248,11 @@ packages: '@jridgewell/gen-mapping': 0.3.3 '@jridgewell/trace-mapping': 0.3.18 + /@antfu/ni@0.21.12: + resolution: {integrity: sha512-2aDL3WUv8hMJb2L3r/PIQWsTLyq7RQr3v9xD16fiz6O8ys1xEyLhhTOv8gxtZvJiTzjTF5pHoArvRdesGL1DMQ==} + hasBin: true + dev: false + /@antfu/utils@0.7.5: resolution: {integrity: sha512-dlR6LdS+0SzOAPx/TPRhnoi7hE251OVeT2Snw0RguNbBSbjUHdWr0l3vcUUDg26rEysT89kCbtw1lVorBXLLCg==} dev: false @@ -4125,13 +4130,6 @@ packages: engines: {node: '>=8'} dev: false - /detect-package-manager@3.0.1: - resolution: {integrity: sha512-qoHDH6+lMcpJPAScE7+5CYj91W0mxZNXTwZPrCqi1KMk+x+AoQScQ2V1QyqTln1rHU5Haq5fikvOGHv+leKD8A==} - engines: {node: '>=12'} - dependencies: - execa: 5.1.1 - dev: false - /didyoumean@1.2.2: resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==} @@ -7129,6 +7127,22 @@ packages: camelcase-css: 2.0.1 postcss: 8.4.38 + /postcss-load-config@4.0.1: + resolution: {integrity: sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA==} + engines: {node: '>= 14'} + peerDependencies: + postcss: '>=8.0.9' + ts-node: '>=9.0.0' + peerDependenciesMeta: + postcss: + optional: true + ts-node: + optional: true + dependencies: + lilconfig: 2.1.0 + yaml: 2.4.1 + dev: true + /postcss-load-config@4.0.1(postcss@8.4.38): resolution: {integrity: sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA==} engines: {node: '>= 14'} @@ -8336,7 +8350,7 @@ packages: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} dev: false - /tsup@7.2.0(postcss@8.4.38)(typescript@5.1.6): + /tsup@7.2.0(typescript@5.1.6): resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==} engines: {node: '>=16.14'} hasBin: true @@ -8360,8 +8374,7 @@ packages: execa: 5.1.1 globby: 11.1.0 joycon: 3.1.1 - postcss: 8.4.38 - postcss-load-config: 4.0.1(postcss@8.4.38) + postcss-load-config: 4.0.1 resolve-from: 5.0.0 rollup: 3.27.2 source-map: 0.8.0-beta.0