summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/rich-singers-accept.md5
-rw-r--r--packages/upgrade/package.json9
-rw-r--r--packages/upgrade/src/actions/context.ts4
-rw-r--r--packages/upgrade/src/messages.ts4
-rw-r--r--pnpm-lock.yaml19
5 files changed, 25 insertions, 16 deletions
diff --git a/.changeset/rich-singers-accept.md b/.changeset/rich-singers-accept.md
new file mode 100644
index 000000000..d69ac5446
--- /dev/null
+++ b/.changeset/rich-singers-accept.md
@@ -0,0 +1,5 @@
+---
+"@astrojs/upgrade": patch
+---
+
+Fixes @astrojs/upgrade not using the package manager that was used to install the project to install dependencies
diff --git a/packages/upgrade/package.json b/packages/upgrade/package.json
index c396409e1..22894e641 100644
--- a/packages/upgrade/package.json
+++ b/packages/upgrade/package.json
@@ -22,21 +22,18 @@
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "astro-scripts test \"test/**/*.test.js\""
},
- "files": [
- "dist",
- "upgrade.js"
- ],
+ "files": ["dist", "upgrade.js"],
"//a": "MOST PACKAGES SHOULD GO IN DEV_DEPENDENCIES! THEY WILL BE BUNDLED.",
"//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
"dependencies": {
"@astrojs/cli-kit": "^0.4.1",
"semver": "^7.6.2",
- "which-pm-runs": "^1.1.0",
+ "preferred-pm": "^3.1.3",
"terminal-link": "^3.0.0"
},
"devDependencies": {
"@types/semver": "^7.5.8",
- "@types/which-pm-runs": "^1.0.2",
+ "@types/preferred-pm": "^3.0.0",
"arg": "^5.0.2",
"astro-scripts": "workspace:*",
"strip-ansi": "^7.1.0"
diff --git a/packages/upgrade/src/actions/context.ts b/packages/upgrade/src/actions/context.ts
index 775c552c0..9c229a363 100644
--- a/packages/upgrade/src/actions/context.ts
+++ b/packages/upgrade/src/actions/context.ts
@@ -1,7 +1,7 @@
import { pathToFileURL } from 'node:url';
import { prompt } from '@astrojs/cli-kit';
import arg from 'arg';
-import detectPackageManager from 'which-pm-runs';
+import detectPackageManager from 'preferred-pm';
export interface Context {
help: boolean;
@@ -38,7 +38,7 @@ export async function getContext(argv: string[]): Promise<Context> {
{ argv, permissive: true }
);
- const packageManager = detectPackageManager()?.name ?? 'npm';
+ const packageManager = (await detectPackageManager(process.cwd()))?.name ?? 'npm';
const {
_: [version = 'latest'] = [],
'--help': help = false,
diff --git a/packages/upgrade/src/messages.ts b/packages/upgrade/src/messages.ts
index 4f396422e..4fe181094 100644
--- a/packages/upgrade/src/messages.ts
+++ b/packages/upgrade/src/messages.ts
@@ -1,8 +1,8 @@
/* eslint no-console: 'off' */
import { color, label, spinner as load } from '@astrojs/cli-kit';
import { align } from '@astrojs/cli-kit/utils';
+import detectPackageManager from 'preferred-pm';
import terminalLink from 'terminal-link';
-import detectPackageManager from 'which-pm-runs';
import type { PackageInfo } from './actions/context.js';
import { shell } from './shell.js';
@@ -14,7 +14,7 @@ let _registry: string;
export async function getRegistry(): Promise<string> {
if (_registry) return _registry;
const fallback = 'https://registry.npmjs.org';
- const packageManager = detectPackageManager()?.name || 'npm';
+ const packageManager = (await detectPackageManager(process.cwd()))?.name || 'npm';
try {
const { stdout } = await shell(packageManager, ['config', 'get', 'registry']);
_registry = stdout?.trim()?.replace(/\/$/, '') || fallback;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 283188b8c..990982252 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -5691,22 +5691,22 @@ importers:
'@astrojs/cli-kit':
specifier: ^0.4.1
version: 0.4.1
+ preferred-pm:
+ specifier: ^3.1.3
+ version: 3.1.3
semver:
specifier: ^7.6.2
version: 7.6.2
terminal-link:
specifier: ^3.0.0
version: 3.0.0
- which-pm-runs:
- specifier: ^1.1.0
- version: 1.1.0
devDependencies:
+ '@types/preferred-pm':
+ specifier: ^3.0.0
+ version: 3.0.0
'@types/semver':
specifier: ^7.5.8
version: 7.5.8
- '@types/which-pm-runs':
- specifier: ^1.0.2
- version: 1.0.2
arg:
specifier: ^5.0.2
version: 5.0.2
@@ -8771,6 +8771,13 @@ packages:
resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==}
dev: true
+ /@types/preferred-pm@3.0.0:
+ resolution: {integrity: sha512-Ub1de7EkdavsyM1KNrTb1K1QL+ISepEELELh2QWccyDcVEcyUDiGoYzzOJfonpGNwpymYXY13oRFpXQluGOC5w==}
+ deprecated: This is a stub types definition. preferred-pm provides its own type definitions, so you do not need this installed.
+ dependencies:
+ preferred-pm: 3.1.3
+ dev: true
+
/@types/prismjs@1.26.4:
resolution: {integrity: sha512-rlAnzkW2sZOjbqZ743IHUhFcvzaGbqijwOu8QZnZCjfQzBqFE3s4lOTJEsxikImav9uzz/42I+O7YUs1mWgMlg==}
dev: true