mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -05:00
Fix astro add for prerelease packages (#11548)
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Bjorn Lu <34116392+bluwy@users.noreply.github.com>
This commit is contained in:
parent
7f26de906e
commit
602c5bf05d
2 changed files with 7 additions and 2 deletions
5
.changeset/violet-coats-fail.md
Normal file
5
.changeset/violet-coats-fail.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes `astro add` for packages with only prerelease versions
|
|
@ -691,9 +691,9 @@ async function convertIntegrationsToInstallSpecifiers(
|
||||||
async function resolveRangeToInstallSpecifier(name: string, range: string): Promise<string> {
|
async function resolveRangeToInstallSpecifier(name: string, range: string): Promise<string> {
|
||||||
const versions = await fetchPackageVersions(name);
|
const versions = await fetchPackageVersions(name);
|
||||||
if (versions instanceof Error) return name;
|
if (versions instanceof Error) return name;
|
||||||
// Filter out any prerelease versions
|
// Filter out any prerelease versions, but fallback if there are no stable versions
|
||||||
const stableVersions = versions.filter((v) => !v.includes('-'));
|
const stableVersions = versions.filter((v) => !v.includes('-'));
|
||||||
const maxStable = maxSatisfying(stableVersions, range);
|
const maxStable = maxSatisfying(stableVersions.length !== 0 ? stableVersions : versions, range);
|
||||||
return `${name}@^${maxStable}`;
|
return `${name}@^${maxStable}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue