0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-10 22:38:53 -05:00

Fix reference in create-astro

This commit is contained in:
Reuben Tier 2024-09-27 11:25:15 +01:00
parent 2594eb088d
commit 87b9c89914
No known key found for this signature in database
GPG key ID: 08B0E5AC1EFCC6AB
2 changed files with 5 additions and 4 deletions

View file

@ -74,6 +74,7 @@ export async function getContext(argv: string[]): Promise<Context> {
'--ref': ref,
} = flags;
let projectName = cwd;
ref ??= 'latest'
if (no) {
yes = false;
@ -93,13 +94,13 @@ export async function getContext(argv: string[]): Promise<Context> {
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,

View file

@ -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<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())