@interopio/desktop-cli
Version:
CLI tool for setting up, building and packaging io.Connect Desktop projects
151 lines • 4.92 kB
JavaScript
;
/**
* ANSI color utility for terminal output
* Replaces chalk dependency with native ANSI escape codes
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.bgCyanBlack = exports.strikethrough = exports.underline = exports.italic = exports.dim = exports.bold = exports.bgBlack = exports.bgWhite = exports.bgCyan = exports.bgMagenta = exports.bgBlue = exports.bgYellow = exports.bgGreen = exports.bgRed = exports.black = exports.grey = exports.gray = exports.white = exports.cyan = exports.magenta = exports.blue = exports.yellow = exports.green = exports.red = void 0;
// ANSI color codes
const COLORS = {
// Text colors
red: '\x1b[31m',
green: '\x1b[32m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
magenta: '\x1b[35m',
cyan: '\x1b[36m',
white: '\x1b[37m',
gray: '\x1b[90m',
grey: '\x1b[90m',
black: '\x1b[30m',
// Background colors
bgRed: '\x1b[41m',
bgGreen: '\x1b[42m',
bgYellow: '\x1b[43m',
bgBlue: '\x1b[44m',
bgMagenta: '\x1b[45m',
bgCyan: '\x1b[46m',
bgWhite: '\x1b[47m',
bgBlack: '\x1b[40m',
// Text styles
bold: '\x1b[1m',
dim: '\x1b[2m',
italic: '\x1b[3m',
underline: '\x1b[4m',
blink: '\x1b[5m',
reverse: '\x1b[7m',
strikethrough: '\x1b[9m',
// Reset
reset: '\x1b[0m'
};
/**
* Check if colors should be disabled (for CI environments, non-TTY, etc.)
*/
function shouldDisableColors() {
return (process.env["NO_COLOR"] !== undefined ||
process.env["NODE_DISABLE_COLORS"] === '1' ||
process.env["CI"] === 'true' ||
!process.stdout.isTTY);
}
/**
* Apply ANSI color/style to text
*/
function colorize(color, text) {
if (shouldDisableColors()) {
return text;
}
return `${color}${text}${COLORS.reset}`;
}
/**
* Combine multiple styles
*/
function combineStyles(styles, text) {
if (shouldDisableColors()) {
return text;
}
return `${styles.join('')}${text}${COLORS.reset}`;
}
// Main color functions
const red = (text) => colorize(COLORS.red, text);
exports.red = red;
const green = (text) => colorize(COLORS.green, text);
exports.green = green;
const yellow = (text) => colorize(COLORS.yellow, text);
exports.yellow = yellow;
const blue = (text) => colorize(COLORS.blue, text);
exports.blue = blue;
const magenta = (text) => colorize(COLORS.magenta, text);
exports.magenta = magenta;
const cyan = (text) => colorize(COLORS.cyan, text);
exports.cyan = cyan;
const white = (text) => colorize(COLORS.white, text);
exports.white = white;
const gray = (text) => colorize(COLORS.gray, text);
exports.gray = gray;
const grey = (text) => colorize(COLORS.grey, text);
exports.grey = grey;
const black = (text) => colorize(COLORS.black, text);
exports.black = black;
// Background colors
const bgRed = (text) => colorize(COLORS.bgRed, text);
exports.bgRed = bgRed;
const bgGreen = (text) => colorize(COLORS.bgGreen, text);
exports.bgGreen = bgGreen;
const bgYellow = (text) => colorize(COLORS.bgYellow, text);
exports.bgYellow = bgYellow;
const bgBlue = (text) => colorize(COLORS.bgBlue, text);
exports.bgBlue = bgBlue;
const bgMagenta = (text) => colorize(COLORS.bgMagenta, text);
exports.bgMagenta = bgMagenta;
const bgCyan = (text) => colorize(COLORS.bgCyan, text);
exports.bgCyan = bgCyan;
const bgWhite = (text) => colorize(COLORS.bgWhite, text);
exports.bgWhite = bgWhite;
const bgBlack = (text) => colorize(COLORS.bgBlack, text);
exports.bgBlack = bgBlack;
// Text styles
const bold = (text) => colorize(COLORS.bold, text);
exports.bold = bold;
const dim = (text) => colorize(COLORS.dim, text);
exports.dim = dim;
const italic = (text) => colorize(COLORS.italic, text);
exports.italic = italic;
const underline = (text) => colorize(COLORS.underline, text);
exports.underline = underline;
const strikethrough = (text) => colorize(COLORS.strikethrough, text);
exports.strikethrough = strikethrough;
// Combined styles (like chalk's chaining)
const bgCyanBlack = (text) => combineStyles([COLORS.bgCyan, COLORS.black], text);
exports.bgCyanBlack = bgCyanBlack;
// Default export with chalk-like interface
const colors = {
red: exports.red,
green: exports.green,
yellow: exports.yellow,
blue: exports.blue,
magenta: exports.magenta,
cyan: exports.cyan,
white: exports.white,
gray: exports.gray,
grey: exports.grey,
black: exports.black,
bgRed: exports.bgRed,
bgGreen: exports.bgGreen,
bgYellow: exports.bgYellow,
bgBlue: exports.bgBlue,
bgMagenta: exports.bgMagenta,
//bgCyan,
bgWhite: exports.bgWhite,
bgBlack: exports.bgBlack,
bold: exports.bold,
dim: exports.dim,
italic: exports.italic,
underline: exports.underline,
strikethrough: exports.strikethrough,
// Special combined styles
bgCyan: {
black: exports.bgCyanBlack
}
};
exports.default = colors;
//# sourceMappingURL=colors.js.map