generate json file

This commit is contained in:
Leifer
2022-10-27 11:10:04 +02:00
parent ceade85334
commit 860bd8539f
8 changed files with 109 additions and 18 deletions

5
.gitignore vendored
View File

@@ -1,5 +1,4 @@
/node_modules /node_modules
/node_modules/*
session.json session.json
chats/* chats/*
!chats/.gitkeep !chats/.gitkeep
@@ -9,4 +8,6 @@ mediaSend/*
!mediaSend/.gitkeep !mediaSend/.gitkeep
!mediaSend/nota-de-voz.mp3 !mediaSend/nota-de-voz.mp3
.env .env
.wwebjs_auth .wwebjs_auth
packages/cli/config.json
config.json

18
package-lock.json generated
View File

@@ -6135,9 +6135,9 @@
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
}, },
"node_modules/whatsapp-web.js": { "node_modules/whatsapp-web.js": {
"version": "1.18.0", "version": "1.18.2",
"resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.18.0.tgz", "resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.18.2.tgz",
"integrity": "sha512-3cCW28/w7llZmTgiO9osumaopOuBBduvyuW02yfy3q9Rz4Wq9Oe1dRedE/kkq764zB8AZcuTs0tE8OKTq2Zobw==", "integrity": "sha512-RMzLgstoS9hLK4ix+RchDxXdpuSXuV8jm7SDb/8xc5Ju09zrkOP11dj/4XYszmuwNR0n1VsxNQGp39pnulmcUA==",
"dependencies": { "dependencies": {
"@pedroslopez/moduleraid": "^5.0.2", "@pedroslopez/moduleraid": "^5.0.2",
"fluent-ffmpeg": "^2.1.2", "fluent-ffmpeg": "^2.1.2",
@@ -6431,6 +6431,9 @@
"packages/cli": { "packages/cli": {
"version": "1.0.0", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"dependencies": {
"whatsapp-web.js": "^1.18.2"
},
"devDependencies": { "devDependencies": {
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"detect-package-manager": "^2.0.1", "detect-package-manager": "^2.0.1",
@@ -7500,7 +7503,8 @@
"detect-package-manager": "^2.0.1", "detect-package-manager": "^2.0.1",
"kleur": "^4.1.5", "kleur": "^4.1.5",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"rimraf": "^3.0.2" "rimraf": "^3.0.2",
"whatsapp-web.js": "1.18.2"
} }
}, },
"cli-tableau": { "cli-tableau": {
@@ -11106,9 +11110,9 @@
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
}, },
"whatsapp-web.js": { "whatsapp-web.js": {
"version": "1.18.0", "version": "1.18.2",
"resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.18.0.tgz", "resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.18.2.tgz",
"integrity": "sha512-3cCW28/w7llZmTgiO9osumaopOuBBduvyuW02yfy3q9Rz4Wq9Oe1dRedE/kkq764zB8AZcuTs0tE8OKTq2Zobw==", "integrity": "sha512-RMzLgstoS9hLK4ix+RchDxXdpuSXuV8jm7SDb/8xc5Ju09zrkOP11dj/4XYszmuwNR0n1VsxNQGp39pnulmcUA==",
"requires": { "requires": {
"@pedroslopez/moduleraid": "^5.0.2", "@pedroslopez/moduleraid": "^5.0.2",
"archiver": "^5.3.1", "archiver": "^5.3.1",

View File

@@ -5,7 +5,7 @@
- [x] Obtener Package Manager - [x] Obtener Package Manager
- [x] Revisar las libreria de WhatsappWeb para obtener version reciente - [x] Revisar las libreria de WhatsappWeb para obtener version reciente
- [x] Opcion interactiva de limpiar session - [x] Opcion interactiva de limpiar session
- [ ] Opcion de generar `json` con la configuracion - [x] Opcion de generar `json` con la configuracion
- [x] Agregar `rollup` para limpiar el codigo - [x] Agregar `rollup` para limpiar el codigo
--- ---

View File

@@ -0,0 +1,33 @@
const { writeFile } = require('fs').promises
const { join } = require('path')
/**
* JSON_TEMPLATE = {[key:string]{...pros}}
*/
const JSON_TEMPLATE = {
provider: {
vendor: '',
},
database: {
host: '',
password: '',
port: '',
username: '',
db: '',
},
io: {
vendor: '',
},
}
const PATH_CONFIG = join(process.cwd(), 'config.json')
const jsonConfig = () => {
return writeFile(
PATH_CONFIG,
JSON.stringify(JSON_TEMPLATE, null, 2),
'utf-8'
)
}
module.exports = { jsonConfig }

View File

