Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle error state for version #7939

Merged
merged 3 commits into from
Aug 3, 2023
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/late-falcons-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Handle error state for version number
2 changes: 1 addition & 1 deletion packages/create-astro/src/actions/intro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function intro(ctx: Pick<Context, 'skipHouston' | 'version' | 'user
'Welcome',
'to',
label('astro', color.bgGreen, color.black),
color.green(`v${ctx.version}`) + ',',
(ctx.version ? color.green(`v${ctx.version}`) : '') + ',',
`${ctx.username}!`,
],
random(welcome),
Expand Down
7 changes: 4 additions & 3 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export const getVersion = () =>
if (v) return resolve(v);
let registry = await getRegistry();
const { version } = await fetch(`${registry}/astro/latest`, { redirect: 'follow' }).then(
(res) => res.json()
(res) => res.json(),
() => ({ version: '' })
);
v = version;
resolve(version);
Expand All @@ -92,9 +93,9 @@ export const getVersion = () =>
export const log = (message: string) => stdout.write(message + '\n');
export const banner = async (version: string) =>
log(
`\n${label('astro', color.bgGreen, color.black)} ${color.green(
`\n${label('astro', color.bgGreen, color.black)} ${version ? color.green(
color.bold(`v${version}`)
)} ${color.bold('Launch sequence initiated.')}`
): ''} ${color.bold('Launch sequence initiated.')}`
);

export const info = async (prefix: string, text: string) => {
Expand Down
Loading