kubiy-paas-cli 0.1.9 → 0.1.17

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/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # Kubiy CLI (`kubiy-cli`)
2
+
3
+ **English:** Official CLI for the Kubiy PaaS platform. Install from npm and use the `kubiy` command to manage your apps and services deployed on Kubiy.
4
+
5
+ **Español:** CLI oficial para la plataforma PaaS de Kubiy. Instala el paquete desde npm y usa el comando `kubiy` para interactuar con tus apps y servicios desplegados en Kubiy.
6
+
7
+ ---
8
+
9
+ ### Installation / Instalación
10
+
11
+ ```bash
12
+ npm install -g kubiy-cli
13
+
14
+ # Get help / Ver ayuda
15
+ kubiy
16
+ ```
17
+
18
+ **English:** This installs the global `kubiy` binary on your system.
19
+
20
+ **Español:** Esto instalará el binario global `kubiy` en tu sistema.
21
+
22
+ ---
23
+
24
+ ### Main commands / Comandos principales
25
+
26
+ | Command | English | Español |
27
+ |--------|---------|---------|
28
+ | `kubiy link <appId> [--env=prod\|stg\|dev] [--apikey=...] [--save-secrets]` | Link the current project to a Kubiy app/service and create `.kubiy.json`. | Vincula el proyecto actual con una app/servicio de Kubiy y genera el archivo `.kubiy.json`. |
29
+ | `kubiy deploy --message "<text>" [--static] [--dir=<folder>]` | Deploy your project to Kubiy using `.kubiy.json`. | Realiza un deploy de tu proyecto a Kubiy. Usa la configuración de `.kubiy.json`. |
30
+ | `kubiy service:get <serviceId>` | Show detailed information for a Kubiy service. | Muestra información detallada de un servicio en Kubiy. |
31
+ | `kubiy logs [<serviceId>] [--kind=deploy\|app] [--lines=200]` | Show deploy or app logs for a service. | Muestra logs de deploy o de la app para un servicio. |
32
+ | `kubiy rollback <deployId>` | Roll back to the given deploy using `.kubiy.json`. | Ejecuta un rollback al `deployId` indicado usando los datos de `.kubiy.json`. |
33
+ | `kubiy rollback <appId> <serviceId> <deployId>` | Explicit variant with all IDs passed on the command line. | Variante explícita que recibe todos los identificadores por línea de comandos. |
34
+ | `kubiy config --lang es\|en` | Set or show CLI language (Spanish or English). | Define o muestra el idioma del CLI (español o inglés). |
35
+ | `kubiy version` | Show the current CLI version. | Muestra la versión actual del CLI. |
36
+
37
+ You can also pass the language per run: `kubiy --lang en deploy ...`
38
+ También puedes indicar el idioma por ejecución: `kubiy --lang es deploy ...`
39
+
40
+ ---
41
+
42
+ ### Command `kubiy login`
43
+
44
+ **English:** In this version of the CLI, the command `kubiy login <cliToken>` is **temporarily disabled** and is not used in the current authentication flow. If you run it, the CLI will show a message that it is disabled.
45
+
46
+ **Español:** En esta versión del CLI, el comando `kubiy login <cliToken>` está **deshabilitado temporalmente** y no se utiliza en el flujo actual de autenticación. Si lo ejecutas, el CLI mostrará un mensaje indicando que está deshabilitado.
47
+
48
+ ---
49
+
50
+ ### Security / Seguridad
51
+
52
+ **English:** This CLI acts as a client to the Kubiy API:
53
+
54
+ - No secrets are hardcoded (no API keys or tokens in the source code).
55
+ - Tokens and API keys are always provided from outside (by the user or configuration).
56
+ - All sensitive operations are validated and authorized on the **Kubiy API**, not in the CLI.
57
+ - Requests are always made over HTTPS to `https://cli.kubiy.cloud/v1` (or the configured URL).
58
+
59
+ Recommendations: Do not share your `cliToken` or API keys. Do not commit `.kubiy.json` files from real projects to public repos if they contain sensitive identifiers or keys.
60
+
61
+ **Español:** Este CLI actúa como cliente frente a la API de Kubiy:
62
+
63
+ - No incluye ningún secreto hardcodeado (no hay API keys ni tokens dentro del código fuente).
64
+ - Los tokens y apikeys se proporcionan siempre desde fuera (por el usuario o por configuración).
65
+ - Todas las operaciones delicadas se validan y autorizan en la **API de Kubiy**, no en el CLI.
66
+ - Las llamadas se realizan siempre sobre HTTPS hacia `https://cli.kubiy.cloud/v1` (o la URL configurada).
67
+
68
+ Recomendaciones: No compartas tu `cliToken` ni apikeys. No subas archivos `.kubiy.json` de proyectos reales a repos públicos si contienen identificadores o claves sensibles.
69
+
70
+ ---
71
+
72
+ ### Publishing to npm / Publicación en npm
73
+
74
+ **English:** This package is ready to be published as a public npm package:
75
+
76
+ - Package name: `kubiy-cli`
77
+ - Global command: `kubiy` (defined in the `bin` field)
78
+ - Only the needed files are published (`index.js` and `src/`)
79
+
80
+ To publish a new version:
81
+
82
+ ```bash
83
+ # 1. Make sure you've updated "version" in package.json
84
+
85
+ cd kubiy-npm-cli
86
+ npm login # once, if you haven't already
87
+ npm publish # publishes kubiy-cli as a public package
88
+ ```
89
+
90
+ After publishing, users can install it with:
91
+
92
+ ```bash
93
+ npm install -g kubiy-cli
94
+ kubiy version
95
+ ```
96
+
97
+ **Español:** Este paquete está preparado para publicarse como paquete público en npm:
98
+
99
+ - Nombre del paquete: `kubiy-cli`
100
+ - Comando global: `kubiy` (definido en el campo `bin`)
101
+ - Solo se publican los archivos necesarios (`index.js` y `src/`)
102
+
103
+ Para publicar una nueva versión:
104
+
105
+ ```bash
106
+ # 1. Asegúrate de haber actualizado "version" en package.json
107
+
108
+ cd kubiy-npm-cli
109
+ npm login # una sola vez, si aún no lo hiciste
110
+ npm publish # publica kubiy-cli como paquete público
111
+ ```
112
+
113
+ Después de publicar, los usuarios pueden instalarlo con:
114
+
115
+ ```bash
116
+ npm install -g kubiy-cli
117
+ kubiy version
118
+ ```
package/index.js CHANGED
@@ -2,38 +2,79 @@
2
2
 
