@openfactu/cli 0.0.7 → 0.0.8
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/README.md +161 -5
- package/dist/src/commands/backup.d.ts +2 -0
- package/dist/src/commands/backup.js +424 -0
- package/dist/src/commands/deploy.js +486 -67
- package/dist/src/commands/doctor.d.ts +2 -0
- package/dist/src/commands/doctor.js +295 -0
- package/dist/src/commands/install-quick.d.ts +2 -0
- package/dist/src/commands/install-quick.js +249 -0
- package/dist/src/commands/install-script.d.ts +2 -0
- package/dist/src/commands/install-script.js +474 -0
- package/dist/src/commands/install.js +966 -72
- package/dist/src/commands/monitoring.d.ts +2 -0
- package/dist/src/commands/monitoring.js +352 -0
- package/dist/src/commands/service.d.ts +2 -0
- package/dist/src/commands/service.js +402 -0
- package/dist/src/commands/setup.js +7 -2
- package/dist/src/commands/sync-ports.d.ts +2 -0
- package/dist/src/commands/sync-ports.js +298 -0
- package/dist/src/commands/uninstall.d.ts +2 -0
- package/dist/src/commands/uninstall.js +189 -0
- package/dist/src/index.js +17 -1
- package/dist/src/utils/config.d.ts +8 -0
- package/dist/src/utils/config.js +25 -1
- package/dist/src/utils/env.d.ts +11 -0
- package/dist/src/utils/env.js +31 -0
- package/dist/src/utils/helpers.d.ts +22 -0
- package/dist/src/utils/helpers.js +244 -0
- package/dist/src/utils/monitoring.d.ts +38 -0
- package/dist/src/utils/monitoring.js +353 -0
- package/dist/src/utils/paths.d.ts +1 -0
- package/dist/src/utils/paths.js +2 -0
- package/package.json +8 -5
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerMonitoringCommand = registerMonitoringCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const ora_1 = __importDefault(require("ora"));
|
|
9
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const logger_1 = require("../utils/logger");
|
|
14
|
+
const paths_1 = require("../utils/paths");
|
|
15
|
+
const helpers_1 = require("../utils/helpers");
|
|
16
|
+
const monitoring_1 = require("../utils/monitoring");
|
|
17
|
+
function readEnv(envPath) {
|
|
18
|
+
const env = {};
|
|
19
|
+
if (!fs_1.default.existsSync(envPath))
|
|
20
|
+
return env;
|
|
21
|
+
const lines = fs_1.default.readFileSync(envPath, 'utf-8').split('\n');
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
const trimmed = line.trim();
|
|
24
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
25
|
+
continue;
|
|
26
|
+
const eqIdx = trimmed.indexOf('=');
|
|
27
|
+
if (eqIdx > 0) {
|
|
28
|
+
env[trimmed.substring(0, eqIdx).trim()] = trimmed.substring(eqIdx + 1).trim();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return env;
|
|
32
|
+
}
|
|
33
|
+
function writeEnv(envPath, env) {
|
|
34
|
+
const lines = [];
|
|
35
|
+
for (const [key, value] of Object.entries(env)) {
|
|
36
|
+
lines.push(`${key}=${value}`);
|
|
37
|
+
}
|
|
38
|
+
fs_1.default.writeFileSync(envPath, lines.join('\n') + '\n');
|
|
39
|
+
}
|
|
40
|
+
function registerMonitoringCommand(program) {
|
|
41
|
+
// ── openfactu monitoring ──
|
|
42
|
+
program
|
|
43
|
+
.command('monitoring')
|
|
44
|
+
.description('Configura el stack de monitoreo y analitica')
|
|
45
|
+
.option('--generate-compose', 'Generar docker-compose.monitoring.yml')
|
|
46
|
+
.option('--with-analytics', 'Incluir stack completo de analitica')
|
|
47
|
+
.action(async (opts) => {
|
|
48
|
+
console.log();
|
|
49
|
+
console.log(chalk_1.default.bold.white(' OpenFactu — Configurar Monitoreo'));
|
|
50
|
+
console.log(chalk_1.default.dim(' ────────────────────────────────────'));
|
|
51
|
+
console.log();
|
|
52
|
+
try {
|
|
53
|
+
const root = (0, paths_1.getProjectRoot)();
|
|
54
|
+
const envPath = path_1.default.join(root, '.env');
|
|
55
|
+
const env = readEnv(envPath);
|
|
56
|
+
const includeAnalytics = opts.withAnalytics || false;
|
|
57
|
+
const { services } = await inquirer_1.default.prompt([
|
|
58
|
+
{
|
|
59
|
+
type: 'checkbox',
|
|
60
|
+
name: 'services',
|
|
61
|
+
message: 'Servicios a activar:',
|
|
62
|
+
choices: (0, monitoring_1.monitoringChoices)({ analytics: includeAnalytics }),
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
const serviceSet = new Set(services);
|
|
66
|
+
const { customizePorts } = await inquirer_1.default.prompt([
|
|
67
|
+
{
|
|
68
|
+
type: 'confirm',
|
|
69
|
+
name: 'customizePorts',
|
|
70
|
+
message: 'Personalizar puertos?',
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
const ports = {};
|
|
75
|
+
if (customizePorts) {
|
|
76
|
+
const portQuestions = [];
|
|
77
|
+
if (serviceSet.has('pgadmin'))
|
|
78
|
+
portQuestions.push({ type: 'input', name: 'PGADMIN_PORT', message: 'Puerto pgAdmin:', default: env.PGADMIN_PORT || '5050' });
|
|
79
|
+
if (serviceSet.has('grafana'))
|
|
80
|
+
portQuestions.push({ type: 'input', name: 'GRAFANA_PORT', message: 'Puerto Grafana:', default: env.GRAFANA_PORT || '3001' });
|
|
81
|
+
if (serviceSet.has('prometheus'))
|
|
82
|
+
portQuestions.push({ type: 'input', name: 'PROMETHEUS_PORT', message: 'Puerto Prometheus:', default: env.PROMETHEUS_PORT || '9090' });
|
|
83
|
+
if (serviceSet.has('loki'))
|
|
84
|
+
portQuestions.push({ type: 'input', name: 'LOKI_PORT', message: 'Puerto Loki:', default: env.LOKI_PORT || '3100' });
|
|
85
|
+
if (serviceSet.has('cadvisor'))
|
|
86
|
+
portQuestions.push({ type: 'input', name: 'CADVISOR_PORT', message: 'Puerto cAdvisor:', default: env.CADVISOR_PORT || '8081' });
|
|
87
|
+
if (serviceSet.has('node-exporter'))
|
|
88
|
+
portQuestions.push({ type: 'input', name: 'NODE_EXPORTER_PORT', message: 'Puerto Node Exporter:', default: env.NODE_EXPORTER_PORT || '9100' });
|
|
89
|
+
if (serviceSet.has('portainer'))
|
|
90
|
+
portQuestions.push({ type: 'input', name: 'PORTAINER_PORT', message: 'Puerto Portainer:', default: env.PORTAINER_PORT || '9000' });
|
|
91
|
+
if (serviceSet.has('alertmanager'))
|
|
92
|
+
portQuestions.push({ type: 'input', name: 'ALERTMANAGER_PORT', message: 'Puerto Alertmanager:', default: env.ALERTMANAGER_PORT || '9093' });
|
|
93
|
+
if (portQuestions.length > 0) {
|
|
94
|
+
const answers = await inquirer_1.default.prompt(portQuestions);
|
|
95
|
+
Object.assign(ports, answers);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const { customizeCredentials } = await inquirer_1.default.prompt([
|
|
99
|
+
{
|
|
100
|
+
type: 'confirm',
|
|
101
|
+
name: 'customizeCredentials',
|
|
102
|
+
message: 'Personalizar credenciales?',
|
|
103
|
+
default: false,
|
|
104
|
+
},
|
|
105
|
+
]);
|
|
106
|
+
if (customizeCredentials) {
|
|
107
|
+
if (serviceSet.has('pgadmin')) {
|
|
108
|
+
const creds = await inquirer_1.default.prompt([
|
|
109
|
+
{ type: 'input', name: 'PGADMIN_EMAIL', message: 'Email pgAdmin:', default: env.PGADMIN_EMAIL || 'admin@openfactu.local' },
|
|
110
|
+
{ type: 'password', name: 'PGADMIN_PASSWORD', message: 'Password pgAdmin:', default: env.PGADMIN_PASSWORD || 'admin' },
|
|
111
|
+
]);
|
|
112
|
+
Object.assign(ports, creds);
|
|
113
|
+
}
|
|
114
|
+
if (serviceSet.has('grafana')) {
|
|
115
|
+
const creds = await inquirer_1.default.prompt([
|
|
116
|
+
{ type: 'input', name: 'GRAFANA_USER', message: 'Usuario Grafana:', default: env.GRAFANA_USER || 'admin' },
|
|
117
|
+
{ type: 'password', name: 'GRAFANA_PASSWORD', message: 'Password Grafana:', default: env.GRAFANA_PASSWORD || 'admin' },
|
|
118
|
+
]);
|
|
119
|
+
Object.assign(ports, creds);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Generate compose file
|
|
123
|
+
if (opts.generateCompose) {
|
|
124
|
+
const composeSpinner = (0, ora_1.default)('Generando docker-compose.monitoring.yml...').start();
|
|
125
|
+
const composeContent = (0, monitoring_1.generateMonitoringCompose)(serviceSet);
|
|
126
|
+
const composePath = path_1.default.join(root, 'docker-compose.monitoring.yml');
|
|
127
|
+
fs_1.default.writeFileSync(composePath, composeContent);
|
|
128
|
+
composeSpinner.succeed('docker-compose.monitoring.yml generado');
|
|
129
|
+
(0, monitoring_1.writeMonitoringConfigs)(root, serviceSet);
|
|
130
|
+
}
|
|
131
|
+
// Save config
|
|
132
|
+
const envSpinner = (0, ora_1.default)('Guardando configuracion...').start();
|
|
133
|
+
for (const [key, value] of Object.entries(ports)) {
|
|
134
|
+
env[key] = value;
|
|
135
|
+
}
|
|
136
|
+
env.MONITORING_SERVICES = services.join(',');
|
|
137
|
+
writeEnv(envPath, env);
|
|
138
|
+
envSpinner.succeed('Configuracion guardada en .env');
|
|
139
|
+
logger_1.log.blank();
|
|
140
|
+
const { start } = await inquirer_1.default.prompt([
|
|
141
|
+
{
|
|
142
|
+
type: 'confirm',
|
|
143
|
+
name: 'start',
|
|
144
|
+
message: 'Levantar los servicios de monitoreo ahora?',
|
|
145
|
+
default: true,
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
if (start) {
|
|
149
|
+
const dockerCmd = (0, helpers_1.getDockerComposeCommand)();
|
|
150
|
+
const composePath = path_1.default.join(root, 'docker-compose.monitoring.yml');
|
|
151
|
+
if (!fs_1.default.existsSync(composePath)) {
|
|
152
|
+
logger_1.log.warn('docker-compose.monitoring.yml no existe');
|
|
153
|
+
logger_1.log.dim(' Ejecuta: openfactu monitoring --generate-compose');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const upSpinner = (0, ora_1.default)('Levantando servicios...').start();
|
|
157
|
+
try {
|
|
158
|
+
const scaleFlags = [];
|
|
159
|
+
for (const svc of monitoring_1.ALL_MONITORING_SERVICES) {
|
|
160
|
+
scaleFlags.push(`--scale ${svc}=${serviceSet.has(svc) ? 1 : 0}`);
|
|
161
|
+
}
|
|
162
|
+
(0, child_process_1.execSync)(`${dockerCmd} -f docker-compose.monitoring.yml up -d ${scaleFlags.join(' ')}`, { cwd: root, stdio: 'pipe', timeout: 120000 });
|
|
163
|
+
upSpinner.succeed('Servicios levantados');
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
upSpinner.fail('Error: ' + err.message);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
logger_1.log.blank();
|
|
170
|
+
console.log(chalk_1.default.bold.green(' Monitoreo configurado'));
|
|
171
|
+
console.log(chalk_1.default.dim(' ────────────────────────────────────'));
|
|
172
|
+
logger_1.log.blank();
|
|
173
|
+
const urls = [];
|
|
174
|
+
if (serviceSet.has('pgadmin'))
|
|
175
|
+
urls.push(['pgAdmin', `http://localhost:${env.PGADMIN_PORT || '5050'}`]);
|
|
176
|
+
if (serviceSet.has('grafana'))
|
|
177
|
+
urls.push(['Grafana', `http://localhost:${env.GRAFANA_PORT || '3001'}`]);
|
|
178
|
+
if (serviceSet.has('prometheus'))
|
|
179
|
+
urls.push(['Prometheus', `http://localhost:${env.PROMETHEUS_PORT || '9090'}`]);
|
|
180
|
+
if (serviceSet.has('loki'))
|
|
181
|
+
urls.push(['Loki', `http://localhost:${env.LOKI_PORT || '3100'}`]);
|
|
182
|
+
if (serviceSet.has('cadvisor'))
|
|
183
|
+
urls.push(['cAdvisor', `http://localhost:${env.CADVISOR_PORT || '8081'}`]);
|
|
184
|
+
if (serviceSet.has('node-exporter'))
|
|
185
|
+
urls.push(['Node Exporter', `http://localhost:${env.NODE_EXPORTER_PORT || '9100'}`]);
|
|
186
|
+
if (serviceSet.has('portainer'))
|
|
187
|
+
urls.push(['Portainer', `http://localhost:${env.PORTAINER_PORT || '9000'}`]);
|
|
188
|
+
if (serviceSet.has('alertmanager'))
|
|
189
|
+
urls.push(['Alertmanager', `http://localhost:${env.ALERTMANAGER_PORT || '9093'}`]);
|
|
190
|
+
for (const [name, url] of urls) {
|
|
191
|
+
logger_1.log.info(`${chalk_1.default.dim(name.padEnd(15))} ${chalk_1.default.cyan(url)}`);
|
|
192
|
+
}
|
|
193
|
+
logger_1.log.blank();
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
logger_1.log.error(err.message);
|
|
197
|
+
process.exitCode = 1;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
// ── openfactu monitoring:up ──
|
|
201
|
+
program
|
|
202
|
+
.command('monitoring:up')
|
|
203
|
+
.description('Levanta los servicios de monitoreo')
|
|
204
|
+
.action(async () => {
|
|
205
|
+
try {
|
|
206
|
+
const root = (0, paths_1.getProjectRoot)();
|
|
207
|
+
const dockerCmd = (0, helpers_1.getDockerComposeCommand)();
|
|
208
|
+
const composeFile = path_1.default.join(root, 'docker-compose.monitoring.yml');
|
|
209
|
+
if (!fs_1.default.existsSync(composeFile)) {
|
|
210
|
+
logger_1.log.error('docker-compose.monitoring.yml no encontrado');
|
|
211
|
+
logger_1.log.dim(' Ejecuta: openfactu monitoring --generate-compose');
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const envPath = path_1.default.join(root, '.env');
|
|
215
|
+
const env = readEnv(envPath);
|
|
216
|
+
const services = (env.MONITORING_SERVICES || 'pgadmin,grafana,prometheus,loki,portainer').split(',');
|
|
217
|
+
const serviceSet = new Set(services);
|
|
218
|
+
const spinner = (0, ora_1.default)('Levantando servicios...').start();
|
|
219
|
+
const scaleFlags = [];
|
|
220
|
+
for (const svc of monitoring_1.ALL_MONITORING_SERVICES) {
|
|
221
|
+
scaleFlags.push(`--scale ${svc}=${serviceSet.has(svc) ? 1 : 0}`);
|
|
222
|
+
}
|
|
223
|
+
(0, child_process_1.execSync)(`${dockerCmd} -f docker-compose.monitoring.yml up -d ${scaleFlags.join(' ')}`, { cwd: root, stdio: 'pipe', timeout: 120000 });
|
|
224
|
+
spinner.succeed('Servicios levantados');
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
logger_1.log.error(err.message);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
// ── openfactu monitoring:down ──
|
|
231
|
+
program
|
|
232
|
+
.command('monitoring:down')
|
|
233
|
+
.description('Para los servicios de monitoreo')
|
|
234
|
+
.action(async () => {
|
|
235
|
+
try {
|
|
236
|
+
const root = (0, paths_1.getProjectRoot)();
|
|
237
|
+
const dockerCmd = (0, helpers_1.getDockerComposeCommand)();
|
|
238
|
+
const spinner = (0, ora_1.default)('Parando servicios...').start();
|
|
239
|
+
(0, child_process_1.execSync)(`${dockerCmd} -f docker-compose.monitoring.yml down`, { cwd: root, stdio: 'pipe' });
|
|
240
|
+
spinner.succeed('Servicios parados');
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
logger_1.log.error(err.message);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
// ── openfactu monitoring:status ──
|
|
247
|
+
program
|
|
248
|
+
.command('monitoring:status')
|
|
249
|
+
.description('Estado de los servicios de monitoreo')
|
|
250
|
+
.action(async () => {
|
|
251
|
+
try {
|
|
252
|
+
const root = (0, paths_1.getProjectRoot)();
|
|
253
|
+
const dockerCmd = (0, helpers_1.getDockerComposeCommand)();
|
|
254
|
+
const output = (0, child_process_1.execSync)(`${dockerCmd} -f docker-compose.monitoring.yml ps`, { cwd: root }).toString();
|
|
255
|
+
console.log(output);
|
|
256
|
+
const envPath = path_1.default.join(root, '.env');
|
|
257
|
+
const env = readEnv(envPath);
|
|
258
|
+
logger_1.log.blank();
|
|
259
|
+
if (env.PGADMIN_PORT)
|
|
260
|
+
logger_1.log.info(`pgAdmin: http://localhost:${env.PGADMIN_PORT}`);
|
|
261
|
+
if (env.GRAFANA_PORT)
|
|
262
|
+
logger_1.log.info(`Grafana: http://localhost:${env.GRAFANA_PORT}`);
|
|
263
|
+
if (env.PROMETHEUS_PORT)
|
|
264
|
+
logger_1.log.info(`Prometheus: http://localhost:${env.PROMETHEUS_PORT}`);
|
|
265
|
+
if (env.LOKI_PORT)
|
|
266
|
+
logger_1.log.info(`Loki: http://localhost:${env.LOKI_PORT}`);
|
|
267
|
+
if (env.CADVISOR_PORT)
|
|
268
|
+
logger_1.log.info(`cAdvisor: http://localhost:${env.CADVISOR_PORT}`);
|
|
269
|
+
if (env.NODE_EXPORTER_PORT)
|
|
270
|
+
logger_1.log.info(`Node Exp: http://localhost:${env.NODE_EXPORTER_PORT}`);
|
|
271
|
+
if (env.PORTAINER_PORT)
|
|
272
|
+
logger_1.log.info(`Portainer: http://localhost:${env.PORTAINER_PORT}`);
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
logger_1.log.error('Servicios no disponibles');
|
|
276
|
+
logger_1.log.dim(' ' + err.message);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
// ── openfactu monitoring:config ──
|
|
280
|
+
program
|
|
281
|
+
.command('monitoring:config')
|
|
282
|
+
.description('Cambiar configuracion del monitoreo')
|
|
283
|
+
.action(async () => {
|
|
284
|
+
try {
|
|
285
|
+
const root = (0, paths_1.getProjectRoot)();
|
|
286
|
+
const envPath = path_1.default.join(root, '.env');
|
|
287
|
+
const env = readEnv(envPath);
|
|
288
|
+
const { key } = await inquirer_1.default.prompt([
|
|
289
|
+
{
|
|
290
|
+
type: 'list',
|
|
291
|
+
name: 'key',
|
|
292
|
+
message: 'Variable a cambiar:',
|
|
293
|
+
choices: [
|
|
294
|
+
{ name: `PGADMIN_PORT (${env.PGADMIN_PORT || '5050'})`, value: 'PGADMIN_PORT' },
|
|
295
|
+
{ name: `GRAFANA_PORT (${env.GRAFANA_PORT || '3001'})`, value: 'GRAFANA_PORT' },
|
|
296
|
+
{ name: `PROMETHEUS_PORT (${env.PROMETHEUS_PORT || '9090'})`, value: 'PROMETHEUS_PORT' },
|
|
297
|
+
{ name: `LOKI_PORT (${env.LOKI_PORT || '3100'})`, value: 'LOKI_PORT' },
|
|
298
|
+
{ name: `CADVISOR_PORT (${env.CADVISOR_PORT || '8081'})`, value: 'CADVISOR_PORT' },
|
|
299
|
+
{ name: `NODE_EXPORTER_PORT (${env.NODE_EXPORTER_PORT || '9100'})`, value: 'NODE_EXPORTER_PORT' },
|
|
300
|
+
{ name: `PORTAINER_PORT (${env.PORTAINER_PORT || '9000'})`, value: 'PORTAINER_PORT' },
|
|
301
|
+
{ name: `PGADMIN_EMAIL (${env.PGADMIN_EMAIL || 'admin@openfactu.local'})`, value: 'PGADMIN_EMAIL' },
|
|
302
|
+
{ name: `GRAFANA_USER (${env.GRAFANA_USER || 'admin'})`, value: 'GRAFANA_USER' },
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
]);
|
|
306
|
+
const { value } = await inquirer_1.default.prompt([
|
|
307
|
+
{ type: 'input', name: 'value', message: `Nuevo valor para ${key}:`, default: env[key] },
|
|
308
|
+
]);
|
|
309
|
+
env[key] = value;
|
|
310
|
+
writeEnv(envPath, env);
|
|
311
|
+
logger_1.log.success(`${key} actualizado a: ${value}`);
|
|
312
|
+
logger_1.log.info('Reinicia con: openfactu monitoring:down && openfactu monitoring:up');
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
logger_1.log.error(err.message);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
// ── openfactu monitoring:generate ──
|
|
319
|
+
program
|
|
320
|
+
.command('monitoring:generate')
|
|
321
|
+
.description('Generar docker-compose.monitoring.yml sin interaccion')
|
|
322
|
+
.option('--services <services>', 'Servicios separados por coma')
|
|
323
|
+
.option('--analytics', 'Incluir stack completo de analitica')
|
|
324
|
+
.action(async (opts) => {
|
|
325
|
+
try {
|
|
326
|
+
const root = (0, paths_1.getProjectRoot)();
|
|
327
|
+
const envPath = path_1.default.join(root, '.env');
|
|
328
|
+
const env = readEnv(envPath);
|
|
329
|
+
let services;
|
|
330
|
+
if (opts.services) {
|
|
331
|
+
services = opts.services.split(',');
|
|
332
|
+
}
|
|
333
|
+
else if (opts.analytics) {
|
|
334
|
+
services = (0, monitoring_1.fullMonitoringServices)();
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
services = (0, monitoring_1.basicMonitoringServices)();
|
|
338
|
+
}
|
|
339
|
+
const serviceSet = new Set(services);
|
|
340
|
+
const composeContent = (0, monitoring_1.generateMonitoringCompose)(serviceSet);
|
|
341
|
+
const composePath = path_1.default.join(root, 'docker-compose.monitoring.yml');
|
|
342
|
+
fs_1.default.writeFileSync(composePath, composeContent);
|
|
343
|
+
logger_1.log.success('docker-compose.monitoring.yml generado');
|
|
344
|
+
(0, monitoring_1.writeMonitoringConfigs)(root, serviceSet);
|
|
345
|
+
env.MONITORING_SERVICES = services.join(',');
|
|
346
|
+
writeEnv(envPath, env);
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
logger_1.log.error(err.message);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|