mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
chore: ⚡ improvement cli
This commit is contained in:
@@ -2,50 +2,64 @@ const { red, yellow, green, bgCyan } = require('kleur')
|
||||
const { exec } = require('node:child_process')
|
||||
|
||||
const checkNodeVersion = () => {
|
||||
console.log(bgCyan('🚀 Revisando tu Node.js'))
|
||||
const version = process.version
|
||||
const majorVersion = parseInt(version.replace('v', '').split('.').shift())
|
||||
if (majorVersion < 16) {
|
||||
console.error(
|
||||
red(
|
||||
`🔴 Se require Node.js 16 o superior. Actualmente esta ejecutando Node.js ${version}`
|
||||
)
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(bgCyan('🚀 Revisando tu Node.js'))
|
||||
const version = process.version
|
||||
const majorVersion = parseInt(
|
||||
version.replace('v', '').split('.').shift()
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(green(`Node.js: ${version} compatible ✅`))
|
||||
console.log(``)
|
||||
if (majorVersion < 16) {
|
||||
console.error(
|
||||
red(
|
||||
`🔴 Se require Node.js 16 o superior. Actualmente esta ejecutando Node.js ${version}`
|
||||
)
|
||||
)
|
||||
console.log(``)
|
||||
reject('ERROR_NODE')
|
||||
}
|
||||
console.log(green(`Node.js: ${version} compatible ✅`))
|
||||
console.log(``)
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
const checkOs = () => {
|
||||
console.log(bgCyan('🙂 Revisando tu sistema operativo'))
|
||||
const os = process.platform
|
||||
if (!os.includes('win32')) {
|
||||
const messages = [
|
||||
`El sistema operativo actual (${os}) posiblemente requiera`,
|
||||
`una configuración adicional referente al puppeteer`,
|
||||
``,
|
||||
`Recuerda pasar por el WIKI`,
|
||||
`🔗 https://github.com/leifermendez/bot-whatsapp/wiki/Instalación`,
|
||||
``,
|
||||
]
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(bgCyan('🙂 Revisando tu sistema operativo'))
|
||||
const os = process.platform
|
||||
if (!os.includes('win32')) {
|
||||
const messages = [
|
||||
`El sistema operativo actual (${os}) posiblemente requiera`,
|
||||
`una configuración adicional referente al puppeteer`,
|
||||
``,
|
||||
`Recuerda pasar por el WIKI`,
|
||||
`🔗 https://github.com/leifermendez/bot-whatsapp/wiki/Instalación`,
|
||||
``,
|
||||
]
|
||||
|
||||
console.log(yellow(messages.join(' \n')))
|
||||
}
|
||||
console.log(green(`OS: compatible ✅`))
|
||||
console.log(``)
|
||||
console.log(yellow(messages.join(' \n')))
|
||||
}
|
||||
console.log(green(`OS: compatible ✅`))
|
||||
console.log(``)
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
const checkGit = () => {
|
||||
console.log(bgCyan('🤓 Revisando GIT'))
|
||||
exec('git --version', (error) => {
|
||||
if (error) {
|
||||
console.error(red(`🔴 Se require instalar GIT`))
|
||||
process.exit(1)
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(bgCyan('🤓 Revisando GIT'))
|
||||
exec('git --version', (error) => {
|
||||
if (error) {
|
||||
console.error(red(`🔴 Se require instalar GIT`))
|
||||
console.log(``)
|
||||
reject('ERROR_GIT')
|
||||
} else {
|
||||
console.log(green(`Git: Compatible ✅`))
|
||||
console.log(``)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
console.log(green(`Git: Compatible ✅`))
|
||||
console.log(``)
|
||||
}
|
||||
|
||||
module.exports = { checkNodeVersion, checkOs, checkGit }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const prompts = require('prompts')
|
||||
const { join } = require('path')
|
||||
const { yellow, red, cyan, bgMagenta } = require('kleur')
|
||||
const { yellow, red, cyan, bgMagenta, bgRed } = require('kleur')
|
||||
const { existsSync } = require('fs')
|
||||
const { copyBaseApp } = require('../create-app')
|
||||
const { checkNodeVersion, checkOs, checkGit } = require('../check')
|
||||
@@ -21,6 +21,22 @@ const bannerDone = () => {
|
||||
}
|
||||
|
||||
const startInteractive = async () => {
|
||||
try {
|
||||
console.clear()
|
||||
await checkNodeVersion()
|
||||
checkOs()
|
||||
await checkGit()
|
||||
console.clear()
|
||||
await nextSteps()
|
||||
} catch (e) {
|
||||
console.error(bgRed(`Ups! 🙄 algo no va bien.`))
|
||||
console.error(
|
||||
bgRed(`Revisa los requerimientos minimos en la documentacion`)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const nextSteps = async () => {
|
||||
const questions = [
|
||||
{
|
||||
type: 'text',
|
||||
@@ -58,10 +74,6 @@ const startInteractive = async () => {
|
||||
},
|
||||
]
|
||||
|
||||
console.clear()
|
||||
checkOs()
|
||||
checkNodeVersion()
|
||||
checkGit()
|
||||
const onCancel = () => {
|
||||
console.log('¡Proceso cancelado!')
|
||||
return true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "create-bot-whatsapp",
|
||||
"version": "0.0.78-alpha.0",
|
||||
"version": "0.0.92-alpha.0",
|
||||
"description": "",
|
||||
"main": "./lib/bundle.create-bot-whatsapp.cjs",
|
||||
"files": [
|
||||
|
||||
Reference in New Issue
Block a user