3
3
  const path = require("path");
4
4
  const { logInfo, logError } = require("./src/logger");
5
+ const { getLang, setLang } = require("./src/config");
6
+
7
+ const rawArgs = process.argv.slice(2);
8
+
9
+ // Extraer --lang / --lang= del CLI y dejar el resto de args limpios
10
+ let langFromCli = null;
11
+ const args = [];
12
+ for (let i = 0; i < rawArgs.length; i++) {
13
+ const a = rawArgs[i];
14
+ if (a === "--lang" && i + 1 < rawArgs.length) {
15
+ langFromCli = rawArgs[i + 1];
16
+ i++;
17
+ } else if (a.startsWith("--lang=")) {
18
+ langFromCli = a.split("=")[1];
19
+ } else {
20
+ args.push(a);
21
+ }
22
+ }
5
23
 
6
- const args = process.argv.slice(2);
7
24
  const command = args[0];
8
25
 
26
+ function resolveLang(langFromCli) {
27
+ // 1) CLI
28
+ if (langFromCli === "es" || langFromCli === "en") {
29
+ return langFromCli;
30
+ }
31
+
32
+ // 2) Config persistente
33
+ const saved = getLang && getLang();
34
+ if (saved === "es" || saved === "en") {
35
+ return saved;
36
+ }
37
+
38
+ // 3) Default
39
+ return "es";
40
+ }
41
+
9
42
  async function main() {
43
+ const lang = resolveLang(langFromCli);
44
+
10
45
  try {
11
46
  switch (command) {
12
47
  case "login":
13
- await require("./src/commands/login").run(args.slice(1));
14
- break;
48
+ logInfo("El comando 'kubiy login' está deshabilitado temporalmente y no se utiliza en esta versión del CLI.");
49
+ process.exit(1);
15
50
  case "whoami":
16
- await require("./src/commands/whoami").run(args.slice(1));
51
+ await require("./src/commands/whoami").run(args.slice(1), { lang });
17
52
  break;
18
53
  case "service:get":
19
- await require("./src/commands/service-get").run(args.slice(1));
54
+ await require("./src/commands/service-get").run(args.slice(1), { lang });
20
55
  break;
21
- case "git:connect":
22
- await require("./src/commands/git-connect").run(args.slice(1));
56
+ case "link":
57
+ await require("./src/commands/service-link").run(args.slice(1), { lang });
23
58
  break;
24
59
  case "deploy":
25
- await require("./src/commands/deploy").run();
60
+ await require("./src/commands/deploy").run(args.slice(1), { lang });
26
61
  break;
27
62
  case "logs":
28
- await require("./src/commands/logs").run(args.slice(1));
63
+ await require("./src/commands/logs").run(args.slice(1), { lang });
64
+ break;
65
+ case "rollback":
66
+ await require("./src/commands/rollback").run(args.slice(1), { lang });
29
67
  break;
30
68
  case "version":
31
69
  case "--version":
32
70
  case "-v":
33
- await require("./src/commands/version").run(args.slice(1));
71
+ await require("./src/commands/version").run(args.slice(1), { lang });
72
+ break;
73
+ case "config":
74
+ await require("./src/commands/config").run(args.slice(1), { lang, langFromCli });
34
75
  break;
35
76
  default:
36
- printHelp();
77
+ printHelp(lang);
37
78
  process.exit(0);
38
79
  }
39
80
  } catch (err) {
@@ -42,17 +83,31 @@ async function main() {
42
83
  }
43
84
  }
44
85
 
45
- function printHelp() {
46
- logInfo("Kubiy PaaS CLI");
86
+ function printHelp(lang) {
87
+ const isEs = lang === "es";
88
+
89
+ logInfo(isEs ? "Kubiy PaaS CLI" : "Kubiy PaaS CLI");
47
90
  console.log("");
48
- console.log("Uso:");
49
- console.log(" kubiy login <cliToken>");
91
+ console.log(isEs ? "Uso:" : "Usage:");
92
+ console.log(" kubiy login <cliToken> (deshabilitado temporalmente)");
50
93
  console.log(" kubiy whoami");
94
+ console.log(" kubiy link <appId> [--env=prod|stg|dev] [--apikey=...] [--save-secrets]");
95
+ console.log(' kubiy deploy --message "<texto>" [--static] [--dir=<carpeta>]');
51
96
  console.log(" kubiy service:get <serviceId>");
52
- console.log(" kubiy git:connect <serviceId>");
53
- console.log(" kubiy deploy");
54
- console.log(" kubiy logs <serviceId> --kind=deploy|app --lines=200");
97
+ console.log(" kubiy logs [<serviceId>] [--kind=deploy|app] [--lines=200]");
98
+ console.log(" kubiy rollback <deployId>");
99
+ console.log(" kubiy rollback <appId> <serviceId> <deployId>");
55
100
  console.log(" kubiy version");
101
+ console.log(" kubiy config --lang es|en");
102
+ console.log("");
103
+ console.log(isEs ? "Ejemplos:" : "Examples:");
104
+ console.log(" kubiy link my-app-id --apikey=xxx");
105
+ console.log(' kubiy deploy --message "Release v1.0"');
106
+ console.log(' kubiy deploy -m "Fix login" --static');
107
+ console.log(' kubiy deploy --message="Deploy prod" --static --dir=dist');
108
+ console.log(" kubiy logs --kind=deploy --lines=100");
109
+ console.log(" kubiy config --lang es");
110
+ console.log(" kubiy config --lang en");
56
111
  console.log("");
57
112
  }
58
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubiy-paas-cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.17",
4
4
  "description": "CLI para la plataforma PaaS de Kubiy",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -19,5 +19,9 @@
19
19
  "license": "MIT",
20
20
  "engines": {
21
21
  "node": ">=12.0.0"
22
- }
22
+ },
23
+ "files": [
24
+ "index.js",
25
+ "src"
26
+ ]
23
27
  }
