viza 1.7.48 → 1.8.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.
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../context/env.js";
2
- import { resolveResourceHubIntent } 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
  /**
5
5
  * Target teams for `viza login aws`.
@@ -29,7 +29,7 @@ const TARGET_TEAMS = {
29
29
  export async function bootstrapAgeCommand(options) {
30
30
  // 1) Resolve environment
31
31
  const env = resolveEnv(options);
32
- const intent = resolveResourceHubIntent(env);
32
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
33
33
  // Resolve allowed teams
34
34
  // - Dispatch mode: restrict by targetEnv
35
35
  // - Status mode: allow union of all env teams (read-only query)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
- import { resolveResourceHubIntent } 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
  /**
5
5
  * Target teams for `viza aws rolesanywhere bootstrap`.
@@ -22,7 +22,7 @@ const TARGET_TEAMS = {
22
22
  export async function bootstrapAwsRolesAnywhereCommand(options) {
23
23
  // 1) Resolve environment
24
24
  const env = resolveEnv(options);
25
- const intent = resolveResourceHubIntent(env);
25
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
26
26
  // 2) Resolve allowed teams (no status mode for bootstrap)
27
27
  const allowedTeams = TARGET_TEAMS[env];
28
28
  // 3) Dispatch intent (freeze)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
- import { resolveResourceHubIntent } 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
  /**
5
5
  * Target teams for `viza aws rolesanywhere bootstrap`.
@@ -26,7 +26,7 @@ const TARGET_TEAMS = {
26
26
  export async function rebootstrapAwsRolesAnywhereCommand(options) {
27
27
  // 1) Resolve environment
28
28
  const env = resolveEnv(options);
29
- const intent = resolveResourceHubIntent(env);
29
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
30
30
  // 2) Resolve allowed teams (no status mode for bootstrap)
31
31
  const allowedTeams = TARGET_TEAMS[env];
32
32
  // 3) Dispatch intent (freeze)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
- import { resolveResourceHubIntent } 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
  /**
5
5
  * Target teams for `viza aws rolesanywhere rotate`.
@@ -29,7 +29,7 @@ const TARGET_TEAMS = {
29
29
  export async function rotateAwsRolesAnywhereCommand(options) {
30
30
  // 1) Resolve environment
31
31
  const env = resolveEnv(options);
32
- const intent = resolveResourceHubIntent(env);
32
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
33
33
  // 2) Resolve allowed teams (no status mode for rotate)
34
34
  const allowedTeams = TARGET_TEAMS[env];
35
35
  // 3) Dispatch intent (freeze)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
- import { resolveResourceHubIntent } 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
  /**
5
5
  * Target teams for `viza aws rolesanywhere update-role`.
@@ -26,7 +26,7 @@ const TARGET_TEAMS = {
26
26
  export async function updateAwsRolesAnywhereRoleCommand(options) {
27
27
  // 1) Resolve environment
28
28
  const env = resolveEnv(options);
29
- const intent = resolveResourceHubIntent(env);
29
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
30
30
  // 2) Resolve allowed teams (no status mode for rotate)
31
31
  const allowedTeams = TARGET_TEAMS[env];
32
32
  // 3) Dispatch intent (freeze)
@@ -1,4 +1,4 @@
1
- import { resolveRuntimeHubIntent } from "../../../../context/hubIntent.js";
1
+ import { RUNTIME_HUB_INTENT } from "../../../../context/hubIntent.js";
2
2
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
3
3
  import { showSsoLinkMenu } from "../../../../ui/sso/awsLoginMenu.js";
4
4
  /**
@@ -23,7 +23,7 @@ const TARGET_TEAMS = [
23
23
  */
