atendeticket 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/appInstaller.js CHANGED
@@ -167,4 +167,152 @@ async function runInstaller() {
167
167
  }
168
168
  }
169
169
 
170
- module.exports = { runInstaller };
170
+ async function handleMenu(choice) {
171
+ if (choice.action === 'install') {
172
+ const answers = await installPrompts();
173
+
174
+ // Generate JWT secrets
175
+ const jwt_secret = require('crypto').randomBytes(64).toString('base64');
176
+ const jwt_refresh_secret = require('crypto').randomBytes(64).toString('base64');
177
+
178
+ // Configurações automáticas do Redis
179
+ const redis_host = "localhost";
180
+ const redis_password = answers.mysql_root_password;
181
+ const redis_uri = `redis://:${redis_password}@${redis_host}:${answers.redisPort}`;
182
+
183
+ // Sistema
184
+ await updateSystem();
185
+ await installNode();
186
+ await installDocker();
187
+ await installPM2();
188
+ await installNginx();
189
+ await installCertbot();
190
+ await createUser(answers.mysql_root_password);
191
+
192
+ // Backend
193
+ await createDatabase(answers.instancia_add, answers.mysql_root_password);
194
+ await createRedis(answers.instancia_add, answers.redisPort, answers.mysql_root_password);
195
+ await setBackendEnv(
196
+ '', // node_env
197
+ answers.backendUrl,
198
+ answers.frontendUrl,
199
+ 443, // proxy_port
200
+ answers.backendPort,
201
+ 'localhost', // db_host
202
+ 'postgres', // db_dialect
203
+ answers.instancia_add, // db_user
204
+ answers.mysql_root_password, // db_pass
205
+ answers.instancia_add, // db_name
206
+ 5432, // db_port
207
+ 'senha_master', // master_key
208
+ 1, // import_fallback_file
209
+ 1000, // timeout_to_import_message
210
+ 3, // app_trialexpiration
211
+ jwt_secret,
212
+ jwt_refresh_secret,
213
+ redis_uri,
214
+ 1, // redis_opt_limiter_max
215
+ 3000, // redis_opt_limiter_duration
216
+ 8, // flow_menu_cooldown_sec
217
+ answers.max_user, // user_limit
218
+ answers.max_whats, // connections_limit
219
+ true, // closed_send_by_me
220
+ 'whaticket', // verify_token
221
+ '', // mp_access_token
222
+ '2813216208828642', // facebook_app_id
223
+ '8233912aeade366dd8e2ebef6be256b6', // facebook_app_secret
224
+ 'smtp.gmail.com', // smtp_host
225
+ '587', // smtp_port
226
+ 'false', // smtp_secure
227
+ 'seuemail@gmail.com', // smtp_user
228
+ 'suasenha', // smtp_pass
229
+ 'Redefinição de senha <seuemail@gmail.com>' // smtp_from
230
+ );
231
+ await installBackendDeps();
232
+ await buildBackend();
233
+ await migrate();
234
+ await seed();
235
+ await startBackendPM2();
236
+ await setupBackendNginx(answers.backendUrl.replace(/^https?:\/\//, ''));
237
+
238
+ // Frontend
239
+ await setFrontendEnv(
240
+ answers.backendUrl,
241
+ 24, // hours_close_tickets_auto
242
+ 'https', // backend_protocol
243
+ answers.backendUrl.replace(/^https?:\/\//, ''), // backend_host
244
+ answers.backendPort, // backend_port_param
245
+ 'pt-br', // locale
246
+ 'America/Sao_Paulo', // timezone
247
+ '55XXXXXXXXXXX', // number_support
248
+ '2813216208828642', // facebook_app_id
249
+ true, // require_business_management
250
+ false, // certificates
251
+ true, // https
252
+ 'F:\\bkpidx\\workflow\\backend\\certs\\localhost.pem', // ssl_crt_file
253
+ 'F:\\bkpidx\\workflow\\backend\\certs\\localhost-key.pem', // ssl_key_file
254
+ '2813216208828642', // react_app_facebook_app_id
255
+ true, // react_app_require_business_management
256
+ false, // generate_sourcemap
257
+ false // disable_eslint_plugin
258
+ );
259
+ await installFrontendDeps();
260
+ await buildFrontend();
261
+ await startFrontendPM2();
262
+ await setupFrontendNginx(answers.frontendUrl.replace(/^https?:\/\//, ''));
263
+
264
+ // SSL
265
+ const backend_domain = answers.backendUrl.replace(/^https?:\/\//, '');
266
+ const frontend_domain = answers.frontendUrl.replace(/^https?:\/\//, '');
267
+ await setupSSL(backend_domain, frontend_domain, answers.deployEmail);
268
+
269
+ success('Instalação completa do Multizap!');
270
+ }
271
+
272
+ if (choice.action === 'update') {
273
+ const answers = await updatePrompts();
274
+
275
+ if (answers.updateSystem) await updateSystem();
276
+ if (answers.updateBackend) {
277
+ await installBackendDeps();
278
+ await buildBackend();
279
+ await migrate();
280
+ await seed();
281
+ await startBackendPM2();
282
+ }
283
+ if (answers.updateFrontend) {
284
+ await installFrontendDeps();
285
+ await buildFrontend();
286
+ await startFrontendPM2();
287
+ }
288
+
289
+ success('Atualização concluída!');
290
+ }
291
+
292
+ if (choice.action === 'delete') {
293
+ await deleteAction();
294
+ success('Instância deletada com sucesso!');
295
+ }
296
+
297
+ if (choice.action === 'block') {
298
+ await block();
299
+ success('Instância bloqueada com sucesso!');
300
+ }
301
+
302
+ if (choice.action === 'unblock') {
303
+ await unblock();
304
+ success('Instância desbloqueada com sucesso!');
305
+ }
306
+
307
+ if (choice.action === 'changeDomain') {
308
+ await changeDomain();
309
+ success('Domínio alterado com sucesso!');
310
+ }
311
+
312
+ if (choice.action === 'update') {
313
+ await update();
314
+ success('Atualização concluída!');
315
+ }
316
+ }
317
+
318
+ module.exports = { runInstaller, handleMenu };
package/core/banner.js CHANGED
@@ -1,12 +1,12 @@
1
- async function showBanner() {
2
- const chalk = (await import('chalk')).default;
1
+ function showBanner() {
2
+ const chalk = require('chalk');
3
3
 
4
4
  console.log(chalk.cyan(`
5
- ___ _ _ _ _ _
6
- / _ \\ _ __(_)_ _____| | ___ | | (_) | ___
7
- | | | | '__| \\ \\ / / _ \\ |/ _ \\ | | | |/ _ \\
8
- | |_| | | | |\\ V / __/ | __/ | |__| | | __/
9
- \\___/|_| |_| \\_/ \\___|_|\\___| |____/|_|\\___|
5
+ ___ _ _ _ _ _
6
+ / _ \\ _ __(_)_ _____| | ___ | | (_) | ___
7
+ | | | | '__| \\ \\ / / _ \\ |/ _ \\ | | | |/ _ \\
8
+ | |_| | | | |\\ V / __/ | __/ | |__| | | __/
9
+ \\___/|_| |_| \\_/ \\___|_|\\___| |____/|_|\\___|
10
10
  `));
11
11
  }
12
12
 
package/index.js CHANGED
@@ -4,7 +4,7 @@ const { mainMenuPrompt } = require('./prompts/mainMenu');
4
4
  const { handleMenu } = require('./appInstaller');
5
5
 
6
6
  (async () => {
7
- showBanner();
7
+ await showBanner();
8
8
  const choice = await mainMenuPrompt();
9
9
  await handleMenu(choice);
10
10
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atendeticket",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "Instalador CLI para AtendeTicket",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  "atendeticket": "./index.js"
11
11
  },
12
12
  "dependencies": {
13
- "chalk": "^5.3.0",
13
+ "chalk": "^4.1.2",
14
14
  "inquirer": "^9.2.7",
15
15
  "cross-spawn": "^7.0.6"
16
16
  }
@@ -9,6 +9,10 @@ async function mainMenuPrompt() {
9
9
  choices: [
10
10
  { name: 'Instalar sistema', value: 'install' },
11
11
  { name: 'Atualizar sistema', value: 'update' },
12
+ { name: 'Deletar instância', value: 'delete' },
13
+ { name: 'Bloquear instância', value: 'block' },
14
+ { name: 'Desbloquear instância', value: 'unblock' },
15
+ { name: 'Alterar domínio', value: 'changeDomain' },
12
16
  ],
13
17
  },
14
18
  ]);