Skip to content

Commit

Permalink
Fix: Use ref passed by user to get version in create astro
Browse files Browse the repository at this point in the history
  • Loading branch information
apatel369 committed Nov 26, 2024
1 parent 0910a32 commit 7990ec9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
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 the `getVersion` function was incorrectly using the `latest` tag instead of the user-specified `ref` to determine the Astro version.
2 changes: 1 addition & 1 deletion packages/create-astro/src/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
dryRun,
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, 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())
Expand Down

0 comments on commit 7990ec9

Please sign in to comment.