24
24
  export async function loginBillingAwsCommand(options) {
25
25
  // 1) Resolve environment
26
- const intent = resolveRuntimeHubIntent();
26
+ const intent = RUNTIME_HUB_INTENT;
27
27
  const allowedTeams = TARGET_TEAMS;
28
28
  // 5) Dispatch intent (freeze)
29
29
  const result = await dispatchIntentAndWait({
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../context/env.js";
2
- import { resolveResourceHubIntent } 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
  const TARGET_TEAMS = {
5
5
  "dev": [
@@ -26,7 +26,7 @@ const TARGET_TEAMS = {
26
26
  export async function logsCommand(runId, options) {
27
27
  // 1️⃣ Resolve environment
28
28
  const env = resolveEnv(options);
29
- const intent = resolveResourceHubIntent(env);
29
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
30
30
  // Resolve allowed teams (same contract as other commands)
31
31
  const allowedTeams = TARGET_TEAMS[env];
32
32
  // 2️⃣ Handle --app locally (do NOT dispatch)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../context/env.js";
2
- import { resolveRuntimeHubIntent } from "../../../context/hubIntent.js";
2
+ import { RUNTIME_HUB_INTENT } from "../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../core/dispatch.js";
4
4
  import { showDispatchRuns } from "./show-runs.js";
5
5
  const TARGET_TEAMS = {
@@ -27,7 +27,7 @@ const TARGET_TEAMS = {
27
27
  export async function runsCommand(options) {
28
28
  // 1️⃣ Resolve environment
29
29
  const env = resolveEnv(options);
30
- const intent = resolveRuntimeHubIntent();
30
+ const intent = RUNTIME_HUB_INTENT;
31
31
  // Resolve allowed teams (same contract as other commands)
32
32
  const allowedTeams = TARGET_TEAMS[env];
33
33
  // 2️⃣ Handle --app locally (do NOT dispatch)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
- import { resolveResourceHubIntent } 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
  /**
5
5
  * Target teams for `viza login aws`.
@@ -27,7 +27,7 @@ const TARGET_TEAMS = {
27
27
  export async function backupGithubSecretsCommand(options) {
28
28
  // 1) Resolve environment
29
29
  const env = resolveEnv(options);
30
- const intent = resolveResourceHubIntent(env);
30
+ const intent = RESOURCE_HUB_INTENT_BY_ENV;
31
31
  // Resolve allowed teams
32
32
  // - Dispatch mode: restrict by targetEnv
33
33
  // - Status mode: allow union of all env teams (read-only query)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
- import { resolveRuntimeHubIntent } from "../../../../context/hubIntent.js";
2
+ import { RUNTIME_HUB_INTENT } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
4
  /**
5
5
  * Target teams for `viza login aws`.
@@ -29,7 +29,7 @@ const TARGET_TEAMS = {
29
29
  export async function restoreGithubSecretsCommand(options) {
30
30
  // 1) Resolve environment
31
31
  const env = resolveEnv(options);
32
- const intent = resolveRuntimeHubIntent();
32
+ const intent = RUNTIME_HUB_INTENT;
33
33
  // Resolve allowed teams
34
34
  // - Dispatch mode: restrict by targetEnv
35
35
  // - Status mode: allow union of all env teams (read-only query)
@@ -30,7 +30,7 @@ export async function deployCommandHubCommand(options) {
30
30
  // 1) Resolve environment
31
31
  const env = resolveEnv(options);
32
32
  const cloudRunner = options.cloudRunner === true;
33
- const intent = resolveHubIntent(env, cloudRunner);
33
+ const intent = resolveHubIntent(cloudRunner);
34
34
  // Resolve allowed teams
35
35
  // - Dispatch mode: restrict by targetEnv
36
36
  // - Status mode: allow union of all env teams (read-only query)
@@ -1,5 +1,5 @@
1
1
  import { resolveEnv } from "../../../context/env.js";
2
- import { resolveRuntimeHubIntent } from "../../../context/hubIntent.js";
2
+ import { RUNTIME_HUB_INTENT } from "../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../core/dispatch.js";
4
4
  import { showSsoLinkMenu } from "../../../ui/sso/awsLoginMenu.js";
5
5
  /**
@@ -33,7 +33,7 @@ const TARGET_TEAMS = {
33
33
  export async function loginAwsCommand(options) {
34
34
  // 1) Resolve environment
35
35
  const env = resolveEnv(options);
36
- const intent = resolveRuntimeHubIntent();
36
+ const intent = RUNTIME_HUB_INTENT;
37
37
  // Resolve allowed teams
38
38
  // - Dispatch mode: restrict by targetEnv
39
39
  // - Status mode: allow union of all env teams (read-only query)
@@ -2,34 +2,23 @@
2
2
  /**
3
3
  * Deploy infrastructure resources (hub layer)
4
4
  */
5
- export const RESOURCE_HUB_INTENT_BY_ENV = {
6
- dev: "hub-dev",
7
- prod: "hub",
8
- };
5
+ export const RESOURCE_HUB_INTENT_BY_ENV = "hub";
6
+ /**
7
+ * Deploy infrastructure resources (deployer reserved layer)
8
+ */
9
+ export const RESOURCE_DEPLOYER_INTENT_BY_ENV = "deployer";
9
10
  /**
10
11
  * Build & publish application layer
11
12
  */
12
- export const APP_HUB_INTENT_BY_ENV = {
13
- dev: "builder",
14
- prod: "publisher",
15
- };
13
+ export const RESOURCE_BACKER_INTENT_BY_ENV = "backer";
16
14
  /**
17
15
  * Runtime command hub (worker layer)
18
16
  * Single intent for both dev and prod (env derived at gateway)
19
17
  */
20
18
  export const RUNTIME_HUB_INTENT = "hub-worker";
21
- export function resolveResourceHubIntent(env) {
22
- return RESOURCE_HUB_INTENT_BY_ENV[env];
23
- }
24
- export function resolveAppHubIntent(env) {
25
- return APP_HUB_INTENT_BY_ENV[env];
26
- }
27
- export function resolveRuntimeHubIntent() {
28
- return RUNTIME_HUB_INTENT;
29
- }
30
- export function resolveHubIntent(env, cloudRunner) {
19
+ export function resolveHubIntent(cloudRunner) {
31
20
  if (cloudRunner) {
32
- return resolveAppHubIntent(env);
21
+ return RESOURCE_BACKER_INTENT_BY_ENV;
33
22
  }
34
- return resolveResourceHubIntent(env);
23
+ return RESOURCE_HUB_INTENT_BY_ENV;
35
24
  }
@@ -11,7 +11,7 @@ import { renderRuntimeLog } from "../ui/runtimeLogRenderer.js";
11
11
  * - success + hide => no log
12
12
  * - otherwise => render log (if present)
13
13
  */
14
- function maybeRenderLog(result, policy) {
14
+ function maybeRenderLog(result, policy, currentUser) {
15
15
  // Runtime execution (hub-worker)
16
16
  if (result.kind !== "github") {
17
17
  // Respect log policy: hide means do not render runtime logs
@@ -26,7 +26,7 @@ function maybeRenderLog(result, policy) {
26
26
  return;
27
27
  }
28
28
  if (result.logBuffer) {
29
- renderLog(result.logBuffer, { status: result.status });
29
+ renderLog(result.logBuffer, { status: result.status, currentUser });
30
30
  return;
31
31
  }
32
32
  // Log artifact not available (likely GitHub log archive not ready yet)
@@ -129,10 +129,11 @@ export async function dispatchIntentAndWait(input, opts = {}) {
129
129
  // 2. Định nghĩa một hàm async để gộp toàn bộ quá trình dispatch
130
130
  const dispatchFlow = async () => {
131
131
  const handle = await dispatchIntent(input, mode); // Khởi tạo
132
- return await handle.wait(); // Đợi kết quả
132
+ const result = await handle.wait(); // Đợi kết quả
133
+ return { result, currentUser: handle.currentUser };
133
134
  };
134
135
  // Trong block try:
135
- const [result, updateInfo] = await Promise.all([
136
+ const [{ result, currentUser }, updateInfo] = await Promise.all([
136
137
  dispatchFlow(),
137
138
  Promise.race([
138
139
  updateCheckPromise,
@@ -142,7 +143,7 @@ export async function dispatchIntentAndWait(input, opts = {}) {
142
143
  // 4. Dừng spinner và in kết quả dispatch trước
143
144
  stopSpinner(spinner, result.status === "success" ? "✅ Done" : "❌ Failed");
144
145
  // 5. Render log và thông báo update
145
- maybeRenderLog(result, policy);
146
+ maybeRenderLog(result, policy, currentUser);
146
147
  if (result.status !== "success") {
147
148
  throw new Error(`Dispatch failed: ${result.status}`);
148
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viza",
3
- "version": "1.7.48",
3
+ "version": "1.8.1",
4
4
  "type": "module",
5
5
  "description": "Viza unified command line interface",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "release:full": "rm -rf dist && npx npm-check-updates -u && npm install && git add package.json package-lock.json && git commit -m 'chore(deps): auto update dependencies before release' || echo 'No changes' && node versioning.js && npm login && npm publish --tag latest --access public && git push"
18
18
  },
19
19
  "dependencies": {
20
- "@vizamodo/viza-dispatcher": "^1.5.27",
20
+ "@vizamodo/viza-dispatcher": "^1.5.29",
21
21
  "adm-zip": "^0.5.16",
22
22
  "chalk": "^5.6.2",
23
23
  "clipboardy": "^5.3.1",