@vxrn/takeout-cli
Version:
CLI tools for Takeout starter kit - interactive onboarding and project setup
76 lines (75 loc) • 2.45 kB
JavaScript
import * as p from "@clack/prompts";
import pc from "picocolors";
function displayWelcome(projectName = "Takeout") {
console.info(), p.intro(pc.bgCyan(pc.black(` ${projectName} Starter Kit `)));
}
function displayOutro(message) {
p.outro(pc.green(message));
}
function displayPrerequisites(checks) {
const items = checks.map(check => {
const icon = check.installed ? pc.green("\u2713") : pc.red("\u2717"),
message = check.message || "";
return `${icon} ${pc.bold(check.name)}: ${message}`;
});
p.note(items.join(`
`), "Prerequisites");
}
function displayPortConflicts(conflicts) {
if (conflicts.length === 0) return;
const items = conflicts.map(conflict => {
const pid = conflict.pid ? ` (PID: ${conflict.pid})` : "";
return `${pc.yellow("\u26A0")} Port ${conflict.port} (${conflict.name})${pid}`;
});
p.note(items.join(`
`), pc.yellow("Port Conflicts Detected"));
}
async function confirmContinue(message, defaultValue = !0) {
const result = await p.confirm({
message,
initialValue: defaultValue
});
return p.isCancel(result) && (p.cancel("Operation cancelled."), process.exit(0)), result;
}
async function promptText(message, defaultValue, placeholder) {
const result = await p.text({
message,
defaultValue,
placeholder
});
return p.isCancel(result) && (p.cancel("Operation cancelled."), process.exit(0)), result;
}
async function promptPassword(message) {
const result = await p.password({
message
});
return p.isCancel(result) && (p.cancel("Operation cancelled."), process.exit(0)), result;
}
async function promptSelect(message, options) {
const result = await p.select({
message,
options
});
return p.isCancel(result) && (p.cancel("Operation cancelled."), process.exit(0)), result;
}
function showSpinner(message) {
const s = p.spinner();
return s.start(message), s;
}
function showError(message) {
p.log.error(pc.red(message));
}
function showWarning(message) {
p.log.warning(pc.yellow(message));
}
function showSuccess(message) {
p.log.success(pc.green(message));
}
function showInfo(message) {
p.log.info(pc.blue(message));
}
function showStep(message) {
p.log.step(message);
}
export { confirmContinue, displayOutro, displayPortConflicts, displayPrerequisites, displayWelcome, promptPassword, promptSelect, promptText, showError, showInfo, showSpinner, showStep, showSuccess, showWarning };
//# sourceMappingURL=prompts.mjs.map