@astrojs/cli-kit
Advanced tools
Comparing version 0.0.4 to 0.1.0
import readline from 'node:readline'; | ||
import color from 'chalk'; | ||
import logUpdate from 'log-update'; | ||
import { random, randomBetween, sleep } from '../utils/index.js'; | ||
import { random, randomBetween, sleep, isWin } from '../utils/index.js'; | ||
import { action } from '../prompt/util/action.js'; | ||
@@ -41,10 +41,14 @@ import { strip } from '../prompt/util/clear.js'; | ||
const _messages = Array.isArray(messages) ? messages : [messages]; | ||
const eyes = ['●', '●', '●', '●', '●', '○', '○', '•']; | ||
const mouths = ['•', '○', '■', '▪', '▫', '▬', '▭', '-', '○']; | ||
const eyes = isWin ? ['•', '•', 'o', 'o', '•', 'O', '^', '•'] : ['●', '●', '●', '●', '●', '○', '○', '•']; | ||
const mouths = isWin ? ['•', 'O', '*', 'o', 'o', '•', '-'] : ['•', '○', '■', '▪', '▫', '▬', '▭', '-', '○']; | ||
const walls = isWin ? ['—', '|'] : ['─', '│']; | ||
const corners = isWin ? ['+', '+', '+', '+'] : ['╭', '╮', '╰', '╯']; | ||
const face = (msg, { mouth = mouths[0], eye = eyes[0] } = {}) => { | ||
const head = '─'.repeat(3 - strip(hat).split('').length); | ||
const [h, v] = walls; | ||
const [tl, tr, bl, br] = corners; | ||
const head = h.repeat(3 - strip(hat).split('').length); | ||
return [ | ||
`╭──${hat}${head}╮ ${color.bold(color.cyan('Houston:'))}`, | ||
`│ ${eye} ${color.cyanBright(mouth)} ${eye} ${msg}`, | ||
`╰─────╯`, | ||
`${tl}${h.repeat(2)}${hat}${head}${tr} ${color.bold(color.cyan('Houston:'))}`, | ||
`${v} ${eye} ${color.cyanBright(mouth)} ${eye} ${msg}`, | ||
`${bl}${h.repeat(5)}${br}`, | ||
].join('\n'); | ||
@@ -70,3 +74,3 @@ }; | ||
await sleep(100); | ||
const text = '\n' + face(_message.join(' '), { mouth: '◡', eye: '◠' }); | ||
const text = '\n' + face(_message.join(' '), { mouth: isWin ? 'u' : '◡', eye: isWin ? '^' : '◠' }); | ||
logUpdate(text); | ||
@@ -73,0 +77,0 @@ if (!cancelled) |
import Prompt from './prompt.js'; | ||
import { erase, cursor } from 'sisteransi'; | ||
import color from 'chalk'; | ||
import { isWin } from '../../utils/index.js'; | ||
import clear, { strip } from '../util/clear.js'; | ||
@@ -134,3 +135,3 @@ export default class SelectPrompt extends Prompt { | ||
else { | ||
this.outputText.push(this.choices.map((choice, i) => i === this.cursor ? `${prefix} ${color.green('●')} ${this.highlight(choice.label)} ${choice.hint ? color.dim(choice.hint) : ''}` : color.dim(`${prefix} ○ ${choice.label} `)).join('\n')); | ||
this.outputText.push(this.choices.map((choice, i) => i === this.cursor ? `${prefix} ${color.green(isWin ? '>' : '●')} ${this.highlight(choice.label)} ${choice.hint ? color.dim(choice.hint) : ''}` : color.dim(`${prefix} ${isWin ? '—' : '○'} ${choice.label} `)).join('\n')); | ||
} | ||
@@ -137,0 +138,0 @@ this.outputText = this.outputText.join(''); |
import Prompt from './prompt.js'; | ||
import { erase, cursor } from 'sisteransi'; | ||
import color from 'chalk'; | ||
import { isWin } from '../../utils/index.js'; | ||
import clear, { lines, strip } from '../util/clear.js'; | ||
@@ -197,3 +198,3 @@ /** | ||
if (this.error) { | ||
this.outputError += ` ${color.redBright('▶ ' + this.errorMsg)}`; | ||
this.outputError += ` ${color.redBright((isWin ? '> ' : '▶ ') + this.errorMsg)}`; | ||
} | ||
@@ -200,0 +201,0 @@ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0)); |
/// <reference types="node" /> | ||
export declare const isWin: boolean; | ||
export declare const hookExit: () => () => NodeJS.Process; | ||
@@ -3,0 +4,0 @@ export declare const sleep: (ms: number) => Promise<unknown>; |
import color from 'chalk'; | ||
import { get } from 'node:https'; | ||
import { exec } from 'node:child_process'; | ||
import { platform } from 'node:os'; | ||
import { strip } from '../prompt/util/clear.js'; | ||
export const isWin = platform() === 'win32'; | ||
export const hookExit = () => { | ||
@@ -6,0 +8,0 @@ const onExit = (code) => { |
{ | ||
"name": "@astrojs/cli-kit", | ||
"type": "module", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51619
1585