@@ -1,9 +1,15 @@
const { readFileSync } = require('fs') const { readFileSync, existsSync } = require('fs')
const { join } = require('path') const { join } = require('path')
const { installDeps } = require('./tool') const { installDeps } = require('./tool')
const PATHS_DIR = [
join(__dirname, 'pkg-to-update.json'),
join(__dirname, '..', 'pkg-to-update.json'),
]
const PKG_TO_UPDATE = () => { const PKG_TO_UPDATE = () => {
const data = readFileSync(join(__dirname, 'pkg-to-update.json'), 'utf-8') const PATH_INDEX = PATHS_DIR.findIndex((a) => existsSync(a))
const data = readFileSync(PATHS_DIR[PATH_INDEX], 'utf-8')
const dataParse = JSON.parse(data) const dataParse = JSON.parse(data)
const pkg = Object.keys(dataParse).map((n) => `${n}@${dataParse[n]}`) const pkg = Object.keys(dataParse).map((n) => `${n}@${dataParse[n]}`)
return pkg return pkg

View File

@@ -3,6 +3,7 @@ const { yellow, red } = require('kleur')
const { installAll } = require('../install') const { installAll } = require('../install')
const { cleanSession } = require('../clean') const { cleanSession } = require('../clean')
const { checkNodeVersion, checkOs } = require('../check') const { checkNodeVersion, checkOs } = require('../check')
const { jsonConfig } = require('../configuration')
const startInteractive = async () => { const startInteractive = async () => {
const questions = [ const questions = [
@@ -120,6 +121,7 @@ const startInteractive = async () => {
await cleanAllSession() await cleanAllSession()
await vendorProvider() await vendorProvider()
await dbProvider() await dbProvider()
await jsonConfig()
} }
module.exports = { startInteractive } module.exports = { startInteractive }

View File

@@ -76,12 +76,18 @@ const installDeps$1 = (pkgManager, packageList) => {
var tool = { getPkgManage, installDeps: installDeps$1 }; var tool = { getPkgManage, installDeps: installDeps$1 };
const { readFileSync } = require$$0$1; const { readFileSync, existsSync } = require$$0$1;
const { join: join$1 } = require$$1$1; const { join: join$2 } = require$$1$1;
const { installDeps } = tool; const { installDeps } = tool;
const PATHS_DIR = [
join$2(__dirname, 'pkg-to-update.json'),
join$2(__dirname, '..', 'pkg-to-update.json'),
];
const PKG_TO_UPDATE = () => { const PKG_TO_UPDATE = () => {
const data = readFileSync(join$1(__dirname, 'pkg-to-update.json'), 'utf-8'); const PATH_INDEX = PATHS_DIR.findIndex((a) => existsSync(a));
const data = readFileSync(PATHS_DIR[PATH_INDEX], 'utf-8');
const dataParse = JSON.parse(data); const dataParse = JSON.parse(data);
const pkg = Object.keys(dataParse).map((n) => `${n}@${dataParse[n]}`); const pkg = Object.keys(dataParse).map((n) => `${n}@${dataParse[n]}`);
return pkg return pkg
@@ -96,11 +102,11 @@ var install = { installAll: installAll$1 };
const rimraf = require$$0$2; const rimraf = require$$0$2;
const { yellow: yellow$2 } = require$$0; const { yellow: yellow$2 } = require$$0;
const { join } = require$$1$1; const { join: join$1 } = require$$1$1;
const PATH_WW = [ const PATH_WW = [
join(process.cwd(), '.wwebjs_auth'), join$1(process.cwd(), '.wwebjs_auth'),
join(process.cwd(), 'session.json'), join$1(process.cwd(), 'session.json'),
]; ];
const cleanSession$1 = () => { const cleanSession$1 = () => {
@@ -153,11 +159,46 @@ const checkOs$1 = () => {
var check = { checkNodeVersion: checkNodeVersion$1, checkOs: checkOs$1 }; var check = { checkNodeVersion: checkNodeVersion$1, checkOs: checkOs$1 };
const { writeFile } = require$$0$1.promises;
const { join } = require$$1$1;
/**
* JSON_TEMPLATE = {[key:string]{...pros}}
*/
const JSON_TEMPLATE = {
provider: {
vendor: '',
},
database: {
host: '',
password: '',
port: '',
username: '',
db: '',
},
io: {
vendor: '',
},
};
const PATH_CONFIG = join(process.cwd(), 'config.json');
const jsonConfig$1 = () => {
return writeFile(
PATH_CONFIG,
JSON.stringify(JSON_TEMPLATE, null, 2),
'utf-8'
)
};
var configuration = { jsonConfig: jsonConfig$1 };
const prompts = require$$0$3; const prompts = require$$0$3;
const { yellow, red } = require$$0; const { yellow, red } = require$$0;
const { installAll } = install; const { installAll } = install;
const { cleanSession } = clean; const { cleanSession } = clean;
const { checkNodeVersion, checkOs } = check; const { checkNodeVersion, checkOs } = check;
const { jsonConfig } = configuration;
const startInteractive$1 = async () => { const startInteractive$1 = async () => {
const questions = [ const questions = [
@@ -275,6 +316,7 @@ const startInteractive$1 = async () => {
await cleanAllSession(); await cleanAllSession();
await vendorProvider(); await vendorProvider();
await dbProvider(); await dbProvider();
await jsonConfig();
}; };
var interactive = { startInteractive: startInteractive$1 }; var interactive = { startInteractive: startInteractive$1 };

View File

@@ -21,5 +21,8 @@
"kleur": "^4.1.5", "kleur": "^4.1.5",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"rimraf": "^3.0.2" "rimraf": "^3.0.2"
},
"dependencies": {
"whatsapp-web.js": "^1.18.2"
} }
} }