summaryrefslogtreecommitdiff
path: root/packages/create-astro/src/actions/intro.ts
blob: 1781fb26010909d4808f6f8df64a84385ad187cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import type { Context } from './context.js';

import { color, label } from '@astrojs/cli-kit';
import { random } from '@astrojs/cli-kit/utils';
import { banner, say, welcome } from '../messages.js';

export async function intro(
	ctx: Pick<Context, 'hat' | 'skipHouston' | 'version' | 'username' | 'fancy'>
) {
	banner();

	if (!ctx.skipHouston) {
		await say(
			[
				[
					'Welcome',
					'to',
					label('astro', color.bgGreen, color.black),
					Promise.resolve(ctx.version).then(
						(version) => (version ? color.green(`v${version}`) : '') + ','
					),
					Promise.resolve(ctx.username).then((username) => `${username}!`),
				],
				random(welcome),
			],
			{ clear: true, hat: ctx.hat }
		);
	}
}