Skip to content
Merged
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/selfish-bulldogs-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Fixes an issue where installing Astro beta using `create-astro` displays the wrong Astro version in the installation messages.
24 changes: 23 additions & 1 deletion packages/create-astro/src/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,24 @@ export interface Context {
tasks: Task[];
}

function getPackageTag(packageSpecifier: string | undefined): string | undefined {
switch (packageSpecifier) {
case 'alpha':
case 'beta':
case 'rc':
return packageSpecifier;
// Will fallback to latest
case undefined:
default:
return undefined;
}
}

export async function getContext(argv: string[]): Promise<Context> {
const packageSpecifier = argv
.find((argItem) => /^(astro|create-astro)@/.exec(argItem))
?.split('@')[1];

const flags = arg(
{
'--template': String,
Expand Down Expand Up @@ -93,7 +110,12 @@ export async function getContext(argv: string[]): Promise<Context> {
prompt,
packageManager,
username: getName(),
version: getVersion(packageManager, 'astro', process.env.ASTRO_VERSION),
version: getVersion(
packageManager,
'astro',
getPackageTag(packageSpecifier),
process.env.ASTRO_VERSION,
),
skipHouston,
fancy,
add,
Expand Down
4 changes: 2 additions & 2 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export const getName = () =>
});
});

export const getVersion = (packageManager: string, packageName: string, fallback = '') =>
export const getVersion = (packageManager: string, packageName: string, packageTag = 'latest', fallback = '') =>
new Promise<string>(async (resolve) => {
let registry = await getRegistry(packageManager);
const { version } = await fetch(`${registry}/${packageName}/latest`, {
const { version } = await fetch(`${registry}/${packageName}/${packageTag}`, {
redirect: 'follow',
})
.then((res) => res.json())
Expand Down