|
|
|
import chalk from 'chalk'
|
|
|
|
import { repeatString } from './strings.js'
|
|
|
|
|
|
|
|
// Chalk styles
|
|
|
|
export const greenChalk = chalk.hex('#008800')
|
|
|
|
export const headerStyle = chalk.blue.bold.underline
|
|
|
|
export const manualTitleStyle = greenChalk.bold.underline
|
|
|
|
export const heading1 = chalk.bold.underline
|
|
|
|
export const heading2 = chalk.underline
|
|
|
|
|
|
|
|
// Preformatted phrases that can be used in backticked console.log strings
|
|
|
|
export const theAO = `the ${greenChalk.bold('AO')}`
|
|
|
|
export const theMenu = `the ${greenChalk.bold('Menu')}`
|
|
|
|
|
|
|
|
// Returns a colored capitalized status word
|
|
|
|
export const styledStatus = (fullWord, width) => {
|
|
|
|
const title = fullWord.toTitleCase()
|
|
|
|
const lookup = {
|
|
|
|
unknown: chalk.grey(title),
|
|
|
|
off: chalk.grey(title),
|
|
|
|
'not installed': chalk.grey(title),
|
|
|
|
blank: chalk.grey(title),
|
|
|
|
downloaded: chalk.yellow(title),
|
|
|
|
installed: chalk.blue(title),
|
|
|
|
initialized: chalk.green(title),
|
|
|
|
created: chalk.green(title),
|
|
|
|
enabled: greenChalk(title),
|
|
|
|
running: greenChalk(title),
|
|
|
|
synced: greenChalk(title),
|
|
|
|
error: chalk.red(title),
|
|
|
|
missing: chalk.red(title)
|
|
|
|
}
|
|
|
|
let styledWord = lookup[fullWord.toLowerCase()]
|
|
|
|
const halfDiff = (width - fullWord.length) / 2
|
|
|
|
const left = halfDiff % 2 === 0 ? repeatString(' ', halfDiff) : repeatString(' ', Math.ceil(halfDiff))
|
|
|
|
const right = repeatString(' ', Math.floor(halfDiff))
|
|
|
|
return left + styledWord + right
|
|
|
|
}
|