From 2dc8cd8e867a9cacf33ee6b6c112548747561eab Mon Sep 17 00:00:00 2001 From: Canaris Date: Mon, 1 Jan 2024 20:14:39 +0800 Subject: [PATCH 1/5] `yarn add` should be used to install packages instead of `yarn install` --- packages/upgrade/src/actions/install.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/upgrade/src/actions/install.ts b/packages/upgrade/src/actions/install.ts index 3f343463fadf..465bfa16251d 100644 --- a/packages/upgrade/src/actions/install.ts +++ b/packages/upgrade/src/actions/install.ts @@ -123,6 +123,8 @@ async function runInstallCommand( const cwd = fileURLToPath(ctx.cwd); if (ctx.packageManager === 'yarn') await ensureYarnLock({ cwd }); + const installCmd = ctx.packageManager === 'yarn' ? 'add' : 'install'; + await spinner({ start: `Installing dependencies with ${ctx.packageManager}...`, end: `Installed dependencies!`, @@ -132,7 +134,7 @@ async function runInstallCommand( await shell( ctx.packageManager, [ - 'install', + installCmd, ...dependencies.map( ({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}` ), @@ -144,7 +146,7 @@ async function runInstallCommand( await shell( ctx.packageManager, [ - 'install', + installCmd, '--save-dev', ...devDependencies.map( ({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}` @@ -161,7 +163,7 @@ async function runInstallCommand( error( 'error', `Dependencies failed to install, please run the following command manually:\n${color.bold( - `${ctx.packageManager} install ${packages}` + `${ctx.packageManager} ${installCmd} ${packages}` )}` ); return ctx.exit(1); From cf2a86acce9e6d1ab89a449f659ad19b67ad6bc8 Mon Sep 17 00:00:00 2001 From: Canaris Date: Mon, 1 Jan 2024 20:22:36 +0800 Subject: [PATCH 2/5] Add changeset --- .changeset/poor-cars-battle.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/poor-cars-battle.md diff --git a/.changeset/poor-cars-battle.md b/.changeset/poor-cars-battle.md new file mode 100644 index 000000000000..e24b2110dcd5 --- /dev/null +++ b/.changeset/poor-cars-battle.md @@ -0,0 +1,5 @@ +--- +"@astrojs/upgrade": patch +--- + +Change the command used for upgrading packages for yarn from `install` to `add` From df74b8234d7ae7e37fd698a82e9dc73f915e40ad Mon Sep 17 00:00:00 2001 From: Canaris Date: Tue, 2 Jan 2024 17:57:57 +0800 Subject: [PATCH 3/5] Update packages/upgrade/src/actions/install.ts Fix install command for pnpm Co-authored-by: Bjorn Lu --- packages/upgrade/src/actions/install.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/upgrade/src/actions/install.ts b/packages/upgrade/src/actions/install.ts index 465bfa16251d..14011a07ee7d 100644 --- a/packages/upgrade/src/actions/install.ts +++ b/packages/upgrade/src/actions/install.ts @@ -123,7 +123,7 @@ async function runInstallCommand( const cwd = fileURLToPath(ctx.cwd); if (ctx.packageManager === 'yarn') await ensureYarnLock({ cwd }); - const installCmd = ctx.packageManager === 'yarn' ? 'add' : 'install'; + const installCmd = ctx.packageManager === 'yarn' || ctx.packageManager === 'pnpm' ? 'add' : 'install'; await spinner({ start: `Installing dependencies with ${ctx.packageManager}...`, From 21bf6fa4709c2298f2c9a03982e1a0222ade796a Mon Sep 17 00:00:00 2001 From: Canaris Date: Tue, 2 Jan 2024 17:58:23 +0800 Subject: [PATCH 4/5] Update .changeset/poor-cars-battle.md Co-authored-by: Florian Lefebvre --- .changeset/poor-cars-battle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/poor-cars-battle.md b/.changeset/poor-cars-battle.md index e24b2110dcd5..b4123427a95e 100644 --- a/.changeset/poor-cars-battle.md +++ b/.changeset/poor-cars-battle.md @@ -2,4 +2,4 @@ "@astrojs/upgrade": patch --- -Change the command used for upgrading packages for yarn from `install` to `add` +Fixes packages upgrading when using yarn From cbe7aaf125fed23c92454085fedbcb384ad538f4 Mon Sep 17 00:00:00 2001 From: Canaris Date: Tue, 2 Jan 2024 18:38:04 +0800 Subject: [PATCH 5/5] Update .changeset/poor-cars-battle.md Co-authored-by: Florian Lefebvre --- .changeset/poor-cars-battle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/poor-cars-battle.md b/.changeset/poor-cars-battle.md index b4123427a95e..5832e363cadd 100644 --- a/.changeset/poor-cars-battle.md +++ b/.changeset/poor-cars-battle.md @@ -2,4 +2,4 @@ "@astrojs/upgrade": patch --- -Fixes packages upgrading when using yarn +Updates the command used for installing packages with pnpm and yarn