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

Update astro add to install stable peer dep #9398

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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/plenty-pumas-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

When adding integrations with the `astro add` command, only install the stable version of peer dependencies by default
13 changes: 10 additions & 3 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,16 @@ async function getInstallIntegrationsCommand({
.map<[string, string | null][]>((i) => [[i.packageName, null], ...i.dependencies])
.flat(1)
.filter((dep, i, arr) => arr.findIndex((d) => d[0] === dep[0]) === i)
.map(([name, version]) =>
version === null ? name : `${name}@${version.split(/\s*\|\|\s*/).pop()}`
)
.map(([name, version]) => {
if (version !== null) {
// If there are multiple versions, use the last non-prerelease one
const versions = version.split(/\s*\|\|\s*/);
if (versions.length > 1) {
version = versions.reverse().find((v) => !/\-.*?\./.test(v)) ?? version;
}
}
return version === null ? name : `${name}@${version}`;
})
.sort();

switch (pm.name) {
Expand Down
Loading