chore(create-bot): use colorette instead of chalk

This commit is contained in:
alina 🌸 2024-02-22 14:34:50 +03:00
parent f05ada6cd2
commit 43e10dda73
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
5 changed files with 24 additions and 23 deletions

View file

@ -14,7 +14,7 @@
"create-bot": "./src/main.js"
},
"dependencies": {
"chalk": "5.3.0",
"colorette": "^2.0.20",
"cross-spawn": "7.0.3",
"glob": "10.2.6",
"handlebars": "4.7.8",
@ -22,7 +22,7 @@
"open": "9.1.0"
},
"devDependencies": {
"@types/inquirer": "^9.0.6",
"@types/cross-spawn": "^6.0.6"
"@types/cross-spawn": "^6.0.6",
"@types/inquirer": "^9.0.6"
}
}

View file

@ -1,4 +1,4 @@
import chalk from 'chalk'
import * as colors from 'colorette'
import inquirer from 'inquirer'
import open from 'open'
@ -47,14 +47,16 @@ export async function askForConfigPersisted(): Promise<UserConfigPersisted> {
setTimeout(() => void open(TELEGRAM_APPS_PAGE), 1000)
return [
chalk.italic(`Opening ${chalk.blue(TELEGRAM_APPS_PAGE)}...`),
`🔒 Log in with your ${chalk.blueBright('Telegram')} account`,
colors.italic(`Opening ${colors.blue(TELEGRAM_APPS_PAGE)}...`),
`🔒 Log in with your ${colors.blueBright('Telegram')} account`,
'📝 Fill out the form:',
` - ${chalk.bold('App title, short name')}: anything you want, can be changed later`,
` - ${chalk.bold('Platform')}: doesn't matter`,
` - ${chalk.bold('URL')}: can be left blank`,
`🚀 Click ${chalk.bold('Create application')}`,
`${chalk.bold.red('❗ DO NOT')} share your API hash with anyone, as it can't be revoked`,
` - ${colors.bold('App title, short name')}: anything you want, can be changed later`,
` - ${colors.bold('Platform')}: doesn't matter`,
` - ${colors.bold('URL')}: can be left blank`,
`🚀 Click ${colors.bold('Create application')}`,
`${colors.bold(
colors.red('❗ DO NOT'),
)} share your API hash with anyone, as it can't be revoked`,
].join('\n')
}
if (!/^\d+$/.test(v)) return 'API ID must be a number'
@ -109,8 +111,8 @@ export async function askForConfig(): Promise<UserConfig> {
allowEmptyBotToken = true
return [
`You most likely need a bot token. You can obtain one from ${chalk.blue('@BotFather')}`,
` Press ${chalk.bold('Enter')} again if you want to create a ${chalk.magenta('userbot')}`,
`You most likely need a bot token. You can obtain one from ${colors.blue('@BotFather')}`,
` Press ${colors.bold('Enter')} again if you want to create a ${colors.magenta('userbot')}`,
].join('\n')
}
if (!v.match(/^(\d+):[a-z0-9-_]{16,50}$/i)) return 'Invalid bot token'

View file

@ -1,4 +1,4 @@
import chalk from 'chalk'
import * as colors from 'colorette'
import { join } from 'node:path'
import { askForConfig } from './cli.js'
@ -37,7 +37,7 @@ if (config.features.includes(MtcuteFeature.Linters)) {
await exec(outDir, 'pnpm', 'exec', 'husky', 'install')
}
console.log(`✅ Scaffolded new project at ${chalk.blue(outDir)}`)
console.log(`✅ Scaffolded new project at ${colors.blue(outDir)}`)
console.log('🚀 Run it with:')
console.log(` ${chalk.blue('$')} cd ${projectName}`)
console.log(` ${chalk.blue('$')} pnpm start`)
console.log(` ${colors.blue('$')} cd ${projectName}`)
console.log(` ${colors.blue('$')} pnpm start`)

View file

@ -1,9 +1,9 @@
import chalk from 'chalk'
import * as colors from 'colorette'
import { spawn } from 'cross-spawn'
export function exec(cwd: string, ...cmd: string[]) {
return new Promise<void>((resolve, reject) => {
console.log(`${chalk.blue('$')} ${cmd.join(' ')}`)
console.log(`${colors.blue('$')} ${cmd.join(' ')}`)
const proc = spawn(cmd[0], cmd.slice(1), {
stdio: 'inherit',

View file

@ -151,9 +151,9 @@ importers:
packages/create-bot:
dependencies:
chalk:
specifier: 5.3.0
version: 5.3.0
colorette:
specifier: ^2.0.20
version: 2.0.20
cross-spawn:
specifier: 7.0.3
version: 7.0.3
@ -2039,7 +2039,6 @@ packages:
/colorette@2.0.20:
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
dev: true
/commander@10.0.1:
resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==}