diff options
author | 2023-08-03 16:03:04 -0500 | |
---|---|---|
committer | 2023-08-03 16:03:04 -0500 | |
commit | 89cd4b877e870ce4a263dd45f42f818fd2c4d5a6 (patch) | |
tree | e56fd3b05efb2dfcf6344f5fa807a25f1f9b7a74 | |
parent | a2b989cba184de30196de0ccad666455c1539207 (diff) | |
download | astro-89cd4b877e870ce4a263dd45f42f818fd2c4d5a6.tar.gz astro-89cd4b877e870ce4a263dd45f42f818fd2c4d5a6.tar.zst astro-89cd4b877e870ce4a263dd45f42f818fd2c4d5a6.zip |
Handle error state for version (#7939)
* fix(create-astro): handle error state for version
* fix: handle missing version
-rw-r--r-- | .changeset/late-falcons-dream.md | 5 | ||||
-rw-r--r-- | packages/create-astro/src/actions/intro.ts | 2 | ||||
-rw-r--r-- | packages/create-astro/src/messages.ts | 7 |
3 files changed, 10 insertions, 4 deletions
diff --git a/.changeset/late-falcons-dream.md b/.changeset/late-falcons-dream.md new file mode 100644 index 000000000..6d959c05a --- /dev/null +++ b/.changeset/late-falcons-dream.md @@ -0,0 +1,5 @@ +--- +'create-astro': patch +--- + +Handle error state for version number diff --git a/packages/create-astro/src/actions/intro.ts b/packages/create-astro/src/actions/intro.ts index e4370d706..e5d68069f 100644 --- a/packages/create-astro/src/actions/intro.ts +++ b/packages/create-astro/src/actions/intro.ts @@ -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), diff --git a/packages/create-astro/src/messages.ts b/packages/create-astro/src/messages.ts index b25ad8c55..93778a8db 100644 --- a/packages/create-astro/src/messages.ts +++ b/packages/create-astro/src/messages.ts @@ -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); @@ -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) => { |