kubiy-paas-cli 0.1.0
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/fix-link.js +50 -0
- package/index.js +77 -0
- package/package.json +25 -0
package/fix-link.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
// Ruta donde npm instala los comandos globales
|
|
8
|
+
const npmBinPath = path.join(os.homedir(), 'AppData', 'Roaming', 'npm');
|
|
9
|
+
const kubiyCmdPath = path.join(npmBinPath, 'kubiy.cmd');
|
|
10
|
+
const kubiyPs1Path = path.join(npmBinPath, 'kubiy.ps1');
|
|
11
|
+
|
|
12
|
+
// Corregir kubiy.cmd
|
|
13
|
+
if (fs.existsSync(kubiyCmdPath)) {
|
|
14
|
+
let content = fs.readFileSync(kubiyCmdPath, 'utf8');
|
|
15
|
+
|
|
16
|
+
// Verificar si necesita corrección (no tiene 'node' explícito)
|
|
17
|
+
if (!content.includes('node "%dp0%')) {
|
|
18
|
+
// Reemplazar la línea que ejecuta el .js directamente
|
|
19
|
+
content = content.replace(
|
|
20
|
+
/"%dp0%\\node_modules\\kubiy-paas-cli\\index\.js"/g,
|
|
21
|
+
'node "%dp0%\\node_modules\\kubiy-paas-cli\\index.js"'
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
fs.writeFileSync(kubiyCmdPath, content, 'utf8');
|
|
25
|
+
console.log('✅ Archivo kubiy.cmd corregido');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Corregir kubiy.ps1
|
|
30
|
+
if (fs.existsSync(kubiyPs1Path)) {
|
|
31
|
+
let content = fs.readFileSync(kubiyPs1Path, 'utf8');
|
|
32
|
+
|
|
33
|
+
// Verificar si necesita corrección (no tiene 'node' explícito)
|
|
34
|
+
if (!content.includes('node "$basedir')) {
|
|
35
|
+
// Reemplazar las líneas que ejecutan el .js directamente
|
|
36
|
+
content = content.replace(
|
|
37
|
+
/& "`$basedir\/node_modules\/kubiy-paas-cli\/index\.js"/g,
|
|
38
|
+
'& node "$basedir/node_modules/kubiy-paas-cli/index.js"'
|
|
39
|
+
);
|
|
40
|
+
// También corregir la versión sin backticks
|
|
41
|
+
content = content.replace(
|
|
42
|
+
/& "\$basedir\/node_modules\/kubiy-paas-cli\/index\.js"/g,
|
|
43
|
+
'& node "$basedir/node_modules/kubiy-paas-cli/index.js"'
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
fs.writeFileSync(kubiyPs1Path, content, 'utf8');
|
|
47
|
+
console.log('✅ Archivo kubiy.ps1 corregido');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// CLI minimalista
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
8
|
+
const args = process.argv.slice(2); // [command, ...rest]
|
|
9
|
+
|
|
10
|
+
const CONFIG_DIR = path.join(os.homedir(), ".kubiy");
|
|
11
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
12
|
+
|
|
13
|
+
function ensureConfigDir() {
|
|
14
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
15
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function readConfig() {
|
|
20
|
+
if (!fs.existsSync(CONFIG_FILE)) return {};
|
|
21
|
+
const raw = fs.readFileSync(CONFIG_FILE, "utf8");
|
|
22
|
+
return JSON.parse(raw);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function writeConfig(obj) {
|
|
26
|
+
ensureConfigDir();
|
|
27
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(obj, null, 2), "utf8");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function cmdLogin() {
|
|
31
|
+
// Versión simple: aceptamos token por argumento
|
|
32
|
+
// kubiy login <token>
|
|
33
|
+
const token = args[1];
|
|
34
|
+
if (!token) {
|
|
35
|
+
console.error("Uso: kubiy login <cliToken>");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cfg = readConfig();
|
|
40
|
+
cfg.cliToken = token.trim();
|
|
41
|
+
writeConfig(cfg);
|
|
42
|
+
|
|
43
|
+
console.log("✅ CLI token guardado en ~/.kubiy/config.json");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function cmdWhoami() {
|
|
47
|
+
const cfg = readConfig();
|
|
48
|
+
if (!cfg.cliToken) {
|
|
49
|
+
console.log("No hay token configurado. Ejecuta: kubiy login <cliToken>");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
console.log("CLI configurado. Token (truncado):", cfg.cliToken.slice(0, 6) + "****");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function main() {
|
|
56
|
+
const command = args[0];
|
|
57
|
+
|
|
58
|
+
switch (command) {
|
|
59
|
+
case "login":
|
|
60
|
+
await cmdLogin();
|
|
61
|
+
break;
|
|
62
|
+
case "whoami":
|
|
63
|
+
await cmdWhoami();
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
console.log("Kubiy PaaS CLI");
|
|
67
|
+
console.log("Uso:");
|
|
68
|
+
console.log(" kubiy login <cliToken>");
|
|
69
|
+
console.log(" kubiy whoami");
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
main().catch((err) => {
|
|
75
|
+
console.error("Error en CLI:", err);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kubiy-paas-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI para desplegar apps en la plataforma PaaS de Kubiy",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"kubiy": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"preferGlobal": true,
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node index.js",
|
|
12
|
+
"postinstall": "node fix-link.js"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"kubiy",
|
|
16
|
+
"paas",
|
|
17
|
+
"cli",
|
|
18
|
+
"deploy"
|
|
19
|
+
],
|
|
20
|
+
"author": "Elfego Guerra",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=12.0.0"
|
|
24
|
+
}
|
|
25
|
+
}
|