@tacuchi/updater 2.0.4 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +557 -128
- package/package.json +8 -3
package/dist/cli.js
CHANGED
|
@@ -5,10 +5,11 @@ import { render } from "ink";
|
|
|
5
5
|
import { execaSync } from "execa";
|
|
6
6
|
|
|
7
7
|
// src/app.tsx
|
|
8
|
-
import { Box as Box8, Text as Text9,
|
|
8
|
+
import { Box as Box8, Text as Text9, useApp as useInkApp } from "ink";
|
|
9
9
|
|
|
10
10
|
// src/hooks/use-app-machine.tsx
|
|
11
11
|
import { createContext, useContext, useReducer, useEffect, useRef, useCallback } from "react";
|
|
12
|
+
import { useApp } from "ink";
|
|
12
13
|
|
|
13
14
|
// src/state/types.ts
|
|
14
15
|
var SELECTION_SEP = "\0";
|
|
@@ -161,6 +162,80 @@ import { execa as execa2, ExecaError } from "execa";
|
|
|
161
162
|
|
|
162
163
|
// src/lib/exec/run.ts
|
|
163
164
|
import { execa } from "execa";
|
|
165
|
+
|
|
166
|
+
// src/lib/exec/decode.ts
|
|
167
|
+
import iconv from "iconv-lite";
|
|
168
|
+
var DEFAULT_OEM = 437;
|
|
169
|
+
function looksLikeUtf16LE(buf) {
|
|
170
|
+
const n = Math.min(buf.length, 4096);
|
|
171
|
+
if (n < 4) return false;
|
|
172
|
+
let oddZeros = 0;
|
|
173
|
+
let oddTotal = 0;
|
|
174
|
+
for (let i = 1; i < n; i += 2) {
|
|
175
|
+
oddTotal++;
|
|
176
|
+
if (buf[i] === 0) oddZeros++;
|
|
177
|
+
}
|
|
178
|
+
return oddTotal > 0 && oddZeros / oddTotal > 0.6;
|
|
179
|
+
}
|
|
180
|
+
function isValidUtf8(buf) {
|
|
181
|
+
try {
|
|
182
|
+
new TextDecoder("utf-8", { fatal: true }).decode(buf);
|
|
183
|
+
return true;
|
|
184
|
+
} catch {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function oemEncoding(oem) {
|
|
189
|
+
const name = `cp${oem}`;
|
|
190
|
+
return iconv.encodingExists(name) ? name : "utf8";
|
|
191
|
+
}
|
|
192
|
+
function sniff(buf, oem = DEFAULT_OEM) {
|
|
193
|
+
if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) return { enc: "utf8", bomLen: 3 };
|
|
194
|
+
if (buf.length >= 2 && buf[0] === 255 && buf[1] === 254) return { enc: "utf16-le", bomLen: 2 };
|
|
195
|
+
if (buf.length >= 2 && buf[0] === 254 && buf[1] === 255) return { enc: "utf16-be", bomLen: 2 };
|
|
196
|
+
if (looksLikeUtf16LE(buf)) return { enc: "utf16-le", bomLen: 0 };
|
|
197
|
+
if (isValidUtf8(buf)) return { enc: "utf8", bomLen: 0 };
|
|
198
|
+
return { enc: oemEncoding(oem), bomLen: 0 };
|
|
199
|
+
}
|
|
200
|
+
function decodeSmart(buf, oem = DEFAULT_OEM) {
|
|
201
|
+
if (!buf || buf.length === 0) return "";
|
|
202
|
+
const { enc, bomLen } = sniff(buf, oem);
|
|
203
|
+
return iconv.decode(bomLen ? buf.subarray(bomLen) : buf, enc);
|
|
204
|
+
}
|
|
205
|
+
var StreamDecoder = class {
|
|
206
|
+
constructor(oem = DEFAULT_OEM) {
|
|
207
|
+
this.oem = oem;
|
|
208
|
+
}
|
|
209
|
+
dec = null;
|
|
210
|
+
write(chunk) {
|
|
211
|
+
if (!chunk || chunk.length === 0) return "";
|
|
212
|
+
let b = chunk;
|
|
213
|
+
let dec = this.dec;
|
|
214
|
+
if (!dec) {
|
|
215
|
+
const { enc, bomLen } = sniff(b, this.oem);
|
|
216
|
+
dec = iconv.getDecoder(enc);
|
|
217
|
+
this.dec = dec;
|
|
218
|
+
if (bomLen) b = b.subarray(bomLen);
|
|
219
|
+
}
|
|
220
|
+
return dec.write(b);
|
|
221
|
+
}
|
|
222
|
+
end() {
|
|
223
|
+
return this.dec ? this.dec.end() ?? "" : "";
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/lib/exec/kill-tree.ts
|
|
228
|
+
import treeKill from "tree-kill";
|
|
229
|
+
function killTree(pid, signal = "SIGTERM") {
|
|
230
|
+
if (!pid) return;
|
|
231
|
+
try {
|
|
232
|
+
treeKill(pid, signal, () => {
|
|
233
|
+
});
|
|
234
|
+
} catch {
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/lib/exec/run.ts
|
|
164
239
|
var DEFAULT_TAIL_BYTES = 16384;
|
|
165
240
|
function withSudo(cmd, args2, sudo) {
|
|
166
241
|
if (process.platform === "win32") return [cmd, args2];
|
|
@@ -186,27 +261,48 @@ function execaOptions(opts, all) {
|
|
|
186
261
|
cwd: opts.cwd,
|
|
187
262
|
env: opts.env,
|
|
188
263
|
cancelSignal: opts.signal,
|
|
189
|
-
all
|
|
264
|
+
all,
|
|
265
|
+
// Capture raw bytes; we sniff-decode (UTF-8 / UTF-16LE / OEM) ourselves.
|
|
266
|
+
encoding: "buffer"
|
|
190
267
|
};
|
|
191
268
|
}
|
|
269
|
+
function attachTreeKill(signal, child) {
|
|
270
|
+
if (!signal) return;
|
|
271
|
+
const onAbort = () => killTree(child.pid);
|
|
272
|
+
if (signal.aborted) onAbort();
|
|
273
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
274
|
+
}
|
|
192
275
|
var WARN_RE = /error|fail|denied|errno|cannot|unable/i;
|
|
193
276
|
async function* runStream(cmd, args2, opts, percentParser) {
|
|
194
277
|
const [finalCmd, finalArgs] = withSudo(cmd, args2, opts.sudo);
|
|
195
278
|
const tailBytes = opts.tailBytes ?? DEFAULT_TAIL_BYTES;
|
|
196
279
|
const started = Date.now();
|
|
197
280
|
const child = execa(finalCmd, finalArgs, { ...execaOptions(opts, true), stdout: "pipe", stderr: "pipe" });
|
|
281
|
+
attachTreeKill(opts.signal, child);
|
|
198
282
|
if (child.all) {
|
|
283
|
+
const decoder = new StreamDecoder();
|
|
284
|
+
let lineBuf = "";
|
|
285
|
+
const emit = function* (raw) {
|
|
286
|
+
const line = raw.replace(/\r$/, "");
|
|
287
|
+
if (!line) return;
|
|
288
|
+
const percent = percentParser?.(line);
|
|
289
|
+
if (percent !== void 0) {
|
|
290
|
+
yield { type: "progress", message: line, percent };
|
|
291
|
+
} else {
|
|
292
|
+
yield { type: "log", message: line, severity: WARN_RE.test(line) ? "warn" : "info" };
|
|
293
|
+
}
|
|
294
|
+
};
|
|
199
295
|
for await (const chunk of child.all) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
yield { type: "log", message: line, severity: WARN_RE.test(line) ? "warn" : "info" };
|
|
207
|
-
}
|
|
296
|
+
lineBuf += decoder.write(chunk);
|
|
297
|
+
let nl;
|
|
298
|
+
while ((nl = lineBuf.indexOf("\n")) >= 0) {
|
|
299
|
+
const raw = lineBuf.slice(0, nl);
|
|
300
|
+
lineBuf = lineBuf.slice(nl + 1);
|
|
301
|
+
yield* emit(raw);
|
|
208
302
|
}
|
|
209
303
|
}
|
|
304
|
+
lineBuf += decoder.end();
|
|
305
|
+
if (lineBuf) yield* emit(lineBuf);
|
|
210
306
|
}
|
|
211
307
|
const result = await child;
|
|
212
308
|
return {
|
|
@@ -214,8 +310,8 @@ async function* runStream(cmd, args2, opts, percentParser) {
|
|
|
214
310
|
exitCode: result.exitCode ?? null,
|
|
215
311
|
durationMs: Date.now() - started,
|
|
216
312
|
timedOut: result.timedOut ?? false,
|
|
217
|
-
stdoutTail: tail(
|
|
218
|
-
stderrTail: tail(
|
|
313
|
+
stdoutTail: tail(decodeSmart(result.stdout), tailBytes),
|
|
314
|
+
stderrTail: tail(decodeSmart(result.stderr), tailBytes)
|
|
219
315
|
};
|
|
220
316
|
}
|
|
221
317
|
|
|
@@ -226,18 +322,19 @@ async function execCommand(cmd, args2, timeout = 5e3, sudo = false) {
|
|
|
226
322
|
const result = await execa2(finalCmd, finalArgs, {
|
|
227
323
|
timeout,
|
|
228
324
|
reject: false,
|
|
229
|
-
all: false
|
|
325
|
+
all: false,
|
|
326
|
+
encoding: "buffer"
|
|
230
327
|
});
|
|
231
328
|
return {
|
|
232
|
-
stdout: result.stdout,
|
|
233
|
-
stderr: result.stderr,
|
|
329
|
+
stdout: decodeSmart(result.stdout),
|
|
330
|
+
stderr: decodeSmart(result.stderr),
|
|
234
331
|
exitCode: result.exitCode ?? (result.failed ? 127 : 0)
|
|
235
332
|
};
|
|
236
333
|
} catch (err) {
|
|
237
334
|
if (err instanceof ExecaError) {
|
|
238
335
|
return {
|
|
239
|
-
stdout: err.stdout
|
|
240
|
-
stderr: err.stderr
|
|
336
|
+
stdout: decodeSmart(err.stdout),
|
|
337
|
+
stderr: decodeSmart(err.stderr) || String(err.message),
|
|
241
338
|
exitCode: err.exitCode ?? 1
|
|
242
339
|
};
|
|
243
340
|
}
|
|
@@ -260,19 +357,26 @@ function classifyCommand(rec, successExitCodes) {
|
|
|
260
357
|
|
|
261
358
|
// src/lib/result/verify.ts
|
|
262
359
|
var KIND_PRIORITY = ["NO_PASSWORDLESS_SUDO", "TIMEOUT", "NETWORK", "COMMAND_FAILED"];
|
|
263
|
-
function
|
|
264
|
-
const
|
|
360
|
+
function rebootFrom(commands) {
|
|
361
|
+
const codes = new Set(commands.map((c) => c.exitCode));
|
|
362
|
+
if (codes.has(1641)) return "initiated";
|
|
363
|
+
if (codes.has(3010)) return "required";
|
|
364
|
+
if (codes.has(350) || codes.has(1604)) return "deferred";
|
|
365
|
+
return void 0;
|
|
366
|
+
}
|
|
367
|
+
function dominantFailureKind(commands, successExitCodes) {
|
|
368
|
+
const kinds = commands.map((c) => classifyCommand(c, successExitCodes)).filter((k) => k !== null);
|
|
265
369
|
for (const k of KIND_PRIORITY) {
|
|
266
370
|
if (kinds.includes(k)) return k;
|
|
267
371
|
}
|
|
268
372
|
return kinds[0] ?? null;
|
|
269
373
|
}
|
|
270
|
-
function reconcile(requested, before, after, commands) {
|
|
374
|
+
function reconcile(requested, before, after, commands, successExitCodes) {
|
|
271
375
|
const beforeByName = new Map(before.map((p) => [p.name, p]));
|
|
272
376
|
const targetNames = requested ?? before.map((p) => p.name);
|
|
273
377
|
const targets = [...new Set(targetNames)];
|
|
274
378
|
const stillOutdated = new Set(after.stillOutdated.map((p) => p.name));
|
|
275
|
-
const cmdKind = dominantFailureKind(commands);
|
|
379
|
+
const cmdKind = dominantFailureKind(commands, successExitCodes);
|
|
276
380
|
const packages = targets.map((name) => {
|
|
277
381
|
const b = beforeByName.get(name);
|
|
278
382
|
if (stillOutdated.has(name)) {
|
|
@@ -315,6 +419,7 @@ function reconcile(requested, before, after, commands) {
|
|
|
315
419
|
status,
|
|
316
420
|
skipped: 0,
|
|
317
421
|
reason,
|
|
422
|
+
reboot: rebootFrom(commands),
|
|
318
423
|
packages,
|
|
319
424
|
commands
|
|
320
425
|
};
|
|
@@ -328,6 +433,7 @@ import path2 from "path";
|
|
|
328
433
|
import fs from "fs";
|
|
329
434
|
import path from "path";
|
|
330
435
|
import os from "os";
|
|
436
|
+
import envPaths from "env-paths";
|
|
331
437
|
var DEFAULTS = {
|
|
332
438
|
enabledManagers: {},
|
|
333
439
|
verbosity: "info",
|
|
@@ -354,13 +460,33 @@ function normalizeConfig(parsed) {
|
|
|
354
460
|
logTailBytes: typeof parsed.logTailBytes === "number" && parsed.logTailBytes > 0 ? Math.round(parsed.logTailBytes) : DEFAULTS.logTailBytes
|
|
355
461
|
};
|
|
356
462
|
}
|
|
463
|
+
var APP = "tacuchi-updater";
|
|
357
464
|
function getConfigDir() {
|
|
465
|
+
if (process.platform === "win32") return envPaths(APP, { suffix: "" }).config;
|
|
358
466
|
return path.join(os.homedir(), ".tacuchi-updater");
|
|
359
467
|
}
|
|
468
|
+
function getLogDir() {
|
|
469
|
+
if (process.platform === "win32") return envPaths(APP, { suffix: "" }).log;
|
|
470
|
+
return path.join(getConfigDir(), "logs");
|
|
471
|
+
}
|
|
360
472
|
function getConfigPath() {
|
|
361
473
|
return path.join(getConfigDir(), "config.json");
|
|
362
474
|
}
|
|
475
|
+
function migrateLegacyConfig() {
|
|
476
|
+
if (process.platform !== "win32") return;
|
|
477
|
+
try {
|
|
478
|
+
const target = getConfigPath();
|
|
479
|
+
if (fs.existsSync(target)) return;
|
|
480
|
+
const legacy = path.join(os.homedir(), ".tacuchi-updater", "config.json");
|
|
481
|
+
if (!fs.existsSync(legacy)) return;
|
|
482
|
+
const dir = getConfigDir();
|
|
483
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
484
|
+
fs.copyFileSync(legacy, target);
|
|
485
|
+
} catch {
|
|
486
|
+
}
|
|
487
|
+
}
|
|
363
488
|
function loadConfig() {
|
|
489
|
+
migrateLegacyConfig();
|
|
364
490
|
const configPath = getConfigPath();
|
|
365
491
|
try {
|
|
366
492
|
if (!fs.existsSync(configPath)) return { ...DEFAULTS };
|
|
@@ -376,9 +502,24 @@ function saveConfig(config) {
|
|
|
376
502
|
if (!fs.existsSync(dir)) {
|
|
377
503
|
fs.mkdirSync(dir, { recursive: true });
|
|
378
504
|
}
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
505
|
+
const target = getConfigPath();
|
|
506
|
+
const tmp = target + ".tmp";
|
|
507
|
+
const data = JSON.stringify(config, null, 2);
|
|
508
|
+
try {
|
|
509
|
+
fs.writeFileSync(tmp, data, "utf-8");
|
|
510
|
+
fs.renameSync(tmp, target);
|
|
511
|
+
} catch (err) {
|
|
512
|
+
const code = err.code;
|
|
513
|
+
if (code === "EPERM" || code === "EBUSY" || code === "EEXIST") {
|
|
514
|
+
fs.writeFileSync(target, data, "utf-8");
|
|
515
|
+
try {
|
|
516
|
+
fs.unlinkSync(tmp);
|
|
517
|
+
} catch {
|
|
518
|
+
}
|
|
519
|
+
} else {
|
|
520
|
+
throw err;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
382
523
|
}
|
|
383
524
|
function isManagerEnabled(config, managerId) {
|
|
384
525
|
if (Object.prototype.hasOwnProperty.call(config.enabledManagers, managerId)) {
|
|
@@ -388,10 +529,8 @@ function isManagerEnabled(config, managerId) {
|
|
|
388
529
|
}
|
|
389
530
|
|
|
390
531
|
// src/lib/logger.ts
|
|
391
|
-
var
|
|
392
|
-
var
|
|
393
|
-
var configStream = null;
|
|
394
|
-
var localStream = null;
|
|
532
|
+
var logFilePath = null;
|
|
533
|
+
var logStream = null;
|
|
395
534
|
var inMemoryLog = [];
|
|
396
535
|
var entryCounter = 0;
|
|
397
536
|
function createStream(dir, filename) {
|
|
@@ -404,35 +543,32 @@ function initLogger() {
|
|
|
404
543
|
const now = /* @__PURE__ */ new Date();
|
|
405
544
|
const stamp = now.toISOString().replace(/[T:]/g, "_").split(".")[0]?.replace(/-/g, "");
|
|
406
545
|
const filename = `system_updater_${stamp}.log`;
|
|
407
|
-
const configLogsDir = path2.join(getConfigDir(), "logs");
|
|
408
|
-
const config = createStream(configLogsDir, filename);
|
|
409
|
-
configStream = config.stream;
|
|
410
|
-
configLogPath = config.filePath;
|
|
411
|
-
const localLogsDir = path2.join(process.cwd(), "logs");
|
|
412
546
|
try {
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
localLogPath = null;
|
|
547
|
+
const { stream, filePath } = createStream(getLogDir(), filename);
|
|
548
|
+
logStream = stream;
|
|
549
|
+
logFilePath = filePath;
|
|
550
|
+
logStream.on("error", () => {
|
|
551
|
+
logStream = null;
|
|
419
552
|
});
|
|
420
553
|
} catch {
|
|
554
|
+
logStream = null;
|
|
555
|
+
logFilePath = null;
|
|
421
556
|
}
|
|
422
557
|
writeRaw("INFO", "Logger iniciado \u2014 @tacuchi/updater");
|
|
423
|
-
writeRaw("INFO", `Log
|
|
424
|
-
|
|
425
|
-
|
|
558
|
+
writeRaw("INFO", `Log: ${logFilePath ?? "(no disponible)"}`);
|
|
559
|
+
writeRaw(
|
|
560
|
+
"INFO",
|
|
561
|
+
`PID: ${process.pid} | UID: ${process.getuid?.() ?? "N/A"} | SUDO_USER: ${process.env["SUDO_USER"] ?? "N/A"}`
|
|
562
|
+
);
|
|
426
563
|
writeRaw("INFO", `Platform: ${process.platform} | Node: ${process.version}`);
|
|
427
|
-
return
|
|
564
|
+
return logFilePath ?? "";
|
|
428
565
|
}
|
|
429
566
|
function writeRaw(level, message) {
|
|
430
567
|
const now = /* @__PURE__ */ new Date();
|
|
431
568
|
const timestamp = now.toISOString().replace("T", " ").split(".")[0];
|
|
432
569
|
const line = `${timestamp} [${level.padEnd(5)}] SystemUpdater - ${message}
|
|
433
570
|
`;
|
|
434
|
-
|
|
435
|
-
localStream?.write(line);
|
|
571
|
+
logStream?.write(line);
|
|
436
572
|
}
|
|
437
573
|
function addToMemory(level, message) {
|
|
438
574
|
const id = String(++entryCounter);
|
|
@@ -458,13 +594,14 @@ function logResult(r) {
|
|
|
458
594
|
const ok = r.status === "success" || r.status === "noop";
|
|
459
595
|
const level = ok ? "INFO" : r.status === "partial" ? "WARN" : "ERROR";
|
|
460
596
|
const reason = r.reason ? ` reason=${r.reason}` : "";
|
|
461
|
-
|
|
597
|
+
const reboot = r.reboot ? ` reboot=${r.reboot}` : "";
|
|
598
|
+
writeRaw(level, `${id}: status=${r.status} upgraded=${r.upgraded} failed=${r.failed}${reason}${reboot}`);
|
|
462
599
|
for (const e of r.errors) writeRaw(level, ` ${id}: ${e}`);
|
|
463
600
|
const memLevel = ok ? "info" : r.status === "partial" ? "warn" : "error";
|
|
464
601
|
addToMemory(memLevel, `${id}: ${r.status} (${r.upgraded} ok, ${r.failed} fail)`);
|
|
465
602
|
}
|
|
466
603
|
function getLogFilePath() {
|
|
467
|
-
return
|
|
604
|
+
return logFilePath;
|
|
468
605
|
}
|
|
469
606
|
|
|
470
607
|
// src/managers/engine.ts
|
|
@@ -578,7 +715,7 @@ function fromDescriptor(d, cfg, deps = defaultDeps) {
|
|
|
578
715
|
managerId: d.id,
|
|
579
716
|
startedAt,
|
|
580
717
|
finishedAt: Date.now(),
|
|
581
|
-
...reconcile(packages, before, after, commands)
|
|
718
|
+
...reconcile(packages, before, after, commands, d.successExitCodes)
|
|
582
719
|
};
|
|
583
720
|
logResult(result);
|
|
584
721
|
return result;
|
|
@@ -644,6 +781,19 @@ function once(key, fn) {
|
|
|
644
781
|
function pipCmd() {
|
|
645
782
|
return process.platform === "win32" ? "pip" : "pip3";
|
|
646
783
|
}
|
|
784
|
+
function pipInvocation(python) {
|
|
785
|
+
return python ? { cmd: python, baseArgs: ["-m", "pip"] } : { cmd: pipCmd(), baseArgs: [] };
|
|
786
|
+
}
|
|
787
|
+
async function pythonModuleCmd() {
|
|
788
|
+
return once("pip:python", async () => {
|
|
789
|
+
const candidates = process.platform === "win32" ? ["python", "py", "python3"] : ["python3", "python"];
|
|
790
|
+
for (const c of candidates) {
|
|
791
|
+
const probe = await execCommand(c, ["-m", "pip", "--version"], 5e3);
|
|
792
|
+
if (probe.exitCode === 0) return c;
|
|
793
|
+
}
|
|
794
|
+
return null;
|
|
795
|
+
});
|
|
796
|
+
}
|
|
647
797
|
function parsePipOutdated(stdout) {
|
|
648
798
|
try {
|
|
649
799
|
const data = JSON.parse(stdout);
|
|
@@ -680,15 +830,15 @@ var pip = {
|
|
|
680
830
|
escapeHatch: {
|
|
681
831
|
listOutdated,
|
|
682
832
|
async *upgrade(packages, ctx) {
|
|
683
|
-
const cmd = pipCmd();
|
|
684
833
|
yield { type: "phase", phase: "upgrading", message: "Actualizando pip..." };
|
|
685
834
|
const flags = await pep668Flags();
|
|
686
835
|
if (flags.length) yield { type: "log", message: "Entorno PEP 668: usando --break-system-packages" };
|
|
836
|
+
const { cmd, baseArgs } = pipInvocation(await pythonModuleCmd());
|
|
687
837
|
const before = await listOutdated();
|
|
688
838
|
const target = packages && packages.length ? packages : before.map((p) => p.name);
|
|
689
839
|
const commands = [];
|
|
690
840
|
if (target.length) {
|
|
691
|
-
const args2 = ["install", "--user", "--upgrade", ...flags, ...target];
|
|
841
|
+
const args2 = [...baseArgs, "install", "--user", "--upgrade", ...flags, ...target];
|
|
692
842
|
yield { type: "log", message: `${cmd} ${args2.join(" ")}` };
|
|
693
843
|
const rec = yield* runStream(cmd, args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
694
844
|
commands.push(rec);
|
|
@@ -874,6 +1024,8 @@ var softwareupdate = {
|
|
|
874
1024
|
|
|
875
1025
|
// src/managers/descriptors/winget.ts
|
|
876
1026
|
var ACCEPT = ["--accept-source-agreements", "--accept-package-agreements"];
|
|
1027
|
+
var UPGRADE_FLAGS = ["--silent", "--disable-interactivity", "--source", "winget", ...ACCEPT];
|
|
1028
|
+
var WINGET_OK_CODES = [0, 2316632107, 2316632143, 2316632107 - 4294967296, 2316632143 - 4294967296];
|
|
877
1029
|
function parseWingetOutdated(stdout) {
|
|
878
1030
|
const lines = stdout.split("\n").map((l) => (l.split("\r").pop() ?? l).replace(/[⠀-⣿]/g, "").replace(/\s+$/, ""));
|
|
879
1031
|
const dashIdx = lines.findIndex((l) => l.trim().length >= 3 && /^-+$/.test(l.trim()));
|
|
@@ -896,7 +1048,11 @@ function parseWingetOutdated(stdout) {
|
|
|
896
1048
|
return out;
|
|
897
1049
|
}
|
|
898
1050
|
async function listWinget() {
|
|
899
|
-
const res = await execCommand(
|
|
1051
|
+
const res = await execCommand(
|
|
1052
|
+
"winget",
|
|
1053
|
+
["list", "--upgrade-available", "--include-unknown", "--accept-source-agreements"],
|
|
1054
|
+
6e4
|
|
1055
|
+
);
|
|
900
1056
|
return parseWingetOutdated(res.stdout);
|
|
901
1057
|
}
|
|
902
1058
|
var winget = {
|
|
@@ -907,7 +1063,10 @@ var winget = {
|
|
|
907
1063
|
kind: "direct",
|
|
908
1064
|
detectCmd: { cmd: "winget", args: ["--version"], timeout: 3e3 },
|
|
909
1065
|
parseVersion: (stdout) => stdout.trim() || void 0,
|
|
910
|
-
listOutdatedCmd: () => ({
|
|
1066
|
+
listOutdatedCmd: () => ({
|
|
1067
|
+
cmd: "winget",
|
|
1068
|
+
args: ["list", "--upgrade-available", "--include-unknown", "--accept-source-agreements"]
|
|
1069
|
+
}),
|
|
911
1070
|
parseOutdated: (stdout) => parseWingetOutdated(stdout),
|
|
912
1071
|
// Escape hatch: winget upgrades ONE package per invocation (no multi-target),
|
|
913
1072
|
// so a single bulk `--id A --id B` silently fails. Loop one `winget upgrade
|
|
@@ -926,13 +1085,13 @@ var winget = {
|
|
|
926
1085
|
logCommand(rec);
|
|
927
1086
|
};
|
|
928
1087
|
if (!targets.length) {
|
|
929
|
-
yield* run(["upgrade", "--all", ...
|
|
1088
|
+
yield* run(["upgrade", "--all", "--include-unknown", "--include-pinned", ...UPGRADE_FLAGS]);
|
|
930
1089
|
} else {
|
|
931
|
-
for (const id of targets) yield* run(["upgrade", "--exact", "--id", id, ...
|
|
1090
|
+
for (const id of targets) yield* run(["upgrade", "--exact", "--id", id, "--include-unknown", ...UPGRADE_FLAGS]);
|
|
932
1091
|
}
|
|
933
1092
|
yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
|
|
934
1093
|
const after = await listWinget();
|
|
935
|
-
return reconcile(packages, before, { stillOutdated: after.map((p) => ({ name: p.name })) }, commands);
|
|
1094
|
+
return reconcile(packages, before, { stillOutdated: after.map((p) => ({ name: p.name })) }, commands, WINGET_OK_CODES);
|
|
936
1095
|
}
|
|
937
1096
|
}
|
|
938
1097
|
};
|
|
@@ -1415,6 +1574,10 @@ var choco = {
|
|
|
1415
1574
|
platforms: ["win32"],
|
|
1416
1575
|
requiresAdmin: true,
|
|
1417
1576
|
kind: "direct",
|
|
1577
|
+
// Chocolatey "success" is not just 0: 1641 = reboot initiated, 3010 = reboot
|
|
1578
|
+
// required, 1605/1614 = already-(un)installed. Without these, a reboot-pending
|
|
1579
|
+
// upgrade would be misclassified as COMMAND_FAILED.
|
|
1580
|
+
successExitCodes: [0, 1605, 1614, 1641, 3010],
|
|
1418
1581
|
detectCmd: { cmd: "choco", args: ["--version"], timeout: 3e3 },
|
|
1419
1582
|
parseVersion: (stdout) => stdout.trim() || void 0,
|
|
1420
1583
|
listOutdatedCmd: () => ({ cmd: "choco", args: ["outdated", "--limit-output"] }),
|
|
@@ -1901,20 +2064,20 @@ var scoop = {
|
|
|
1901
2064
|
platforms: ["win32"],
|
|
1902
2065
|
requiresAdmin: false,
|
|
1903
2066
|
kind: "direct",
|
|
1904
|
-
detectCmd: { cmd: "scoop", args: ["--version"], timeout: 3e3 },
|
|
2067
|
+
detectCmd: { cmd: "scoop.cmd", args: ["--version"], timeout: 3e3 },
|
|
1905
2068
|
parseVersion: (stdout) => {
|
|
1906
2069
|
const m = stdout.match(/v?\d+\.\d+(?:\.\d+)?/);
|
|
1907
2070
|
return m?.[0];
|
|
1908
2071
|
},
|
|
1909
|
-
listOutdatedCmd: () => ({ cmd: "scoop", args: ["status"] }),
|
|
2072
|
+
listOutdatedCmd: () => ({ cmd: "scoop.cmd", args: ["status"] }),
|
|
1910
2073
|
parseOutdated: (stdout) => parseScoopOutdated(stdout),
|
|
1911
2074
|
// `scoop update` (no app) refreshes scoop itself + all buckets so the
|
|
1912
2075
|
// following `scoop update *` / `scoop update <names>` sees the latest
|
|
1913
2076
|
// manifests.
|
|
1914
|
-
preUpgradeCmds: () => [{ cmd: "scoop", args: ["update"] }],
|
|
2077
|
+
preUpgradeCmds: () => [{ cmd: "scoop.cmd", args: ["update"] }],
|
|
1915
2078
|
// Single bulk command: `scoop update *` upgrades every app, otherwise one
|
|
1916
2079
|
// invocation carrying every selected app name.
|
|
1917
|
-
upgradeCmd: (pkgs) => pkgs && pkgs.length ? { cmd: "scoop", args: ["update", ...pkgs] } : { cmd: "scoop", args: ["update", "*"] },
|
|
2080
|
+
upgradeCmd: (pkgs) => pkgs && pkgs.length ? { cmd: "scoop.cmd", args: ["update", ...pkgs] } : { cmd: "scoop.cmd", args: ["update", "*"] },
|
|
1918
2081
|
manualCommand: () => "scoop update *"
|
|
1919
2082
|
};
|
|
1920
2083
|
|
|
@@ -2533,8 +2696,9 @@ var en = {
|
|
|
2533
2696
|
// src/i18n/index.ts
|
|
2534
2697
|
var currentLang = detectLanguage();
|
|
2535
2698
|
function detectLanguage() {
|
|
2536
|
-
const lang = process.env["LANG"] ?? process.env["LANGUAGE"] ?? "";
|
|
2537
|
-
|
|
2699
|
+
const lang = (process.env["LANG"] ?? process.env["LANGUAGE"] ?? "").toLowerCase();
|
|
2700
|
+
if (lang.startsWith("en")) return "en";
|
|
2701
|
+
return "es";
|
|
2538
2702
|
}
|
|
2539
2703
|
function setLanguage(lang) {
|
|
2540
2704
|
currentLang = lang;
|
|
@@ -2552,6 +2716,61 @@ function managerName(id) {
|
|
|
2552
2716
|
return names[id] ?? id;
|
|
2553
2717
|
}
|
|
2554
2718
|
|
|
2719
|
+
// src/hooks/use-app-machine.tsx
|
|
2720
|
+
import { writeFileSync, mkdirSync } from "fs";
|
|
2721
|
+
import { dirname } from "path";
|
|
2722
|
+
|
|
2723
|
+
// src/lib/elevation.ts
|
|
2724
|
+
import path3 from "path";
|
|
2725
|
+
import { execa as execa3 } from "execa";
|
|
2726
|
+
import isAdmin from "is-admin";
|
|
2727
|
+
async function isElevated() {
|
|
2728
|
+
if (process.platform === "win32") {
|
|
2729
|
+
try {
|
|
2730
|
+
return await isAdmin();
|
|
2731
|
+
} catch {
|
|
2732
|
+
return false;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
return process.getuid?.() === 0;
|
|
2736
|
+
}
|
|
2737
|
+
function elevatedSummaryPath() {
|
|
2738
|
+
const base = process.env["LOCALAPPDATA"] ?? process.env["TEMP"] ?? process.cwd();
|
|
2739
|
+
return path3.join(base, "tacuchi-updater", "last-run-summary.json");
|
|
2740
|
+
}
|
|
2741
|
+
var psQuote = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
2742
|
+
async function relaunchElevated(extraArgs = []) {
|
|
2743
|
+
if (process.platform !== "win32") return false;
|
|
2744
|
+
const node = process.execPath;
|
|
2745
|
+
const script = process.argv[1] ?? "";
|
|
2746
|
+
const args2 = [script, ...process.argv.slice(2), ...extraArgs];
|
|
2747
|
+
const argList = args2.map(psQuote).join(",");
|
|
2748
|
+
const command = `Start-Process -FilePath ${psQuote(node)} -ArgumentList @(${argList}) -Verb RunAs`;
|
|
2749
|
+
try {
|
|
2750
|
+
const res = await execa3("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", command], {
|
|
2751
|
+
reject: false
|
|
2752
|
+
});
|
|
2753
|
+
return (res.exitCode ?? 1) === 0;
|
|
2754
|
+
} catch {
|
|
2755
|
+
return false;
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
// src/lib/cancellation.ts
|
|
2760
|
+
var handlers = /* @__PURE__ */ new Set();
|
|
2761
|
+
function onProcessCancel(handler) {
|
|
2762
|
+
handlers.add(handler);
|
|
2763
|
+
return () => handlers.delete(handler);
|
|
2764
|
+
}
|
|
2765
|
+
function fireProcessCancel() {
|
|
2766
|
+
for (const handler of handlers) {
|
|
2767
|
+
try {
|
|
2768
|
+
handler();
|
|
2769
|
+
} catch {
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2555
2774
|
// src/hooks/use-app-machine.tsx
|
|
2556
2775
|
import { jsx } from "react/jsx-runtime";
|
|
2557
2776
|
function toManagerResult(r, logRef) {
|
|
@@ -2565,16 +2784,38 @@ function toManagerResult(r, logRef) {
|
|
|
2565
2784
|
failed: r.failed,
|
|
2566
2785
|
skipped: r.skipped ?? 0,
|
|
2567
2786
|
failures,
|
|
2568
|
-
manualCommand: r.manualCommand
|
|
2787
|
+
manualCommand: r.manualCommand,
|
|
2788
|
+
reboot: r.reboot
|
|
2569
2789
|
};
|
|
2570
2790
|
}
|
|
2791
|
+
function summarizeRun(state) {
|
|
2792
|
+
let upgraded = 0;
|
|
2793
|
+
let failed = 0;
|
|
2794
|
+
let skipped = 0;
|
|
2795
|
+
const managers = [];
|
|
2796
|
+
for (const id of state.run.queue) {
|
|
2797
|
+
const e = state.managers[id];
|
|
2798
|
+
if (!e) continue;
|
|
2799
|
+
if (e.status === "skipped") {
|
|
2800
|
+
skipped++;
|
|
2801
|
+
managers.push({ id, status: "skipped", upgraded: 0, failed: 0 });
|
|
2802
|
+
continue;
|
|
2803
|
+
}
|
|
2804
|
+
const u = e.result?.upgraded ?? 0;
|
|
2805
|
+
const f = e.result?.failed ?? 0;
|
|
2806
|
+
upgraded += u;
|
|
2807
|
+
failed += f;
|
|
2808
|
+
managers.push({ id, status: e.status, upgraded: u, failed: f });
|
|
2809
|
+
}
|
|
2810
|
+
return { upgraded, failed, skipped, managers };
|
|
2811
|
+
}
|
|
2571
2812
|
var MachineContext = createContext(null);
|
|
2572
2813
|
function useMachine() {
|
|
2573
2814
|
const ctx = useContext(MachineContext);
|
|
2574
2815
|
if (!ctx) throw new Error("useMachine must be used inside <MachineProvider>");
|
|
2575
2816
|
return ctx;
|
|
2576
2817
|
}
|
|
2577
|
-
function useAppMachine(sudoMode2) {
|
|
2818
|
+
function useAppMachine(sudoMode2, nonInteractive2 = false) {
|
|
2578
2819
|
const configRef = useRef(loadConfig());
|
|
2579
2820
|
const [state, dispatch] = useReducer(
|
|
2580
2821
|
appReducer,
|
|
@@ -2624,6 +2865,7 @@ function useAppMachine(sudoMode2) {
|
|
|
2624
2865
|
setLanguage(configRef.current.language);
|
|
2625
2866
|
void boot();
|
|
2626
2867
|
}, [boot]);
|
|
2868
|
+
useEffect(() => onProcessCancel(() => abortRef.current?.abort()), []);
|
|
2627
2869
|
const startRun = useCallback(() => {
|
|
2628
2870
|
const config = configRef.current;
|
|
2629
2871
|
const packagesByManager = /* @__PURE__ */ new Map();
|
|
@@ -2696,6 +2938,65 @@ function useAppMachine(sudoMode2) {
|
|
|
2696
2938
|
dispatch({ type: "RESCAN" });
|
|
2697
2939
|
void boot();
|
|
2698
2940
|
}, [boot]);
|
|
2941
|
+
const { exit } = useApp();
|
|
2942
|
+
const exitedRef = useRef(false);
|
|
2943
|
+
const finishNonInteractive = useCallback(
|
|
2944
|
+
(code) => {
|
|
2945
|
+
if (exitedRef.current) return;
|
|
2946
|
+
exitedRef.current = true;
|
|
2947
|
+
process.exitCode = code;
|
|
2948
|
+
exit();
|
|
2949
|
+
if (!process.env["VITEST"]) {
|
|
2950
|
+
const t3 = setTimeout(() => process.exit(code), 100);
|
|
2951
|
+
t3.unref?.();
|
|
2952
|
+
}
|
|
2953
|
+
},
|
|
2954
|
+
[exit]
|
|
2955
|
+
);
|
|
2956
|
+
useEffect(() => {
|
|
2957
|
+
if (!nonInteractive2) return;
|
|
2958
|
+
if (state.phase === "select") {
|
|
2959
|
+
const hasOutdated = state.order.some((id) => (state.managers[id]?.outdated.length ?? 0) > 0);
|
|
2960
|
+
if (!hasOutdated) finishNonInteractive(0);
|
|
2961
|
+
else if (state.selection.size === 0) dispatch({ type: "SELECT_ALL" });
|
|
2962
|
+
else dispatch({ type: "GOTO_CONFIRM" });
|
|
2963
|
+
} else if (state.phase === "confirm") {
|
|
2964
|
+
startRun();
|
|
2965
|
+
} else if (state.phase === "summary") {
|
|
2966
|
+
finishNonInteractive(state.run.failedCount > 0 ? 1 : 0);
|
|
2967
|
+
}
|
|
2968
|
+
}, [
|
|
2969
|
+
nonInteractive2,
|
|
2970
|
+
state.phase,
|
|
2971
|
+
state.selection.size,
|
|
2972
|
+
state.run.failedCount,
|
|
2973
|
+
state.order,
|
|
2974
|
+
state.managers,
|
|
2975
|
+
startRun,
|
|
2976
|
+
finishNonInteractive
|
|
2977
|
+
]);
|
|
2978
|
+
useEffect(() => {
|
|
2979
|
+
if (state.phase !== "summary" || process.platform !== "win32") return;
|
|
2980
|
+
try {
|
|
2981
|
+
const p = elevatedSummaryPath();
|
|
2982
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
2983
|
+
writeFileSync(p, JSON.stringify({ ...summarizeRun(state), at: Date.now() }, null, 2), "utf-8");
|
|
2984
|
+
} catch {
|
|
2985
|
+
}
|
|
2986
|
+
}, [state.phase]);
|
|
2987
|
+
const relaunch = useCallback(() => {
|
|
2988
|
+
void (async () => {
|
|
2989
|
+
const ok = await relaunchElevated();
|
|
2990
|
+
if (ok) {
|
|
2991
|
+
process.exitCode = 0;
|
|
2992
|
+
exit();
|
|
2993
|
+
if (!process.env["VITEST"]) {
|
|
2994
|
+
const t3 = setTimeout(() => process.exit(0), 100);
|
|
2995
|
+
t3.unref?.();
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
})();
|
|
2999
|
+
}, [exit]);
|
|
2699
3000
|
const persist = useCallback((next) => {
|
|
2700
3001
|
dispatch(next);
|
|
2701
3002
|
}, []);
|
|
@@ -2722,6 +3023,7 @@ function useAppMachine(sudoMode2) {
|
|
|
2722
3023
|
goSelect: useCallback(() => persist({ type: "GOTO_SELECT" }), [persist]),
|
|
2723
3024
|
startRun,
|
|
2724
3025
|
cancelRun,
|
|
3026
|
+
relaunch,
|
|
2725
3027
|
rescan,
|
|
2726
3028
|
openSettings: useCallback(() => persist({ type: "OPEN_SETTINGS" }), [persist]),
|
|
2727
3029
|
closeSettings: useCallback(() => persist({ type: "CLOSE_SETTINGS" }), [persist]),
|
|
@@ -2733,6 +3035,14 @@ function MachineProvider({ value, children }) {
|
|
|
2733
3035
|
return /* @__PURE__ */ jsx(MachineContext.Provider, { value, children });
|
|
2734
3036
|
}
|
|
2735
3037
|
|
|
3038
|
+
// src/hooks/use-safe-input.ts
|
|
3039
|
+
import { useInput, useStdin } from "ink";
|
|
3040
|
+
function useSafeInput(handler, options) {
|
|
3041
|
+
const { isRawModeSupported } = useStdin();
|
|
3042
|
+
const active = (options?.isActive ?? true) && isRawModeSupported;
|
|
3043
|
+
useInput(handler, { ...options, isActive: active });
|
|
3044
|
+
}
|
|
3045
|
+
|
|
2736
3046
|
// src/screens/detect.tsx
|
|
2737
3047
|
import { Box as Box2, Text as Text3 } from "ink";
|
|
2738
3048
|
|
|
@@ -2788,6 +3098,61 @@ var semantic = {
|
|
|
2788
3098
|
muted: colors.onSurfaceVariant
|
|
2789
3099
|
};
|
|
2790
3100
|
|
|
3101
|
+
// src/lib/glyphs.ts
|
|
3102
|
+
function shouldUseAscii(env, platform) {
|
|
3103
|
+
if (env["TACUCHI_ASCII"] === "1") return true;
|
|
3104
|
+
if (env["TACUCHI_ASCII"] === "0") return false;
|
|
3105
|
+
if (env["TERM"] === "dumb") return true;
|
|
3106
|
+
if (platform === "win32" && !env["WT_SESSION"]) return true;
|
|
3107
|
+
return false;
|
|
3108
|
+
}
|
|
3109
|
+
var UNICODE = {
|
|
3110
|
+
pending: "\xB7",
|
|
3111
|
+
scanning: "\u25CC",
|
|
3112
|
+
outdated: "\u203A",
|
|
3113
|
+
uptodate: "\u2713",
|
|
3114
|
+
running: "\u25B8",
|
|
3115
|
+
done: "\u2713",
|
|
3116
|
+
failed: "\u2717",
|
|
3117
|
+
skipped: "\u2298",
|
|
3118
|
+
cursor: "\u276F",
|
|
3119
|
+
checkOn: "[\u2713]",
|
|
3120
|
+
checkOff: "[ ]",
|
|
3121
|
+
arrow: "\u2192",
|
|
3122
|
+
scrollUp: "\u25B2",
|
|
3123
|
+
scrollDown: "\u25BC",
|
|
3124
|
+
stepOn: "\u2586",
|
|
3125
|
+
stepOff: "\u2581",
|
|
3126
|
+
info: "\u24D8",
|
|
3127
|
+
ellipsis: "\u2026",
|
|
3128
|
+
bullet: "\u25B8",
|
|
3129
|
+
reboot: "\u27F3"
|
|
3130
|
+
};
|
|
3131
|
+
var ASCII_GLYPHS = {
|
|
3132
|
+
pending: ".",
|
|
3133
|
+
scanning: "o",
|
|
3134
|
+
outdated: ">",
|
|
3135
|
+
uptodate: "+",
|
|
3136
|
+
running: ">",
|
|
3137
|
+
done: "+",
|
|
3138
|
+
failed: "x",
|
|
3139
|
+
skipped: "-",
|
|
3140
|
+
cursor: ">",
|
|
3141
|
+
checkOn: "[x]",
|
|
3142
|
+
checkOff: "[ ]",
|
|
3143
|
+
arrow: "->",
|
|
3144
|
+
scrollUp: "^",
|
|
3145
|
+
scrollDown: "v",
|
|
3146
|
+
stepOn: "#",
|
|
3147
|
+
stepOff: "_",
|
|
3148
|
+
info: "i",
|
|
3149
|
+
ellipsis: "...",
|
|
3150
|
+
bullet: ">",
|
|
3151
|
+
reboot: "*"
|
|
3152
|
+
};
|
|
3153
|
+
var ASCII = shouldUseAscii(process.env, process.platform);
|
|
3154
|
+
var g = ASCII ? ASCII_GLYPHS : UNICODE;
|
|
3155
|
+
|
|
2791
3156
|
// src/components/step-header.tsx
|
|
2792
3157
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
2793
3158
|
var STEP = {
|
|
@@ -2800,13 +3165,15 @@ var STEP = {
|
|
|
2800
3165
|
function StepHeader({ phase }) {
|
|
2801
3166
|
if (phase === "summary") {
|
|
2802
3167
|
return /* @__PURE__ */ jsx2(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: semantic.success, bold: true, children: [
|
|
2803
|
-
|
|
3168
|
+
g.stepOn,
|
|
3169
|
+
" ",
|
|
2804
3170
|
t("flow", "summary")
|
|
2805
3171
|
] }) });
|
|
2806
3172
|
}
|
|
2807
3173
|
if (phase === "settings") {
|
|
2808
3174
|
return /* @__PURE__ */ jsx2(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: semantic.action, bold: true, children: [
|
|
2809
|
-
|
|
3175
|
+
g.stepOn,
|
|
3176
|
+
" ",
|
|
2810
3177
|
t("flow", "settings")
|
|
2811
3178
|
] }) });
|
|
2812
3179
|
}
|
|
@@ -2814,7 +3181,7 @@ function StepHeader({ phase }) {
|
|
|
2814
3181
|
if (!step) return null;
|
|
2815
3182
|
return /* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
|
|
2816
3183
|
[1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxs(Text, { color: i === step.n ? semantic.action : semantic.muted, bold: i === step.n, children: [
|
|
2817
|
-
i === step.n ?
|
|
3184
|
+
i === step.n ? g.stepOn : g.stepOff,
|
|
2818
3185
|
" "
|
|
2819
3186
|
] }, i)),
|
|
2820
3187
|
/* @__PURE__ */ jsxs(Text, { color: semantic.muted, children: [
|
|
@@ -2833,15 +3200,15 @@ function StepHeader({ phase }) {
|
|
|
2833
3200
|
import { Text as Text2 } from "ink";
|
|
2834
3201
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
2835
3202
|
var SPECS = {
|
|
2836
|
-
pending: { glyph:
|
|
2837
|
-
scanning: { glyph:
|
|
2838
|
-
outdated: { glyph:
|
|
2839
|
-
uptodate: { glyph:
|
|
2840
|
-
queued: { glyph:
|
|
2841
|
-
running: { glyph:
|
|
2842
|
-
done: { glyph:
|
|
2843
|
-
failed: { glyph:
|
|
2844
|
-
skipped: { glyph:
|
|
3203
|
+
pending: { glyph: g.pending, color: semantic.muted },
|
|
3204
|
+
scanning: { glyph: g.scanning, color: semantic.action },
|
|
3205
|
+
outdated: { glyph: g.outdated, color: semantic.warning },
|
|
3206
|
+
uptodate: { glyph: g.uptodate, color: semantic.muted },
|
|
3207
|
+
queued: { glyph: g.pending, color: semantic.muted },
|
|
3208
|
+
running: { glyph: g.running, color: semantic.action },
|
|
3209
|
+
done: { glyph: g.done, color: semantic.success },
|
|
3210
|
+
failed: { glyph: g.failed, color: semantic.error },
|
|
3211
|
+
skipped: { glyph: g.skipped, color: semantic.warning }
|
|
2845
3212
|
};
|
|
2846
3213
|
function statusColor(status) {
|
|
2847
3214
|
return SPECS[status].color;
|
|
@@ -2881,8 +3248,9 @@ function DetectScreen() {
|
|
|
2881
3248
|
/* @__PURE__ */ jsx4(Box2, { width: 18, children: /* @__PURE__ */ jsx4(Text3, { color: e.status === "outdated" ? semantic.text : semantic.muted, children: managerName(id) }) }),
|
|
2882
3249
|
e.status === "outdated" ? /* @__PURE__ */ jsxs2(Text3, { color: semantic.warning, children: [
|
|
2883
3250
|
e.outdated.length,
|
|
2884
|
-
"
|
|
2885
|
-
|
|
3251
|
+
" ",
|
|
3252
|
+
g.outdated
|
|
3253
|
+
] }) : e.status === "uptodate" ? /* @__PURE__ */ jsx4(Text3, { color: colors.outline, children: "-" }) : /* @__PURE__ */ jsx4(Text3, { color: semantic.muted, children: g.ellipsis })
|
|
2886
3254
|
] }, id);
|
|
2887
3255
|
})
|
|
2888
3256
|
] });
|
|
@@ -2890,10 +3258,10 @@ function DetectScreen() {
|
|
|
2890
3258
|
|
|
2891
3259
|
// src/screens/select.tsx
|
|
2892
3260
|
import { useState } from "react";
|
|
2893
|
-
import { Box as Box3, Text as Text4
|
|
3261
|
+
import { Box as Box3, Text as Text4 } from "ink";
|
|
2894
3262
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2895
3263
|
function clip(s, n) {
|
|
2896
|
-
return s.length > n ? s.slice(0, n -
|
|
3264
|
+
return s.length > n ? s.slice(0, Math.max(0, n - g.ellipsis.length)) + g.ellipsis : s;
|
|
2897
3265
|
}
|
|
2898
3266
|
function SelectScreen() {
|
|
2899
3267
|
const { state, toggleItem, selectAll, selectNone, goConfirm, openSettings } = useMachine();
|
|
@@ -2904,7 +3272,7 @@ function SelectScreen() {
|
|
|
2904
3272
|
if (m && m.status === "outdated") for (const pkg of m.outdated) rows.push({ managerId: id, pkg });
|
|
2905
3273
|
}
|
|
2906
3274
|
const clamped = Math.min(cursor, Math.max(0, rows.length - 1));
|
|
2907
|
-
|
|
3275
|
+
useSafeInput((input, key) => {
|
|
2908
3276
|
if (key.downArrow || input === "j") setCursor((c) => Math.min(rows.length - 1, c + 1));
|
|
2909
3277
|
else if (key.upArrow || input === "k") setCursor((c) => Math.max(0, c - 1));
|
|
2910
3278
|
else if (input === " ") {
|
|
@@ -2949,9 +3317,9 @@ function SelectScreen() {
|
|
|
2949
3317
|
] })
|
|
2950
3318
|
] }),
|
|
2951
3319
|
start > 0 && /* @__PURE__ */ jsxs3(Text4, { color: colors.outline, children: [
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
3320
|
+
g.scrollUp,
|
|
3321
|
+
" ",
|
|
3322
|
+
start
|
|
2955
3323
|
] }),
|
|
2956
3324
|
visible.map((r) => {
|
|
2957
3325
|
const header = r.managerId !== prevManager ? managerName(r.managerId) : null;
|
|
@@ -2961,13 +3329,13 @@ function SelectScreen() {
|
|
|
2961
3329
|
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
|
|
2962
3330
|
header && /* @__PURE__ */ jsx5(Text4, { color: semantic.muted, bold: true, children: header }),
|
|
2963
3331
|
/* @__PURE__ */ jsxs3(Box3, { children: [
|
|
2964
|
-
/* @__PURE__ */ jsx5(Text4, { color: isCursor ? semantic.action : colors.outline, children: isCursor ?
|
|
2965
|
-
/* @__PURE__ */ jsx5(Text4, { color: selected ? semantic.success : colors.outline, children: selected ?
|
|
3332
|
+
/* @__PURE__ */ jsx5(Text4, { color: isCursor ? semantic.action : colors.outline, children: isCursor ? `${g.cursor} ` : " " }),
|
|
3333
|
+
/* @__PURE__ */ jsx5(Text4, { color: selected ? semantic.success : colors.outline, children: selected ? `${g.checkOn} ` : `${g.checkOff} ` }),
|
|
2966
3334
|
/* @__PURE__ */ jsx5(Box3, { width: 22, children: /* @__PURE__ */ jsx5(Text4, { color: semantic.text, bold: isCursor, children: clip(r.pkg.name, 21) }) }),
|
|
2967
3335
|
/* @__PURE__ */ jsxs3(Text4, { color: semantic.muted, wrap: "truncate-end", children: [
|
|
2968
3336
|
clip(r.pkg.currentVersion, 14),
|
|
2969
3337
|
" ",
|
|
2970
|
-
/* @__PURE__ */ jsx5(Text4, { color: semantic.action, children:
|
|
3338
|
+
/* @__PURE__ */ jsx5(Text4, { color: semantic.action, children: g.arrow }),
|
|
2971
3339
|
" ",
|
|
2972
3340
|
clip(r.pkg.newVersion, 14)
|
|
2973
3341
|
] })
|
|
@@ -2975,26 +3343,28 @@ function SelectScreen() {
|
|
|
2975
3343
|
] }, `${r.managerId}:${r.pkg.name}`);
|
|
2976
3344
|
}),
|
|
2977
3345
|
end < rows.length && /* @__PURE__ */ jsxs3(Text4, { color: colors.outline, children: [
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
3346
|
+
g.scrollDown,
|
|
3347
|
+
" ",
|
|
3348
|
+
rows.length - end
|
|
2981
3349
|
] }),
|
|
2982
3350
|
/* @__PURE__ */ jsx5(Box3, { marginTop: 1, children: /* @__PURE__ */ jsx5(Text4, { color: semantic.muted, children: clip(t("ui", "selectHint"), width) }) })
|
|
2983
3351
|
] });
|
|
2984
3352
|
}
|
|
2985
3353
|
|
|
2986
3354
|
// src/screens/confirm.tsx
|
|
2987
|
-
import { Box as Box4, Text as Text5
|
|
3355
|
+
import { Box as Box4, Text as Text5 } from "ink";
|
|
2988
3356
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2989
3357
|
function ConfirmScreen() {
|
|
2990
|
-
const { state, startRun, goSelect, sudoMode: sudoMode2 } = useMachine();
|
|
3358
|
+
const { state, startRun, goSelect, sudoMode: sudoMode2, relaunch } = useMachine();
|
|
2991
3359
|
const byManager = /* @__PURE__ */ new Map();
|
|
2992
3360
|
for (const key of state.selection) {
|
|
2993
3361
|
const [id] = parseSelectionKey(key);
|
|
2994
3362
|
byManager.set(id, (byManager.get(id) ?? 0) + 1);
|
|
2995
3363
|
}
|
|
2996
|
-
|
|
2997
|
-
|
|
3364
|
+
const needsElevation = process.platform === "win32" && !sudoMode2 && [...byManager.keys()].some((id) => state.managers[id]?.requiresAdmin);
|
|
3365
|
+
useSafeInput((input, key) => {
|
|
3366
|
+
if ((input === "e" || input === "E") && needsElevation) relaunch();
|
|
3367
|
+
else if (key.return || input === "y" || input === "Y") startRun();
|
|
2998
3368
|
else if (key.escape) goSelect();
|
|
2999
3369
|
});
|
|
3000
3370
|
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
|
|
@@ -3004,24 +3374,28 @@ function ConfirmScreen() {
|
|
|
3004
3374
|
const m = state.managers[id];
|
|
3005
3375
|
const willSkip = m?.requiresAdmin && !sudoMode2;
|
|
3006
3376
|
return /* @__PURE__ */ jsxs4(Box4, { children: [
|
|
3007
|
-
/* @__PURE__ */
|
|
3377
|
+
/* @__PURE__ */ jsxs4(Text5, { color: semantic.action, children: [
|
|
3378
|
+
g.bullet,
|
|
3379
|
+
" "
|
|
3380
|
+
] }),
|
|
3008
3381
|
/* @__PURE__ */ jsx6(Box4, { width: 20, children: /* @__PURE__ */ jsx6(Text5, { color: semantic.text, bold: true, children: managerName(id) }) }),
|
|
3009
3382
|
/* @__PURE__ */ jsxs4(Text5, { color: semantic.muted, children: [
|
|
3010
3383
|
count,
|
|
3011
3384
|
" paquete(s)"
|
|
3012
3385
|
] }),
|
|
3013
|
-
willSkip && /* @__PURE__ */ jsx6(Text5, { color: semantic.warning, children: " \xB7 requiere sudo \u2192 manual" })
|
|
3386
|
+
willSkip && /* @__PURE__ */ jsx6(Text5, { color: semantic.warning, children: process.platform === "win32" ? " \xB7 requiere admin \u2192 manual" : " \xB7 requiere sudo \u2192 manual" })
|
|
3014
3387
|
] }, id);
|
|
3015
3388
|
}) }),
|
|
3016
|
-
/* @__PURE__ */ jsx6(Text5, { color: semantic.muted, children: t("ui", "confirmHint") })
|
|
3389
|
+
/* @__PURE__ */ jsx6(Text5, { color: semantic.muted, children: t("ui", "confirmHint") }),
|
|
3390
|
+
needsElevation && /* @__PURE__ */ jsx6(Text5, { color: semantic.warning, children: "E \xB7 relanzar como Administrador (1 UAC) para los gestores que lo requieren" })
|
|
3017
3391
|
] });
|
|
3018
3392
|
}
|
|
3019
3393
|
|
|
3020
3394
|
// src/screens/update.tsx
|
|
3021
|
-
import { Box as Box5, Text as Text6
|
|
3395
|
+
import { Box as Box5, Text as Text6 } from "ink";
|
|
3022
3396
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3023
3397
|
function clip2(s, n) {
|
|
3024
|
-
return s.length > n ? s.slice(0, Math.max(0, n -
|
|
3398
|
+
return s.length > n ? s.slice(0, Math.max(0, n - g.ellipsis.length)) + g.ellipsis : s;
|
|
3025
3399
|
}
|
|
3026
3400
|
function Row({ e, width }) {
|
|
3027
3401
|
let detail = "";
|
|
@@ -3037,7 +3411,7 @@ function Row({ e, width }) {
|
|
|
3037
3411
|
}
|
|
3038
3412
|
function UpdateScreen() {
|
|
3039
3413
|
const { state, cancelRun } = useMachine();
|
|
3040
|
-
|
|
3414
|
+
useSafeInput((_input, key) => {
|
|
3041
3415
|
if (key.escape) cancelRun();
|
|
3042
3416
|
});
|
|
3043
3417
|
const total = state.run.queue.length;
|
|
@@ -3053,17 +3427,20 @@ function UpdateScreen() {
|
|
|
3053
3427
|
" "
|
|
3054
3428
|
] }),
|
|
3055
3429
|
/* @__PURE__ */ jsxs5(Text6, { color: semantic.success, children: [
|
|
3056
|
-
|
|
3430
|
+
g.done,
|
|
3431
|
+
" ",
|
|
3057
3432
|
state.run.doneCount,
|
|
3058
3433
|
" "
|
|
3059
3434
|
] }),
|
|
3060
3435
|
/* @__PURE__ */ jsxs5(Text6, { color: semantic.error, children: [
|
|
3061
|
-
|
|
3436
|
+
g.failed,
|
|
3437
|
+
" ",
|
|
3062
3438
|
state.run.failedCount,
|
|
3063
3439
|
" "
|
|
3064
3440
|
] }),
|
|
3065
3441
|
/* @__PURE__ */ jsxs5(Text6, { color: semantic.warning, children: [
|
|
3066
|
-
|
|
3442
|
+
g.skipped,
|
|
3443
|
+
" ",
|
|
3067
3444
|
state.run.skippedCount
|
|
3068
3445
|
] })
|
|
3069
3446
|
] }),
|
|
@@ -3079,11 +3456,11 @@ function UpdateScreen() {
|
|
|
3079
3456
|
}
|
|
3080
3457
|
|
|
3081
3458
|
// src/screens/summary.tsx
|
|
3082
|
-
import { Box as Box6, Text as Text7
|
|
3459
|
+
import { Box as Box6, Text as Text7 } from "ink";
|
|
3083
3460
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3084
3461
|
function SummaryScreen() {
|
|
3085
3462
|
const { state, rescan } = useMachine();
|
|
3086
|
-
|
|
3463
|
+
useSafeInput((input) => {
|
|
3087
3464
|
if (input === "r" || input === "R") rescan();
|
|
3088
3465
|
});
|
|
3089
3466
|
let upgraded = 0;
|
|
@@ -3091,6 +3468,7 @@ function SummaryScreen() {
|
|
|
3091
3468
|
let skipped = 0;
|
|
3092
3469
|
const failures = [];
|
|
3093
3470
|
const manuals = [];
|
|
3471
|
+
const reboots = [];
|
|
3094
3472
|
for (const id of state.run.queue) {
|
|
3095
3473
|
const e = state.managers[id];
|
|
3096
3474
|
if (!e) continue;
|
|
@@ -3104,12 +3482,13 @@ function SummaryScreen() {
|
|
|
3104
3482
|
upgraded += r.upgraded;
|
|
3105
3483
|
failed += r.failed;
|
|
3106
3484
|
for (const f of r.failures) failures.push({ manager: id, package: f.package, message: f.message, kind: f.kind });
|
|
3485
|
+
if (r.reboot) reboots.push({ manager: id, state: r.reboot });
|
|
3107
3486
|
}
|
|
3108
3487
|
}
|
|
3109
3488
|
const hasErrors = failed > 0;
|
|
3110
3489
|
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
3111
3490
|
/* @__PURE__ */ jsx8(StepHeader, { phase: state.phase }),
|
|
3112
|
-
/* @__PURE__ */ jsx8(Box6, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text7, { color: hasErrors ? semantic.error : semantic.success, bold: true, children: hasErrors ?
|
|
3491
|
+
/* @__PURE__ */ jsx8(Box6, { marginBottom: 1, children: /* @__PURE__ */ jsx8(Text7, { color: hasErrors ? semantic.error : semantic.success, bold: true, children: hasErrors ? `${g.failed} ${t("ui", "withErrors")}` : `${g.done} ${t("ui", "allDone")}` }) }),
|
|
3113
3492
|
/* @__PURE__ */ jsxs6(Box6, { marginBottom: 1, children: [
|
|
3114
3493
|
/* @__PURE__ */ jsxs6(Text7, { color: semantic.success, children: [
|
|
3115
3494
|
upgraded,
|
|
@@ -3131,7 +3510,8 @@ function SummaryScreen() {
|
|
|
3131
3510
|
] }),
|
|
3132
3511
|
failures.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
|
|
3133
3512
|
failures.slice(0, 8).map((f, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.error, wrap: "truncate-end", children: [
|
|
3134
|
-
|
|
3513
|
+
g.failed,
|
|
3514
|
+
" ",
|
|
3135
3515
|
managerName(f.manager),
|
|
3136
3516
|
f.package ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.text, children: [
|
|
3137
3517
|
" ",
|
|
@@ -3142,7 +3522,10 @@ function SummaryScreen() {
|
|
|
3142
3522
|
f.kind
|
|
3143
3523
|
] }) : null
|
|
3144
3524
|
] }, i)),
|
|
3145
|
-
failures.some((f) => f.kind === "TIMEOUT") && /* @__PURE__ */
|
|
3525
|
+
failures.some((f) => f.kind === "TIMEOUT") && /* @__PURE__ */ jsxs6(Text7, { color: semantic.warning, children: [
|
|
3526
|
+
g.info,
|
|
3527
|
+
" Un TIMEOUT suele indicar un paquete que pide interacci\xF3n (ej. un cask que requiere cerrar la app o sudo). Actual\xEDzalo manualmente en una terminal."
|
|
3528
|
+
] })
|
|
3146
3529
|
] }),
|
|
3147
3530
|
manuals.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
|
|
3148
3531
|
/* @__PURE__ */ jsx8(Text7, { color: semantic.warning, children: t("ui", "manualNeeded") }),
|
|
@@ -3153,6 +3536,11 @@ function SummaryScreen() {
|
|
|
3153
3536
|
/* @__PURE__ */ jsx8(Text7, { color: semantic.text, children: m.command })
|
|
3154
3537
|
] }, i))
|
|
3155
3538
|
] }),
|
|
3539
|
+
reboots.length > 0 && /* @__PURE__ */ jsx8(Box6, { marginBottom: 1, children: /* @__PURE__ */ jsxs6(Text7, { color: semantic.warning, children: [
|
|
3540
|
+
g.reboot,
|
|
3541
|
+
" Reinicio pendiente: ",
|
|
3542
|
+
reboots.map((r) => `${managerName(r.manager)} (${r.state})`).join(", ")
|
|
3543
|
+
] }) }),
|
|
3156
3544
|
hasErrors && /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
|
|
3157
3545
|
t("ui", "logAt"),
|
|
3158
3546
|
" ",
|
|
@@ -3164,14 +3552,14 @@ function SummaryScreen() {
|
|
|
3164
3552
|
|
|
3165
3553
|
// src/screens/settings-screen.tsx
|
|
3166
3554
|
import { useState as useState2 } from "react";
|
|
3167
|
-
import { Box as Box7, Text as Text8
|
|
3555
|
+
import { Box as Box7, Text as Text8 } from "ink";
|
|
3168
3556
|
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3169
3557
|
function SettingsScreen() {
|
|
3170
3558
|
const { state, toggleEnabled, setLang, closeSettings } = useMachine();
|
|
3171
3559
|
const ids = state.order;
|
|
3172
3560
|
const [cursor, setCursor] = useState2(0);
|
|
3173
3561
|
const clamped = Math.min(cursor, Math.max(0, ids.length - 1));
|
|
3174
|
-
|
|
3562
|
+
useSafeInput((input, key) => {
|
|
3175
3563
|
if (key.escape) closeSettings();
|
|
3176
3564
|
else if (key.downArrow || input === "j") setCursor((c) => Math.min(ids.length - 1, c + 1));
|
|
3177
3565
|
else if (key.upArrow || input === "k") setCursor((c) => Math.max(0, c - 1));
|
|
@@ -3193,7 +3581,7 @@ function SettingsScreen() {
|
|
|
3193
3581
|
const enabled = isManagerEnabled(state.config, id);
|
|
3194
3582
|
const isCursor = i === clamped;
|
|
3195
3583
|
return /* @__PURE__ */ jsxs7(Box7, { children: [
|
|
3196
|
-
/* @__PURE__ */ jsx9(Text8, { color: isCursor ? semantic.action : colors.outline, children: isCursor ?
|
|
3584
|
+
/* @__PURE__ */ jsx9(Text8, { color: isCursor ? semantic.action : colors.outline, children: isCursor ? `${g.cursor} ` : " " }),
|
|
3197
3585
|
/* @__PURE__ */ jsxs7(Text8, { color: enabled ? semantic.success : colors.outline, children: [
|
|
3198
3586
|
enabled ? "[on ]" : "[off]",
|
|
3199
3587
|
" "
|
|
@@ -3205,11 +3593,39 @@ function SettingsScreen() {
|
|
|
3205
3593
|
] });
|
|
3206
3594
|
}
|
|
3207
3595
|
|
|
3596
|
+
// src/lib/version.ts
|
|
3597
|
+
import { readFileSync } from "fs";
|
|
3598
|
+
import { fileURLToPath } from "url";
|
|
3599
|
+
import path4 from "path";
|
|
3600
|
+
var cached = null;
|
|
3601
|
+
function getVersion() {
|
|
3602
|
+
if (cached !== null) return cached;
|
|
3603
|
+
const here = path4.dirname(fileURLToPath(import.meta.url));
|
|
3604
|
+
for (const rel of ["../package.json", "../../package.json"]) {
|
|
3605
|
+
try {
|
|
3606
|
+
const pkg = JSON.parse(readFileSync(path4.join(here, rel), "utf-8"));
|
|
3607
|
+
if (pkg.version) {
|
|
3608
|
+
cached = pkg.version;
|
|
3609
|
+
return cached;
|
|
3610
|
+
}
|
|
3611
|
+
} catch {
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
cached = "0.0.0";
|
|
3615
|
+
return cached;
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3208
3618
|
// src/app.tsx
|
|
3209
3619
|
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3210
3620
|
function Header({ sudoMode: sudoMode2 }) {
|
|
3211
3621
|
return /* @__PURE__ */ jsxs8(Box8, { justifyContent: "space-between", marginBottom: 1, children: [
|
|
3212
|
-
/* @__PURE__ */
|
|
3622
|
+
/* @__PURE__ */ jsxs8(Box8, { children: [
|
|
3623
|
+
/* @__PURE__ */ jsx10(Text9, { color: semantic.action, bold: true, children: "@tacuchi/updater" }),
|
|
3624
|
+
/* @__PURE__ */ jsxs8(Text9, { color: colors.outline, children: [
|
|
3625
|
+
" v",
|
|
3626
|
+
getVersion()
|
|
3627
|
+
] })
|
|
3628
|
+
] }),
|
|
3213
3629
|
/* @__PURE__ */ jsx10(Text9, { color: sudoMode2 ? semantic.warning : colors.outline, children: sudoMode2 ? "SUDO" : `${process.platform}` })
|
|
3214
3630
|
] });
|
|
3215
3631
|
}
|
|
@@ -3236,7 +3652,7 @@ function PhaseRouter() {
|
|
|
3236
3652
|
}
|
|
3237
3653
|
function Shell({ sudoMode: sudoMode2 }) {
|
|
3238
3654
|
const { exit } = useInkApp();
|
|
3239
|
-
|
|
3655
|
+
useSafeInput((input) => {
|
|
3240
3656
|
if (input === "q" || input === "Q") {
|
|
3241
3657
|
exit();
|
|
3242
3658
|
process.exit(0);
|
|
@@ -3247,8 +3663,11 @@ function Shell({ sudoMode: sudoMode2 }) {
|
|
|
3247
3663
|
/* @__PURE__ */ jsx10(PhaseRouter, {})
|
|
3248
3664
|
] });
|
|
3249
3665
|
}
|
|
3250
|
-
function App({
|
|
3251
|
-
|
|
3666
|
+
function App({
|
|
3667
|
+
sudoMode: sudoMode2 = false,
|
|
3668
|
+
nonInteractive: nonInteractive2 = false
|
|
3669
|
+
}) {
|
|
3670
|
+
const machine = useAppMachine(sudoMode2, nonInteractive2);
|
|
3252
3671
|
return /* @__PURE__ */ jsx10(MachineProvider, { value: machine, children: /* @__PURE__ */ jsx10(Shell, { sudoMode: sudoMode2 }) });
|
|
3253
3672
|
}
|
|
3254
3673
|
|
|
@@ -3269,18 +3688,19 @@ if (args.includes("--help") || args.includes("-h")) {
|
|
|
3269
3688
|
Flags:
|
|
3270
3689
|
-s, --sudo Permite actualizar gestores que requieren admin
|
|
3271
3690
|
(softwareupdate, apt, dnf, pacman, snap)
|
|
3691
|
+
-y, --yes, --all Modo no-interactivo: actualiza todo sin teclado
|
|
3692
|
+
(autom\xE1tico cuando stdin no es un TTY / CI / pipe)
|
|
3272
3693
|
-h, --help Mostrar ayuda
|
|
3273
3694
|
-v, --version Mostrar versi\xF3n
|
|
3695
|
+
|
|
3696
|
+
Tip: ejecuta siempre la \xFAltima versi\xF3n con npx @tacuchi/updater@latest
|
|
3274
3697
|
`);
|
|
3275
3698
|
process.exit(0);
|
|
3276
3699
|
}
|
|
3277
3700
|
if (args.includes("--version") || args.includes("-v")) {
|
|
3278
|
-
console.log(
|
|
3701
|
+
console.log(getVersion());
|
|
3279
3702
|
process.exit(0);
|
|
3280
3703
|
}
|
|
3281
|
-
if (sudoRequested && process.platform === "win32") {
|
|
3282
|
-
console.log("\x1B[33m\xBB En Windows, ejecuta la terminal como Administrador en vez de usar --sudo\x1B[0m");
|
|
3283
|
-
}
|
|
3284
3704
|
if (sudoRequested && !isRoot && process.platform !== "win32") {
|
|
3285
3705
|
console.log("\x1B[35m\xBB Modo SUDO: ingresa tu contrase\xF1a para continuar...\x1B[0m");
|
|
3286
3706
|
try {
|
|
@@ -3297,13 +3717,22 @@ if (sudoRequested && !isRoot && process.platform !== "win32") {
|
|
|
3297
3717
|
console.error("\x1B[31m\u2717 No se pudo autenticar sudo. Continuando sin permisos elevados.\x1B[0m");
|
|
3298
3718
|
}
|
|
3299
3719
|
}
|
|
3300
|
-
var
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
}
|
|
3306
|
-
process.
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3720
|
+
var elevated = await isElevated();
|
|
3721
|
+
if (process.platform === "win32" && sudoRequested && !elevated) {
|
|
3722
|
+
console.log(
|
|
3723
|
+
"\x1B[33m\xBB En Windows --sudo no eleva. Abr\xED la terminal como Administrador (se detecta autom\xE1ticamente).\x1B[0m"
|
|
3724
|
+
);
|
|
3725
|
+
}
|
|
3726
|
+
var sudoMode = process.platform === "win32" ? elevated : isRoot || sudoRequested;
|
|
3727
|
+
var nonInteractive = !process.stdin.isTTY || args.includes("--yes") || args.includes("-y") || args.includes("--all");
|
|
3728
|
+
var { unmount } = render(/* @__PURE__ */ jsx11(App, { sudoMode, nonInteractive }));
|
|
3729
|
+
var onSignal = (code) => () => {
|
|
3730
|
+
fireProcessCancel();
|
|
3731
|
+
setTimeout(() => {
|
|
3732
|
+
unmount();
|
|
3733
|
+
process.exit(code);
|
|
3734
|
+
}, 200);
|
|
3735
|
+
};
|
|
3736
|
+
process.on("SIGINT", onSignal(130));
|
|
3737
|
+
process.on("SIGTERM", onSignal(143));
|
|
3738
|
+
process.on("SIGBREAK", onSignal(130));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tacuchi/updater",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "CLI multiplataforma para actualizar gestores de paquetes del sistema",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"dev": "tsx src/cli.tsx",
|
|
17
17
|
"build": "tsup",
|
|
18
|
+
"postbuild": "node scripts/assert-shebang.mjs",
|
|
18
19
|
"test": "vitest run",
|
|
19
20
|
"test:watch": "vitest",
|
|
20
21
|
"typecheck": "tsc --noEmit",
|
|
21
|
-
"prepublishOnly": "
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
22
23
|
},
|
|
23
24
|
"keywords": [
|
|
24
25
|
"cli",
|
|
@@ -36,14 +37,18 @@
|
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"@inkjs/ui": "^2.0.0",
|
|
38
39
|
"chalk": "^5.4.1",
|
|
40
|
+
"env-paths": "^4.0.0",
|
|
39
41
|
"execa": "^9.6.0",
|
|
42
|
+
"iconv-lite": "^0.7.2",
|
|
40
43
|
"ink": "^6.8.0",
|
|
44
|
+
"is-admin": "^4.0.0",
|
|
41
45
|
"react": "^19.2.0",
|
|
42
|
-
"
|
|
46
|
+
"tree-kill": "^1.2.2"
|
|
43
47
|
},
|
|
44
48
|
"devDependencies": {
|
|
45
49
|
"@types/react": "^19.0.0",
|
|
46
50
|
"ink-testing-library": "^4.0.0",
|
|
51
|
+
"react-devtools-core": "^7.0.1",
|
|
47
52
|
"tsup": "^8.4.0",
|
|
48
53
|
"tsx": "^4.19.3",
|
|
49
54
|
"typescript": "^5.7.3",
|