Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn add should be used to install packages instead of yarn install #9562

Merged
merged 5 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-cars-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/upgrade": patch
---

Fixes packages upgrading when using yarn
DET171 marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 5 additions & 3 deletions packages/upgrade/src/actions/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!`,
Expand All @@ -132,7 +134,7 @@ async function runInstallCommand(
await shell(
ctx.packageManager,
[
'install',
installCmd,
...dependencies.map(
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}`
),
Expand All @@ -144,7 +146,7 @@ async function runInstallCommand(
await shell(
ctx.packageManager,
[
'install',
installCmd,
'--save-dev',
...devDependencies.map(
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, '')}`
Expand All @@ -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);
Expand Down
Loading