UNPKG

studiocms

Version:

Astro Native CMS for AstroDB. Built from the ground up by the Astro community.

39 lines (38 loc) 1.28 kB
import { StudioCMSColorway, StudioCMSColorwayBg } from "@withstudiocms/cli-kit/colors"; import { label, say } from "@withstudiocms/cli-kit/messages"; import { readJson } from "@withstudiocms/internal_helpers/utils"; import { Effect, genLogger } from "../../effect.js"; import { CliContext } from "./context.js"; import { logger } from "./logger.js"; import getSeasonalMessages from "./seasonal.js"; const pkgJson = readJson(new URL("../../../package.json", import.meta.url)); const random = (...arr) => { const flattenedArray = arr.flat(1); return flattenedArray[Math.floor(flattenedArray.length * Math.random())]; }; const intro = (debug) => genLogger("studiocms/cli/utils/intro")(function* () { const { chalk, username } = yield* CliContext; const { messages } = getSeasonalMessages(); const welcome = random(messages); debug && logger.debug("Printing welcome message..."); yield* Effect.tryPromise( () => say( [ [ "Welcome", "to", label("StudioCMS", StudioCMSColorwayBg, chalk.black), StudioCMSColorway(`v${pkgJson.version}`), username ], welcome ], { clear: true } ) ); debug && logger.debug("Welcome message printed"); }); export { intro, random };