From 67e06f9db1b0492ccfb4b053762dc91d69a53ecb Mon Sep 17 00:00:00 2001 From: Canaris Date: Tue, 2 Jan 2024 22:52:22 +0800 Subject: [PATCH 1/2] `yarn add` should be used to install packages instead of `yarn install` (#9562) Co-authored-by: Bjorn Lu Co-authored-by: Florian Lefebvre --- .changeset/poor-cars-battle.md | 5 +++++ packages/upgrade/src/actions/install.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) 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..5832e363cadd --- /dev/null +++ b/.changeset/poor-cars-battle.md @@ -0,0 +1,5 @@ +--- +"@astrojs/upgrade": patch +--- + +Updates the command used for installing packages with pnpm and yarn diff --git a/packages/upgrade/src/actions/install.ts b/packages/upgrade/src/actions/install.ts index 3f343463fadf..14011a07ee7d 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' || ctx.packageManager === 'pnpm' ? '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 f192fc3a35872cb187cf631c62fa5b44f004242b Mon Sep 17 00:00:00 2001 From: Canaris Date: Tue, 2 Jan 2024 14:53:17 +0000 Subject: [PATCH 2/2] [ci] format --- packages/upgrade/src/actions/install.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/upgrade/src/actions/install.ts b/packages/upgrade/src/actions/install.ts index 14011a07ee7d..3c294a8ee2a5 100644 --- a/packages/upgrade/src/actions/install.ts +++ b/packages/upgrade/src/actions/install.ts @@ -123,7 +123,8 @@ async function runInstallCommand( const cwd = fileURLToPath(ctx.cwd); if (ctx.packageManager === 'yarn') await ensureYarnLock({ cwd }); - const installCmd = ctx.packageManager === 'yarn' || ctx.packageManager === 'pnpm' ? 'add' : 'install'; + const installCmd = + ctx.packageManager === 'yarn' || ctx.packageManager === 'pnpm' ? 'add' : 'install'; await spinner({ start: `Installing dependencies with ${ctx.packageManager}...`,