kooni-bot 0.2.3 → 0.2.5
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 +22 -11
- package/package.json +1 -1
package/bin/kooni.js
CHANGED
|
@@ -22,7 +22,7 @@ import { execFileSync, spawnSync } from "node:child_process";
|
|
|
22
22
|
import { randomUUID } from "node:crypto";
|
|
23
23
|
import { fileURLToPath } from "node:url";
|
|
24
24
|
|
|
25
|
-
const CLI_VERSION = "0.2.
|
|
25
|
+
const CLI_VERSION = "0.2.5";
|
|
26
26
|
|
|
27
27
|
const REPO = process.env.KOONI_REPO || "iamnocodeveloper/kooni-bot";
|
|
28
28
|
const BRANCH = process.env.KOONI_BRANCH || "main";
|
|
@@ -102,7 +102,7 @@ const DICT = {
|
|
|
102
102
|
migrations: "Aplicando migraciones D1…",
|
|
103
103
|
deploying: "Desplegando el worker…",
|
|
104
104
|
panel: "Panel de administración:",
|
|
105
|
-
next: "
|
|
105
|
+
next: "Abre tu panel → Conexiones para conectar canales (Telegram, Zernio, WhatsApp…) — ahí mismo se activan y quedan en verde.",
|
|
106
106
|
// update
|
|
107
107
|
updRevalidating: "Buscando la versión nueva…",
|
|
108
108
|
updUpToDate: "Ya estás en la última versión.",
|
|
@@ -174,7 +174,7 @@ const DICT = {
|
|
|
174
174
|
migrations: "Applying D1 migrations…",
|
|
175
175
|
deploying: "Deploying the worker…",
|
|
176
176
|
panel: "Admin dashboard:",
|
|
177
|
-
next: "
|
|
177
|
+
next: "Open your panel → Connections to connect channels (Telegram, Zernio, WhatsApp…) — they activate and turn green right there.",
|
|
178
178
|
updRevalidating: "Checking for a new version…",
|
|
179
179
|
updUpToDate: "You're on the latest version.",
|
|
180
180
|
updDone: (v) => `Updated to v${v} (your config and data were preserved)`,
|
|
@@ -499,9 +499,11 @@ const isWin = process.platform === "win32";
|
|
|
499
499
|
|
|
500
500
|
// Ejecuta un binario de forma segura en Windows/macOS/Linux:
|
|
501
501
|
// - Unix/mac: `spawnSync(file, args)` directo.
|
|
502
|
-
// - Windows: `npx`/`pnpm` son shims
|
|
503
|
-
//
|
|
504
|
-
//
|
|
502
|
+
// - Windows: `npx`/`pnpm` son shims, pero `cmd.exe /c` los resuelve SIN la
|
|
503
|
+
// extensión `.cmd` (probado: `cmd.exe /c pnpm --version` funciona, mientras
|
|
504
|
+
// que `pnpm.cmd` explícito falla con "no se reconoce"). Así que aquí NO se
|
|
505
|
+
// mapea a `.cmd`: se lanza `cmd.exe /c <file> <args...>` con args separados.
|
|
506
|
+
// Nada de `shell: true` ni concatenación → sin EINVAL ni DEP0190.
|
|
505
507
|
// - `stdio` hereda por defecto (progreso en vivo); `capture` captura para parsear.
|
|
506
508
|
function run(file, args = [], opts = {}) {
|
|
507
509
|
const cwd = opts.cwd;
|
|
@@ -512,20 +514,24 @@ function run(file, args = [], opts = {}) {
|
|
|
512
514
|
let argv = args;
|
|
513
515
|
|
|
514
516
|
if (isWin) {
|
|
515
|
-
const shim = { npx: "npx.cmd", pnpm: "pnpm.cmd" }[file] || file;
|
|
516
517
|
cmd = "cmd.exe";
|
|
517
|
-
argv = ["/d", "/c",
|
|
518
|
+
argv = ["/d", "/c", file, ...args];
|
|
518
519
|
}
|
|
519
520
|
|
|
520
521
|
const r = spawnSync(cmd, argv, { cwd, input, stdio, encoding: "utf8" });
|
|
521
522
|
if (r.error) throw r.error;
|
|
522
523
|
if (r.status !== 0) {
|
|
523
|
-
const err = new Error(`Command failed: ${[
|
|
524
|
+
const err = new Error(`Command failed: ${[file, ...args].join(" ")}`);
|
|
524
525
|
err.stdout = r.stdout;
|
|
525
526
|
err.stderr = r.stderr;
|
|
526
527
|
err.status = r.status;
|
|
527
528
|
throw err;
|
|
528
529
|
}
|
|
530
|
+
// En modo capture, combinamos stdout+stderr: wrangler suele imprimir la URL del
|
|
531
|
+
// worker en stderr (progreso/banners), y necesitamos verla para parsearla.
|
|
532
|
+
if (opts.capture) {
|
|
533
|
+
return `${r.stdout || ""}\n${r.stderr || ""}`;
|
|
534
|
+
}
|
|
529
535
|
return (r.stdout || "").toString();
|
|
530
536
|
}
|
|
531
537
|
|
|
@@ -906,8 +912,11 @@ async function deployBot(dir, { flags = {}, rl } = {}) {
|
|
|
906
912
|
try {
|
|
907
913
|
const dep = runPnpm(dir, ["run", "deploy"], { capture: true });
|
|
908
914
|
url = (dep.match(/https:\/\/[a-z0-9-]+\.workers\.dev/) || [])[0] || "";
|
|
909
|
-
} catch {
|
|
910
|
-
// el deploy
|
|
915
|
+
} catch (e) {
|
|
916
|
+
// Muestra el detalle real del deploy en vez de tragarlo: así el usuario ve
|
|
917
|
+
// qué falló (deploy-check, binding, auth…) y puede corregirlo.
|
|
918
|
+
const tail = ((e && (e.stderr || e.stdout || e.message)) || "").toString().trim().split("\n").slice(-12).join("\n");
|
|
919
|
+
if (tail) console.log(C.red(" ✗ " + tail));
|
|
911
920
|
throw new Error(t().deployFailed);
|
|
912
921
|
}
|
|
913
922
|
if (url) {
|
|
@@ -1092,6 +1101,8 @@ async function cmdInit(flags, rest) {
|
|
|
1092
1101
|
console.log("\n " + C.green(C.b(m("🎉 BOT EN LÍNEA", "🎉 BOT LIVE"))));
|
|
1093
1102
|
console.log(" " + C.cyan(t().panel) + " " + C.b(url + "/admin"));
|
|
1094
1103
|
console.log(" " + C.dim(t().next) + "\n");
|
|
1104
|
+
} else {
|
|
1105
|
+
console.log(" " + C.yellow(m("No detecté la URL automáticamente. Búscala en la salida de `pnpm run deploy` arriba (https://…workers.dev) y abre <url>/admin.", "Couldn't auto-detect the URL. Find it in the `pnpm run deploy` output above (https://…workers.dev) and open <url>/admin.")) + "\n");
|
|
1095
1106
|
}
|
|
1096
1107
|
}
|
|
1097
1108
|
|
package/package.json
CHANGED