create-jireh
Version:
Scaffold frontend apps from Jireh templates (Next.js, React+Vite, Vanilla, etc.)
41 lines (40 loc) • 1.19 kB
JavaScript
// src/prompts.ts
import prompts from "prompts";
import { registry } from "./registry.js";
export async function ask(opts) {
const templateChoices = Object.entries(registry).map(([key, v]) => ({
title: v.label,
value: key
}));
const res = await prompts([
{
name: "name",
type: opts.name ? null : "text",
message: "Project name:",
initial: "my-app"
},
{
name: "templateKey",
type: opts.templateKey ? null : "select",
message: "Select a template:",
choices: templateChoices
},
{
name: "install",
type: typeof opts.install === "boolean" ? null : "toggle",
message: "Install dependencies?",
active: "yes",
inactive: "no",
initial: true
},
{
name: "git",
type: typeof opts.git === "boolean" ? null : "toggle",
message: "Initialize git?",
active: "yes",
inactive: "no",
initial: true
}
], { onCancel: () => process.exit(1) });
return { ...opts, ...res };
}