@entro314labs/starlight-document-converter
Version:
A comprehensive document converter for Astro Starlight that transforms various document formats into Starlight-compatible Markdown with proper frontmatter
165 lines (164 loc) • 5.06 kB
JavaScript
// src/utils/cli-styling.ts
import boxen from "boxen";
import Table from "cli-table3";
import figures from "figures";
import gradient from "gradient-string";
import pc from "picocolors";
var symbols = {
success: figures.tick,
error: figures.cross,
warning: figures.warning,
info: figures.info,
arrow: figures.arrowRight,
bullet: figures.bullet,
star: figures.star,
heart: figures.heart,
checkbox: figures.checkboxOn,
radioOn: figures.radioOn,
pointer: figures.pointer,
line: figures.line,
corner: figures.pointer
// Use pointer as fallback since cornerDownRight might not exist
};
var colors = {
primary: pc.cyan,
success: pc.green,
error: pc.red,
warning: pc.yellow,
info: pc.blue,
muted: pc.gray,
bold: pc.bold,
dim: pc.dim
};
var gradients = {
primary: (text) => gradient(["#00f5ff", "#0099ff"])(text),
success: (text) => gradient(["#00ff88", "#00aa55"])(text),
warning: (text) => gradient(["#ffaa00", "#ff6600"])(text),
error: (text) => gradient(["#ff4444", "#cc0000"])(text),
rainbow: (text) => gradient.rainbow(text)
};
var status = {
success: (text) => `${colors.success(symbols.success)} ${text}`,
error: (text) => `${colors.error(symbols.error)} ${text}`,
warning: (text) => `${colors.warning(symbols.warning)} ${text}`,
info: (text) => `${colors.info(symbols.info)} ${text}`,
processing: (text) => `${colors.primary(symbols.arrow)} ${text}`,
bullet: (text) => `${colors.muted(symbols.bullet)} ${text}`
};
var boxes = {
success: (text, title) => boxen(text, {
padding: 1,
margin: 1,
borderStyle: "round",
borderColor: "green",
title,
titleAlignment: "center"
}),
error: (text, title) => boxen(text, {
padding: 1,
margin: 1,
borderStyle: "round",
borderColor: "red",
title,
titleAlignment: "center"
}),
info: (text, title) => boxen(text, {
padding: 1,
margin: 1,
borderStyle: "round",
borderColor: "cyan",
title,
titleAlignment: "center"
}),
warning: (text, title) => boxen(text, {
padding: 1,
margin: 1,
borderStyle: "round",
borderColor: "yellow",
title,
titleAlignment: "center"
})
};
var createTable = (options) => new Table({
style: { head: ["cyan"] },
chars: {
top: "\u2500",
"top-mid": "\u252C",
"top-left": "\u250C",
"top-right": "\u2510",
bottom: "\u2500",
"bottom-mid": "\u2534",
"bottom-left": "\u2514",
"bottom-right": "\u2518",
left: "\u2502",
"left-mid": "\u251C",
mid: "\u2500",
"mid-mid": "\u253C",
right: "\u2502",
"right-mid": "\u2524",
middle: "\u2502"
},
...options
});
var createResultsTable = (stats) => {
const table = createTable({
head: ["Metric", "Count", "Status"]
});
if (stats.filesProcessed !== void 0) {
table.push(["Files Processed", stats.filesProcessed.toString(), status.info("")]);
}
if (stats.totalRepaired !== void 0) {
const statusIcon = stats.totalRepaired > 0 ? status.success("") : status.info("");
table.push(["Files Repaired", stats.totalRepaired.toString(), statusIcon]);
}
if (stats.totalIssues !== void 0) {
const statusIcon = stats.totalIssues === 0 ? status.success("") : status.warning("");
table.push(["Issues Resolved", stats.totalIssues.toString(), statusIcon]);
}
if (stats.totalFiles !== void 0) {
table.push(["Total Files", stats.totalFiles.toString(), status.info("")]);
}
if (stats.validFiles !== void 0) {
const statusIcon = stats.validFiles > 0 ? status.success("") : status.warning("");
table.push(["Valid Files", stats.validFiles.toString(), statusIcon]);
}
if (stats.issueCount !== void 0) {
const statusIcon = stats.issueCount === 0 ? status.success("") : status.warning("");
table.push(["Issues Found", stats.issueCount.toString(), statusIcon]);
}
if (stats.totalFiles !== void 0 && stats.validFiles !== void 0) {
const rate = Math.round(stats.validFiles / stats.totalFiles * 100);
const statusIcon = rate >= 90 ? status.success("") : rate >= 70 ? status.warning("") : status.error("");
table.push(["Success Rate", `${rate}%`, statusIcon]);
}
return table;
};
var createBrandHeader = (title, version) => {
const titleText = gradients.primary(title);
const versionText = version ? colors.dim(`v${version}`) : "";
const headerText = versionText ? `${titleText} ${versionText}` : titleText;
return boxen(headerText, {
padding: 1,
margin: 1,
borderStyle: "double",
borderColor: "cyan",
textAlignment: "center"
});
};
var formatHelpSection = (title, items) => {
const lines = ["", colors.bold(colors.primary(title)), colors.dim("\u2500".repeat(title.length)), ""];
items.forEach((item) => {
lines.push(` ${colors.success(symbols.bullet)} ${colors.bold(item.name)}`);
lines.push(` ${colors.muted(item.description)}`);
lines.push("");
});
return lines.join("\n");
};
export {
status,
boxes,
createResultsTable,
createBrandHeader,
formatHelpSection
};
//# sourceMappingURL=chunk-RI3FHBT3.js.map