Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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.
9 changes: 8 additions & 1 deletion packages/create-astro/src/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ export interface Context {
}

export async function getContext(argv: string[]): Promise<Context> {
const packageSpecifier = argv
.find((argItem) => /^(astro|create-astro)@/.exec(argItem))
?.split('@')[1];
// Fallback to 'latest' if it's a version number
const packageTag =
packageSpecifier && /^v?\d[^a-zA-Z]*$/.test(packageSpecifier) ? 'latest' : packageSpecifier;

const flags = arg(
{
'--template': String,
Expand Down Expand Up @@ -93,7 +100,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', packageTag, 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 @@ -60,10 +60,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
Loading