UNPKG

@webda/shell

Version:

Deploy a Webda app or configure it

75 lines 5 kB
import { Terminal } from "@webda/workout"; import chalk from "chalk"; export class WebdaTerminal extends Terminal { constructor(wo, versions, logo = undefined, level = undefined, format = undefined, tty = undefined) { super(wo, level, format, tty); this.versions = versions; this.setTitle("Webda"); this.setLogo(logo); } handleTitleMessage(msg) { this.setTitle(msg.title); } setDefaultLogo() { let logo = `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    `.split("\n"); if (Object.keys(this.versions).length) { let logoLength = Math.max(...logo.map(this.getTrueLength)); logo.push(""); for (let j in this.versions) { let version = chalk.bold(`${j} - v${this.versions[j].version}`); version = version.padStart(version.length + (logoLength - version.length) / 2).padEnd(logoLength); logo.push(version); } } } setTitle(title = "") { this.title = WebdaTerminal.webdaize(title, this.tty); } getBar(size, complete) { if (complete) { return "[" + chalk.bold(chalk.yellow("\u2836".repeat(size))); } else { return " ".repeat(size) + "]"; } } /** * Colorized any 'da' letters from webda within output * * @param str * @returns */ static webdaize(str, isTTY = process.stdout.isTTY) { if (!isTTY) { return str; } return str.replace(/(web)(da)/gi, "web" + chalk.yellow("da")); } /** * @override */ displayString(str, limit = undefined) { return WebdaTerminal.webdaize(super.displayString(str, limit), this.tty); } } //# sourceMappingURL=terminal.js.map