kooni-bot 0.3.1 → 0.3.2
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/bin/kooni.js +25 -9
- package/package.json +1 -1
package/bin/kooni.js
CHANGED
|
@@ -454,12 +454,27 @@ async function downloadTemplate(dest) {
|
|
|
454
454
|
writeFileSync(dest, Buffer.from(await res.arrayBuffer()));
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
// ── extracción
|
|
457
|
+
// ── extracción ───────────────────────────────────────────────────────────────
|
|
458
|
+
// Compat de tar entre shells: el bsdtar de Windows (System32\tar.exe) entiende
|
|
459
|
+
// rutas "C:\…", pero el GNU tar de Git-Bash/MSYS cree que "C:" es un host remoto
|
|
460
|
+
// y falla ("tar: Cannot connect to C: resolve failed"). Solución portátil:
|
|
461
|
+
// correr tar con cwd fijado y pasarle SOLO nombres relativos (sin dos puntos).
|
|
462
|
+
function relTo(base, p) {
|
|
463
|
+
const b = String(base).replace(/[\\/]+$/, "");
|
|
464
|
+
if (p === b) return ".";
|
|
465
|
+
if (p.startsWith(b + "\\") || p.startsWith(b + "/")) return p.slice(b.length + 1) || ".";
|
|
466
|
+
return p; // fuera de base: último recurso
|
|
467
|
+
}
|
|
468
|
+
function tarExtract(tgz, outDir) {
|
|
469
|
+
mkdirSync(outDir, { recursive: true });
|
|
470
|
+
const cwd = dirname(tgz);
|
|
471
|
+
execFileSync("tar", ["-xzf", basename(tgz), "-C", relTo(cwd, outDir)], { cwd });
|
|
472
|
+
}
|
|
473
|
+
|
|
458
474
|
function extractFresh(tgz, dir) {
|
|
459
475
|
mkdirSync(dir, { recursive: true });
|
|
460
476
|
const tmp = join(dir, ".kooni-extract");
|
|
461
|
-
|
|
462
|
-
execFileSync("tar", ["-xzf", tgz, "-C", tmp]);
|
|
477
|
+
tarExtract(tgz, tmp);
|
|
463
478
|
const root = readdirSync(tmp)[0];
|
|
464
479
|
const src = join(tmp, root);
|
|
465
480
|
for (const e of readdirSync(src)) {
|
|
@@ -473,8 +488,7 @@ function extractFresh(tgz, dir) {
|
|
|
473
488
|
|
|
474
489
|
// Extrae a un dir TEMP (sin pisar nada) para leer la versión y archivos del template.
|
|
475
490
|
function extractToTemp(tgz, outDir) {
|
|
476
|
-
|
|
477
|
-
execFileSync("tar", ["-xzf", tgz, "-C", outDir]);
|
|
491
|
+
tarExtract(tgz, outDir);
|
|
478
492
|
const root = readdirSync(outDir)[0];
|
|
479
493
|
return join(outDir, root);
|
|
480
494
|
}
|
|
@@ -505,10 +519,11 @@ function backupBeforeUpdate(dir, version) {
|
|
|
505
519
|
const dest = join(backDir, `${stamp}_v${version}.tgz`);
|
|
506
520
|
try {
|
|
507
521
|
mkdirSync(backDir, { recursive: true });
|
|
508
|
-
|
|
522
|
+
// cwd = dir + ruta relativa del archivo → tar portátil (ver relTo/tarExtract).
|
|
523
|
+
execFileSync("tar", ["-czf", relTo(dir, dest), "-C", ".",
|
|
509
524
|
"--exclude=./node_modules", "--exclude=./.kooni-backups", "--exclude=./.kooni-extract",
|
|
510
525
|
"--exclude=./.git", "--exclude=./.wrangler", "--exclude=./.dev.vars", "--exclude=./.dev.vars.*",
|
|
511
|
-
"--exclude=./.env", "--exclude=./.env.*", "."]);
|
|
526
|
+
"--exclude=./.env", "--exclude=./.env.*", "."], { cwd: dir });
|
|
512
527
|
const olds = readdirSync(backDir).filter((f) => f.endsWith(".tgz")).sort();
|
|
513
528
|
for (const f of olds.slice(0, -5)) rmSync(join(backDir, f), { force: true });
|
|
514
529
|
return dest;
|
|
@@ -907,8 +922,9 @@ async function onboarding(rl, answers, defaultDir) {
|
|
|
907
922
|
}
|
|
908
923
|
|
|
909
924
|
// Licencia Pro: si el usuario dice que es Pro, pide el código y lo valida
|
|
910
|
-
// localmente (
|
|
911
|
-
//
|
|
925
|
+
// localmente (Ed25519 con la clave PÚBLICA embebida — solo verifica, no firma).
|
|
926
|
+
// Si es válido se guarda tras el deploy (settings pro_license → límites
|
|
927
|
+
// quitados). Si es inválido, se avisa y sigue gratis.
|
|
912
928
|
const wantsPro = interactive()
|
|
913
929
|
? await confirm(rl, m("¿Tu bot será Pro (tienes una licencia)?", "Will your bot be Pro (do you have a license)?"))
|
|
914
930
|
: !!(flags.license || answers.licenseCode);
|
package/package.json
CHANGED