kubiy-paas-cli 0.1.6 → 0.1.9

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/index.js CHANGED
@@ -24,6 +24,9 @@ async function main() {
24
24
  case "deploy":
25
25
  await require("./src/commands/deploy").run();
26
26
  break;
27
+ case "logs":
28
+ await require("./src/commands/logs").run(args.slice(1));
29
+ break;
27
30
  case "version":
28
31
  case "--version":
29
32
  case "-v":
@@ -48,6 +51,7 @@ function printHelp() {
48
51
  console.log(" kubiy service:get <serviceId>");
49
52
  console.log(" kubiy git:connect <serviceId>");
50
53
  console.log(" kubiy deploy");
54
+ console.log(" kubiy logs <serviceId> --kind=deploy|app --lines=200");
51
55
  console.log(" kubiy version");
52
56
  console.log("");
53
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubiy-paas-cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "description": "CLI para la plataforma PaaS de Kubiy",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -21,4 +21,3 @@
21
21
  "node": ">=12.0.0"
22
22
  }
23
23
  }
24
-
@@ -173,7 +173,10 @@ async function run() {
173
173
  logSuccess("🚀 Deploy completado. Revisa tu servicio Kubiy.");
174
174
  } catch (err) {
175
175
  const msg = String(err.message || "").toLowerCase();
176
- logError("Error en kubiy deploy:");
176
+ console.error("Error en kubiy deploy:");
177
+ console.error("✖ El git push falló. Muy probablemente el hook de deploy hizo rollback y dejó la versión anterior activa.");
178
+ console.error("ℹ Sugerencia: revisa los logs del deploy con:");
179
+ console.error(` kubiy logs ${serviceId} --kind=deploy --lines=200`);
177
180
 
178
181
  // Caso clásico: el remoto tiene commits que el local no
179
182
  if (
@@ -108,6 +108,7 @@ async function run(argv) {
108
108
  console.log(" git add .");
109
109
  console.log(" git commit -m \"tu mensaje\"");
110
110
  console.log(" git push kubiy main # o master");
111
+ console.log(" kubiy deploy");
111
112
  }
112
113
 
113
114
  module.exports = { run };
@@ -0,0 +1,65 @@
1
+ // src/commands/logs.js
2
+ const { apiGet } = require("../api");
3
+ const { logError, logInfo, logSuccess } = require("../logger");
4
+ const { getCliToken } = require("../config");
5
+
6
+ async function run(args) {
7
+ const serviceId = args[0];
8
+ if (!serviceId) {
9
+ logError("Uso: kubiy logs <serviceId> --kind=app|deploy --lines=N");
10
+ process.exit(1);
11
+ }
12
+
13
+ let kind = "app";
14
+ let lines = 100;
15
+
16
+ for (const arg of args.slice(1)) {
17
+ if (arg.startsWith("--kind=")) {
18
+ kind = arg.split("=")[1] || "app";
19
+ } else if (arg.startsWith("--lines=")) {
20
+ const v = parseInt(arg.split("=")[1], 10);
21
+ if (!isNaN(v)) lines = v;
22
+ }
23
+ }
24
+
25
+ const token = getCliToken();
26
+ if (!token) {
27
+ logError("No hay CLI token. Ejecuta: kubiy login <cliToken>");
28
+ process.exit(1);
29
+ }
30
+
31
+ logInfo(
32
+ `Obteniendo logs (${kind}) del servicio ${serviceId} (últimas ${lines} líneas)...`
33
+ );
34
+
35
+ const resp = await apiGet(
36
+ `/services/${serviceId}/logs?kind=${encodeURIComponent(
37
+ kind
38
+ )}&lines=${lines}`
39
+ );
40
+
41
+ if (resp.error) {
42
+ logError(`Error desde API: ${resp.error}`);
43
+ if (resp.detail) console.error(resp.detail);
44
+ process.exit(1);
45
+ }
46
+
47
+ const stdout = resp.stdout || "";
48
+ const stderr = resp.stderr || "";
49
+
50
+ logSuccess("Logs recibidos:\n");
51
+ if (stdout.trim().length === 0 && stderr.trim().length === 0) {
52
+ console.log("(sin contenido)");
53
+ return;
54
+ }
55
+
56
+ if (stdout) {
57
+ console.log(stdout);
58
+ }
59
+ if (stderr) {
60
+ console.log("\n[stderr]:");
61
+ console.log(stderr);
62
+ }
63
+ }
64
+
65
+ module.exports = { run };