@vxrn/takeout-cli
Version:
CLI tools for Takeout starter kit - interactive onboarding and project setup
133 lines (132 loc) • 4.99 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() {
var projectName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "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) {
var items = checks.map(function(check) {
var 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) {
var items = conflicts.map(function(conflict) {
var 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) {
var defaultValue = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, 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) {
var result = await p.text({
message,
defaultValue,
placeholder
});
return p.isCancel(result) && (p.cancel("Operation cancelled."), process.exit(0)), result;
}
async function promptPassword(message) {
var result = await p.password({
message
});
return p.isCancel(result) && (p.cancel("Operation cancelled."), process.exit(0)), result;
}
async function promptSelect(message, options) {
var result = await p.select({
message,
options
});
return p.isCancel(result) && (p.cancel("Operation cancelled."), process.exit(0)), result;
}
function showSpinner(message) {
var 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);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
confirmContinue,
displayOutro,
displayPortConflicts,
displayPrerequisites,
displayWelcome,
promptPassword,
promptSelect,
promptText,
showError,
showInfo,
showSpinner,
showStep,
showSuccess,
showWarning
});
//# sourceMappingURL=prompts.js.map