viza 1.8.30 → 1.8.32

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
@@ -4,8 +4,14 @@ import { handleError } from "../src/errors/handleError.js";
4
4
  import { resolveBinaryContext } from "../src/context/resolveBinaryContext.js";
5
5
  import { setEnv } from "../src/context/env.js";
6
6
  import { setHubIntent } from "../src/context/hubIntent.js";
7
+ import { setCommand } from "../src/context/command.js";
8
+ import path from "path";
7
9
  (async () => {
8
10
  const { env, runner } = resolveBinaryContext();
11
+ const binName = path.basename(process.argv[1] || "viza");
12
+ const args = process.argv.slice(2).join(" ");
13
+ const fullCommand = args ? `${binName} ${args}` : binName;
14
+ setCommand(fullCommand);
9
15
  setEnv(env);
10
16
  setHubIntent(runner);
11
17
  const program = await createProgram();
@@ -1,5 +1,5 @@
1
1
  import { getEnv } from "../../../context/env.js";
2
- import { resolveHubIntent } from "../../../context/hubIntent.js";
2
+ import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../core/dispatch.js";
4
4
  import { policy } from "./policy.js";
5
5
  /**
@@ -15,7 +15,7 @@ import { policy } from "./policy.js";
15
15
  export async function bootstrapAgeCommand(options) {
16
16
  // 1) Resolve environment
17
17
  const env = getEnv();
18
- const intent = resolveHubIntent();
18
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
19
19
  // Resolve allowed teams
20
20
  // - Dispatch mode: restrict by targetEnv
21
21
  // - Status mode: allow union of all env teams (read-only query)
@@ -1,5 +1,5 @@
1
1
  import { getEnv } from "../../../../context/env.js";
2
- import { resolveHubIntent } from "../../../../context/hubIntent.js";
2
+ import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
4
  import { policy } from "./policy.js";
5
5
  /**
@@ -14,7 +14,7 @@ import { policy } from "./policy.js";
14
14
  export async function bootstrapAwsRolesAnywhereCommand(options) {
15
15
  // 1) Resolve environment
16
16
  const env = getEnv();
17
- const intent = resolveHubIntent();
17
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
18
18
  // 2) Resolve allowed teams (no status mode for bootstrap)
19
19
  const allowedTeams = Array.from(policy.byEnv[env]);
20
20
  // 3) Dispatch intent (freeze)
@@ -1,5 +1,5 @@
1
1
  import { getEnv } from "../../../../context/env.js";
2
- import { resolveHubIntent } from "../../../../context/hubIntent.js";
2
+ import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
4
  import { policy } from "./policy.js";
5
5
  /**
@@ -14,7 +14,7 @@ import { policy } from "./policy.js";
14
14
  export async function rebootstrapAwsRolesAnywhereCommand(options) {
15
15
  // 1) Resolve environment
16
16
  const env = getEnv();
17
- const intent = resolveHubIntent();
17
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
18
18
  // 2) Resolve allowed teams (no status mode for bootstrap)
19
19
  const allowedTeams = Array.from(policy.byEnv[env]);
20
20
  // 3) Dispatch intent (freeze)
@@ -1,5 +1,5 @@
1
1
  import { getEnv } from "../../../../context/env.js";
2
- import { resolveHubIntent } from "../../../../context/hubIntent.js";
2
+ import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
4
  import { policy } from "./policy.js";
5
5
  /**
@@ -14,7 +14,7 @@ import { policy } from "./policy.js";
14
14
  export async function rotateAwsRolesAnywhereCommand(options) {
15
15
  // 1) Resolve environment
16
16
  const env = getEnv();
17
- const intent = resolveHubIntent();
17
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
18
18
  // 2) Resolve allowed teams (no status mode for rotate)
19
19
  const allowedTeams = Array.from(policy.byEnv[env]);
20
20
  // 3) Dispatch intent (freeze)
@@ -1,5 +1,5 @@
1
1
  import { getEnv } from "../../../../context/env.js";
2
- import { resolveHubIntent } from "../../../../context/hubIntent.js";
2
+ import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
4
  import { policy } from "./policy.js";
5
5
  /**
@@ -14,7 +14,7 @@ import { policy } from "./policy.js";
14
14
  export async function updateAwsRolesAnywhereRoleCommand(options) {
15
15
  // 1) Resolve environment
16
16
  const env = getEnv();
17
- const intent = resolveHubIntent();
17
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
18
18
  // 2) Resolve allowed teams (no status mode for rotate)
19
19
  const allowedTeams = Array.from(policy.byEnv[env]);
20
20
  // 3) Dispatch intent (freeze)
@@ -0,0 +1,7 @@
1
+ let currentCommand;
2
+ export function setCommand(cmd) {
3
+ currentCommand = cmd;
4
+ }
5
+ export function getCommand() {
6
+ return currentCommand;
7
+ }
@@ -9,7 +9,7 @@ export function getRunner() {
9
9
  /**
10
10
  * Deploy infrastructure resources (hub layer)
11
11
  */
12
- const RESOURCE_HUB_INTENT_BY_ENV = "hub";
12
+ export const RESOURCE_HUB_INTENT_BY_ENV = "hub";
13
13
  /**
14
14
  * Deploy infrastructure resources (deployer reserved layer)
15
15
  */
@@ -1,5 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import figlet from "figlet";
3
+ import { getCommand } from "../context/command.js";
3
4
  const ENV_BANNER_CONFIG = {
4
5
  "dev": { title: "Viza Development", color: "cyanBright" },
5
6
  "prod": { title: "Viza Production", color: "yellowBright" },
@@ -20,13 +21,15 @@ function pickBannerConfig(env) {
20
21
  export function showDispatchBanner(input, meta, status) {
21
22
  const cfg = pickBannerConfig(input.targetEnv);
22
23
  // Default commandType: commandType (or caller-provided commandType)
23
- const commandType = `${input.commandType}`;
24
+ const fullCommand = getCommand();
25
+ const commandType = fullCommand ?? `${input.commandType}`;
24
26
  showBanner({
25
27
  title: cfg.title,
26
28
  commandType,
27
29
  color: cfg.color,
28
30
  env: input.targetEnv,
29
31
  status,
32
+ intent: input.intent,
30
33
  runner: input.selfHosted
31
34
  ? {
32
35
  type: "selfhosted",
@@ -38,8 +41,46 @@ export function showDispatchBanner(input, meta, status) {
38
41
  }
39
42
  });
40
43
  }
44
+ function formatCommandTokens(cmd, maxLen = 90) {
45
+ const tokens = cmd.trim().split(/\s+/);
46
+ const kept = [];
47
+ let length = 0;
48
+ for (let i = 0; i < tokens.length; i++) {
49
+ const t = tokens[i];
50
+ const addLen = (kept.length ? 1 : 0) + t.length; // space + token
51
+ if (length + addLen > maxLen)
52
+ break;
53
+ kept.push(t);
54
+ length += addLen;
55
+ }
56
+ const remaining = tokens.length - kept.length;
57
+ return { kept, remaining };
58
+ }
59
+ function renderCommand(cmd, status) {
60
+ const { kept, remaining } = formatCommandTokens(cmd, 90);
61
+ // semantic highlight: [bin] [subcommand] [rest...]
62
+ const main = kept[0] ?? "";
63
+ const sub = kept[1];
64
+ const rest = kept.slice(2);
65
+ const parts = [];
66
+ if (main)
67
+ parts.push(chalk.magentaBright(main));
68
+ if (sub)
69
+ parts.push(chalk.yellowBright(sub));
70
+ if (rest.length)
71
+ parts.push(chalk.cyan(rest.join(" ")));
72
+ let line = parts.join(" ");
73
+ if (remaining > 0) {
74
+ line += chalk.gray(` … (+${remaining} more)`);
75
+ }
76
+ return [
77
+ chalk.gray("Command:"),
78
+ line,
79
+ status ? chalk.gray("[status checking]") : "",
80
+ ].join(" ");
81
+ }
41
82
  export function showBanner(opts) {
42
- const { title, commandType, status, color = "cyanBright", runner, meta } = opts;
83
+ const { title, commandType, status, color = "cyanBright", intent, runner, meta } = opts;
43
84
  process.stdout.write("\u001b[2J\u001b[3J\u001b[H");
44
85
  const font = opts.env === "prod"
45
86
  ? "Ogre"
@@ -49,15 +90,15 @@ export function showBanner(opts) {
49
90
  const bannerText = figlet.textSync(title, { font });
50
91
  console.log(chalk[color](bannerText));
51
92
  if (commandType) {
52
- console.log(chalk.gray("Command:"), chalk.magentaBright(commandType), (status ? chalk.gray("[status checking]") : ""));
93
+ console.log(renderCommand(commandType, status));
53
94
  }
54
95
  // Environment line removed; replaced by user-friendly info line below
55
96
  if (runner) {
56
97
  if (runner.type === "github") {
57
- console.log(chalk.gray("Runner:"), chalk.yellowBright("GitHub-hosted"));
98
+ console.log(chalk.gray("Runner:"), chalk.yellowBright("GitHub-hosted"), intent ? chalk.gray(`(${intent})`) : "");
58
99
  }
59
100
  else {
60
- console.log(chalk.gray("Runner:"), chalk.yellowBright("Self-hosted"), runner.label ? chalk.gray(" | label:") : "", runner.label ? chalk.cyan(runner.label) : "");
101
+ console.log(chalk.gray("Runner:"), chalk.yellowBright("Self-hosted"), intent ? chalk.gray(`(${intent})`) : "", runner.label ? chalk.gray(" | label:") : "", runner.label ? chalk.cyan(runner.label) : "");
61
102
  }
62
103
  }
63
104
  // User-friendly info line
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viza",
3
- "version": "1.8.30",
3
+ "version": "1.8.32",
4
4
  "type": "module",
5
5
  "description": "Viza unified command line interface",
6
6
  "bin": {