@tacuchi/updater 1.0.0

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.
Files changed (3) hide show
  1. package/README.md +69 -0
  2. package/dist/cli.js +2736 -0
  3. package/package.json +47 -0
package/dist/cli.js ADDED
@@ -0,0 +1,2736 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // src/lib/executor.ts
13
+ var executor_exports = {};
14
+ __export(executor_exports, {
15
+ execCommand: () => execCommand,
16
+ execStream: () => execStream
17
+ });
18
+ import { execa, ExecaError } from "execa";
19
+ function withSudo(cmd, args2, sudo) {
20
+ if (process.platform === "win32") return [cmd, args2];
21
+ const isRoot2 = process.getuid?.() === 0;
22
+ const originalUser = process.env["SUDO_USER"];
23
+ if (sudo) {
24
+ if (isRoot2) return [cmd, args2];
25
+ return ["sudo", ["-n", cmd, ...args2]];
26
+ }
27
+ if (isRoot2 && originalUser) {
28
+ return ["sudo", ["-iu", originalUser, cmd, ...args2]];
29
+ }
30
+ return [cmd, args2];
31
+ }
32
+ async function execCommand(cmd, args2, timeout = 5e3, sudo = false) {
33
+ const [finalCmd, finalArgs] = withSudo(cmd, args2, sudo);
34
+ try {
35
+ const result = await execa(finalCmd, finalArgs, {
36
+ timeout,
37
+ reject: false,
38
+ all: false
39
+ });
40
+ return {
41
+ stdout: result.stdout,
42
+ stderr: result.stderr,
43
+ exitCode: result.exitCode ?? 0
44
+ };
45
+ } catch (err) {
46
+ if (err instanceof ExecaError) {
47
+ return {
48
+ stdout: err.stdout ?? "",
49
+ stderr: err.stderr ?? String(err.message),
50
+ exitCode: err.exitCode ?? 1
51
+ };
52
+ }
53
+ throw err;
54
+ }
55
+ }
56
+ async function* execStream(cmd, args2, timeout = DEFAULT_TIMEOUT, sudo = false) {
57
+ const [finalCmd, finalArgs] = withSudo(cmd, args2, sudo);
58
+ const child = execa(finalCmd, finalArgs, {
59
+ timeout,
60
+ reject: false,
61
+ stdout: "pipe",
62
+ stderr: "pipe",
63
+ all: true
64
+ });
65
+ if (child.all) {
66
+ for await (const chunk of child.all) {
67
+ const lines = String(chunk).split("\n").filter(Boolean);
68
+ for (const line of lines) {
69
+ const isError = line.toLowerCase().includes("error") || line.toLowerCase().includes("permission denied") || line.toLowerCase().includes("errno");
70
+ yield { type: isError ? "error" : "log", message: line };
71
+ }
72
+ }
73
+ }
74
+ const result = await child;
75
+ if ((result.exitCode ?? 0) !== 0) {
76
+ const stderrMsg = result.stderr?.trim();
77
+ if (stderrMsg) {
78
+ yield { type: "error", message: stderrMsg };
79
+ } else {
80
+ yield { type: "error", message: `Exit code: ${result.exitCode}` };
81
+ }
82
+ } else {
83
+ yield { type: "complete", message: "OK", percent: 100 };
84
+ }
85
+ }
86
+ var DEFAULT_TIMEOUT;
87
+ var init_executor = __esm({
88
+ "src/lib/executor.ts"() {
89
+ "use strict";
90
+ DEFAULT_TIMEOUT = 3e5;
91
+ }
92
+ });
93
+
94
+ // src/cli.tsx
95
+ import { render } from "ink";
96
+ import { execaSync } from "execa";
97
+
98
+ // src/app.tsx
99
+ import { createContext, useContext, useState as useState7, useEffect as useEffect3 } from "react";
100
+ import { Box as Box10, useInput as useInput6, useStdout } from "ink";
101
+
102
+ // src/components/nav-bar.tsx
103
+ import { Box, Text, useInput } from "ink";
104
+
105
+ // src/theme.ts
106
+ var colors = {
107
+ // Superficies (fondo)
108
+ surface: "#131313",
109
+ surfaceContainer: "#201f1f",
110
+ surfaceContainerLow: "#1c1b1b",
111
+ surfaceContainerHigh: "#2a2a2a",
112
+ surfaceContainerHighest: "#353534",
113
+ surfaceContainerLowest: "#0e0e0e",
114
+ // Primario (púrpura)
115
+ primary: "#c9bfff",
116
+ primaryContainer: "#6a49f8",
117
+ onPrimary: "#131313",
118
+ onPrimaryContainer: "#f0e9ff",
119
+ // Secundario (rosa)
120
+ secondary: "#ffade0",
121
+ secondaryContainer: "#7a3060",
122
+ onSecondary: "#131313",
123
+ onSecondaryContainer: "#ffd8ef",
124
+ // Terciario (verde - señal de éxito/activo)
125
+ tertiary: "#31e368",
126
+ tertiaryContainer: "#005229",
127
+ onTertiary: "#131313",
128
+ onTertiaryContainer: "#adffd0",
129
+ // Error
130
+ error: "#ffb4ab",
131
+ errorContainer: "#93000a",
132
+ onError: "#690005",
133
+ onErrorContainer: "#ffdad6",
134
+ // Texto
135
+ onSurface: "#e5e2e1",
136
+ onSurfaceVariant: "#a09d9c",
137
+ // Bordes
138
+ outlineVariant: "#484556",
139
+ outline: "#6f6d70"
140
+ };
141
+ var box = {
142
+ topLeft: "\u250C",
143
+ topRight: "\u2510",
144
+ bottomLeft: "\u2514",
145
+ bottomRight: "\u2518",
146
+ horizontal: "\u2500",
147
+ vertical: "\u2502",
148
+ // Doble
149
+ dTopLeft: "\u2554",
150
+ dTopRight: "\u2557",
151
+ dBottomLeft: "\u255A",
152
+ dBottomRight: "\u255D",
153
+ dHorizontal: "\u2550",
154
+ dVertical: "\u2551",
155
+ // Bloques para progress bar
156
+ blockFull: "\u2588",
157
+ blockDark: "\u2593",
158
+ blockMedium: "\u2592",
159
+ blockLight: "\u2591",
160
+ // Indicadores
161
+ bullet: "\u203A",
162
+ dot: "\u2022",
163
+ arrow: "\u2192",
164
+ check: "\u2713",
165
+ cross: "\u2717"
166
+ };
167
+
168
+ // src/i18n/es.ts
169
+ var es = {
170
+ // Navegación
171
+ nav: {
172
+ title: "KINETIC_PKG_MGR",
173
+ dashboard: "PANEL",
174
+ packages: "PAQUETES",
175
+ registry: "REGISTRO",
176
+ settings: "AJUSTES",
177
+ version: "v1.0.0"
178
+ },
179
+ // Teclas de acción (barra inferior)
180
+ keys: {
181
+ quit: "[Q] SALIR",
182
+ help: "[?] AYUDA",
183
+ next: "[TAB] SIGUIENTE",
184
+ exec: "[ENTER] EJECUTAR",
185
+ back: "[ESC] VOLVER",
186
+ select: "[ESPACIO] SELECCIONAR",
187
+ update: "[U] ACTUALIZAR",
188
+ sync: "[S] SINCRONIZAR",
189
+ logView: "[F1] VER LOG"
190
+ },
191
+ // Panel principal (Dashboard)
192
+ dashboard: {
193
+ title: "PANEL_",
194
+ status: "ESTADO: ENTORNO ACTIVO",
195
+ totalUpdates: "TOTAL ACTUALIZACIONES",
196
+ systemLoad: "CARGA DEL SISTEMA",
197
+ systemInfo: "INFO_SISTEMA",
198
+ os: "SO",
199
+ kernel: "KERNEL",
200
+ uptime: "ACTIVO",
201
+ lastScan: "\xDALTIMO ESCANEO",
202
+ terminalLog: "TERMINAL_LOG",
203
+ noManagers: "No se detectaron gestores de paquetes",
204
+ scanning: "Escaneando...",
205
+ active: "ACTIVO",
206
+ degraded: "DEGRADADO",
207
+ available: "DISPONIBLE"
208
+ },
209
+ // Actualizaciones activas
210
+ activeUpdates: {
211
+ title: "ACTUALIZACIONES_ACTIVAS",
212
+ syncing: "\u25CF SINCRONIZANDO...",
213
+ stdout: "STDOUT \u2014 SESI\xD3N",
214
+ active: "ACTIVO",
215
+ success: "EXITOSO",
216
+ errors: "ERRORES",
217
+ pending: "[PENDIENTE]",
218
+ ok: "[OK]",
219
+ err: "[ERR]",
220
+ noActive: "No hay actualizaciones en curso",
221
+ goToPackages: "Ve a PAQUETES para iniciar una actualizaci\xF3n",
222
+ verifying: "VERIFICANDO_SUMA...",
223
+ retrying: "REINTENTANDO_EN_5S",
224
+ upgraded: "actualizado(s)",
225
+ failed: "fallido(s)",
226
+ noChanges: "Sin cambios",
227
+ allDone: "\u25CF COMPLETADO",
228
+ rescanHint: "Re-escanear actualizaciones disponibles"
229
+ },
230
+ // Sincronización de paquetes
231
+ packageSync: {
232
+ title: "SYNC_PAQUETES.",
233
+ diskUsage: "USO DE DISCO",
234
+ queueSize: "COLA",
235
+ pending: "OPERACIONES_PENDIENTES",
236
+ colSel: "SEL",
237
+ colManager: "GESTOR",
238
+ colPackage: "PAQUETE",
239
+ colVersion: "VERSION",
240
+ colNew: "NUEVA",
241
+ colSize: "TAMA\xD1O",
242
+ hint: "\u203A Presiona [ESPACIO] para seleccionar, [U] para Actualizar Seleccionados",
243
+ eligible: "paquetes elegibles para actualizar",
244
+ systemState: "ESTADO DEL SISTEMA",
245
+ noUpdates: "El sistema est\xE1 actualizado",
246
+ requiresAdmin: "REQUIERE ADMIN",
247
+ manualCmd: "Comando manual:"
248
+ },
249
+ // Ajustes
250
+ settings: {
251
+ title: "CONFIGURACI\xD3N_DEL_SISTEMA",
252
+ subtitle: "KINETIC::PKG::AJUSTES",
253
+ nav: {
254
+ general: "General",
255
+ sources: "Fuentes",
256
+ automation: "Automatizaci\xF3n",
257
+ networking: "Red",
258
+ advanced: "Avanzado"
259
+ },
260
+ activeManagers: "[01] GESTORES DE PAQUETES ACTIVOS",
261
+ automation: "[02] AUTOMATIZACI\xD3N Y LOGS",
262
+ autoScanInterval: "INTERVALO_AUTO_ESCANEO",
263
+ autoScanDesc: "Tiempo entre escaneos autom\xE1ticos.",
264
+ verbosity: "NIVEL_VERBOSIDAD",
265
+ verbosityDesc: "Controla la cantidad de datos guardados en logs.",
266
+ notifications: "NOTIFICACIONES",
267
+ desktopAlerts: "ALERTAS DE ESCRITORIO",
268
+ terminalBell: "CAMPANILLA",
269
+ telemetry: "TELEMETR\xCDA",
270
+ anonymousData: "DATOS AN\xD3NIMOS",
271
+ anonymousDesc: "Comparte datos de uso para mejorar la herramienta.",
272
+ language: "IDIOMA",
273
+ statusSynced: "Configuraci\xF3n sincronizada con archivo local.",
274
+ stable: "ESTABLE",
275
+ detected: "DETECTADO",
276
+ notFound: "NO ENCONTRADO",
277
+ on: "[ ON ]",
278
+ off: "[OFF]",
279
+ seconds: "SEGUNDOS"
280
+ },
281
+ // Estados comunes
282
+ states: {
283
+ loading: "Cargando...",
284
+ error: "Error",
285
+ success: "Exitoso",
286
+ warning: "Advertencia",
287
+ notFound: "No encontrado",
288
+ available: "Disponible",
289
+ unavailable: "No disponible",
290
+ requiresAdmin: "Requiere admin",
291
+ minutesAgo: "hace %d min",
292
+ justNow: "ahora mismo",
293
+ never: "nunca"
294
+ },
295
+ // Managers
296
+ managers: {
297
+ brew: "Homebrew",
298
+ pip: "pip / Python",
299
+ npm: "Node NPM",
300
+ conda: "Conda",
301
+ gem: "RubyGems",
302
+ softwareupdate: "macOS Updates",
303
+ winget: "Winget",
304
+ apt: "APT / Debian",
305
+ dnf: "DNF / Fedora",
306
+ pacman: "Pacman / Arch",
307
+ flatpak: "Flatpak",
308
+ snap: "Snap",
309
+ flutter: "Flutter SDK",
310
+ angular: "Angular CLI",
311
+ cargo: "Rust / Cargo",
312
+ go: "Go SDK",
313
+ composer: "Composer / PHP",
314
+ choco: "Chocolatey"
315
+ },
316
+ // Verbosidad
317
+ verbosity: {
318
+ silent: "SILENCIO",
319
+ info: "NORMAL",
320
+ debug: "DEBUG",
321
+ trace: "DETALLADO"
322
+ }
323
+ };
324
+
325
+ // src/i18n/en.ts
326
+ var en = {
327
+ nav: {
328
+ title: "KINETIC_PKG_MGR",
329
+ dashboard: "DASHBOARD",
330
+ packages: "PACKAGES",
331
+ registry: "REGISTRY",
332
+ settings: "SETTINGS",
333
+ version: "v1.0.0"
334
+ },
335
+ keys: {
336
+ quit: "[Q] QUIT",
337
+ help: "[?] HELP",
338
+ next: "[TAB] NEXT",
339
+ exec: "[ENTER] EXEC",
340
+ back: "[ESC] BACK",
341
+ select: "[SPACE] SELECT",
342
+ update: "[U] UPDATE",
343
+ sync: "[S] SYNC",
344
+ logView: "[F1] LOG VIEW"
345
+ },
346
+ dashboard: {
347
+ title: "DASHBOARD_",
348
+ status: "STATUS: ACTIVE ENVIRONMENT",
349
+ totalUpdates: "TOTAL UPDATES",
350
+ systemLoad: "SYSTEM LOAD",
351
+ systemInfo: "SYSTEM_INFO",
352
+ os: "OS",
353
+ kernel: "KERNEL",
354
+ uptime: "UPTIME",
355
+ lastScan: "LAST SCAN",
356
+ terminalLog: "TERMINAL_LOG",
357
+ noManagers: "No package managers detected",
358
+ scanning: "Scanning...",
359
+ active: "ACTIVE",
360
+ degraded: "DEGRADED",
361
+ available: "AVAILABLE"
362
+ },
363
+ activeUpdates: {
364
+ title: "ACTIVE_UPDATES",
365
+ syncing: "\u25CF SYNCING_REPOS...",
366
+ stdout: "STDOUT \u2014 SESSION",
367
+ active: "ACTIVE",
368
+ success: "SUCCESS",
369
+ errors: "ERRORS",
370
+ pending: "[PENDING]",
371
+ ok: "[OK]",
372
+ err: "[ERR]",
373
+ noActive: "No active updates",
374
+ goToPackages: "Go to PACKAGES to start an update",
375
+ verifying: "VERIFYING_CHECKSUM...",
376
+ retrying: "RETRYING_IN_5S",
377
+ upgraded: "upgraded",
378
+ failed: "failed",
379
+ noChanges: "No changes",
380
+ allDone: "\u25CF COMPLETED",
381
+ rescanHint: "Re-scan for available updates"
382
+ },
383
+ packageSync: {
384
+ title: "PACKAGE_SYNC.",
385
+ diskUsage: "DISK USAGE",
386
+ queueSize: "QUEUE SIZE",
387
+ pending: "PENDING_OPERATIONS",
388
+ colSel: "SEL",
389
+ colManager: "MANAGER",
390
+ colPackage: "PACKAGE",
391
+ colVersion: "VERSION",
392
+ colNew: "NEW",
393
+ colSize: "SIZE",
394
+ hint: "\u203A Press [SPACE] to select, [U] to Update Selected",
395
+ eligible: "packages eligible for update",
396
+ systemState: "SYSTEM STATE",
397
+ noUpdates: "System is up to date",
398
+ requiresAdmin: "REQUIRES ADMIN",
399
+ manualCmd: "Manual command:"
400
+ },
401
+ settings: {
402
+ title: "SYSTEM_CONFIGURATION",
403
+ subtitle: "KINETIC::PKG::SETTINGS",
404
+ nav: {
405
+ general: "General",
406
+ sources: "Sources",
407
+ automation: "Automation",
408
+ networking: "Networking",
409
+ advanced: "Advanced"
410
+ },
411
+ activeManagers: "[01] ACTIVE PACKAGE MANAGERS",
412
+ automation: "[02] AUTOMATION & LOGGING",
413
+ autoScanInterval: "AUTO_SCAN_INTERVAL",
414
+ autoScanDesc: "Time between automatic global package scans.",
415
+ verbosity: "VERBOSITY_LEVEL",
416
+ verbosityDesc: "Controls the amount of data saved to logs.",
417
+ notifications: "NOTIFICATIONS",
418
+ desktopAlerts: "DESKTOP ALERTS",
419
+ terminalBell: "TERMINAL BELL",
420
+ telemetry: "TELEMETRY",
421
+ anonymousData: "ANONYMOUS DATA",
422
+ anonymousDesc: "Share usage data to improve kinetic tools.",
423
+ language: "LANGUAGE",
424
+ statusSynced: "Configuration is currently synced with local yaml file.",
425
+ stable: "STABLE",
426
+ detected: "DETECTED",
427
+ notFound: "NOT FOUND",
428
+ on: "[ ON ]",
429
+ off: "[OFF]",
430
+ seconds: "SECONDS"
431
+ },
432
+ states: {
433
+ loading: "Loading...",
434
+ error: "Error",
435
+ success: "Success",
436
+ warning: "Warning",
437
+ notFound: "Not found",
438
+ available: "Available",
439
+ unavailable: "Unavailable",
440
+ requiresAdmin: "Requires admin",
441
+ minutesAgo: "%d mins ago",
442
+ justNow: "just now",
443
+ never: "never"
444
+ },
445
+ managers: {
446
+ brew: "Homebrew",
447
+ pip: "pip / Python",
448
+ npm: "Node NPM",
449
+ conda: "Conda",
450
+ gem: "RubyGems",
451
+ softwareupdate: "macOS Updates",
452
+ winget: "Winget",
453
+ apt: "APT / Debian",
454
+ dnf: "DNF / Fedora",
455
+ pacman: "Pacman / Arch",
456
+ flatpak: "Flatpak",
457
+ snap: "Snap",
458
+ flutter: "Flutter SDK",
459
+ angular: "Angular CLI",
460
+ cargo: "Rust / Cargo",
461
+ go: "Go SDK",
462
+ composer: "Composer / PHP",
463
+ choco: "Chocolatey"
464
+ },
465
+ verbosity: {
466
+ silent: "SILENT",
467
+ info: "NORMAL",
468
+ debug: "DEBUG",
469
+ trace: "TRACE"
470
+ }
471
+ };
472
+
473
+ // src/i18n/index.ts
474
+ var currentLang = detectLanguage();
475
+ function detectLanguage() {
476
+ const lang = process.env["LANG"] ?? process.env["LANGUAGE"] ?? "";
477
+ return lang.startsWith("es") ? "es" : "es";
478
+ }
479
+ function setLanguage(lang) {
480
+ currentLang = lang;
481
+ }
482
+ var translations = { es, en };
483
+ function t(section, key) {
484
+ const dict = translations[currentLang] ?? es;
485
+ const sec = dict[section];
486
+ if (key === void 0) return sec;
487
+ return sec[key];
488
+ }
489
+
490
+ // src/components/nav-bar.tsx
491
+ import { jsx, jsxs } from "react/jsx-runtime";
492
+ var screens = [
493
+ { id: "dashboard", labelKey: "dashboard" },
494
+ { id: "packages", labelKey: "packages" },
495
+ { id: "settings", labelKey: "settings" }
496
+ ];
497
+ function NavBar({ currentScreen, onNavigate, osInfo, sudoMode: sudoMode2 }) {
498
+ const nav = t("nav");
499
+ useInput((input, key) => {
500
+ if (key.tab) {
501
+ const idx = screens.findIndex((s) => s.id === currentScreen);
502
+ const next = screens[(idx + 1) % screens.length];
503
+ if (next) onNavigate(next.id);
504
+ }
505
+ if (input === "1") onNavigate("dashboard");
506
+ if (input === "2") onNavigate("packages");
507
+ if (input === "3") onNavigate("settings");
508
+ });
509
+ return /* @__PURE__ */ jsxs(
510
+ Box,
511
+ {
512
+ flexDirection: "row",
513
+ justifyContent: "space-between",
514
+ alignItems: "center",
515
+ backgroundColor: colors.surfaceContainerLow,
516
+ paddingX: 2,
517
+ paddingY: 0,
518
+ children: [
519
+ /* @__PURE__ */ jsxs(Box, { gap: 2, alignItems: "center", children: [
520
+ /* @__PURE__ */ jsx(Text, { color: colors.primary, bold: true, children: nav.title }),
521
+ /* @__PURE__ */ jsx(Text, { color: colors.outlineVariant, children: "\u2502" }),
522
+ screens.map((s) => {
523
+ const label = nav[s.labelKey];
524
+ return /* @__PURE__ */ jsx(
525
+ Text,
526
+ {
527
+ color: currentScreen === s.id ? colors.tertiary : colors.onSurfaceVariant,
528
+ bold: currentScreen === s.id,
529
+ children: typeof label === "string" ? label : s.id.toUpperCase()
530
+ },
531
+ s.id
532
+ );
533
+ })
534
+ ] }),
535
+ /* @__PURE__ */ jsxs(Box, { gap: 2, alignItems: "center", children: [
536
+ sudoMode2 && /* @__PURE__ */ jsxs(Text, { color: colors.onPrimary, backgroundColor: colors.error, bold: true, children: [
537
+ " ",
538
+ "SUDO",
539
+ " "
540
+ ] }),
541
+ osInfo && /* @__PURE__ */ jsx(Text, { color: colors.onSurfaceVariant, dimColor: true, children: osInfo }),
542
+ /* @__PURE__ */ jsx(Text, { color: colors.primary, children: nav.version })
543
+ ] })
544
+ ]
545
+ }
546
+ );
547
+ }
548
+
549
+ // src/components/key-hint-bar.tsx
550
+ import React from "react";
551
+ import { Box as Box2, Text as Text2 } from "ink";
552
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
553
+ function KeyHintBar({ hints }) {
554
+ return /* @__PURE__ */ jsx2(
555
+ Box2,
556
+ {
557
+ flexDirection: "row",
558
+ gap: 1,
559
+ backgroundColor: colors.surfaceContainerLow,
560
+ paddingX: 2,
561
+ paddingY: 0,
562
+ children: hints.map((hint) => /* @__PURE__ */ jsxs2(React.Fragment, { children: [
563
+ /* @__PURE__ */ jsx2(
564
+ Box2,
565
+ {
566
+ backgroundColor: hint.active ? colors.primaryContainer : colors.surfaceContainerHighest,
567
+ paddingX: 1,
568
+ children: /* @__PURE__ */ jsx2(
569
+ Text2,
570
+ {
571
+ color: hint.active ? colors.onPrimaryContainer : colors.onSurface,
572
+ bold: hint.active,
573
+ children: hint.key
574
+ }
575
+ )
576
+ }
577
+ ),
578
+ /* @__PURE__ */ jsx2(Text2, { color: colors.onSurfaceVariant, children: hint.label })
579
+ ] }, `${hint.key}-${hint.label}`))
580
+ }
581
+ );
582
+ }
583
+
584
+ // src/screens/dashboard.tsx
585
+ import { Box as Box3, Text as Text4, useInput as useInput2 } from "ink";
586
+
587
+ // src/components/status-pill.tsx
588
+ import { Text as Text3 } from "ink";
589
+ import { jsxs as jsxs3 } from "react/jsx-runtime";
590
+ var pillStyles = {
591
+ success: { color: colors.onTertiary, bgColor: colors.tertiary },
592
+ error: { color: colors.onErrorContainer, bgColor: colors.errorContainer },
593
+ active: { color: colors.onPrimaryContainer, bgColor: colors.primaryContainer },
594
+ warning: { color: colors.onSecondaryContainer, bgColor: colors.secondaryContainer },
595
+ muted: { color: colors.onSurfaceVariant, bgColor: colors.surfaceContainerHigh },
596
+ info: { color: colors.primary, bgColor: colors.surfaceContainerHighest }
597
+ };
598
+ function StatusPill({ variant, children }) {
599
+ const style = pillStyles[variant];
600
+ return /* @__PURE__ */ jsxs3(Text3, { color: style.color, backgroundColor: style.bgColor, children: [
601
+ " ",
602
+ children,
603
+ " "
604
+ ] });
605
+ }
606
+
607
+ // src/screens/dashboard.tsx
608
+ import { jsx as jsx3, jsxs as jsxs4 } from "react/jsx-runtime";
609
+ function Dashboard() {
610
+ const { managers, detecting, lastScan, rescan, systemInfo, setScreen } = useApp();
611
+ const d = t("dashboard");
612
+ useInput2((input, key) => {
613
+ if (input === "r" || input === "R") rescan();
614
+ if (key.return) setScreen("packages");
615
+ });
616
+ const totalUpdates = managers.reduce((sum, m) => sum + m.outdated.length, 0);
617
+ const isScanning = detecting || managers.some((m) => m.scanning);
618
+ function formatLastScan(date) {
619
+ if (!date) return t("states", "never");
620
+ const diffMin = Math.floor((Date.now() - date.getTime()) / 6e4);
621
+ if (diffMin < 1) return t("states", "justNow");
622
+ return `${diffMin} min`;
623
+ }
624
+ return /* @__PURE__ */ jsxs4(Box3, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [
625
+ /* @__PURE__ */ jsxs4(Box3, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [
626
+ /* @__PURE__ */ jsxs4(Box3, { gap: 2, alignItems: "center", children: [
627
+ /* @__PURE__ */ jsx3(StatusPill, { variant: isScanning ? "active" : totalUpdates > 0 ? "warning" : "success", children: isScanning ? d.scanning : totalUpdates > 0 ? `${totalUpdates} ${d.available}` : d.active }),
628
+ /* @__PURE__ */ jsxs4(Text4, { color: colors.onSurfaceVariant, dimColor: true, children: [
629
+ d.uptime,
630
+ ": ",
631
+ systemInfo.uptime,
632
+ " ",
633
+ box.dot,
634
+ " ",
635
+ d.lastScan,
636
+ ": ",
637
+ formatLastScan(lastScan)
638
+ ] })
639
+ ] }),
640
+ !detecting && totalUpdates > 0 && /* @__PURE__ */ jsxs4(Text4, { color: colors.primaryContainer, backgroundColor: colors.primary, bold: true, children: [
641
+ " ",
642
+ "ENTER ",
643
+ box.arrow,
644
+ " PAQUETES",
645
+ " "
646
+ ] })
647
+ ] }),
648
+ detecting ? /* @__PURE__ */ jsx3(Box3, { paddingY: 1, children: /* @__PURE__ */ jsx3(Text4, { color: colors.primary, children: d.scanning }) }) : managers.length === 0 ? /* @__PURE__ */ jsx3(Box3, { paddingY: 1, children: /* @__PURE__ */ jsx3(Text4, { color: colors.onSurfaceVariant, children: d.noManagers }) }) : /* @__PURE__ */ jsxs4(Box3, { flexDirection: "column", marginTop: 1, children: [
649
+ /* @__PURE__ */ jsx3(Box3, { children: /* @__PURE__ */ jsxs4(Text4, { color: colors.outlineVariant, children: [
650
+ " ",
651
+ padR("GESTOR", 18),
652
+ padR("VER", 12),
653
+ padR("UPD", 6),
654
+ "ESTADO"
655
+ ] }) }),
656
+ managers.map(({ manager, outdated, scanning }) => {
657
+ const id = manager.manager.id;
658
+ const name = t("managers", id);
659
+ const version = manager.detection.version ?? "\u2014";
660
+ const count = outdated.length;
661
+ const isAdmin = manager.manager.requiresAdmin;
662
+ return /* @__PURE__ */ jsxs4(Box3, { flexDirection: "row", children: [
663
+ /* @__PURE__ */ jsxs4(Text4, { color: colors.tertiary, children: [
664
+ count > 0 ? box.bullet : " ",
665
+ " "
666
+ ] }),
667
+ /* @__PURE__ */ jsx3(Text4, { color: colors.onSurface, bold: count > 0, children: padR(name, 18) }),
668
+ /* @__PURE__ */ jsx3(Text4, { color: colors.onSurfaceVariant, children: padR(version, 12) }),
669
+ /* @__PURE__ */ jsx3(Text4, { color: count > 0 ? colors.secondary : colors.onSurfaceVariant, bold: count > 0, children: padR(scanning ? ".." : count > 0 ? String(count) : "\u2014", 6) }),
670
+ scanning ? /* @__PURE__ */ jsx3(Text4, { color: colors.primary, children: d.scanning }) : isAdmin ? /* @__PURE__ */ jsx3(Text4, { color: colors.onSurfaceVariant, dimColor: true, children: "ADMIN" }) : count > 0 ? /* @__PURE__ */ jsx3(StatusPill, { variant: "warning", children: count }) : /* @__PURE__ */ jsx3(Text4, { color: colors.tertiary, children: box.check })
671
+ ] }, id);
672
+ })
673
+ ] }),
674
+ !detecting && managers.length > 0 && /* @__PURE__ */ jsxs4(Box3, { marginTop: 1, gap: 2, children: [
675
+ /* @__PURE__ */ jsxs4(Text4, { color: colors.onSurfaceVariant, children: [
676
+ managers.length,
677
+ " ",
678
+ box.dot
679
+ ] }),
680
+ /* @__PURE__ */ jsxs4(Text4, { color: totalUpdates > 0 ? colors.secondary : colors.tertiary, bold: true, children: [
681
+ totalUpdates,
682
+ " actualizaciones"
683
+ ] })
684
+ ] })
685
+ ] });
686
+ }
687
+ function padR(str, len) {
688
+ if (str.length >= len) return str.slice(0, len - 1) + " ";
689
+ return str + " ".repeat(len - str.length);
690
+ }
691
+
692
+ // src/screens/active-updates.tsx
693
+ import { useState } from "react";
694
+ import { Box as Box6, Text as Text7, useInput as useInput3 } from "ink";
695
+
696
+ // src/components/progress-gauge.tsx
697
+ import { Box as Box4, Text as Text5 } from "ink";
698
+ import { jsx as jsx4, jsxs as jsxs5 } from "react/jsx-runtime";
699
+ function ProgressGauge({
700
+ value,
701
+ width = 20,
702
+ color = colors.tertiary,
703
+ showPercent = true,
704
+ label
705
+ }) {
706
+ const clampedValue = Math.min(100, Math.max(0, value));
707
+ const filled = Math.round(clampedValue / 100 * width);
708
+ const empty = width - filled;
709
+ const filledBar = box.blockFull.repeat(filled);
710
+ const emptyBar = box.blockLight.repeat(empty);
711
+ return /* @__PURE__ */ jsxs5(Box4, { flexDirection: "row", gap: 1, alignItems: "center", children: [
712
+ label && /* @__PURE__ */ jsx4(Text5, { color: colors.onSurface, bold: true, children: label }),
713
+ /* @__PURE__ */ jsx4(Text5, { color, children: filledBar }),
714
+ /* @__PURE__ */ jsx4(Text5, { color: colors.surfaceContainerHighest, children: emptyBar }),
715
+ showPercent && /* @__PURE__ */ jsxs5(Text5, { color: colors.onSurfaceVariant, children: [
716
+ clampedValue.toFixed(0),
717
+ "%"
718
+ ] })
719
+ ] });
720
+ }
721
+
722
+ // src/components/ghost-box.tsx
723
+ import { Box as Box5, Text as Text6 } from "ink";
724
+ import { jsx as jsx5, jsxs as jsxs6 } from "react/jsx-runtime";
725
+ function GhostBox({ title, children, width, dimBorder = true }) {
726
+ const borderColor = dimBorder ? colors.outlineVariant : colors.outline;
727
+ return /* @__PURE__ */ jsxs6(Box5, { flexDirection: "column", width, children: [
728
+ /* @__PURE__ */ jsx5(Box5, { children: /* @__PURE__ */ jsxs6(Text6, { color: borderColor, dimColor: dimBorder, children: [
729
+ box.topLeft,
730
+ title ? ` ${title} ` : "",
731
+ box.horizontal
732
+ ] }) }),
733
+ /* @__PURE__ */ jsx5(Box5, { flexDirection: "column", paddingLeft: 1, children })
734
+ ] });
735
+ }
736
+
737
+ // src/screens/active-updates.tsx
738
+ import { jsx as jsx6, jsxs as jsxs7 } from "react/jsx-runtime";
739
+ function StatusIndicator({ status }) {
740
+ if (status === "running") return /* @__PURE__ */ jsx6(StatusPill, { variant: "active", children: "ACTIVO" });
741
+ if (status === "success") return /* @__PURE__ */ jsx6(StatusPill, { variant: "success", children: "OK" });
742
+ if (status === "error") return /* @__PURE__ */ jsx6(StatusPill, { variant: "error", children: "ERR" });
743
+ return /* @__PURE__ */ jsx6(StatusPill, { variant: "muted", children: "PENDIENTE" });
744
+ }
745
+ function ResultDetail({ upd }) {
746
+ const a = t("activeUpdates");
747
+ if (!upd.result) return null;
748
+ const { success: success2, upgraded, failed, errors } = upd.result;
749
+ return /* @__PURE__ */ jsxs7(Box6, { flexDirection: "column", paddingLeft: 1, marginTop: 0, children: [
750
+ /* @__PURE__ */ jsxs7(Box6, { gap: 3, children: [
751
+ upgraded > 0 && /* @__PURE__ */ jsxs7(Text7, { color: colors.tertiary, children: [
752
+ box.check,
753
+ " ",
754
+ upgraded,
755
+ " ",
756
+ a.upgraded
757
+ ] }),
758
+ failed > 0 && /* @__PURE__ */ jsxs7(Text7, { color: colors.error, children: [
759
+ box.cross,
760
+ " ",
761
+ failed,
762
+ " ",
763
+ a.failed
764
+ ] }),
765
+ success2 && failed === 0 && upgraded === 0 && /* @__PURE__ */ jsxs7(Text7, { color: colors.tertiary, children: [
766
+ box.check,
767
+ " ",
768
+ a.noChanges
769
+ ] })
770
+ ] }),
771
+ errors.length > 0 && /* @__PURE__ */ jsx6(Box6, { flexDirection: "column", paddingLeft: 1, children: errors.slice(0, 5).map((err, i) => /* @__PURE__ */ jsxs7(Text7, { color: colors.error, dimColor: true, children: [
772
+ box.bullet,
773
+ " ",
774
+ err.slice(0, 70)
775
+ ] }, `err-${i}`)) })
776
+ ] });
777
+ }
778
+ function ActiveUpdates() {
779
+ const { updates, rescan, setScreen } = useApp();
780
+ const a = t("activeUpdates");
781
+ const [showDetail, setShowDetail] = useState(null);
782
+ const entries = Array.from(updates.entries());
783
+ const activeCount = entries.filter(([, u]) => u.status === "running").length;
784
+ const successCount = entries.filter(([, u]) => u.status === "success").length;
785
+ const errorCount = entries.filter(([, u]) => u.status === "error").length;
786
+ const allDone = entries.length > 0 && activeCount === 0;
787
+ const allLogs = entries.flatMap(([, u]) => u.logs).slice(-20);
788
+ useInput3((input, key) => {
789
+ if (input === "r" || input === "R") rescan();
790
+ if (input === "d" || input === "D") {
791
+ if (showDetail) {
792
+ setShowDetail(null);
793
+ } else {
794
+ const first = entries[0];
795
+ if (first) setShowDetail(first[0]);
796
+ }
797
+ }
798
+ if (key.escape) setScreen("dashboard");
799
+ });
800
+ if (entries.length === 0) {
801
+ return /* @__PURE__ */ jsxs7(Box6, { flexDirection: "column", paddingX: 2, paddingY: 2, gap: 1, alignItems: "center", justifyContent: "center", flexGrow: 1, children: [
802
+ /* @__PURE__ */ jsx6(Text7, { color: colors.onSurfaceVariant, children: a.noActive }),
803
+ /* @__PURE__ */ jsx6(Text7, { color: colors.outlineVariant, dimColor: true, children: a.goToPackages })
804
+ ] });
805
+ }
806
+ return /* @__PURE__ */ jsxs7(Box6, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [
807
+ /* @__PURE__ */ jsxs7(Box6, { flexDirection: "row", justifyContent: "space-between", children: [
808
+ /* @__PURE__ */ jsxs7(Box6, { gap: 2, alignItems: "center", children: [
809
+ /* @__PURE__ */ jsx6(Text7, { bold: true, color: colors.onSurface, children: a.title }),
810
+ allDone ? /* @__PURE__ */ jsx6(Text7, { color: colors.tertiary, bold: true, children: a.allDone }) : /* @__PURE__ */ jsx6(Text7, { color: colors.tertiary, children: a.syncing })
811
+ ] }),
812
+ /* @__PURE__ */ jsxs7(Box6, { gap: 3, children: [
813
+ /* @__PURE__ */ jsxs7(Text7, { color: colors.primary, children: [
814
+ a.active,
815
+ ": ",
816
+ String(activeCount).padStart(2, "0")
817
+ ] }),
818
+ /* @__PURE__ */ jsxs7(Text7, { color: colors.tertiary, children: [
819
+ a.success,
820
+ ": ",
821
+ String(successCount).padStart(2, "0")
822
+ ] }),
823
+ /* @__PURE__ */ jsxs7(Text7, { color: colors.error, children: [
824
+ a.errors,
825
+ ": ",
826
+ String(errorCount).padStart(2, "0")
827
+ ] })
828
+ ] })
829
+ ] }),
830
+ /* @__PURE__ */ jsxs7(Box6, { flexDirection: "row", gap: 2, flexGrow: 1, children: [
831
+ /* @__PURE__ */ jsxs7(Box6, { flexDirection: "column", gap: 1, width: "55%", children: [
832
+ entries.map(([id, upd]) => /* @__PURE__ */ jsxs7(Box6, { flexDirection: "column", gap: 0, children: [
833
+ /* @__PURE__ */ jsxs7(Box6, { flexDirection: "row", justifyContent: "space-between", children: [
834
+ /* @__PURE__ */ jsx6(Text7, { color: upd.status === "error" ? colors.error : colors.onSurface, bold: true, children: id }),
835
+ /* @__PURE__ */ jsx6(StatusIndicator, { status: upd.status })
836
+ ] }),
837
+ /* @__PURE__ */ jsx6(
838
+ ProgressGauge,
839
+ {
840
+ value: upd.percent,
841
+ width: 30,
842
+ color: upd.status === "error" ? colors.error : upd.status === "success" ? colors.tertiary : colors.primary
843
+ }
844
+ ),
845
+ upd.status === "running" && upd.currentPackage && /* @__PURE__ */ jsx6(Text7, { color: colors.onSurfaceVariant, dimColor: true, children: upd.currentPackage }),
846
+ upd.manualCommand && /* @__PURE__ */ jsxs7(Text7, { color: colors.secondary, children: [
847
+ t("packageSync", "manualCmd"),
848
+ " ",
849
+ upd.manualCommand
850
+ ] }),
851
+ (upd.status === "success" || upd.status === "error") && /* @__PURE__ */ jsx6(ResultDetail, { upd })
852
+ ] }, id)),
853
+ allDone && /* @__PURE__ */ jsx6(Box6, { marginTop: 1, children: /* @__PURE__ */ jsxs7(Text7, { color: colors.primary, dimColor: true, children: [
854
+ "[R] ",
855
+ a.rescanHint
856
+ ] }) })
857
+ ] }),
858
+ /* @__PURE__ */ jsx6(Box6, { flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ jsx6(GhostBox, { title: showDetail ? `LOG_${showDetail.toUpperCase()}` : `${a.stdout}_${Date.now().toString(16).toUpperCase().slice(-4)}`, children: /* @__PURE__ */ jsx6(Box6, { flexDirection: "column", children: (showDetail ? (updates.get(showDetail)?.logs ?? []).slice(-18) : allLogs.slice(-18)).map((line, i) => /* @__PURE__ */ jsx6(
859
+ Text7,
860
+ {
861
+ color: line.includes("[ERR]") ? colors.error : line.includes("[OK]") ? colors.tertiary : line.startsWith("==>") ? colors.tertiary : line.startsWith("DEBUG") ? colors.onSurfaceVariant : colors.onSurface,
862
+ dimColor: line.startsWith("DEBUG"),
863
+ children: line.slice(0, 70)
864
+ },
865
+ `log-${i}-${line.slice(0, 20)}`
866
+ )) }) }) })
867
+ ] })
868
+ ] });
869
+ }
870
+
871
+ // src/screens/package-sync.tsx
872
+ import { useState as useState2, useMemo } from "react";
873
+ import { Box as Box7, Text as Text8, useInput as useInput4 } from "ink";
874
+ import { Fragment, jsx as jsx7, jsxs as jsxs8 } from "react/jsx-runtime";
875
+ function PackageSync() {
876
+ const { managers, startUpdate, startUninstall, setScreen, sudoMode: sudoMode2 } = useApp();
877
+ const [selectedIds, setSelectedIds] = useState2(/* @__PURE__ */ new Set());
878
+ const [cursor, setCursor] = useState2(0);
879
+ const ps = t("packageSync");
880
+ const rows = useMemo(
881
+ () => managers.flatMap(
882
+ ({ manager, outdated }) => outdated.map((pkg) => ({
883
+ id: `${manager.manager.id}:${pkg.name}`,
884
+ manager: manager.manager.id,
885
+ package: pkg.name,
886
+ currentVersion: pkg.currentVersion,
887
+ newVersion: pkg.newVersion,
888
+ size: pkg.size,
889
+ requiresAdmin: manager.manager.requiresAdmin
890
+ }))
891
+ ),
892
+ [managers]
893
+ );
894
+ const totalUpdates = rows.length;
895
+ const selectedCount = selectedIds.size;
896
+ const allSelected = selectedCount === rows.length && rows.length > 0;
897
+ function selectAll() {
898
+ setSelectedIds(new Set(rows.map((r) => r.id)));
899
+ }
900
+ function deselectAll() {
901
+ setSelectedIds(/* @__PURE__ */ new Set());
902
+ }
903
+ function toggleOne(id) {
904
+ setSelectedIds((prev) => {
905
+ const next = new Set(prev);
906
+ if (next.has(id)) next.delete(id);
907
+ else next.add(id);
908
+ return next;
909
+ });
910
+ }
911
+ function groupSelectedByManager() {
912
+ const toProcess = rows.filter((r) => selectedIds.has(r.id));
913
+ if (toProcess.length === 0) return null;
914
+ const byManager = /* @__PURE__ */ new Map();
915
+ for (const row of toProcess) {
916
+ if (!byManager.has(row.manager)) byManager.set(row.manager, []);
917
+ byManager.get(row.manager).push(row.package);
918
+ }
919
+ return byManager;
920
+ }
921
+ async function startSelected() {
922
+ const byManager = groupSelectedByManager();
923
+ if (!byManager) return;
924
+ setScreen("active");
925
+ for (const [managerId, packages] of byManager) {
926
+ const ms = managers.find((m) => m.manager.manager.id === managerId);
927
+ if (ms) startUpdate(ms.manager.manager, packages, sudoMode2);
928
+ }
929
+ }
930
+ async function uninstallSelected() {
931
+ const byManager = groupSelectedByManager();
932
+ if (!byManager) return;
933
+ setScreen("active");
934
+ for (const [managerId, packages] of byManager) {
935
+ const ms = managers.find((m) => m.manager.manager.id === managerId);
936
+ if (ms?.manager.manager.uninstall) {
937
+ startUninstall(ms.manager.manager, packages, sudoMode2);
938
+ }
939
+ }
940
+ }
941
+ useInput4((input, key) => {
942
+ if (key.upArrow) setCursor((c) => Math.max(0, c - 1));
943
+ if (key.downArrow) setCursor((c) => Math.min(rows.length - 1, c + 1));
944
+ if (input === " ") {
945
+ const row = rows[cursor];
946
+ if (row) toggleOne(row.id);
947
+ }
948
+ if (input === "a" || input === "A") selectAll();
949
+ if (input === "n" || input === "N") deselectAll();
950
+ if ((input === "u" || input === "U") && selectedCount > 0) startSelected();
951
+ if ((input === "x" || input === "X") && selectedCount > 0) uninstallSelected();
952
+ if (key.return && selectedCount > 0) startSelected();
953
+ if (key.escape) setScreen("dashboard");
954
+ });
955
+ if (totalUpdates === 0) {
956
+ return /* @__PURE__ */ jsxs8(Box7, { flexDirection: "column", paddingX: 2, paddingY: 2, gap: 1, alignItems: "center", justifyContent: "center", flexGrow: 1, children: [
957
+ /* @__PURE__ */ jsxs8(Text8, { color: colors.tertiary, bold: true, children: [
958
+ box.check,
959
+ " ",
960
+ ps.noUpdates
961
+ ] }),
962
+ /* @__PURE__ */ jsxs8(Text8, { color: colors.onSurfaceVariant, dimColor: true, children: [
963
+ "ESC ",
964
+ box.arrow,
965
+ " Volver al panel"
966
+ ] })
967
+ ] });
968
+ }
969
+ return /* @__PURE__ */ jsxs8(Box7, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [
970
+ /* @__PURE__ */ jsxs8(Box7, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [
971
+ /* @__PURE__ */ jsxs8(Box7, { gap: 2, alignItems: "center", children: [
972
+ /* @__PURE__ */ jsx7(Text8, { bold: true, color: colors.onSurface, children: ps.title }),
973
+ /* @__PURE__ */ jsxs8(Text8, { color: colors.secondary, bold: true, children: [
974
+ selectedCount,
975
+ "/",
976
+ totalUpdates
977
+ ] }),
978
+ selectedCount > 0 && /* @__PURE__ */ jsxs8(Fragment, { children: [
979
+ /* @__PURE__ */ jsxs8(Text8, { color: colors.onPrimary, backgroundColor: colors.primaryContainer, bold: true, children: [
980
+ " ",
981
+ "U ",
982
+ box.arrow,
983
+ " ACTUALIZAR",
984
+ " "
985
+ ] }),
986
+ /* @__PURE__ */ jsxs8(Text8, { color: colors.onError, backgroundColor: colors.errorContainer, bold: true, children: [
987
+ " ",
988
+ "X ",
989
+ box.arrow,
990
+ " DESINSTALAR",
991
+ " "
992
+ ] })
993
+ ] })
994
+ ] }),
995
+ /* @__PURE__ */ jsxs8(Text8, { color: colors.onSurfaceVariant, dimColor: true, children: [
996
+ "[A] todos ",
997
+ box.dot,
998
+ " [N] ninguno ",
999
+ box.dot,
1000
+ " [ESPACIO] toggle"
1001
+ ] })
1002
+ ] }),
1003
+ /* @__PURE__ */ jsx7(Box7, { marginTop: 1, children: /* @__PURE__ */ jsxs8(Text8, { color: colors.outlineVariant, children: [
1004
+ " ",
1005
+ padR2(ps.colSel, 4),
1006
+ padR2(ps.colManager, 10),
1007
+ padR2(ps.colPackage, 20),
1008
+ padR2(ps.colVersion, 12),
1009
+ padR2(ps.colNew, 12)
1010
+ ] }) }),
1011
+ /* @__PURE__ */ jsx7(Box7, { flexDirection: "column", flexGrow: 1, overflow: "hidden", children: rows.map((row, i) => {
1012
+ const isCursor = i === cursor;
1013
+ const isSelected = selectedIds.has(row.id);
1014
+ const bg = isCursor ? colors.surfaceContainerHigh : void 0;
1015
+ return /* @__PURE__ */ jsxs8(Box7, { backgroundColor: bg, children: [
1016
+ /* @__PURE__ */ jsxs8(Text8, { color: isCursor ? colors.primary : colors.onSurfaceVariant, children: [
1017
+ isCursor ? box.bullet : " ",
1018
+ " "
1019
+ ] }),
1020
+ /* @__PURE__ */ jsx7(Text8, { color: isSelected ? colors.tertiary : colors.onSurfaceVariant, children: padR2(isSelected ? "[x]" : "[ ]", 4) }),
1021
+ /* @__PURE__ */ jsx7(Text8, { color: colors.onSurfaceVariant, children: padR2(row.manager, 10) }),
1022
+ /* @__PURE__ */ jsx7(Text8, { color: colors.onSurface, bold: isSelected, children: padR2(row.package, 20) }),
1023
+ /* @__PURE__ */ jsx7(Text8, { color: colors.onSurfaceVariant, children: padR2(row.currentVersion, 12) }),
1024
+ /* @__PURE__ */ jsx7(Text8, { color: colors.tertiary, children: padR2(`${box.arrow} ${row.newVersion}`, 12) }),
1025
+ row.requiresAdmin && /* @__PURE__ */ jsx7(StatusPill, { variant: "muted", children: "ADM" })
1026
+ ] }, row.id);
1027
+ }) })
1028
+ ] });
1029
+ }
1030
+ function padR2(str, len) {
1031
+ if (str.length >= len) return str.slice(0, len - 1) + " ";
1032
+ return str + " ".repeat(len - str.length);
1033
+ }
1034
+
1035
+ // src/screens/settings.tsx
1036
+ import { useState as useState3 } from "react";
1037
+ import { Box as Box9, Text as Text10, useInput as useInput5 } from "ink";
1038
+
1039
+ // src/components/toggle-switch.tsx
1040
+ import { Box as Box8, Text as Text9 } from "ink";
1041
+ import { jsx as jsx8, jsxs as jsxs9 } from "react/jsx-runtime";
1042
+ function ToggleSwitch({ value, label, statusLabel }) {
1043
+ return /* @__PURE__ */ jsxs9(Box8, { flexDirection: "row", gap: 2, alignItems: "center", children: [
1044
+ label && /* @__PURE__ */ jsx8(Text9, { color: colors.onSurface, children: label }),
1045
+ statusLabel && /* @__PURE__ */ jsx8(Text9, { color: colors.onSurfaceVariant, dimColor: true, children: statusLabel }),
1046
+ /* @__PURE__ */ jsx8(
1047
+ Text9,
1048
+ {
1049
+ color: value ? colors.onTertiary : colors.onSurfaceVariant,
1050
+ backgroundColor: value ? colors.tertiary : colors.surfaceContainerHighest,
1051
+ bold: true,
1052
+ children: value ? "[ ON ]" : "[OFF]"
1053
+ }
1054
+ )
1055
+ ] });
1056
+ }
1057
+
1058
+ // src/screens/settings.tsx
1059
+ import { jsx as jsx9, jsxs as jsxs10 } from "react/jsx-runtime";
1060
+ var SECTIONS = ["general", "sources"];
1061
+ var LANGUAGES = ["es", "en"];
1062
+ function Settings() {
1063
+ const { managers, config, setConfig } = useApp();
1064
+ const s = t("settings");
1065
+ const [sectionIdx, setSectionIdx] = useState3(0);
1066
+ const [managerCursor, setManagerCursor] = useState3(0);
1067
+ const currentSection = SECTIONS[sectionIdx] ?? "general";
1068
+ function toggleManager(id) {
1069
+ const current = config.enabledManagers[id] ?? true;
1070
+ setConfig({
1071
+ ...config,
1072
+ enabledManagers: { ...config.enabledManagers, [id]: !current }
1073
+ });
1074
+ }
1075
+ function cycleLanguage() {
1076
+ const idx = LANGUAGES.indexOf(config.language);
1077
+ const next = LANGUAGES[(idx + 1) % LANGUAGES.length] ?? "es";
1078
+ setConfig({ ...config, language: next });
1079
+ setLanguage(next);
1080
+ }
1081
+ useInput5((input, key) => {
1082
+ if (currentSection === "sources") {
1083
+ if (key.upArrow) setManagerCursor((i) => Math.max(0, i - 1));
1084
+ if (key.downArrow) setManagerCursor((i) => Math.min(managers.length - 1, i + 1));
1085
+ if (input === " ") {
1086
+ const mgr = managers[managerCursor];
1087
+ if (mgr) toggleManager(mgr.manager.manager.id);
1088
+ }
1089
+ }
1090
+ if (key.tab) setSectionIdx((i) => (i + 1) % SECTIONS.length);
1091
+ if (input === "l" || input === "L") cycleLanguage();
1092
+ });
1093
+ return /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, flexGrow: 1, children: [
1094
+ /* @__PURE__ */ jsxs10(Box9, { flexDirection: "row", justifyContent: "space-between", marginBottom: 1, children: [
1095
+ /* @__PURE__ */ jsx9(Text10, { bold: true, color: colors.onSurface, children: s.title }),
1096
+ /* @__PURE__ */ jsx9(Text10, { color: colors.outlineVariant, dimColor: true, children: s.subtitle })
1097
+ ] }),
1098
+ /* @__PURE__ */ jsxs10(Box9, { flexDirection: "row", flexGrow: 1, gap: 2, children: [
1099
+ /* @__PURE__ */ jsx9(
1100
+ Box9,
1101
+ {
1102
+ flexDirection: "column",
1103
+ width: 16,
1104
+ backgroundColor: colors.surfaceContainerLowest,
1105
+ paddingX: 1,
1106
+ paddingY: 0,
1107
+ children: SECTIONS.map((section, i) => /* @__PURE__ */ jsx9(
1108
+ Box9,
1109
+ {
1110
+ backgroundColor: i === sectionIdx ? colors.primaryContainer : void 0,
1111
+ paddingX: 1,
1112
+ children: /* @__PURE__ */ jsxs10(Text10, { color: i === sectionIdx ? colors.onPrimaryContainer : colors.onSurface, children: [
1113
+ String(i + 1).padStart(2, "0"),
1114
+ " ",
1115
+ s.nav[section]
1116
+ ] })
1117
+ },
1118
+ section
1119
+ ))
1120
+ }
1121
+ ),
1122
+ /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", flexGrow: 1, gap: 2, children: [
1123
+ currentSection === "general" && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", gap: 1, children: [
1124
+ /* @__PURE__ */ jsx9(Text10, { color: colors.primary, bold: true, children: s.language }),
1125
+ /* @__PURE__ */ jsxs10(Box9, { flexDirection: "row", gap: 2, alignItems: "center", children: [
1126
+ /* @__PURE__ */ jsx9(Text10, { color: colors.onSurface, children: "Idioma / Language" }),
1127
+ /* @__PURE__ */ jsxs10(
1128
+ Text10,
1129
+ {
1130
+ color: colors.onPrimaryContainer,
1131
+ backgroundColor: colors.primaryContainer,
1132
+ bold: true,
1133
+ children: [
1134
+ " ",
1135
+ config.language === "es" ? "Espa\xF1ol" : "English",
1136
+ " "
1137
+ ]
1138
+ }
1139
+ ),
1140
+ /* @__PURE__ */ jsx9(Text10, { color: colors.onSurfaceVariant, dimColor: true, children: "[L] cambiar" })
1141
+ ] })
1142
+ ] }),
1143
+ currentSection === "sources" && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", gap: 1, children: [
1144
+ /* @__PURE__ */ jsxs10(Box9, { flexDirection: "row", justifyContent: "space-between", children: [
1145
+ /* @__PURE__ */ jsx9(Text10, { color: colors.primary, bold: true, children: s.activeManagers }),
1146
+ /* @__PURE__ */ jsxs10(Text10, { color: colors.onSurfaceVariant, dimColor: true, children: [
1147
+ "[\u2191\u2193] navegar ",
1148
+ box.dot,
1149
+ " [ESPACIO] activar/desactivar"
1150
+ ] })
1151
+ ] }),
1152
+ managers.map(({ manager }, i) => {
1153
+ const id = manager.manager.id;
1154
+ const enabled = config.enabledManagers[id] ?? true;
1155
+ const isCursor = i === managerCursor;
1156
+ const statusLabel = manager.detection.available ? s.detected : s.notFound;
1157
+ return /* @__PURE__ */ jsxs10(
1158
+ Box9,
1159
+ {
1160
+ flexDirection: "row",
1161
+ justifyContent: "space-between",
1162
+ alignItems: "center",
1163
+ backgroundColor: isCursor ? colors.surfaceContainerHigh : void 0,
1164
+ paddingX: 2,
1165
+ paddingY: 0,
1166
+ children: [
1167
+ /* @__PURE__ */ jsxs10(Box9, { gap: 2, alignItems: "center", children: [
1168
+ /* @__PURE__ */ jsx9(Text10, { color: isCursor ? colors.primary : colors.onSurfaceVariant, children: isCursor ? box.bullet : " " }),
1169
+ /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", children: [
1170
+ /* @__PURE__ */ jsx9(Text10, { color: enabled ? colors.onSurface : colors.onSurfaceVariant, bold: enabled, dimColor: !enabled, children: t("managers", id) }),
1171
+ /* @__PURE__ */ jsx9(Text10, { color: colors.onSurfaceVariant, dimColor: true, children: manager.detection.version ?? "N/A" })
1172
+ ] })
1173
+ ] }),
1174
+ /* @__PURE__ */ jsxs10(Box9, { flexDirection: "row", gap: 2, alignItems: "center", children: [
1175
+ /* @__PURE__ */ jsx9(
1176
+ Text10,
1177
+ {
1178
+ color: manager.detection.available ? colors.tertiary : colors.onSurfaceVariant,
1179
+ dimColor: !manager.detection.available,
1180
+ children: statusLabel
1181
+ }
1182
+ ),
1183
+ /* @__PURE__ */ jsx9(ToggleSwitch, { value: enabled })
1184
+ ] })
1185
+ ]
1186
+ },
1187
+ id
1188
+ );
1189
+ })
1190
+ ] })
1191
+ ] })
1192
+ ] })
1193
+ ] });
1194
+ }
1195
+
1196
+ // src/hooks/use-managers.ts
1197
+ import { useState as useState4, useEffect, useCallback, useRef } from "react";
1198
+
1199
+ // src/managers/brew.ts
1200
+ init_executor();
1201
+ var brew = {
1202
+ id: "brew",
1203
+ platforms: ["darwin"],
1204
+ requiresAdmin: false,
1205
+ async detect() {
1206
+ const result = await execCommand("brew", ["--version"], 3e3);
1207
+ if (result.exitCode !== 0) return { available: false };
1208
+ const version = result.stdout.split("\n")[0]?.replace("Homebrew ", "").trim();
1209
+ return { available: true, version };
1210
+ },
1211
+ async listOutdated() {
1212
+ const result = await execCommand("brew", ["outdated", "--json=v2"], 3e4);
1213
+ if (result.exitCode !== 0) return [];
1214
+ try {
1215
+ const data = JSON.parse(result.stdout);
1216
+ const formulae = data.formulae ?? [];
1217
+ const casks = data.casks ?? [];
1218
+ return [...formulae, ...casks].map((f) => ({
1219
+ name: f.name,
1220
+ currentVersion: f.installed_versions[0] ?? "?",
1221
+ newVersion: f.current_version
1222
+ }));
1223
+ } catch {
1224
+ return [];
1225
+ }
1226
+ },
1227
+ async *upgrade(packages) {
1228
+ yield { type: "start", message: "Actualizando Homebrew..." };
1229
+ yield { type: "log", message: "brew update" };
1230
+ yield* execStream("brew", ["update"]);
1231
+ const upgradeArgs = packages && packages.length > 0 ? ["upgrade", ...packages] : ["upgrade"];
1232
+ yield { type: "log", message: `brew ${upgradeArgs.join(" ")}` };
1233
+ yield* execStream("brew", upgradeArgs);
1234
+ yield { type: "log", message: "brew cleanup" };
1235
+ yield* execStream("brew", ["cleanup"]);
1236
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
1237
+ },
1238
+ async *uninstall(packages) {
1239
+ if (!packages.length) {
1240
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1241
+ }
1242
+ yield { type: "start", message: "Desinstalando paquetes Homebrew..." };
1243
+ for (const pkg of packages) {
1244
+ yield { type: "log", message: `brew uninstall ${pkg}` };
1245
+ yield* execStream("brew", ["uninstall", pkg]);
1246
+ }
1247
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
1248
+ }
1249
+ };
1250
+
1251
+ // src/managers/pip.ts
1252
+ init_executor();
1253
+ function getPipCmd() {
1254
+ return process.platform === "win32" ? "pip" : "pip3";
1255
+ }
1256
+ var pip = {
1257
+ id: "pip",
1258
+ platforms: ["darwin", "linux", "win32"],
1259
+ requiresAdmin: false,
1260
+ async detect() {
1261
+ const cmd = getPipCmd();
1262
+ const result = await execCommand(cmd, ["--version"], 3e3);
1263
+ if (result.exitCode !== 0) return { available: false };
1264
+ const version = result.stdout.match(/pip (\S+)/)?.[1];
1265
+ return { available: true, version };
1266
+ },
1267
+ async listOutdated() {
1268
+ const cmd = getPipCmd();
1269
+ const result = await execCommand(cmd, ["list", "--outdated", "--format=json"], 3e4);
1270
+ if (result.exitCode !== 0) return [];
1271
+ try {
1272
+ const data = JSON.parse(result.stdout);
1273
+ return data.map((p) => ({
1274
+ name: p.name,
1275
+ currentVersion: p.version,
1276
+ newVersion: p.latest_version
1277
+ }));
1278
+ } catch {
1279
+ return [];
1280
+ }
1281
+ },
1282
+ async *upgrade(packages) {
1283
+ const cmd = getPipCmd();
1284
+ yield { type: "start", message: "Actualizando pip..." };
1285
+ const testResult = await execCommand(cmd, ["install", "--user", "--dry-run", "pip"], 5e3);
1286
+ const isExternallyManaged = (testResult.stdout + testResult.stderr).includes("externally-managed");
1287
+ const extraFlags = isExternallyManaged ? ["--break-system-packages"] : [];
1288
+ if (isExternallyManaged) {
1289
+ yield { type: "log", message: "Entorno PEP 668 detectado, usando --break-system-packages" };
1290
+ }
1291
+ if (packages && packages.length > 0) {
1292
+ for (const pkg of packages) {
1293
+ const args2 = ["install", "--user", "--upgrade", ...extraFlags, pkg];
1294
+ yield { type: "log", message: `${cmd} ${args2.join(" ")}` };
1295
+ yield* execStream(cmd, args2);
1296
+ }
1297
+ }
1298
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
1299
+ },
1300
+ async *uninstall(packages) {
1301
+ const cmd = getPipCmd();
1302
+ if (!packages.length) {
1303
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1304
+ }
1305
+ yield { type: "start", message: "Desinstalando paquetes pip..." };
1306
+ for (const pkg of packages) {
1307
+ const args2 = ["uninstall", "-y", pkg];
1308
+ yield { type: "log", message: `${cmd} ${args2.join(" ")}` };
1309
+ yield* execStream(cmd, args2);
1310
+ }
1311
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
1312
+ }
1313
+ };
1314
+
1315
+ // src/managers/npm-mgr.ts
1316
+ init_executor();
1317
+ var npmMgr = {
1318
+ id: "npm",
1319
+ platforms: ["darwin", "linux", "win32"],
1320
+ requiresAdmin: false,
1321
+ async detect() {
1322
+ const result = await execCommand("npm", ["--version"], 3e3);
1323
+ if (result.exitCode !== 0) return { available: false };
1324
+ return { available: true, version: result.stdout.trim() };
1325
+ },
1326
+ async listOutdated() {
1327
+ const result = await execCommand("npm", ["outdated", "-g", "--json"], 3e4);
1328
+ if (!result.stdout.trim()) return [];
1329
+ try {
1330
+ const data = JSON.parse(result.stdout);
1331
+ return Object.entries(data).filter(([, info]) => info.current !== info.latest).map(([name, info]) => ({
1332
+ name,
1333
+ currentVersion: info.current,
1334
+ newVersion: info.latest
1335
+ }));
1336
+ } catch {
1337
+ return [];
1338
+ }
1339
+ },
1340
+ async *upgrade(packages) {
1341
+ yield { type: "start", message: "Actualizando paquetes npm globales..." };
1342
+ const args2 = packages && packages.length > 0 ? ["update", "-g", ...packages] : ["update", "-g"];
1343
+ yield { type: "log", message: `npm ${args2.join(" ")}` };
1344
+ yield* execStream("npm", args2);
1345
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
1346
+ },
1347
+ async *uninstall(packages) {
1348
+ if (!packages.length) {
1349
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1350
+ }
1351
+ yield { type: "start", message: "Desinstalando paquetes npm globales..." };
1352
+ const args2 = ["uninstall", "-g", ...packages];
1353
+ yield { type: "log", message: `npm ${args2.join(" ")}` };
1354
+ yield* execStream("npm", args2);
1355
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
1356
+ }
1357
+ };
1358
+
1359
+ // src/managers/conda.ts
1360
+ init_executor();
1361
+ var conda = {
1362
+ id: "conda",
1363
+ platforms: ["darwin", "linux", "win32"],
1364
+ requiresAdmin: false,
1365
+ async detect() {
1366
+ const result = await execCommand("conda", ["--version"], 3e3);
1367
+ if (result.exitCode !== 0) return { available: false };
1368
+ const version = result.stdout.trim().replace("conda ", "");
1369
+ return { available: true, version };
1370
+ },
1371
+ async listOutdated() {
1372
+ const result = await execCommand(
1373
+ "conda",
1374
+ ["update", "--all", "--dry-run", "--json"],
1375
+ 3e4
1376
+ );
1377
+ if (result.exitCode !== 0 && result.exitCode !== 1) return [];
1378
+ try {
1379
+ const data = JSON.parse(result.stdout || result.stderr);
1380
+ const actions = data.actions?.FETCH ?? data.actions?.LINK ?? [];
1381
+ return actions.filter((a) => a.old_version).map((a) => ({
1382
+ name: a.name,
1383
+ currentVersion: a.old_version ?? "?",
1384
+ newVersion: a.version
1385
+ }));
1386
+ } catch {
1387
+ return [];
1388
+ }
1389
+ },
1390
+ async *upgrade(packages) {
1391
+ yield { type: "start", message: "Actualizando entorno conda..." };
1392
+ const args2 = packages && packages.length > 0 ? ["update", "-y", ...packages] : ["update", "--all", "-y"];
1393
+ yield { type: "log", message: `conda ${args2.join(" ")}` };
1394
+ yield* execStream("conda", args2);
1395
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
1396
+ },
1397
+ async *uninstall(packages) {
1398
+ if (!packages.length) {
1399
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1400
+ }
1401
+ yield { type: "start", message: "Desinstalando paquetes conda..." };
1402
+ const args2 = ["remove", "-y", ...packages];
1403
+ yield { type: "log", message: `conda ${args2.join(" ")}` };
1404
+ yield* execStream("conda", args2);
1405
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
1406
+ }
1407
+ };
1408
+
1409
+ // src/managers/gem.ts
1410
+ init_executor();
1411
+ var gem = {
1412
+ id: "gem",
1413
+ platforms: ["darwin", "linux", "win32"],
1414
+ requiresAdmin: false,
1415
+ async detect() {
1416
+ const result = await execCommand("gem", ["--version"], 3e3);
1417
+ if (result.exitCode !== 0) return { available: false };
1418
+ return { available: true, version: result.stdout.trim() };
1419
+ },
1420
+ async listOutdated() {
1421
+ const result = await execCommand("gem", ["outdated"], 3e4);
1422
+ if (result.exitCode !== 0) return [];
1423
+ const filterResult = await execCommand(
1424
+ "ruby",
1425
+ ["-e", 'puts Gem::Specification.select{|s| !s.default_gem? && s.base_dir == Gem.dir}.map(&:name).join("\n")'],
1426
+ 5e3
1427
+ );
1428
+ const userGems = new Set(
1429
+ filterResult.stdout.split("\n").map((l) => l.trim()).filter(Boolean)
1430
+ );
1431
+ return result.stdout.split("\n").filter(Boolean).map((line) => {
1432
+ const match = line.match(/^(\S+)\s+\(([^<]+)<\s+([^)]+)\)/);
1433
+ if (!match) return null;
1434
+ const name = match[1] ?? "";
1435
+ if (!userGems.has(name)) return null;
1436
+ return {
1437
+ name,
1438
+ currentVersion: match[2]?.trim() ?? "?",
1439
+ newVersion: match[3]?.trim() ?? "?"
1440
+ };
1441
+ }).filter((x) => x !== null);
1442
+ },
1443
+ async *upgrade(packages, sudoMode2) {
1444
+ const useSudo = sudoMode2 ?? false;
1445
+ yield { type: "start", message: `Actualizando gems...${useSudo ? " (sudo)" : ""}` };
1446
+ const hasCustomGemHome = !!process.env["GEM_HOME"];
1447
+ const baseArgs = useSudo ? ["update"] : hasCustomGemHome ? ["update"] : ["update", "--user-install"];
1448
+ const args2 = packages && packages.length > 0 ? [...baseArgs, ...packages] : baseArgs;
1449
+ const prefix = useSudo ? "sudo " : "";
1450
+ yield { type: "log", message: `${prefix}gem ${args2.join(" ")}` };
1451
+ yield* execStream("gem", args2, 3e5, useSudo);
1452
+ yield { type: "log", message: "Verificando resultado..." };
1453
+ const checkResult = await execCommand("gem", ["outdated"], 15e3);
1454
+ const stillOutdated = checkResult.stdout.split("\n").filter(Boolean).map((line) => line.match(/^(\S+)/)?.[1]).filter(Boolean);
1455
+ const requested = new Set(packages ?? []);
1456
+ const failedPkgs = requested.size > 0 ? stillOutdated.filter((name) => requested.has(name)) : stillOutdated;
1457
+ const upgraded = (packages?.length ?? stillOutdated.length) - failedPkgs.length;
1458
+ const errors = failedPkgs.length > 0 ? [
1459
+ useSudo ? `${failedPkgs.length} gem(s) no se pudieron actualizar: ${failedPkgs.slice(0, 5).join(", ")}` : `${failedPkgs.length} gem(s) del sistema requieren sudo: ${failedPkgs.slice(0, 5).join(", ")}`
1460
+ ] : [];
1461
+ return {
1462
+ success: failedPkgs.length === 0,
1463
+ upgraded: Math.max(upgraded, 0),
1464
+ failed: failedPkgs.length,
1465
+ errors
1466
+ };
1467
+ },
1468
+ async *uninstall(packages, sudoMode2) {
1469
+ if (!packages.length) {
1470
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1471
+ }
1472
+ const useSudo = sudoMode2 ?? false;
1473
+ yield { type: "start", message: `Desinstalando gems...${useSudo ? " (sudo)" : ""}` };
1474
+ const args2 = ["uninstall", "-aIx", ...packages];
1475
+ const prefix = useSudo ? "sudo " : "";
1476
+ yield { type: "log", message: `${prefix}gem ${args2.join(" ")}` };
1477
+ yield* execStream("gem", args2, 3e5, useSudo);
1478
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
1479
+ }
1480
+ };
1481
+
1482
+ // src/managers/softwareupdate.ts
1483
+ init_executor();
1484
+ var softwareupdate = {
1485
+ id: "softwareupdate",
1486
+ platforms: ["darwin"],
1487
+ requiresAdmin: true,
1488
+ async detect() {
1489
+ await execCommand("softwareupdate", ["--help"], 3e3);
1490
+ return { available: true, version: "macOS nativo" };
1491
+ },
1492
+ async listOutdated() {
1493
+ const result = await execCommand("softwareupdate", ["-l"], 3e4);
1494
+ const output = result.stdout + result.stderr;
1495
+ if (output.includes("No new software available")) return [];
1496
+ const packages = [];
1497
+ const lines = output.split("\n");
1498
+ for (const line of lines) {
1499
+ const match = line.match(/^\s*\*\s+(.+?)(?:\s+-\s+(.+))?$/);
1500
+ if (match) {
1501
+ packages.push({
1502
+ name: match[1]?.trim() ?? "Unknown",
1503
+ currentVersion: "installed",
1504
+ newVersion: match[2]?.trim() ?? "available"
1505
+ });
1506
+ }
1507
+ }
1508
+ return packages;
1509
+ },
1510
+ async *upgrade(_packages, sudoMode2) {
1511
+ if (!sudoMode2) {
1512
+ yield { type: "error", message: "Requiere permisos de administrador." };
1513
+ yield { type: "log", message: "Comando manual: sudo softwareupdate -i -a" };
1514
+ yield { type: "log", message: "O ejecuta: updater --sudo" };
1515
+ return { success: false, upgraded: 0, failed: 0, errors: [], manualCommand: "sudo softwareupdate -i -a" };
1516
+ }
1517
+ yield { type: "start", message: "Instalando actualizaciones de macOS (sudo)..." };
1518
+ yield { type: "log", message: "sudo softwareupdate -i -a" };
1519
+ yield* execStream("softwareupdate", ["-i", "-a"], 6e5, true);
1520
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1521
+ }
1522
+ };
1523
+
1524
+ // src/managers/winget.ts
1525
+ init_executor();
1526
+ var winget = {
1527
+ id: "winget",
1528
+ platforms: ["win32"],
1529
+ requiresAdmin: false,
1530
+ async detect() {
1531
+ const result = await execCommand("winget", ["--version"], 3e3);
1532
+ if (result.exitCode !== 0) return { available: false };
1533
+ return { available: true, version: result.stdout.trim() };
1534
+ },
1535
+ async listOutdated() {
1536
+ const result = await execCommand(
1537
+ "winget",
1538
+ ["list", "--upgrade-available", "--accept-source-agreements"],
1539
+ 3e4
1540
+ );
1541
+ if (result.exitCode !== 0) return [];
1542
+ const packages = [];
1543
+ const lines = result.stdout.split("\n");
1544
+ let inTable = false;
1545
+ for (const line of lines) {
1546
+ if (line.includes("------")) {
1547
+ inTable = true;
1548
+ continue;
1549
+ }
1550
+ if (!inTable) continue;
1551
+ const cols = line.trim().split(/\s{2,}/);
1552
+ if (cols.length >= 4) {
1553
+ packages.push({
1554
+ name: cols[0] ?? "Unknown",
1555
+ currentVersion: cols[2] ?? "?",
1556
+ newVersion: cols[3] ?? "?"
1557
+ });
1558
+ }
1559
+ }
1560
+ return packages;
1561
+ },
1562
+ async *upgrade(packages) {
1563
+ yield { type: "start", message: "Actualizando paquetes con winget..." };
1564
+ const args2 = packages && packages.length > 0 ? ["upgrade", "--accept-source-agreements", "--accept-package-agreements", ...packages] : ["upgrade", "--all", "--accept-source-agreements", "--accept-package-agreements"];
1565
+ yield { type: "log", message: `winget ${args2.join(" ")}` };
1566
+ yield* execStream("winget", args2);
1567
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
1568
+ },
1569
+ async *uninstall(packages) {
1570
+ if (!packages.length) {
1571
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1572
+ }
1573
+ yield { type: "start", message: "Desinstalando paquetes con winget..." };
1574
+ for (const pkg of packages) {
1575
+ const args2 = ["uninstall", "--accept-source-agreements", "--accept-package-agreements", "--name", pkg];
1576
+ yield { type: "log", message: `winget ${args2.join(" ")}` };
1577
+ yield* execStream("winget", args2);
1578
+ }
1579
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
1580
+ }
1581
+ };
1582
+
1583
+ // src/managers/apt.ts
1584
+ init_executor();
1585
+ var apt = {
1586
+ id: "apt",
1587
+ platforms: ["linux"],
1588
+ requiresAdmin: true,
1589
+ async detect() {
1590
+ const result = await execCommand("apt", ["--version"], 3e3);
1591
+ if (result.exitCode !== 0) return { available: false };
1592
+ const version = result.stdout.split("\n")[0]?.replace("apt ", "").split(" ")[0];
1593
+ return { available: true, version };
1594
+ },
1595
+ async listOutdated() {
1596
+ const result = await execCommand("apt", ["list", "--upgradable"], 3e4);
1597
+ if (result.exitCode !== 0) return [];
1598
+ return result.stdout.split("\n").filter((l) => l.includes("[upgradable")).map((line) => {
1599
+ const match = line.match(/^(\S+)\/\S+\s+(\S+)\s+\S+\s+\[upgradable from:\s+([^\]]+)\]/);
1600
+ if (!match) return null;
1601
+ return {
1602
+ name: match[1]?.split(":")[0] ?? "Unknown",
1603
+ currentVersion: match[3]?.trim() ?? "?",
1604
+ newVersion: match[2] ?? "?"
1605
+ };
1606
+ }).filter((x) => x !== null);
1607
+ },
1608
+ async *upgrade(_packages, sudoMode2) {
1609
+ if (!sudoMode2) {
1610
+ yield { type: "error", message: "Requiere permisos de administrador (sudo)." };
1611
+ yield { type: "log", message: "Comando manual: sudo apt update && sudo apt upgrade" };
1612
+ yield { type: "log", message: "O ejecuta: updater --sudo" };
1613
+ return { success: false, upgraded: 0, failed: 0, errors: [], manualCommand: "sudo apt update && sudo apt upgrade" };
1614
+ }
1615
+ yield { type: "start", message: "Actualizando paquetes apt (sudo)..." };
1616
+ yield { type: "log", message: "sudo apt update" };
1617
+ yield* execStream("apt", ["update"], 12e4, true);
1618
+ yield { type: "log", message: "sudo apt upgrade -y" };
1619
+ yield* execStream("apt", ["upgrade", "-y"], 3e5, true);
1620
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1621
+ }
1622
+ };
1623
+
1624
+ // src/managers/dnf.ts
1625
+ init_executor();
1626
+ var dnf = {
1627
+ id: "dnf",
1628
+ platforms: ["linux"],
1629
+ requiresAdmin: true,
1630
+ async detect() {
1631
+ const result = await execCommand("dnf", ["--version"], 3e3);
1632
+ if (result.exitCode !== 0) return { available: false };
1633
+ const version = result.stdout.split("\n")[0]?.trim();
1634
+ return { available: true, version };
1635
+ },
1636
+ async listOutdated() {
1637
+ const result = await execCommand("dnf", ["check-update"], 6e4);
1638
+ if (result.exitCode === 0) return [];
1639
+ if (result.exitCode !== 100) return [];
1640
+ return result.stdout.split("\n").filter((l) => l.trim() && !l.startsWith("Last") && !l.startsWith("Obsoleting")).map((line) => {
1641
+ const cols = line.trim().split(/\s+/);
1642
+ if (cols.length < 2) return null;
1643
+ return {
1644
+ name: cols[0]?.split(".")[0] ?? "Unknown",
1645
+ currentVersion: "installed",
1646
+ newVersion: cols[1] ?? "?"
1647
+ };
1648
+ }).filter((x) => x !== null);
1649
+ },
1650
+ async *upgrade(_packages, sudoMode2) {
1651
+ if (!sudoMode2) {
1652
+ yield { type: "error", message: "Requiere permisos de administrador (sudo)." };
1653
+ yield { type: "log", message: "Comando manual: sudo dnf upgrade" };
1654
+ yield { type: "log", message: "O ejecuta: updater --sudo" };
1655
+ return { success: false, upgraded: 0, failed: 0, errors: [], manualCommand: "sudo dnf upgrade" };
1656
+ }
1657
+ yield { type: "start", message: "Actualizando paquetes dnf (sudo)..." };
1658
+ yield { type: "log", message: "sudo dnf upgrade -y" };
1659
+ yield* execStream("dnf", ["upgrade", "-y"], 3e5, true);
1660
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1661
+ }
1662
+ };
1663
+
1664
+ // src/managers/pacman.ts
1665
+ init_executor();
1666
+ var pacman = {
1667
+ id: "pacman",
1668
+ platforms: ["linux"],
1669
+ requiresAdmin: true,
1670
+ async detect() {
1671
+ const result = await execCommand("pacman", ["--version"], 3e3);
1672
+ if (result.exitCode !== 0) return { available: false };
1673
+ const version = result.stdout.split("\n")[0]?.trim();
1674
+ return { available: true, version };
1675
+ },
1676
+ async listOutdated() {
1677
+ const result = await execCommand("checkupdates", [], 3e4);
1678
+ if (result.exitCode !== 0 && !result.stdout.trim()) return [];
1679
+ return result.stdout.split("\n").filter(Boolean).map((line) => {
1680
+ const match = line.match(/^(\S+)\s+(\S+)\s+->\s+(\S+)/);
1681
+ if (!match) return null;
1682
+ return {
1683
+ name: match[1] ?? "Unknown",
1684
+ currentVersion: match[2] ?? "?",
1685
+ newVersion: match[3] ?? "?"
1686
+ };
1687
+ }).filter((x) => x !== null);
1688
+ },
1689
+ async *upgrade(_packages, sudoMode2) {
1690
+ if (!sudoMode2) {
1691
+ yield { type: "error", message: "Requiere permisos de administrador (sudo)." };
1692
+ yield { type: "log", message: "Comando manual: sudo pacman -Syu" };
1693
+ yield { type: "log", message: "O ejecuta: updater --sudo" };
1694
+ return { success: false, upgraded: 0, failed: 0, errors: [], manualCommand: "sudo pacman -Syu" };
1695
+ }
1696
+ yield { type: "start", message: "Actualizando paquetes pacman (sudo)..." };
1697
+ yield { type: "log", message: "sudo pacman -Syu --noconfirm" };
1698
+ yield* execStream("pacman", ["-Syu", "--noconfirm"], 3e5, true);
1699
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1700
+ }
1701
+ };
1702
+
1703
+ // src/managers/flatpak.ts
1704
+ init_executor();
1705
+ var flatpak = {
1706
+ id: "flatpak",
1707
+ platforms: ["linux"],
1708
+ requiresAdmin: false,
1709
+ async detect() {
1710
+ const result = await execCommand("flatpak", ["--version"], 3e3);
1711
+ if (result.exitCode !== 0) return { available: false };
1712
+ const version = result.stdout.trim().replace("Flatpak ", "");
1713
+ return { available: true, version };
1714
+ },
1715
+ async listOutdated() {
1716
+ const result = await execCommand(
1717
+ "flatpak",
1718
+ ["remote-ls", "--updates", "--columns=application,version"],
1719
+ 3e4
1720
+ );
1721
+ if (result.exitCode !== 0) return [];
1722
+ return result.stdout.split("\n").filter(Boolean).map((line) => {
1723
+ const cols = line.split(" ");
1724
+ return {
1725
+ name: cols[0]?.trim() ?? "Unknown",
1726
+ currentVersion: "installed",
1727
+ newVersion: cols[1]?.trim() ?? "available"
1728
+ };
1729
+ });
1730
+ },
1731
+ async *upgrade(packages) {
1732
+ yield { type: "start", message: "Actualizando aplicaciones Flatpak..." };
1733
+ const args2 = packages && packages.length > 0 ? ["update", "-y", ...packages] : ["update", "-y"];
1734
+ yield { type: "log", message: `flatpak ${args2.join(" ")}` };
1735
+ yield* execStream("flatpak", args2);
1736
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
1737
+ },
1738
+ async *uninstall(packages) {
1739
+ if (!packages.length) {
1740
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1741
+ }
1742
+ yield { type: "start", message: "Desinstalando paquetes Flatpak..." };
1743
+ const args2 = ["uninstall", "-y", ...packages];
1744
+ yield { type: "log", message: `flatpak ${args2.join(" ")}` };
1745
+ yield* execStream("flatpak", args2);
1746
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
1747
+ }
1748
+ };
1749
+
1750
+ // src/managers/snap.ts
1751
+ init_executor();
1752
+ var snap = {
1753
+ id: "snap",
1754
+ platforms: ["linux"],
1755
+ requiresAdmin: true,
1756
+ async detect() {
1757
+ const result = await execCommand("snap", ["--version"], 3e3);
1758
+ if (result.exitCode !== 0) return { available: false };
1759
+ const version = result.stdout.match(/snap\s+(\S+)/)?.[1];
1760
+ return { available: true, version };
1761
+ },
1762
+ async listOutdated() {
1763
+ const result = await execCommand("snap", ["refresh", "--list"], 3e4);
1764
+ if (result.exitCode !== 0) return [];
1765
+ if (result.stdout.includes("All snaps up to date")) return [];
1766
+ return result.stdout.split("\n").slice(1).filter(Boolean).map((line) => {
1767
+ const cols = line.trim().split(/\s+/);
1768
+ return {
1769
+ name: cols[0] ?? "Unknown",
1770
+ currentVersion: cols[2] ?? "?",
1771
+ newVersion: cols[1] ?? "available"
1772
+ };
1773
+ });
1774
+ },
1775
+ async *upgrade(_packages, sudoMode2) {
1776
+ if (!sudoMode2) {
1777
+ yield { type: "error", message: "Requiere permisos de administrador (sudo)." };
1778
+ yield { type: "log", message: "Comando manual: sudo snap refresh" };
1779
+ yield { type: "log", message: "O ejecuta: updater --sudo" };
1780
+ return { success: false, upgraded: 0, failed: 0, errors: [], manualCommand: "sudo snap refresh" };
1781
+ }
1782
+ yield { type: "start", message: "Actualizando snaps (sudo)..." };
1783
+ yield { type: "log", message: "sudo snap refresh" };
1784
+ yield* execStream("snap", ["refresh"], 3e5, true);
1785
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
1786
+ }
1787
+ };
1788
+
1789
+ // src/managers/flutter.ts
1790
+ init_executor();
1791
+ var flutter = {
1792
+ id: "flutter",
1793
+ platforms: ["darwin", "linux", "win32"],
1794
+ requiresAdmin: false,
1795
+ async detect() {
1796
+ const result = await execCommand("flutter", ["--version", "--machine"], 5e3);
1797
+ if (result.exitCode !== 0) return { available: false };
1798
+ try {
1799
+ const data = JSON.parse(result.stdout);
1800
+ return { available: true, version: data.frameworkVersion ?? result.stdout.split("\n")[0]?.trim() };
1801
+ } catch {
1802
+ const version = result.stdout.match(/Flutter (\S+)/)?.[1];
1803
+ return { available: true, version };
1804
+ }
1805
+ },
1806
+ async listOutdated() {
1807
+ const versionResult = await execCommand("flutter", ["--version", "--machine"], 1e4);
1808
+ let currentVersion;
1809
+ try {
1810
+ const data = JSON.parse(versionResult.stdout);
1811
+ currentVersion = data.frameworkVersion;
1812
+ } catch {
1813
+ currentVersion = versionResult.stdout.match(/Flutter (\S+)/)?.[1];
1814
+ }
1815
+ if (!currentVersion) return [];
1816
+ const platformKey = process.platform === "darwin" ? "macos" : process.platform === "win32" ? "windows" : "linux";
1817
+ const apiUrl = `https://storage.googleapis.com/flutter_infra_release/releases/releases_${platformKey}.json`;
1818
+ try {
1819
+ const apiResult = await execCommand("curl", ["-sL", apiUrl], 1e4);
1820
+ const releases = JSON.parse(apiResult.stdout);
1821
+ const latest = releases.releases.find((r) => r.channel === "stable");
1822
+ if (!latest || latest.version === currentVersion) return [];
1823
+ return [{
1824
+ name: "flutter-sdk",
1825
+ currentVersion,
1826
+ newVersion: latest.version
1827
+ }];
1828
+ } catch {
1829
+ const textResult = await execCommand("flutter", ["--version"], 1e4);
1830
+ const output = textResult.stdout + textResult.stderr;
1831
+ if (output.includes("A new version of Flutter is available")) {
1832
+ return [{
1833
+ name: "flutter-sdk",
1834
+ currentVersion,
1835
+ newVersion: "disponible"
1836
+ }];
1837
+ }
1838
+ return [];
1839
+ }
1840
+ },
1841
+ async *upgrade() {
1842
+ yield { type: "start", message: "Actualizando Flutter SDK..." };
1843
+ yield { type: "log", message: "flutter upgrade --force" };
1844
+ yield* execStream("flutter", ["upgrade", "--force"], 6e5);
1845
+ return { success: true, upgraded: 1, failed: 0, errors: [] };
1846
+ }
1847
+ };
1848
+
1849
+ // src/managers/angular.ts
1850
+ init_executor();
1851
+ var angular = {
1852
+ id: "angular",
1853
+ platforms: ["darwin", "linux", "win32"],
1854
+ requiresAdmin: false,
1855
+ async detect() {
1856
+ const result = await execCommand("ng", ["version"], 5e3);
1857
+ if (result.exitCode !== 0) return { available: false };
1858
+ const version = result.stdout.match(/Angular CLI:\s*(\S+)/)?.[1];
1859
+ return { available: true, version };
1860
+ },
1861
+ async listOutdated() {
1862
+ const currentResult = await execCommand("ng", ["version"], 5e3);
1863
+ const currentVersion = currentResult.stdout.match(/Angular CLI:\s*(\S+)/)?.[1];
1864
+ if (!currentVersion) return [];
1865
+ const latestResult = await execCommand("npm", ["view", "@angular/cli", "version"], 1e4);
1866
+ const latestVersion = latestResult.stdout.trim();
1867
+ if (!latestVersion || currentVersion === latestVersion) return [];
1868
+ return [{
1869
+ name: "@angular/cli",
1870
+ currentVersion,
1871
+ newVersion: latestVersion
1872
+ }];
1873
+ },
1874
+ async *upgrade() {
1875
+ yield { type: "start", message: "Actualizando Angular CLI..." };
1876
+ yield { type: "log", message: "npm update -g @angular/cli" };
1877
+ yield* execStream("npm", ["update", "-g", "@angular/cli"]);
1878
+ return { success: true, upgraded: 1, failed: 0, errors: [] };
1879
+ }
1880
+ };
1881
+
1882
+ // src/managers/cargo.ts
1883
+ init_executor();
1884
+ var cargo = {
1885
+ id: "cargo",
1886
+ platforms: ["darwin", "linux", "win32"],
1887
+ requiresAdmin: false,
1888
+ async detect() {
1889
+ const result = await execCommand("rustup", ["--version"], 3e3);
1890
+ if (result.exitCode !== 0) return { available: false };
1891
+ const version = result.stdout.match(/rustup (\S+)/)?.[1];
1892
+ return { available: true, version };
1893
+ },
1894
+ async listOutdated() {
1895
+ const result = await execCommand("rustup", ["check"], 15e3);
1896
+ if (result.exitCode !== 0) return [];
1897
+ const packages = [];
1898
+ for (const line of result.stdout.split("\n")) {
1899
+ const match = line.match(/^(\S+)\s+-\s+Update available\s*:\s*(\S+).*->\s*(\S+)/);
1900
+ if (match) {
1901
+ packages.push({
1902
+ name: match[1] ?? "rust",
1903
+ currentVersion: match[2] ?? "?",
1904
+ newVersion: match[3] ?? "?"
1905
+ });
1906
+ }
1907
+ }
1908
+ return packages;
1909
+ },
1910
+ async *upgrade() {
1911
+ yield { type: "start", message: "Actualizando Rust toolchains..." };
1912
+ yield { type: "log", message: "rustup update" };
1913
+ yield* execStream("rustup", ["update"]);
1914
+ return { success: true, upgraded: 1, failed: 0, errors: [] };
1915
+ }
1916
+ };
1917
+
1918
+ // src/managers/go-lang.ts
1919
+ init_executor();
1920
+ var goLang = {
1921
+ id: "go",
1922
+ platforms: ["darwin", "linux", "win32"],
1923
+ requiresAdmin: true,
1924
+ async detect() {
1925
+ const result = await execCommand("go", ["version"], 3e3);
1926
+ if (result.exitCode !== 0) return { available: false };
1927
+ const version = result.stdout.match(/go(\d+\.\d+\.\d+)/)?.[1];
1928
+ return { available: true, version };
1929
+ },
1930
+ async listOutdated() {
1931
+ const currentResult = await execCommand("go", ["version"], 3e3);
1932
+ const currentVersion = currentResult.stdout.match(/go(\d+\.\d+\.\d+)/)?.[1];
1933
+ if (!currentVersion) return [];
1934
+ try {
1935
+ const latestResult = await execCommand("curl", ["-sL", "https://go.dev/VERSION?m=text"], 5e3);
1936
+ const latest = latestResult.stdout.split("\n")[0]?.replace("go", "").trim();
1937
+ if (!latest || currentVersion === latest) return [];
1938
+ return [{
1939
+ name: "go-sdk",
1940
+ currentVersion,
1941
+ newVersion: latest
1942
+ }];
1943
+ } catch {
1944
+ return [];
1945
+ }
1946
+ },
1947
+ async *upgrade(_packages, sudoMode2) {
1948
+ if (!sudoMode2) {
1949
+ yield { type: "error", message: "Go no tiene auto-update. Descarga desde https://go.dev/dl/" };
1950
+ return {
1951
+ success: false,
1952
+ upgraded: 0,
1953
+ failed: 0,
1954
+ errors: [],
1955
+ manualCommand: "https://go.dev/dl/"
1956
+ };
1957
+ }
1958
+ if (process.platform === "darwin") {
1959
+ yield { type: "start", message: "Actualizando Go via Homebrew..." };
1960
+ yield { type: "log", message: "brew upgrade go" };
1961
+ const { execStream: execStream2 } = await Promise.resolve().then(() => (init_executor(), executor_exports));
1962
+ yield* execStream2("brew", ["upgrade", "go"]);
1963
+ return { success: true, upgraded: 1, failed: 0, errors: [] };
1964
+ }
1965
+ yield { type: "error", message: "Descarga manualmente desde https://go.dev/dl/" };
1966
+ return {
1967
+ success: false,
1968
+ upgraded: 0,
1969
+ failed: 0,
1970
+ errors: [],
1971
+ manualCommand: "https://go.dev/dl/"
1972
+ };
1973
+ }
1974
+ };
1975
+
1976
+ // src/managers/composer.ts
1977
+ init_executor();
1978
+ var composer = {
1979
+ id: "composer",
1980
+ platforms: ["darwin", "linux", "win32"],
1981
+ requiresAdmin: false,
1982
+ async detect() {
1983
+ const result = await execCommand("composer", ["--version"], 3e3);
1984
+ if (result.exitCode !== 0) return { available: false };
1985
+ const version = result.stdout.match(/Composer version (\S+)/)?.[1];
1986
+ return { available: true, version };
1987
+ },
1988
+ async listOutdated() {
1989
+ const result = await execCommand("composer", ["global", "outdated", "--format=json", "--direct"], 3e4);
1990
+ if (result.exitCode !== 0 && !result.stdout.trim()) return [];
1991
+ try {
1992
+ const data = JSON.parse(result.stdout);
1993
+ return (data.installed ?? []).map((p) => ({
1994
+ name: p.name,
1995
+ currentVersion: p.version,
1996
+ newVersion: p.latest
1997
+ }));
1998
+ } catch {
1999
+ return [];
2000
+ }
2001
+ },
2002
+ async *upgrade(packages) {
2003
+ yield { type: "start", message: "Actualizando paquetes Composer globales..." };
2004
+ const args2 = packages && packages.length > 0 ? ["global", "update", ...packages] : ["global", "update"];
2005
+ yield { type: "log", message: `composer ${args2.join(" ")}` };
2006
+ yield* execStream("composer", args2);
2007
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
2008
+ },
2009
+ async *uninstall(packages) {
2010
+ if (!packages.length) {
2011
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
2012
+ }
2013
+ yield { type: "start", message: "Desinstalando paquetes Composer globales..." };
2014
+ const args2 = ["global", "remove", ...packages];
2015
+ yield { type: "log", message: `composer ${args2.join(" ")}` };
2016
+ yield* execStream("composer", args2);
2017
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
2018
+ }
2019
+ };
2020
+
2021
+ // src/managers/choco.ts
2022
+ init_executor();
2023
+ var choco = {
2024
+ id: "choco",
2025
+ platforms: ["win32"],
2026
+ requiresAdmin: true,
2027
+ async detect() {
2028
+ const result = await execCommand("choco", ["--version"], 3e3);
2029
+ if (result.exitCode !== 0) return { available: false };
2030
+ return { available: true, version: result.stdout.trim() };
2031
+ },
2032
+ async listOutdated() {
2033
+ const result = await execCommand("choco", ["outdated", "--limit-output"], 3e4);
2034
+ if (result.exitCode !== 0) return [];
2035
+ return result.stdout.split("\n").filter(Boolean).map((line) => {
2036
+ const [name, current, latest] = line.split("|");
2037
+ if (!name || !current || !latest) return null;
2038
+ return {
2039
+ name,
2040
+ currentVersion: current,
2041
+ newVersion: latest
2042
+ };
2043
+ }).filter((x) => x !== null);
2044
+ },
2045
+ async *upgrade(packages, sudoMode2) {
2046
+ if (!sudoMode2) {
2047
+ yield { type: "error", message: "Chocolatey requiere permisos de administrador." };
2048
+ return {
2049
+ success: false,
2050
+ upgraded: 0,
2051
+ failed: 0,
2052
+ errors: [],
2053
+ manualCommand: "choco upgrade all -y"
2054
+ };
2055
+ }
2056
+ yield { type: "start", message: "Actualizando paquetes Chocolatey..." };
2057
+ const args2 = packages && packages.length > 0 ? ["upgrade", "-y", ...packages] : ["upgrade", "all", "-y"];
2058
+ yield { type: "log", message: `choco ${args2.join(" ")}` };
2059
+ yield* execStream("choco", args2);
2060
+ return { success: true, upgraded: packages?.length ?? 0, failed: 0, errors: [] };
2061
+ },
2062
+ async *uninstall(packages, sudoMode2) {
2063
+ if (!packages.length) {
2064
+ return { success: true, upgraded: 0, failed: 0, errors: [] };
2065
+ }
2066
+ if (!sudoMode2) {
2067
+ yield { type: "error", message: "Chocolatey requiere permisos de administrador." };
2068
+ return {
2069
+ success: false,
2070
+ upgraded: 0,
2071
+ failed: 0,
2072
+ errors: [],
2073
+ manualCommand: `choco uninstall -y ${packages.join(" ")}`
2074
+ };
2075
+ }
2076
+ yield { type: "start", message: "Desinstalando paquetes Chocolatey..." };
2077
+ const args2 = ["uninstall", "-y", ...packages];
2078
+ yield { type: "log", message: `choco ${args2.join(" ")}` };
2079
+ yield* execStream("choco", args2);
2080
+ return { success: true, upgraded: packages.length, failed: 0, errors: [] };
2081
+ }
2082
+ };
2083
+
2084
+ // src/managers/registry.ts
2085
+ var ALL_MANAGERS = [
2086
+ brew,
2087
+ pip,
2088
+ npmMgr,
2089
+ conda,
2090
+ gem,
2091
+ softwareupdate,
2092
+ winget,
2093
+ apt,
2094
+ dnf,
2095
+ pacman,
2096
+ flatpak,
2097
+ snap,
2098
+ flutter,
2099
+ angular,
2100
+ cargo,
2101
+ goLang,
2102
+ composer,
2103
+ choco
2104
+ ];
2105
+ async function detectManagers() {
2106
+ const platform = process.platform;
2107
+ const compatible = ALL_MANAGERS.filter((m) => m.platforms.includes(platform));
2108
+ const results = await Promise.allSettled(
2109
+ compatible.map(async (m) => ({
2110
+ manager: m,
2111
+ detection: await m.detect()
2112
+ }))
2113
+ );
2114
+ return results.filter(
2115
+ (r) => r.status === "fulfilled" && r.value.detection.available
2116
+ ).map((r) => r.value);
2117
+ }
2118
+
2119
+ // src/lib/config.ts
2120
+ import fs from "fs";
2121
+ import path from "path";
2122
+ import os from "os";
2123
+ var DEFAULTS = {
2124
+ enabledManagers: {},
2125
+ verbosity: "info",
2126
+ language: "es"
2127
+ };
2128
+ function getConfigDir() {
2129
+ return path.join(os.homedir(), ".tacuchi-updater");
2130
+ }
2131
+ function getConfigPath() {
2132
+ return path.join(getConfigDir(), "config.json");
2133
+ }
2134
+ function loadConfig() {
2135
+ const configPath = getConfigPath();
2136
+ try {
2137
+ if (!fs.existsSync(configPath)) return { ...DEFAULTS };
2138
+ const raw = fs.readFileSync(configPath, "utf-8");
2139
+ const parsed = JSON.parse(raw);
2140
+ return { ...DEFAULTS, ...parsed };
2141
+ } catch {
2142
+ return { ...DEFAULTS };
2143
+ }
2144
+ }
2145
+ function saveConfig(config) {
2146
+ const dir = getConfigDir();
2147
+ if (!fs.existsSync(dir)) {
2148
+ fs.mkdirSync(dir, { recursive: true });
2149
+ }
2150
+ const tmp = getConfigPath() + ".tmp";
2151
+ fs.writeFileSync(tmp, JSON.stringify(config, null, 2), "utf-8");
2152
+ fs.renameSync(tmp, getConfigPath());
2153
+ }
2154
+ function isManagerEnabled(config, managerId) {
2155
+ if (Object.prototype.hasOwnProperty.call(config.enabledManagers, managerId)) {
2156
+ return config.enabledManagers[managerId] ?? true;
2157
+ }
2158
+ return true;
2159
+ }
2160
+
2161
+ // src/lib/logger.ts
2162
+ import fs2 from "fs";
2163
+ import path2 from "path";
2164
+ var configLogPath = null;
2165
+ var localLogPath = null;
2166
+ var configStream = null;
2167
+ var localStream = null;
2168
+ var inMemoryLog = [];
2169
+ var entryCounter = 0;
2170
+ function createStream(dir, filename) {
2171
+ if (!fs2.existsSync(dir)) fs2.mkdirSync(dir, { recursive: true });
2172
+ const filePath = path2.join(dir, filename);
2173
+ const stream = fs2.createWriteStream(filePath, { flags: "a", encoding: "utf-8" });
2174
+ return { stream, filePath };
2175
+ }
2176
+ function initLogger() {
2177
+ const now = /* @__PURE__ */ new Date();
2178
+ const stamp = now.toISOString().replace(/[T:]/g, "_").split(".")[0]?.replace(/-/g, "");
2179
+ const filename = `system_updater_${stamp}.log`;
2180
+ const configLogsDir = path2.join(getConfigDir(), "logs");
2181
+ const config = createStream(configLogsDir, filename);
2182
+ configStream = config.stream;
2183
+ configLogPath = config.filePath;
2184
+ const localLogsDir = path2.join(process.cwd(), "logs");
2185
+ try {
2186
+ const local = createStream(localLogsDir, filename);
2187
+ localStream = local.stream;
2188
+ localLogPath = local.filePath;
2189
+ localStream.on("error", () => {
2190
+ localStream = null;
2191
+ localLogPath = null;
2192
+ });
2193
+ } catch {
2194
+ }
2195
+ writeRaw("INFO", "Logger iniciado \u2014 @tacuchi/updater");
2196
+ writeRaw("INFO", `Log config: ${configLogPath}`);
2197
+ if (localLogPath) writeRaw("INFO", `Log local: ${localLogPath}`);
2198
+ writeRaw("INFO", `PID: ${process.pid} | UID: ${process.getuid?.() ?? "N/A"} | SUDO_USER: ${process.env["SUDO_USER"] ?? "N/A"}`);
2199
+ writeRaw("INFO", `Platform: ${process.platform} | Node: ${process.version}`);
2200
+ return localLogPath ?? configLogPath;
2201
+ }
2202
+ function writeRaw(level, message) {
2203
+ const now = /* @__PURE__ */ new Date();
2204
+ const timestamp = now.toISOString().replace("T", " ").split(".")[0];
2205
+ const line = `${timestamp} [${level.padEnd(5)}] SystemUpdater - ${message}
2206
+ `;
2207
+ configStream?.write(line);
2208
+ localStream?.write(line);
2209
+ }
2210
+ function addToMemory(level, message) {
2211
+ const id = String(++entryCounter);
2212
+ const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("es-MX", { hour12: false });
2213
+ inMemoryLog.push({ id, timestamp, level, message });
2214
+ if (inMemoryLog.length > 200) inMemoryLog.shift();
2215
+ }
2216
+ function log(message) {
2217
+ writeRaw("INFO", message);
2218
+ addToMemory("info", message);
2219
+ }
2220
+ function debug(message) {
2221
+ writeRaw("DEBUG", message);
2222
+ addToMemory("debug", message);
2223
+ }
2224
+ function warn(message) {
2225
+ writeRaw("WARN", message);
2226
+ addToMemory("warn", message);
2227
+ }
2228
+ function error(message) {
2229
+ writeRaw("ERROR", message);
2230
+ addToMemory("error", message);
2231
+ }
2232
+ function success(message) {
2233
+ writeRaw("INFO", `[OK] ${message}`);
2234
+ addToMemory("success", message);
2235
+ }
2236
+ function getLogEntries() {
2237
+ return [...inMemoryLog];
2238
+ }
2239
+
2240
+ // src/hooks/use-managers.ts
2241
+ function useManagers(config) {
2242
+ const [managers, setManagers] = useState4([]);
2243
+ const [detecting, setDetecting] = useState4(true);
2244
+ const [lastScan, setLastScan] = useState4(null);
2245
+ const configRef = useRef(config);
2246
+ configRef.current = config;
2247
+ const scan = useCallback(async () => {
2248
+ setDetecting(true);
2249
+ log("Detectando gestores de paquetes...");
2250
+ try {
2251
+ const detected = await detectManagers();
2252
+ log(`${detected.length} gestor(es) detectados`);
2253
+ const initial = detected.map((m) => ({
2254
+ manager: m,
2255
+ outdated: [],
2256
+ scanning: isManagerEnabled(configRef.current, m.manager.id)
2257
+ }));
2258
+ setManagers(initial);
2259
+ setDetecting(false);
2260
+ await Promise.allSettled(
2261
+ detected.map(async (dm, idx) => {
2262
+ if (!isManagerEnabled(configRef.current, dm.manager.id)) {
2263
+ setManagers((prev) => {
2264
+ const next = [...prev];
2265
+ if (next[idx]) next[idx] = { ...next[idx], scanning: false };
2266
+ return next;
2267
+ });
2268
+ return;
2269
+ }
2270
+ try {
2271
+ debug(`Escaneando ${dm.manager.id}...`);
2272
+ const outdated = await dm.manager.listOutdated();
2273
+ log(`${dm.manager.id}: ${outdated.length} paquetes desactualizados`);
2274
+ setManagers((prev) => {
2275
+ const next = [...prev];
2276
+ if (next[idx]) {
2277
+ next[idx] = { ...next[idx], outdated, scanning: false };
2278
+ }
2279
+ return next;
2280
+ });
2281
+ } catch (err) {
2282
+ error(`Error escaneando ${dm.manager.id}: ${String(err)}`);
2283
+ setManagers((prev) => {
2284
+ const next = [...prev];
2285
+ if (next[idx]) {
2286
+ next[idx] = { ...next[idx], scanning: false };
2287
+ }
2288
+ return next;
2289
+ });
2290
+ }
2291
+ })
2292
+ );
2293
+ setLastScan(/* @__PURE__ */ new Date());
2294
+ } catch (err) {
2295
+ error(`Error en detecci\xF3n: ${String(err)}`);
2296
+ setDetecting(false);
2297
+ }
2298
+ }, []);
2299
+ useEffect(() => {
2300
+ scan();
2301
+ }, [scan]);
2302
+ return { managers, detecting, lastScan, rescan: scan };
2303
+ }
2304
+
2305
+ // src/hooks/use-updates.ts
2306
+ import { useState as useState5, useCallback as useCallback2 } from "react";
2307
+ var LOG_FLUSH_INTERVAL = 150;
2308
+ function useUpdates() {
2309
+ const [updates, setUpdates] = useState5(/* @__PURE__ */ new Map());
2310
+ const startUpdate = useCallback2(
2311
+ async (manager, packages, sudoMode2) => {
2312
+ const id = manager.id;
2313
+ setUpdates((prev) => {
2314
+ const next = new Map(prev);
2315
+ next.set(id, {
2316
+ managerId: id,
2317
+ status: "running",
2318
+ percent: 0,
2319
+ logs: []
2320
+ });
2321
+ return next;
2322
+ });
2323
+ log(`Iniciando actualizaci\xF3n: ${id}`);
2324
+ try {
2325
+ const gen = manager.upgrade(packages, sudoMode2);
2326
+ let result = await gen.next();
2327
+ let logBuffer = [];
2328
+ let lastPercent = 0;
2329
+ let lastPackage;
2330
+ let lastStatus = "running";
2331
+ let lastFlush = Date.now();
2332
+ const flushToState = () => {
2333
+ const buffered = logBuffer;
2334
+ const pct = lastPercent;
2335
+ const pkg = lastPackage;
2336
+ const st = lastStatus;
2337
+ logBuffer = [];
2338
+ lastFlush = Date.now();
2339
+ setUpdates((prev) => {
2340
+ const next = new Map(prev);
2341
+ const current = next.get(id);
2342
+ if (!current) return prev;
2343
+ next.set(id, {
2344
+ ...current,
2345
+ percent: pct || current.percent,
2346
+ currentPackage: pkg ?? current.currentPackage,
2347
+ logs: buffered.length > 0 ? [...current.logs, ...buffered] : current.logs,
2348
+ status: st
2349
+ });
2350
+ return next;
2351
+ });
2352
+ };
2353
+ while (!result.done) {
2354
+ const event = result.value;
2355
+ if (event.message) {
2356
+ logBuffer.push(event.message);
2357
+ debug(`[${id}] ${event.message}`);
2358
+ }
2359
+ if (event.percent !== void 0) lastPercent = event.percent;
2360
+ if (event.package) lastPackage = event.package;
2361
+ if (event.type === "error") lastStatus = "error";
2362
+ const now = Date.now();
2363
+ const isImportant = event.type === "start" || event.type === "complete" || event.type === "error";
2364
+ if (isImportant || now - lastFlush >= LOG_FLUSH_INTERVAL) {
2365
+ flushToState();
2366
+ }
2367
+ result = await gen.next();
2368
+ }
2369
+ if (logBuffer.length > 0) flushToState();
2370
+ const upgradeResult = result.value;
2371
+ setUpdates((prev) => {
2372
+ const next = new Map(prev);
2373
+ const current = next.get(id);
2374
+ if (!current) return prev;
2375
+ next.set(id, {
2376
+ ...current,
2377
+ status: upgradeResult?.success ? "success" : "error",
2378
+ percent: 100,
2379
+ manualCommand: upgradeResult?.manualCommand,
2380
+ result: upgradeResult
2381
+ });
2382
+ return next;
2383
+ });
2384
+ if (upgradeResult?.success) {
2385
+ success(`${id}: ${upgradeResult.upgraded} paquete(s) actualizado(s)`);
2386
+ } else {
2387
+ warn(`${id}: ${upgradeResult?.failed ?? 0} error(es)`);
2388
+ for (const e of upgradeResult?.errors ?? []) {
2389
+ error(`[${id}] ${e}`);
2390
+ }
2391
+ }
2392
+ } catch (err) {
2393
+ const errMsg = String(err);
2394
+ error(`Error actualizando ${id}: ${errMsg}`);
2395
+ setUpdates((prev) => {
2396
+ const next = new Map(prev);
2397
+ const current = next.get(id);
2398
+ if (current) {
2399
+ next.set(id, {
2400
+ ...current,
2401
+ status: "error",
2402
+ percent: 0,
2403
+ logs: [...current.logs, `[ERR] ${errMsg}`],
2404
+ result: { success: false, upgraded: 0, failed: 1, errors: [errMsg] }
2405
+ });
2406
+ }
2407
+ return next;
2408
+ });
2409
+ }
2410
+ },
2411
+ []
2412
+ );
2413
+ const startUninstall = useCallback2(
2414
+ async (manager, packages, sudoMode2) => {
2415
+ if (!manager.uninstall) return;
2416
+ const id = `${manager.id}:uninstall`;
2417
+ setUpdates((prev) => {
2418
+ const next = new Map(prev);
2419
+ next.set(id, { managerId: id, status: "running", percent: 0, logs: [] });
2420
+ return next;
2421
+ });
2422
+ log(`Iniciando desinstalaci\xF3n: ${manager.id} [${packages.join(", ")}]`);
2423
+ try {
2424
+ const gen = manager.uninstall(packages, sudoMode2);
2425
+ let result = await gen.next();
2426
+ let logBuffer = [];
2427
+ let lastFlush = Date.now();
2428
+ const flush = () => {
2429
+ const buffered = logBuffer;
2430
+ logBuffer = [];
2431
+ lastFlush = Date.now();
2432
+ setUpdates((prev) => {
2433
+ const next = new Map(prev);
2434
+ const current = next.get(id);
2435
+ if (!current) return prev;
2436
+ next.set(id, { ...current, logs: [...current.logs, ...buffered] });
2437
+ return next;
2438
+ });
2439
+ };
2440
+ while (!result.done) {
2441
+ const event = result.value;
2442
+ if (event.message) {
2443
+ logBuffer.push(event.message);
2444
+ debug(`[${id}] ${event.message}`);
2445
+ }
2446
+ if (Date.now() - lastFlush >= LOG_FLUSH_INTERVAL || event.type !== "log") flush();
2447
+ result = await gen.next();
2448
+ }
2449
+ if (logBuffer.length > 0) flush();
2450
+ const uninstallResult = result.value;
2451
+ setUpdates((prev) => {
2452
+ const next = new Map(prev);
2453
+ const current = next.get(id);
2454
+ if (!current) return prev;
2455
+ next.set(id, {
2456
+ ...current,
2457
+ status: uninstallResult?.success ? "success" : "error",
2458
+ percent: 100,
2459
+ result: uninstallResult
2460
+ });
2461
+ return next;
2462
+ });
2463
+ if (uninstallResult?.success) {
2464
+ success(`${manager.id}: ${packages.length} paquete(s) desinstalado(s)`);
2465
+ } else {
2466
+ error(`${manager.id}: error al desinstalar`);
2467
+ }
2468
+ } catch (err) {
2469
+ error(`Error desinstalando ${manager.id}: ${String(err)}`);
2470
+ setUpdates((prev) => {
2471
+ const next = new Map(prev);
2472
+ const current = next.get(id);
2473
+ if (current) {
2474
+ next.set(id, {
2475
+ ...current,
2476
+ status: "error",
2477
+ percent: 0,
2478
+ result: { success: false, upgraded: 0, failed: 1, errors: [String(err)] }
2479
+ });
2480
+ }
2481
+ return next;
2482
+ });
2483
+ }
2484
+ },
2485
+ []
2486
+ );
2487
+ const clearUpdate = useCallback2((managerId) => {
2488
+ setUpdates((prev) => {
2489
+ const next = new Map(prev);
2490
+ next.delete(managerId);
2491
+ return next;
2492
+ });
2493
+ }, []);
2494
+ return { updates, startUpdate, startUninstall, clearUpdate };
2495
+ }
2496
+
2497
+ // src/hooks/use-system-info.ts
2498
+ import { useState as useState6, useEffect as useEffect2 } from "react";
2499
+
2500
+ // src/lib/platform.ts
2501
+ import os2 from "os";
2502
+ function getPlatform() {
2503
+ switch (process.platform) {
2504
+ case "darwin":
2505
+ return "macos";
2506
+ case "win32":
2507
+ return "windows";
2508
+ default:
2509
+ return "linux";
2510
+ }
2511
+ }
2512
+ function formatUptime(seconds) {
2513
+ const days = Math.floor(seconds / 86400);
2514
+ const hours = Math.floor(seconds % 86400 / 3600);
2515
+ const mins = Math.floor(seconds % 3600 / 60);
2516
+ if (days > 0) return `${days}d ${hours}h ${mins}m`;
2517
+ if (hours > 0) return `${hours}h ${mins}m`;
2518
+ return `${mins}m`;
2519
+ }
2520
+ function getSystemInfo() {
2521
+ const platform = getPlatform();
2522
+ const uptimeSec = os2.uptime();
2523
+ const totalMem = os2.totalmem();
2524
+ const freeMem = os2.freemem();
2525
+ const load = os2.loadavg();
2526
+ const osName = {
2527
+ macos: `macOS ${os2.release()}`,
2528
+ windows: `Windows ${os2.release()}`,
2529
+ linux: `Linux ${os2.release()}`
2530
+ };
2531
+ return {
2532
+ platform,
2533
+ os: osName[platform],
2534
+ kernel: os2.release(),
2535
+ hostname: os2.hostname(),
2536
+ uptime: formatUptime(uptimeSec),
2537
+ arch: os2.arch(),
2538
+ totalMemory: `${(totalMem / 1024 / 1024 / 1024).toFixed(1)} GB`,
2539
+ freeMemory: `${(freeMem / 1024 / 1024 / 1024).toFixed(1)} GB`,
2540
+ loadAvg: `${load[0]?.toFixed(2) ?? "0.00"}`
2541
+ };
2542
+ }
2543
+
2544
+ // src/hooks/use-system-info.ts
2545
+ function useSystemInfo(refreshIntervalMs = 1e4) {
2546
+ const [info, setInfo] = useState6(getSystemInfo);
2547
+ useEffect2(() => {
2548
+ const id = setInterval(() => {
2549
+ setInfo(getSystemInfo());
2550
+ }, refreshIntervalMs);
2551
+ return () => clearInterval(id);
2552
+ }, [refreshIntervalMs]);
2553
+ return info;
2554
+ }
2555
+
2556
+ // src/app.tsx
2557
+ import { jsx as jsx10, jsxs as jsxs11 } from "react/jsx-runtime";
2558
+ var AppContext = createContext(null);
2559
+ function useApp() {
2560
+ const ctx = useContext(AppContext);
2561
+ if (!ctx) throw new Error("useApp must be used inside App");
2562
+ return ctx;
2563
+ }
2564
+ function App({ sudoMode: sudoMode2 = false }) {
2565
+ const { stdout } = useStdout();
2566
+ const [terminalWidth, setTerminalWidth] = useState7(stdout?.columns ?? 120);
2567
+ const [terminalHeight, setTerminalHeight] = useState7(stdout?.rows ?? 40);
2568
+ const [screen, setScreen] = useState7("dashboard");
2569
+ const [config, setConfigState] = useState7(loadConfig);
2570
+ const [logEntries, setLogEntries] = useState7([]);
2571
+ useEffect3(() => {
2572
+ initLogger();
2573
+ setLanguage(config.language);
2574
+ }, []);
2575
+ useEffect3(() => {
2576
+ setLanguage(config.language);
2577
+ }, [config.language]);
2578
+ useEffect3(() => {
2579
+ const onResize = () => {
2580
+ setTerminalWidth(stdout?.columns ?? 120);
2581
+ setTerminalHeight(stdout?.rows ?? 40);
2582
+ };
2583
+ stdout?.on("resize", onResize);
2584
+ return () => {
2585
+ stdout?.off("resize", onResize);
2586
+ };
2587
+ }, [stdout]);
2588
+ useEffect3(() => {
2589
+ const id = setInterval(() => {
2590
+ setLogEntries(getLogEntries());
2591
+ }, 500);
2592
+ return () => clearInterval(id);
2593
+ }, []);
2594
+ const { managers, detecting, lastScan, rescan } = useManagers(config);
2595
+ const { updates, startUpdate, startUninstall, clearUpdate } = useUpdates();
2596
+ const systemInfo = useSystemInfo();
2597
+ function setConfig(c) {
2598
+ setConfigState(c);
2599
+ saveConfig(c);
2600
+ }
2601
+ useInput6((input, key) => {
2602
+ if (input === "q" || input === "Q") {
2603
+ process.exit(0);
2604
+ }
2605
+ });
2606
+ const osInfo = `OS: ${systemInfo.os.toUpperCase().replace(" ", "_")} / ${systemInfo.hostname.toUpperCase()}`;
2607
+ const ctx = {
2608
+ screen,
2609
+ setScreen,
2610
+ managers,
2611
+ detecting,
2612
+ lastScan,
2613
+ rescan,
2614
+ updates,
2615
+ startUpdate,
2616
+ startUninstall,
2617
+ clearUpdate,
2618
+ systemInfo,
2619
+ config,
2620
+ setConfig,
2621
+ logs: logEntries,
2622
+ terminalWidth,
2623
+ terminalHeight,
2624
+ sudoMode: sudoMode2
2625
+ };
2626
+ const screenHints = {
2627
+ dashboard: [
2628
+ { key: "Q", label: "SALIR" },
2629
+ { key: "TAB", label: "SIGUIENTE" },
2630
+ { key: "R", label: "ESCANEAR" },
2631
+ { key: "ENTER", label: "VER PAQUETES", active: true }
2632
+ ],
2633
+ packages: [
2634
+ { key: "Q", label: "SALIR" },
2635
+ { key: "A", label: "TODOS" },
2636
+ { key: "U", label: "ACTUALIZAR", active: true },
2637
+ { key: "X", label: "DESINSTALAR" },
2638
+ { key: "ESC", label: "VOLVER" }
2639
+ ],
2640
+ active: [
2641
+ { key: "Q", label: "SALIR" },
2642
+ { key: "TAB", label: "SIGUIENTE" },
2643
+ { key: "R", label: "RE-ESCANEAR" },
2644
+ { key: "D", label: "DETALLE", active: true },
2645
+ { key: "ESC", label: "VOLVER" }
2646
+ ],
2647
+ settings: [
2648
+ { key: "Q", label: "SALIR" },
2649
+ { key: "TAB", label: "SECCI\xD3N" },
2650
+ { key: "SPACE", label: "TOGGLE", active: true },
2651
+ { key: "L", label: "IDIOMA" },
2652
+ { key: "ESC", label: "VOLVER" }
2653
+ ]
2654
+ };
2655
+ return /* @__PURE__ */ jsx10(AppContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs11(
2656
+ Box10,
2657
+ {
2658
+ flexDirection: "column",
2659
+ width: Math.min(terminalWidth, 100),
2660
+ children: [
2661
+ /* @__PURE__ */ jsx10(
2662
+ NavBar,
2663
+ {
2664
+ currentScreen: screen,
2665
+ onNavigate: setScreen,
2666
+ osInfo,
2667
+ sudoMode: sudoMode2
2668
+ }
2669
+ ),
2670
+ /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", flexGrow: 1, overflow: "hidden", children: [
2671
+ screen === "dashboard" && /* @__PURE__ */ jsx10(Dashboard, {}),
2672
+ screen === "packages" && /* @__PURE__ */ jsx10(PackageSync, {}),
2673
+ screen === "active" && /* @__PURE__ */ jsx10(ActiveUpdates, {}),
2674
+ screen === "settings" && /* @__PURE__ */ jsx10(Settings, {})
2675
+ ] }),
2676
+ /* @__PURE__ */ jsx10(KeyHintBar, { hints: screenHints[screen] })
2677
+ ]
2678
+ }
2679
+ ) });
2680
+ }
2681
+
2682
+ // src/cli.tsx
2683
+ import { jsx as jsx11 } from "react/jsx-runtime";
2684
+ var args = process.argv.slice(2);
2685
+ var sudoRequested = args.includes("--sudo") || args.includes("-s");
2686
+ var isRoot = process.getuid?.() === 0;
2687
+ if (args.includes("--help") || args.includes("-h")) {
2688
+ console.log(`
2689
+ @tacuchi/updater \u2014 CLI para actualizar gestores de paquetes
2690
+
2691
+ Uso:
2692
+ updater Modo normal (sin permisos de admin)
2693
+ updater --sudo Ejecutar con permisos de administrador
2694
+ updater --help Mostrar esta ayuda
2695
+
2696
+ Flags:
2697
+ -s, --sudo Permite actualizar gestores que requieren admin
2698
+ (softwareupdate, apt, dnf, pacman, snap)
2699
+ -h, --help Mostrar ayuda
2700
+ -v, --version Mostrar versi\xF3n
2701
+ `);
2702
+ process.exit(0);
2703
+ }
2704
+ if (args.includes("--version") || args.includes("-v")) {
2705
+ console.log("1.0.0");
2706
+ process.exit(0);
2707
+ }
2708
+ if (sudoRequested && process.platform === "win32") {
2709
+ console.log("\x1B[33m\u27E9 En Windows, ejecuta la terminal como Administrador en vez de usar --sudo\x1B[0m");
2710
+ }
2711
+ if (sudoRequested && !isRoot && process.platform !== "win32") {
2712
+ console.log("\x1B[35m\u27E9 Modo SUDO: ingresa tu contrase\xF1a para continuar...\x1B[0m");
2713
+ try {
2714
+ const scriptPath = process.argv[1] ?? "";
2715
+ const isDevMode = scriptPath.endsWith(".tsx") || scriptPath.endsWith(".ts");
2716
+ const restArgs = process.argv.slice(2);
2717
+ const sudoArgs = isDevMode ? ["env", `PATH=${process.env["PATH"] ?? ""}`, "npx", "tsx", scriptPath, ...restArgs] : [process.execPath, scriptPath, ...restArgs];
2718
+ const result = execaSync("sudo", sudoArgs, {
2719
+ stdio: "inherit",
2720
+ reject: false
2721
+ });
2722
+ process.exit(result.exitCode ?? 0);
2723
+ } catch {
2724
+ console.error("\x1B[31m\u2717 No se pudo autenticar sudo. Continuando sin permisos elevados.\x1B[0m");
2725
+ }
2726
+ }
2727
+ var sudoMode = isRoot || sudoRequested;
2728
+ var { unmount } = render(/* @__PURE__ */ jsx11(App, { sudoMode }));
2729
+ process.on("SIGINT", () => {
2730
+ unmount();
2731
+ process.exit(0);
2732
+ });
2733
+ process.on("SIGTERM", () => {
2734
+ unmount();
2735
+ process.exit(0);
2736
+ });