@vizamodo/viza-cli 1.4.22 → 1.4.28

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/bin/viza.js CHANGED
@@ -1,45 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from "commander";
2
+ import { createProgram } from "../src/cli/program.js";
3
3
  import { handleError } from "../src/errors/handleError.js";
4
- import { getCliVersion } from "../src/core/version.js";
5
- import { bootstrapCommand } from "../src/commands/bootstrap/index.js";
6
- import { loginAwsCommand } from "../src/commands/login/aws.js";
7
- /**
8
- * Helper: Gộp tất cả options từ root xuống sub-command
9
- */
10
- function getResolvedOptions(command) {
11
- let allOptions = {};
12
- let current = command;
13
- while (current) {
14
- allOptions = { ...current.opts(), ...allOptions };
15
- current = current.parent;
16
- }
17
- return allOptions;
18
- }
19
- const program = new Command();
20
- program
21
- .name("viza")
22
- .description("Viza CLI")
23
- .version(getCliVersion())
24
- // Global Options
25
- .option("--status", "Show status only (no execution)")
26
- .option("--remove-log", "Remove execution logs after completion", false)
27
- .option("--self-hosted", "Use self-hosted runner (viza-builder)", false);
28
- program
29
- .command("bootstrap")
30
- .description("Bootstrap configuration")
31
- .action(async (_options) => {
32
- await bootstrapCommand();
33
- });
34
- program
35
- .command("login")
36
- .description("Login to cloud providers")
37
- .command("aws")
38
- .description("Login to AWS")
39
- .option("--prod", "Use production environment")
40
- .option("--dev", "Use development environment")
41
- .action(async (_options, command) => {
42
- const fullOpts = getResolvedOptions(command);
43
- await loginAwsCommand(fullOpts);
44
- });
4
+ const program = createProgram();
45
5
  program.parseAsync(process.argv).catch(handleError);
@@ -0,0 +1,6 @@
1
+ export function registerGlobalOptions(program) {
2
+ program
3
+ .option("--status", "Show status only (no execution)")
4
+ .option("--remove-log", "Remove execution logs after completion", false)
5
+ .option("--self-hosted", "Use self-hosted runner (viza-builder)", false);
6
+ }
@@ -0,0 +1,16 @@
1
+ import { Command } from "commander";
2
+ import { getCliVersion } from "../core/version.js";
3
+ import { registerGlobalOptions } from "./options.js";
4
+ import { registerLoginCommand } from "../commands/login/register.js";
5
+ import { registerBootstrapCommand } from "../commands/bootstrap/register.js";
6
+ export function createProgram() {
7
+ const program = new Command();
8
+ program
9
+ .name("viza")
10
+ .description("Viza Command Line Interface")
11
+ .version(getCliVersion());
12
+ registerGlobalOptions(program);
13
+ registerBootstrapCommand(program);
14
+ registerLoginCommand(program);
15
+ return program;
16
+ }
@@ -0,0 +1,9 @@
1
+ export function getResolvedOptions(command) {
2
+ let allOptions = {};
3
+ let current = command;
4
+ while (current) {
5
+ allOptions = { ...current.opts(), ...allOptions };
6
+ current = current.parent;
7
+ }
8
+ return allOptions;
9
+ }
@@ -0,0 +1,16 @@
1
+ import { bootstrapCommand } from "./index.js";
2
+ /**
3
+ * Register `viza bootstrap` commands
4
+ */
5
+ export function registerBootstrapCommand(program) {
6
+ const cmd = program
7
+ .command("bootstrap")
8
+ .description("Bootstrap infrastructure or system components");
9
+ // Default bootstrap
10
+ cmd.action(async (_opts, command) => {
11
+ await bootstrapCommand();
12
+ });
13
+ // ⬇️ Sau này mở rộng rất dễ:
14
+ // registerBootstrapAwsCommand(cmd);
15
+ // registerBootstrapCloudflareCommand(cmd);
16
+ }
@@ -0,0 +1,15 @@
1
+ import { loginAwsCommand } from "./aws.js";
2
+ import { getResolvedOptions } from "../../cli/resolveOptions.js";
3
+ export function registerLoginCommand(program) {
4
+ program
5
+ .command("login")
6
+ .description("Login to cloud providers")
7
+ .command("aws")
8
+ .description("Login to AWS")
9
+ .option("--prod", "Use production environment")
10
+ .option("--dev", "Use development environment")
11
+ .action(async (_opts, command) => {
12
+ const fullOpts = getResolvedOptions(command);
13
+ await loginAwsCommand(fullOpts);
14
+ });
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/viza-cli",
3
- "version": "1.4.22",
3
+ "version": "1.4.28",
4
4
  "type": "module",
5
5
  "description": "Viza unified command line interface",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "adm-zip": "^0.5.16",
21
21
  "chalk": "^5.6.2",
22
22
  "clipboardy": "^5.1.0",
23
- "commander": "^14.0.2",
23
+ "commander": "^14.0.3",
24
24
  "figlet": "^1.10.0",
25
25
  "open": "^11.0.0",
26
26
  "prompts": "^2.4.2"