package/src/api.js CHANGED
@@ -1,19 +1,24 @@
1
1
  const https = require("https");
2
2
  const { getCliToken } = require("./config");
3
- const { logError } = require("./logger");
3
+ const { logError, logInfo } = require("./logger");
4
4
 
5
- // Ajusta esta URL a tu API real
6
- const API_BASE = process.env.KUBIY_API_BASE || "https://i5c812hwh2.execute-api.us-east-1.amazonaws.com";
5
+ // URL base de la API de Kubiy
6
+ const API_BASE = process.env.KUBIY_API_BASE || "https://cli.kubiy.cloud/v1";
7
7
 
8
8
  function request(method, path, body, opts = {}) {
9
9
  return new Promise((resolve, reject) => {
10
10
  const token = opts.token || getCliToken();
11
- const url = new URL(path, API_BASE);
11
+ const url = API_BASE + path; //new URL(path, API_BASE);
12
12
 
13
13
  const headers = {
14
14
  "Accept": "application/json"
15
15
  };
16
16
 
17
+ // Combinar headers personalizados de opts.headers
18
+ if (opts.headers) {
19
+ Object.assign(headers, opts.headers);
20
+ }
21
+
17
22
  let payload = null;
18
23
  if (body) {
19
24
  payload = JSON.stringify(body);
@@ -21,7 +26,8 @@ function request(method, path, body, opts = {}) {
21
26
  headers["Content-Length"] = Buffer.byteLength(payload);
22
27
  }
23
28
 
24
- if (token) {
29
+ // Si se usa X-Kubiy-Token no añadimos Authorization
30
+ if (token && !opts.headers?.["X-Kubiy-Token"]) {
25
31
  headers["Authorization"] = `Bearer ${token}`;
26
32
  }
27
33
 
@@ -29,7 +35,7 @@ function request(method, path, body, opts = {}) {
29
35
  method,
30
36
  headers
31
37
  };
32
-
38
+
33
39
  const req = https.request(url, options, (res) => {
34
40
  let data = "";
35
41
 
@@ -0,0 +1,71 @@
1
+ const { logInfo, logError } = require("../logger");
2
+ const { getLang, setLang } = require("../config");
3
+
4
+ function parseArgs(args) {
5
+ let lang = null;
6
+
7
+ for (let i = 0; i < args.length; i++) {
8
+ const a = args[i];
9
+ if (a === "--lang" && i + 1 < args.length) {
10
+ lang = args[i + 1];
11
+ i++;
12
+ } else if (a.startsWith("--lang=")) {
13
+ lang = a.split("=")[1];
14
+ }
15
+ }
16
+
17
+ return { lang };
18
+ }
19
+
20
+ async function run(args = [], options = {}) {
21
+ const { lang: currentLangFromIndex } = options;
22
+ const { lang } = parseArgs(args);
23
+
24
+ // Si no se pasa --lang, mostrar idioma actual
25
+ if (!lang) {
26
+ const saved = getLang && getLang();
27
+ const effective = currentLangFromIndex || saved || "es";
28
+ const isEs = effective === "es";
29
+
30
+ if (isEs) {
31
+ logInfo(`Idioma actual del CLI: ${effective}`);
32
+ logInfo("Puedes cambiarlo con: kubiy config --lang es|en");
33
+ } else {
34
+ logInfo(`Current CLI language: ${effective}`);
35
+ logInfo("You can change it with: kubiy config --lang es|en");
36
+ }
37
+ return;
38
+ }
39
+
40
+ if (lang !== "es" && lang !== "en") {
41
+ const isEs = (currentLangFromIndex || getLang() || "es") === "es";
42
+ if (isEs) {
43
+ logError("Idioma no soportado. Usa 'es' o 'en'.");
44
+ } else {
45
+ logError("Unsupported language. Use 'es' or 'en'.");
46
+ }
47
+ process.exit(1);
48
+ }
49
+
50
+ try {
51
+ setLang(lang);
52
+ const isEs = lang === "es";
53
+ if (isEs) {
54
+ logInfo("Idioma guardado como Español.");
55
+ } else {
56
+ logInfo("Language saved as English.");
57
+ }
58
+ } catch (err) {
59
+ const isEs = (currentLangFromIndex || getLang() || "es") === "es";
60
+ if (isEs) {
61
+ logError("No se pudo guardar el idioma:");
62
+ } else {
63
+ logError("Failed to save language:");
64
+ }
65
+ logError(err.message || err);
66
+ process.exit(1);
67
+ }
68
+ }
69
+
70
+ module.exports = { run };
71
+