@vxrn/takeout-cli
Version:
CLI tools for Takeout starter kit - interactive onboarding and project setup
122 lines • 4.52 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf,
__hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: !0
});
},
__copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
get: () => from[key],
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: !0
}) : target, mod)),
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
value: !0
}), mod);
var prompts_exports = {};
__export(prompts_exports, {
confirmContinue: () => confirmContinue,
displayOutro: () => displayOutro,
displayPortConflicts: () => displayPortConflicts,
displayPrerequisites: () => displayPrerequisites,
displayWelcome: () => displayWelcome,
promptPassword: () => promptPassword,
promptSelect: () => promptSelect,
promptText: () => promptText,
showError: () => showError,
showInfo: () => showInfo,
showSpinner: () => showSpinner,
showStep: () => showStep,
showSuccess: () => showSuccess,
showWarning: () => showWarning
});
module.exports = __toCommonJS(prompts_exports);
var p = __toESM(require("@clack/prompts"), 1),
import_picocolors = __toESM(require("picocolors"), 1);
function displayWelcome(projectName = "Takeout") {
console.info(), p.intro(import_picocolors.default.bgCyan(import_picocolors.default.black(` ${projectName} Starter Kit `)));
}
function displayOutro(message) {
p.outro(import_picocolors.default.green(message));
}
function displayPrerequisites(checks) {
const items = checks.map(check => {
const icon = check.installed ? import_picocolors.default.green("\u2713") : import_picocolors.default.red("\u2717"),
message = check.message || "";
return `${icon} ${import_picocolors.default.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 `${import_picocolors.default.yellow("\u26A0")} Port ${conflict.port} (${conflict.name})${pid}`;
});
p.note(items.join(`
`), import_picocolors.default.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(import_picocolors.default.red(message));
}
function showWarning(message) {
p.log.warning(import_picocolors.default.yellow(message));
}
function showSuccess(message) {
p.log.success(import_picocolors.default.green(message));
}
function showInfo(message) {
p.log.info(import_picocolors.default.blue(message));
}
function showStep(message) {
p.log.step(message);
}