chore(create-bot): use colorette
instead of chalk
This commit is contained in:
parent
f05ada6cd2
commit
43e10dda73
5 changed files with 24 additions and 23 deletions
|
@ -14,7 +14,7 @@
|
||||||
"create-bot": "./src/main.js"
|
"create-bot": "./src/main.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "5.3.0",
|
"colorette": "^2.0.20",
|
||||||
"cross-spawn": "7.0.3",
|
"cross-spawn": "7.0.3",
|
||||||
"glob": "10.2.6",
|
"glob": "10.2.6",
|
||||||
"handlebars": "4.7.8",
|
"handlebars": "4.7.8",
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
"open": "9.1.0"
|
"open": "9.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/inquirer": "^9.0.6",
|
"@types/cross-spawn": "^6.0.6",
|
||||||
"@types/cross-spawn": "^6.0.6"
|
"@types/inquirer": "^9.0.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import chalk from 'chalk'
|
import * as colors from 'colorette'
|
||||||
import inquirer from 'inquirer'
|
import inquirer from 'inquirer'
|
||||||
import open from 'open'
|
import open from 'open'
|
||||||
|
|
||||||
|
@ -47,14 +47,16 @@ export async function askForConfigPersisted(): Promise<UserConfigPersisted> {
|
||||||
setTimeout(() => void open(TELEGRAM_APPS_PAGE), 1000)
|
setTimeout(() => void open(TELEGRAM_APPS_PAGE), 1000)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
chalk.italic(`Opening ${chalk.blue(TELEGRAM_APPS_PAGE)}...`),
|
colors.italic(`Opening ${colors.blue(TELEGRAM_APPS_PAGE)}...`),
|
||||||
`🔒 Log in with your ${chalk.blueBright('Telegram')} account`,
|
`🔒 Log in with your ${colors.blueBright('Telegram')} account`,
|
||||||
'📝 Fill out the form:',
|
'📝 Fill out the form:',
|
||||||
` - ${chalk.bold('App title, short name')}: anything you want, can be changed later`,
|
` - ${colors.bold('App title, short name')}: anything you want, can be changed later`,
|
||||||
` - ${chalk.bold('Platform')}: doesn't matter`,
|
` - ${colors.bold('Platform')}: doesn't matter`,
|
||||||
` - ${chalk.bold('URL')}: can be left blank`,
|
` - ${colors.bold('URL')}: can be left blank`,
|
||||||
`🚀 Click ${chalk.bold('Create application')}`,
|
`🚀 Click ${colors.bold('Create application')}`,
|
||||||
`${chalk.bold.red('❗ DO NOT')} share your API hash with anyone, as it can't be revoked`,
|
`${colors.bold(
|
||||||
|
colors.red('❗ DO NOT'),
|
||||||
|
)} share your API hash with anyone, as it can't be revoked`,
|
||||||
].join('\n')
|
].join('\n')
|
||||||
}
|
}
|
||||||
if (!/^\d+$/.test(v)) return 'API ID must be a number'
|
if (!/^\d+$/.test(v)) return 'API ID must be a number'
|
||||||
|
@ -109,8 +111,8 @@ export async function askForConfig(): Promise<UserConfig> {
|
||||||
allowEmptyBotToken = true
|
allowEmptyBotToken = true
|
||||||
|
|
||||||
return [
|
return [
|
||||||
`You most likely need a bot token. You can obtain one from ${chalk.blue('@BotFather')}`,
|
`You most likely need a bot token. You can obtain one from ${colors.blue('@BotFather')}`,
|
||||||
` Press ${chalk.bold('Enter')} again if you want to create a ${chalk.magenta('userbot')}`,
|
` Press ${colors.bold('Enter')} again if you want to create a ${colors.magenta('userbot')}`,
|
||||||
].join('\n')
|
].join('\n')
|
||||||
}
|
}
|
||||||
if (!v.match(/^(\d+):[a-z0-9-_]{16,50}$/i)) return 'Invalid bot token'
|
if (!v.match(/^(\d+):[a-z0-9-_]{16,50}$/i)) return 'Invalid bot token'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import chalk from 'chalk'
|
import * as colors from 'colorette'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
|
|
||||||
import { askForConfig } from './cli.js'
|
import { askForConfig } from './cli.js'
|
||||||
|
@ -37,7 +37,7 @@ if (config.features.includes(MtcuteFeature.Linters)) {
|
||||||
await exec(outDir, 'pnpm', 'exec', 'husky', 'install')
|
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('🚀 Run it with:')
|
||||||
console.log(` ${chalk.blue('$')} cd ${projectName}`)
|
console.log(` ${colors.blue('$')} cd ${projectName}`)
|
||||||
console.log(` ${chalk.blue('$')} pnpm start`)
|
console.log(` ${colors.blue('$')} pnpm start`)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import chalk from 'chalk'
|
import * as colors from 'colorette'
|
||||||
import { spawn } from 'cross-spawn'
|
import { spawn } from 'cross-spawn'
|
||||||
|
|
||||||
export function exec(cwd: string, ...cmd: string[]) {
|
export function exec(cwd: string, ...cmd: string[]) {
|
||||||
return new Promise<void>((resolve, reject) => {
|
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), {
|
const proc = spawn(cmd[0], cmd.slice(1), {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
|
|
|
@ -151,9 +151,9 @@ importers:
|
||||||
|
|
||||||
packages/create-bot:
|
packages/create-bot:
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk:
|
colorette:
|
||||||
specifier: 5.3.0
|
specifier: ^2.0.20
|
||||||
version: 5.3.0
|
version: 2.0.20
|
||||||
cross-spawn:
|
cross-spawn:
|
||||||
specifier: 7.0.3
|
specifier: 7.0.3
|
||||||
version: 7.0.3
|
version: 7.0.3
|
||||||
|
@ -2039,7 +2039,6 @@ packages:
|
||||||
|
|
||||||
/colorette@2.0.20:
|
/colorette@2.0.20:
|
||||||
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
|
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/commander@10.0.1:
|
/commander@10.0.1:
|
||||||
resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==}
|
resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==}
|
||||||
|
|
Loading…
Reference in a new issue