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

Adds automatic, seasonally appropriate messages from Houston #9476

Merged
merged 18 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
9 changes: 6 additions & 3 deletions packages/create-astro/src/actions/context.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { prompt } from '@astrojs/cli-kit';
import { random } from '@astrojs/cli-kit/utils';
import arg from 'arg';
import os from 'node:os';

import { getName, getVersion } from '../messages.js';
import getFestiveHouston from '../data/festive.js';

export interface Context {
help: boolean;
Expand All @@ -25,7 +25,10 @@ export interface Context {
stdin?: typeof process.stdin;
stdout?: typeof process.stdout;
exit(code: number): never;
hat?: string;
clothes: {
hat: string;
tie: string;
};
ElianCodes marked this conversation as resolved.
Show resolved Hide resolved
}

export async function getContext(argv: string[]): Promise<Context> {
Expand Down Expand Up @@ -94,7 +97,7 @@ export async function getContext(argv: string[]): Promise<Context> {
projectName,
template,
ref: ref ?? 'latest',
hat: random(['❄️', '🎄', '🎁']), // fancy ? random(['🎩', '🎩', '🎩', '🎩', '🎓', '👑', '🧢', '🍦']) : undefined,
clothes: getFestiveHouston(fancy).clothes,
ElianCodes marked this conversation as resolved.
Show resolved Hide resolved
yes,
install: install ?? (noInstall ? false : undefined),
git: git ?? (noGit ? false : undefined),
Expand Down
4 changes: 2 additions & 2 deletions packages/create-astro/src/actions/intro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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'>
ctx: Pick<Context, 'clothes' | 'skipHouston' | 'version' | 'username' | 'fancy'>
) {
banner();

Expand All @@ -23,7 +23,7 @@ export async function intro(
],
random(welcome),
],
{ clear: true, hat: ctx.hat }
{ clear: true, clothes: { hat: ctx.clothes.hat, tie: ctx.clothes.tie } }
);
}
}
4 changes: 2 additions & 2 deletions packages/create-astro/src/actions/next-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Context } from './context.js';

import { nextSteps, say } from '../messages.js';

export async function next(ctx: Pick<Context, 'hat' | 'cwd' | 'packageManager' | 'skipHouston'>) {
export async function next(ctx: Pick<Context, 'clothes' | 'cwd' | 'packageManager' | 'skipHouston'>) {
let projectDir = path.relative(process.cwd(), ctx.cwd);

const commandMap: { [key: string]: string } = {
Expand All @@ -17,7 +17,7 @@ export async function next(ctx: Pick<Context, 'hat' | 'cwd' | 'packageManager' |
await nextSteps({ projectDir, devCmd });

if (!ctx.skipHouston) {
await say(['Good luck out there, astronaut! 🚀'], { hat: ctx.hat });
await say(['Good luck out there, astronaut! 🚀'], { clothes: { hat: ctx.clothes.hat, tie: ctx.clothes.tie }});
}
return;
}
66 changes: 66 additions & 0 deletions packages/create-astro/src/data/festive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { random } from '@astrojs/cli-kit/utils';

export default function getFestiveHouston(fancy?: boolean) {
ElianCodes marked this conversation as resolved.
Show resolved Hide resolved
const date = new Date();
if (date.getMonth() === 11) {
// Christmas season
return {
clothes: {
hat: random(['🎁', '🎄', '🌲']),
tie: '🧣'
ElianCodes marked this conversation as resolved.
Show resolved Hide resolved
},
messages: [
`Ho, ho, ho! 'Tis the season to code and create.`,
`Jingle all the way through your web creation journey!`,
`Let's unwrap the magic of the web together!`,
`Bells are ringing, and so are your creative ideas!`,
`It's starting to look a lot like Christmas on the internet.`,
`It's time to decorate the web with your festive ideas!`,
]
}
} else if (date.getMonth() === 9) {
// Spooky season
return {
clothes: {
hat: random(['🎃', '👻', '☠️', '💀']),
tie: random(['🦴', ''])
},
messages: [
`Booo! Let's scare the interwebs!`,
`Get ready to haunt the internet with Halloween vibes.`,
`Harness the power of the web for your frightful ideas.`,
`It's time to conjure up an online spooktacular masterpiece.`,
`Prepare for a web of Halloween wonders to be woven.`,
`Chills and thrills await as you embark on your web journey`,
`The internet is about to get a whole lot creepier thanks to your new project.`
]
}
}
// default state
return {
clothes: {
hat: fancy ? random(['🎩', '🎩', '🎩', '🎩', '🎓', '👑', '🧢', '🍦']) : '',
tie: fancy ? random(['🎀', '🧣']) : '',
},
messages: [
`Let's claim your corner of the internet.`,
`I'll be your assistant today.`,
`Let's build something awesome!`,
`Let's build something great!`,
`Let's build something fast!`,
`Let's build the web we want.`,
`Let's make the web weird!`,
`Let's make the web a better place!`,
`Let's create a new project!`,
`Let's create something unique!`,
`Time to build a new website.`,
`Time to build a faster website.`,
`Time to build a sweet new website.`,
`We're glad to have you on board.`,
`Keeping the internet weird since 2021.`,
`Initiating launch sequence...`,
`Initiating launch sequence... right... now!`,
`Awaiting further instructions.`,
]
}
}
1 change: 1 addition & 0 deletions packages/create-astro/src/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default as getFestiveMessages} from './festive.js'
32 changes: 4 additions & 28 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { align, sleep } from '@astrojs/cli-kit/utils';
import { exec } from 'node:child_process';
import stripAnsi from 'strip-ansi';
import { shell } from './shell.js';
import getFestiveHouston from './data/festive.js';

// Users might lack access to the global npm registry, this function
// checks the user's project type and will return the proper npm registry
Expand All @@ -24,8 +25,8 @@ export function setStdout(writable: typeof process.stdout) {
stdout = writable;
}

export async function say(messages: string | string[], { clear = false, hat = '' } = {}) {
return houston(messages, { clear, hat, stdout });
export async function say(messages: string | string[], { clear = false, clothes = { hat: '', tie: ''} } = {}) {
return houston(messages, { clear, clothes, stdout });
}

export async function spinner(args: {
Expand All @@ -39,32 +40,7 @@ export async function spinner(args: {

export const title = (text: string) => align(label(text), 'end', 7) + ' ';

export const welcome = [
// `Let's claim your corner of the internet.`,
// `I'll be your assistant today.`,
// `Let's build something awesome!`,
// `Let's build something great!`,
// `Let's build something fast!`,
// `Let's build the web we want.`,
// `Let's make the web weird!`,
// `Let's make the web a better place!`,
// `Let's create a new project!`,
// `Let's create something unique!`,
// `Time to build a new website.`,
// `Time to build a faster website.`,
// `Time to build a sweet new website.`,
// `We're glad to have you on board.`,
// `Keeping the internet weird since 2021.`,
// `Initiating launch sequence...`,
// `Initiating launch sequence... right... now!`,
// `Awaiting further instructions.`,
`Ho, ho, ho! 'Tis the season to code and create.`,
`Jingle all the way through your web creation journey!`,
`Let's unwrap the magic of the web together!`,
`Bells are ringing, and so are your creative ideas!`,
`It's starting to look a lot like Christmas on the internet.`,
`It's time to decorate the web with your festive ideas!`,
];
export const welcome = getFestiveHouston().messages
ElianCodes marked this conversation as resolved.
Show resolved Hide resolved

export const getName = () =>
new Promise<string>((resolve) => {
Expand Down
Loading