0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-27 22:19:04 -05:00

Fix: Use ref passed by user to get version in create astro

This commit is contained in:
apatel369 2024-11-25 22:54:20 -06:00
parent 74ee2e45ec
commit 4a491f23d4
3 changed files with 8 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'create-astro': patch
---
Fixes an issue where the `getVersion` function was incorrectly using the `latest` tag instead of the user-specified `ref` to determine the Astro version.

View file

@ -93,7 +93,7 @@ export async function getContext(argv: string[]): Promise<Context> {
prompt,
packageManager,
username: getName(),
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION),
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION, ref),
skipHouston,
fancy,
add,

View file

@ -60,10 +60,10 @@ export const getName = () =>
});
});
export const getVersion = (packageManager: string, packageName: string, fallback = '') =>
export const getVersion = (packageManager: string, packageName: string, fallback = '', ref = 'latest') =>
new Promise<string>(async (resolve) => {
let registry = await getRegistry(packageManager);
const { version } = await fetch(`${registry}/${packageName}/latest`, {
const { version } = await fetch(`${registry}/${packageName}/${ref}`, {
redirect: 'follow',
})
.then((res) => res.json())