mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix(upgrade): use preferred-pm instead of which-pm-runs (#11139)
This commit is contained in:
parent
4c7949d1ae
commit
aaf0635cc0
5 changed files with 25 additions and 16 deletions
5
.changeset/rich-singers-accept.md
Normal file
5
.changeset/rich-singers-accept.md
Normal file
|
@ -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
|
|
@ -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"
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue