gufi-cli 0.1.0 → 0.1.1
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/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.js +42 -0
- package/dist/index.js +6 -0
- package/package.json +1 -1
- package/src/commands/list.ts +51 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gufi list - List packages and views
|
|
3
|
+
*/
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
import { listPackages, listViews } from "../lib/api.js";
|
|
7
|
+
import { isLoggedIn } from "../lib/config.js";
|
|
8
|
+
export async function listCommand() {
|
|
9
|
+
if (!isLoggedIn()) {
|
|
10
|
+
console.log(chalk.red("\n ✗ No estás logueado. Usa: gufi login\n"));
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
console.log(chalk.magenta("\n 🟣 Gufi List\n"));
|
|
14
|
+
const spinner = ora("Cargando packages...").start();
|
|
15
|
+
try {
|
|
16
|
+
const packages = await listPackages();
|
|
17
|
+
spinner.stop();
|
|
18
|
+
if (packages.length === 0) {
|
|
19
|
+
console.log(chalk.yellow(" No tienes packages. Crea uno en Developer Center.\n"));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for (const pkg of packages) {
|
|
23
|
+
console.log(chalk.cyan(`\n 📦 ${pkg.name}`) + chalk.gray(` (ID: ${pkg.pk_id})`));
|
|
24
|
+
console.log(chalk.gray(` ${pkg.description || "Sin descripción"}`));
|
|
25
|
+
const views = await listViews(pkg.pk_id);
|
|
26
|
+
if (views.length === 0) {
|
|
27
|
+
console.log(chalk.gray(" └─ Sin vistas"));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
views.forEach((view, i) => {
|
|
31
|
+
const prefix = i === views.length - 1 ? "└─" : "├─";
|
|
32
|
+
console.log(chalk.white(` ${prefix} ${view.name}`) + chalk.gray(` (${view.view_type}, ID: ${view.pk_id})`));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.log(chalk.gray("\n Usa: gufi pull <view-id> para descargar una vista\n"));
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
spinner.fail(chalk.red(error.message));
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { loginCommand, logoutCommand, whoamiCommand } from "./commands/login.js"
|
|
|
16
16
|
import { pullCommand } from "./commands/pull.js";
|
|
17
17
|
import { pushCommand, statusCommand } from "./commands/push.js";
|
|
18
18
|
import { watchCommand } from "./commands/watch.js";
|
|
19
|
+
import { listCommand } from "./commands/list.js";
|
|
19
20
|
const program = new Command();
|
|
20
21
|
program
|
|
21
22
|
.name("gufi")
|
|
@@ -52,4 +53,9 @@ program
|
|
|
52
53
|
.command("status")
|
|
53
54
|
.description("Show sync status")
|
|
54
55
|
.action(statusCommand);
|
|
56
|
+
program
|
|
57
|
+
.command("list")
|
|
58
|
+
.alias("ls")
|
|
59
|
+
.description("List your packages and views")
|
|
60
|
+
.action(listCommand);
|
|
55
61
|
program.parse();
|
package/package.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gufi list - List packages and views
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import ora from "ora";
|
|
7
|
+
import { listPackages, listViews } from "../lib/api.js";
|
|
8
|
+
import { isLoggedIn } from "../lib/config.js";
|
|
9
|
+
|
|
10
|
+
export async function listCommand(): Promise<void> {
|
|
11
|
+
if (!isLoggedIn()) {
|
|
12
|
+
console.log(chalk.red("\n ✗ No estás logueado. Usa: gufi login\n"));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log(chalk.magenta("\n 🟣 Gufi List\n"));
|
|
17
|
+
|
|
18
|
+
const spinner = ora("Cargando packages...").start();
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const packages = await listPackages();
|
|
22
|
+
spinner.stop();
|
|
23
|
+
|
|
24
|
+
if (packages.length === 0) {
|
|
25
|
+
console.log(chalk.yellow(" No tienes packages. Crea uno en Developer Center.\n"));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for (const pkg of packages) {
|
|
30
|
+
console.log(chalk.cyan(`\n 📦 ${pkg.name}`) + chalk.gray(` (ID: ${pkg.pk_id})`));
|
|
31
|
+
console.log(chalk.gray(` ${pkg.description || "Sin descripción"}`));
|
|
32
|
+
|
|
33
|
+
const views = await listViews(pkg.pk_id);
|
|
34
|
+
|
|
35
|
+
if (views.length === 0) {
|
|
36
|
+
console.log(chalk.gray(" └─ Sin vistas"));
|
|
37
|
+
} else {
|
|
38
|
+
views.forEach((view, i) => {
|
|
39
|
+
const prefix = i === views.length - 1 ? "└─" : "├─";
|
|
40
|
+
console.log(chalk.white(` ${prefix} ${view.name}`) + chalk.gray(` (${view.view_type}, ID: ${view.pk_id})`));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(chalk.gray("\n Usa: gufi pull <view-id> para descargar una vista\n"));
|
|
46
|
+
|
|
47
|
+
} catch (error: any) {
|
|
48
|
+
spinner.fail(chalk.red(error.message));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { loginCommand, logoutCommand, whoamiCommand } from "./commands/login.js"
|
|
|
17
17
|
import { pullCommand } from "./commands/pull.js";
|
|
18
18
|
import { pushCommand, statusCommand } from "./commands/push.js";
|
|
19
19
|
import { watchCommand } from "./commands/watch.js";
|
|
20
|
+
import { listCommand } from "./commands/list.js";
|
|
20
21
|
|
|
21
22
|
const program = new Command();
|
|
22
23
|
|
|
@@ -63,4 +64,10 @@ program
|
|
|
63
64
|
.description("Show sync status")
|
|
64
65
|
.action(statusCommand);
|
|
65
66
|
|
|
67
|
+
program
|
|
68
|
+
.command("list")
|
|
69
|
+
.alias("ls")
|
|
70
|
+
.description("List your packages and views")
|
|
71
|
+
.action(listCommand);
|
|
72
|
+
|
|
66
73
|
program.parse();
|