From 2fe2da6b520ce8159bf3f1c8c1c01553e40f21d5 Mon Sep 17 00:00:00 2001 From: Reuben Tier Date: Fri, 27 Sep 2024 11:22:42 +0100 Subject: [PATCH] Fix beta reference in create-astro --- packages/create-astro/src/actions/context.ts | 6 ++++-- packages/create-astro/src/messages.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/create-astro/src/actions/context.ts b/packages/create-astro/src/actions/context.ts index 83a13eda7c..5ce01d31d1 100644 --- a/packages/create-astro/src/actions/context.ts +++ b/packages/create-astro/src/actions/context.ts @@ -75,6 +75,8 @@ export async function getContext(argv: string[]): Promise { } = flags; let projectName = cwd; + ref ??= 'latest' + if (no) { yes = false; if (install == undefined) install = false; @@ -93,13 +95,13 @@ export async function getContext(argv: string[]): Promise { prompt, packageManager, username: getName(), - version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION), + version: getVersion(packageManager, 'astro', ref, process.env.ASTRO_VERSION), skipHouston, fancy, dryRun, projectName, template, - ref: ref ?? 'latest', + ref, welcome: random(messages), hat: hats ? random(hats) : undefined, tie: ties ? random(ties) : undefined, diff --git a/packages/create-astro/src/messages.ts b/packages/create-astro/src/messages.ts index ba765f7232..c9fae33399 100644 --- a/packages/create-astro/src/messages.ts +++ b/packages/create-astro/src/messages.ts @@ -60,10 +60,10 @@ export const getName = () => }); }); -export const getVersion = (packageManager: string, packageName: string, fallback = '') => +export const getVersion = (packageManager: string, packageName: string, ref: string, fallback = '') => new Promise(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())