|
|
|
import chalk from 'chalk'
|
|
|
|
import chalkAnimation from 'chalk-animation'
|
|
|
|
import gradient from 'gradient-string'
|
|
|
|
import figlet from 'figlet'
|
|
|
|
import { createSpinner } from 'nanospinner'
|
|
|
|
import { sleep } from './util.js'
|
|
|
|
import { selectRandom } from './util.js'
|
|
|
|
import { centerLines } from './strings.js'
|
|
|
|
|
|
|
|
// Displays a brief randomly-selected rainbow-animated phrase
|
|
|
|
const greetingMessages = ['Portaling!', 'You are a Unicorn!', "Here we go!", "Wow!", "AO Loading...", "Powering Up!", "Unicorn Portal", "Don't Panic!"]
|
|
|
|
export async function unicornPortal(ms) {
|
|
|
|
const randomGreetingMessage = selectRandom(greetingMessages)
|
|
|
|
const rainbowTitle = chalkAnimation.rainbow(randomGreetingMessage + '\n')
|
|
|
|
await sleep(ms)
|
|
|
|
rainbowTitle.stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prints the given message to the screen in the given ASCII art style. Here is a list of decent styles:
|
|
|
|
const asciiFonts = ['Standard', 'Digital', 'Bubble', 'Script', 'Mini', 'Banner', 'Alphabet', 'Avatar', 'Chunky', 'Computer', 'Contessa', 'Gothic', 'Invita', 'Lockergnome', 'Madrid', 'Morse', 'Moscow', 'Pawp', 'Pepper', 'Pyramid', 'Rectangles', 'Shadow', 'Short', 'Slant', 'Small', 'Stampatello', 'Stop', 'Straight', 'Thick', 'Thin', 'Weird']
|
|
|
|
export async function asciiArt(message, style) {
|
|
|
|
if(!style) style = selectRandom(asciiFonts)
|
|
|
|
let art = figlet.textSync(message || 'Autonomous Organization', { font: style })
|
|
|
|
art = centerLines(art)
|
|
|
|
console.log(gradient.pastel.multiline(art))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clears the console
|
|
|
|
export function clearScreen() {
|
|
|
|
console.clear()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Displays a spinner for 1.2 secconds with the given messages during and after the timer completes
|
|
|
|
export async function spinnerWait(waitingMessage, doneMessage, ms = 1200) {
|
|
|
|
const spinner = createSpinner(waitingMessage || 'Please wait...').start()
|
|
|
|
await sleep(ms)
|
|
|
|
spinner.success({ text: doneMessage || 'Done.' })
|
|
|
|
}
|
|
|
|
|
|
|
|
// Starts a new spinner and returns a function that, when called, will stop it
|
|
|
|
export function spinner(waitingMessage = 'Please wait...', doneMessage = 'Done.') {
|
|
|
|
const spinner = createSpinner(waitingMessage).start()
|
|
|
|
return (doneMessageOverwrite = null) => {
|
|
|
|
spinner.success({text: doneMessageOverwrite || doneMessage})
|
|
|
|
}
|
|
|
|
}
|