import { cancel, confirm, intro, isCancel, outro, select, spinner, text } from "@clack/prompts"; import { setTimeout as sleep } from "node:timers/promises"; function orCancel(value) { if (isCancel(value)) { cancel("Cancelled"); process.exit(0); } return value; } intro("create-slop"); const name = orCancel(await text({ message: "What is your project called?", placeholder: "my-slop", validate: (value) => (value?.trim() ? undefined : "A name is required."), })); const template = orCancel(await select({ message: "Pick a template", options: [ { value: "minimal", label: "Minimal", hint: "one file" }, { value: "server", label: "Server", hint: "node:http" }, { value: "cli", label: "CLI", hint: "@clack/prompts" }, ], })); const git = orCancel(await confirm({ message: "Initialize a git repository?" })); const s = spinner(); s.start("Scaffolding"); await sleep(600); s.stop("Scaffolded"); outro(`${name}: ${template} template, ${git ? "with" : "without"} git, ${process.stdout.columns} columns`);