viza 1.8.4 → 1.8.12

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.
Files changed (34) hide show
  1. package/dist/bin/viza.js +6 -0
  2. package/dist/src/cli/resolveOptions.js +9 -3
  3. package/dist/src/commands/age/bootstrap/bootstrap.js +2 -21
  4. package/dist/src/commands/age/bootstrap/policy.js +12 -0
  5. package/dist/src/commands/aws/rolesanywhere/bootstrap/bootstrap.js +2 -10
  6. package/dist/src/commands/aws/rolesanywhere/bootstrap/policy.js +6 -0
  7. package/dist/src/commands/aws/rolesanywhere/rebootstrap/policy.js +6 -0
  8. package/dist/src/commands/aws/rolesanywhere/rebootstrap/rebootstrap.js +2 -14
  9. package/dist/src/commands/aws/rolesanywhere/rotate/policy.js +13 -0
  10. package/dist/src/commands/aws/rolesanywhere/rotate/rotate.js +2 -17
  11. package/dist/src/commands/aws/rolesanywhere/update-role/policy.js +6 -0
  12. package/dist/src/commands/aws/rolesanywhere/update-role/register.js +1 -0
  13. package/dist/src/commands/aws/rolesanywhere/update-role/update-role.js +4 -16
  14. package/dist/src/commands/billing/login/aws/aws.js +2 -11
  15. package/dist/src/commands/billing/login/aws/policy.js +9 -0
  16. package/dist/src/commands/dispatch/logs/logs.js +2 -15
  17. package/dist/src/commands/dispatch/logs/policy.js +16 -0
  18. package/dist/src/commands/dispatch/runs/policy.js +16 -0
  19. package/dist/src/commands/dispatch/runs/runs.js +2 -15
  20. package/dist/src/commands/github/secrets/backup/backup.js +2 -19
  21. package/dist/src/commands/github/secrets/backup/policy.js +10 -0
  22. package/dist/src/commands/github/secrets/restore/policy.js +12 -0
  23. package/dist/src/commands/github/secrets/restore/register.js +1 -0
  24. package/dist/src/commands/github/secrets/restore/restore.js +18 -25
  25. package/dist/src/commands/infra/deploy/command-hub/command-hub.js +8 -28
  26. package/dist/src/commands/infra/deploy/command-hub/policy.js +12 -0
  27. package/dist/src/commands/infra/deploy/command-hub/register.js +0 -3
  28. package/dist/src/commands/login/aws/aws.js +2 -24
  29. package/dist/src/commands/login/aws/policy.js +15 -0
  30. package/dist/src/context/env.js +8 -0
  31. package/dist/src/context/hubIntent.js +11 -3
  32. package/dist/src/context/resolveBinaryContext.js +11 -0
  33. package/dist/src/types/runner.js +1 -1
  34. package/package.json +7 -2
package/dist/bin/viza.js CHANGED
@@ -1,5 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { createProgram } from "../src/cli/program.js";
3
3
  import { handleError } from "../src/errors/handleError.js";
4
+ import { resolveBinaryContext } from "../src/context/resolveBinaryContext.js";
5
+ import { setEnv } from "../src/context/env.js";
6
+ import { setHubIntent } from "../src/context/hubIntent.js";
7
+ const { env, runner } = resolveBinaryContext();
8
+ setEnv(env);
9
+ setHubIntent(runner);
4
10
  const program = createProgram();
5
11
  program.parseAsync(process.argv).catch(handleError);
@@ -1,9 +1,15 @@
1
1
  export function getResolvedOptions(command) {
2
- let allOptions = {};
2
+ // Commander v10+ provides optsWithGlobals which already merges parent options
3
+ const anyCmd = command;
4
+ if (typeof anyCmd.optsWithGlobals === "function") {
5
+ return anyCmd.optsWithGlobals();
6
+ }
7
+ // Fallback for older commander versions
8
+ const resolved = {};
3
9
  let current = command;
4
10
  while (current) {
5
- allOptions = { ...current.opts(), ...allOptions };
11
+ Object.assign(resolved, current.opts());
6
12
  current = current.parent;
7
13
  }
8
- return allOptions;
14
+ return resolved;
9
15
  }
@@ -1,21 +1,7 @@
1
1
  import { resolveEnv } from "../../../context/env.js";
2
2
  import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza login aws`.
6
- * This is a CLI-only UX constraint for fail-fast validation.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- "dev": [
11
- "viza-admin",
12
- "viza-super"
13
- ],
14
- "prod": [
15
- "viza-admin",
16
- "viza-super"
17
- ]
18
- };
4
+ import { policy } from "./policy.js";
19
5
  /**
20
6
  * viza login aws
21
7
  *
@@ -33,12 +19,7 @@ export async function bootstrapAgeCommand(options) {
33
19
  // Resolve allowed teams
34
20
  // - Dispatch mode: restrict by targetEnv
35
21
  // - Status mode: allow union of all env teams (read-only query)
36
- const allowedTeams = options.status === true && env === "dev"
37
- ? Array.from(new Set([
38
- ...TARGET_TEAMS.dev,
39
- ...TARGET_TEAMS.prod,
40
- ]))
41
- : TARGET_TEAMS[env];
22
+ const allowedTeams = Array.from(policy.byEnv[env]);
42
23
  // 5) Dispatch intent (freeze)
43
24
  await dispatchIntentAndWait({
44
25
  intent,
@@ -0,0 +1,12 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "dev": [
4
+ "viza-admin",
5
+ "viza-super"
6
+ ],
7
+ "prod": [
8
+ "viza-admin",
9
+ "viza-super"
10
+ ]
11
+ }
12
+ };
@@ -1,15 +1,7 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
2
  import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza aws rolesanywhere bootstrap`.
6
- * CLI-only fail-fast UX constraint.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- dev: ["viza-super"],
11
- prod: ["viza-super"],
12
- };
4
+ import { policy } from "./policy.js";
13
5
  /**
14
6
  * viza aws rolesanywhere bootstrap
15
7
  *
@@ -24,7 +16,7 @@ export async function bootstrapAwsRolesAnywhereCommand(options) {
24
16
  const env = resolveEnv(options);
25
17
  const intent = RESOURCE_HUB_INTENT_BY_ENV;
26
18
  // 2) Resolve allowed teams (no status mode for bootstrap)
27
- const allowedTeams = TARGET_TEAMS[env];
19
+ const allowedTeams = Array.from(policy.byEnv[env]);
28
20
  // 3) Dispatch intent (freeze)
29
21
  await dispatchIntentAndWait({
30
22
  intent,
@@ -0,0 +1,6 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ dev: ["viza-super"],
4
+ prod: ["viza-super"],
5
+ }
6
+ };
@@ -0,0 +1,6 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ dev: ["viza-super"],
4
+ prod: ["viza-super"],
5
+ }
6
+ };
@@ -1,19 +1,7 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
2
  import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza aws rolesanywhere bootstrap`.
6
- * CLI-only fail-fast UX constraint.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- "dev": [
11
- "viza-super"
12
- ],
13
- "prod": [
14
- "viza-super"
15
- ]
16
- };
4
+ import { policy } from "./policy.js";
17
5
  /**
18
6
  * viza aws rolesanywhere bootstrap
19
7
  *
@@ -28,7 +16,7 @@ export async function rebootstrapAwsRolesAnywhereCommand(options) {
28
16
  const env = resolveEnv(options);
29
17
  const intent = RESOURCE_HUB_INTENT_BY_ENV;
30
18
  // 2) Resolve allowed teams (no status mode for bootstrap)
31
- const allowedTeams = TARGET_TEAMS[env];
19
+ const allowedTeams = Array.from(policy.byEnv[env]);
32
20
  // 3) Dispatch intent (freeze)
33
21
  await dispatchIntentAndWait({
34
22
  intent,
@@ -0,0 +1,13 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "dev": [
4
+ "viza-manager",
5
+ "viza-admin",
6
+ "viza-super"
7
+ ],
8
+ "prod": [
9
+ "viza-admin",
10
+ "viza-super"
11
+ ]
12
+ }
13
+ };
@@ -1,22 +1,7 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
2
  import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza aws rolesanywhere rotate`.
6
- * CLI-only fail-fast UX constraint.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- "dev": [
11
- "viza-manager",
12
- "viza-admin",
13
- "viza-super"
14
- ],
15
- "prod": [
16
- "viza-admin",
17
- "viza-super"
18
- ]
19
- };
4
+ import { policy } from "./policy.js";
20
5
  /**
21
6
  * viza aws rolesanywhere rotate
22
7
  *
@@ -31,7 +16,7 @@ export async function rotateAwsRolesAnywhereCommand(options) {
31
16
  const env = resolveEnv(options);
32
17
  const intent = RESOURCE_HUB_INTENT_BY_ENV;
33
18
  // 2) Resolve allowed teams (no status mode for rotate)
34
- const allowedTeams = TARGET_TEAMS[env];
19
+ const allowedTeams = Array.from(policy.byEnv[env]);
35
20
  // 3) Dispatch intent (freeze)
36
21
  await dispatchIntentAndWait({
37
22
  intent,
@@ -0,0 +1,6 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ dev: ["viza-super"],
4
+ prod: ["viza-super"],
5
+ }
6
+ };
@@ -6,6 +6,7 @@ export function registerAwsRolesAnywhereUpdateRole(program) {
6
6
  .description("Update AWS RolesAnywhere IAM role policies")
7
7
  .option("--prod", "Use production environment")
8
8
  .option("--dev", "Use development environment")
9
+ .option("--runner <type>", "Execution runner (hub | deployer | builder)", "hub")
9
10
  .action(async (_opts, command) => {
10
11
  const fullOpts = getResolvedOptions(command);
11
12
  await updateAwsRolesAnywhereRoleCommand(fullOpts);
@@ -1,19 +1,7 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
- import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
2
+ import { resolveHubIntent } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza aws rolesanywhere update-role`.
6
- * CLI-only fail-fast UX constraint.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- "dev": [
11
- "viza-super"
12
- ],
13
- "prod": [
14
- "viza-super"
15
- ]
16
- };
4
+ import { policy } from "./policy.js";
17
5
  /**
18
6
  * viza aws rolesanywhere update-role
19
7
  *
@@ -26,9 +14,9 @@ const TARGET_TEAMS = {
26
14
  export async function updateAwsRolesAnywhereRoleCommand(options) {
27
15
  // 1) Resolve environment
28
16
  const env = resolveEnv(options);
29
- const intent = RESOURCE_HUB_INTENT_BY_ENV;
17
+ const intent = resolveHubIntent(options.runner);
30
18
  // 2) Resolve allowed teams (no status mode for rotate)
31
- const allowedTeams = TARGET_TEAMS[env];
19
+ const allowedTeams = Array.from(policy.byEnv[env]);
32
20
  // 3) Dispatch intent (freeze)
33
21
  await dispatchIntentAndWait({
34
22
  intent,
@@ -1,16 +1,7 @@
1
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
- /**
5
- * Target teams for `viza login aws`.
6
- * This is a CLI-only UX constraint for fail-fast validation.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = [
10
- "viza-billing",
11
- "viza-admin",
12
- "viza-super",
13
- ];
4
+ import { policy } from "./policy.js";
14
5
  /**
15
6
  * viza login aws
16
7
  *
@@ -24,7 +15,7 @@ const TARGET_TEAMS = [
24
15
  export async function loginBillingAwsCommand(options) {
25
16
  // 1) Resolve environment
26
17
  const intent = RUNTIME_HUB_INTENT;
27
- const allowedTeams = TARGET_TEAMS;
18
+ const allowedTeams = Array.from(policy.byEnv["prod"]);
28
19
  // 5) Dispatch intent (freeze)
29
20
  const result = await dispatchIntentAndWait({
30
21
  intent,
@@ -0,0 +1,9 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "prod": [
4
+ "viza-billing",
5
+ "viza-admin",
6
+ "viza-super",
7
+ ]
8
+ }
9
+ };
@@ -1,20 +1,7 @@
1
1
  import { resolveEnv } from "../../../context/env.js";
2
2
  import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../core/dispatch.js";
4
- const TARGET_TEAMS = {
5
- "dev": [
6
- "viza-designer",
7
- "viza-deployer",
8
- "viza-manager",
9
- "viza-admin",
10
- "viza-super"
11
- ],
12
- "prod": [
13
- "viza-publisher",
14
- "viza-admin",
15
- "viza-super"
16
- ]
17
- };
4
+ import { policy } from "./policy.js";
18
5
  /**
19
6
  * viza dispatch logs <runId>
20
7
  *
@@ -28,7 +15,7 @@ export async function logsCommand(runId, options) {
28
15
  const env = resolveEnv(options);
29
16
  const intent = RESOURCE_HUB_INTENT_BY_ENV;
30
17
  // Resolve allowed teams (same contract as other commands)
31
- const allowedTeams = TARGET_TEAMS[env];
18
+ const allowedTeams = Array.from(policy.byEnv[env]);
32
19
  // 2️⃣ Handle --app locally (do NOT dispatch)
33
20
  if (options.app === true) {
34
21
  const url = env === "prod"
@@ -0,0 +1,16 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "dev": [
4
+ "viza-designer",
5
+ "viza-deployer",
6
+ "viza-manager",
7
+ "viza-admin",
8
+ "viza-super"
9
+ ],
10
+ "prod": [
11
+ "viza-publisher",
12
+ "viza-admin",
13
+ "viza-super"
14
+ ]
15
+ }
16
+ };
@@ -0,0 +1,16 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "dev": [
4
+ "viza-designer",
5
+ "viza-deployer",
6
+ "viza-manager",
7
+ "viza-admin",
8
+ "viza-super"
9
+ ],
10
+ "prod": [
11
+ "viza-publisher",
12
+ "viza-admin",
13
+ "viza-super"
14
+ ]
15
+ }
16
+ };
@@ -1,21 +1,8 @@
1
1
  import { resolveEnv } from "../../../context/env.js";
2
2
  import { RUNTIME_HUB_INTENT } from "../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../core/dispatch.js";
4
+ import { policy } from "./policy.js";
4
5
  import { showDispatchRuns } from "./show-runs.js";
5
- const TARGET_TEAMS = {
6
- "dev": [
7
- "viza-designer",
8
- "viza-deployer",
9
- "viza-manager",
10
- "viza-admin",
11
- "viza-super"
12
- ],
13
- "prod": [
14
- "viza-publisher",
15
- "viza-admin",
16
- "viza-super"
17
- ]
18
- };
19
6
  /**
20
7
  * viza dispatch runs
21
8
  *
@@ -29,7 +16,7 @@ export async function runsCommand(options) {
29
16
  const env = resolveEnv(options);
30
17
  const intent = RUNTIME_HUB_INTENT;
31
18
  // Resolve allowed teams (same contract as other commands)
32
- const allowedTeams = TARGET_TEAMS[env];
19
+ const allowedTeams = Array.from(policy.byEnv[env]);
33
20
  // 2️⃣ Handle --app locally (do NOT dispatch)
34
21
  if (options.app === true) {
35
22
  const url = env === "prod"
@@ -1,19 +1,7 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
2
  import { RESOURCE_HUB_INTENT_BY_ENV } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza login aws`.
6
- * This is a CLI-only UX constraint for fail-fast validation.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- "dev": [
11
- "viza-super"
12
- ],
13
- "prod": [
14
- "viza-super"
15
- ]
16
- };
4
+ import { policy } from "./policy.js";
17
5
  /**
18
6
  * viza github secrets backup
19
7
  *
@@ -31,12 +19,7 @@ export async function backupGithubSecretsCommand(options) {
31
19
  // Resolve allowed teams
32
20
  // - Dispatch mode: restrict by targetEnv
33
21
  // - Status mode: allow union of all env teams (read-only query)
34
- const allowedTeams = options.status === true && env === "dev"
35
- ? Array.from(new Set([
36
- ...TARGET_TEAMS.dev,
37
- ...TARGET_TEAMS.prod,
38
- ]))
39
- : TARGET_TEAMS[env];
22
+ const allowedTeams = Array.from(policy.byEnv[env]);
40
23
  // 5) Dispatch intent (freeze)
41
24
  await dispatchIntentAndWait({
42
25
  intent,
@@ -0,0 +1,10 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "dev": [
4
+ "viza-super"
5
+ ],
6
+ "prod": [
7
+ "viza-super"
8
+ ]
9
+ }
10
+ };
@@ -0,0 +1,12 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "dev": [
4
+ "viza-admin",
5
+ "viza-super"
6
+ ],
7
+ "prod": [
8
+ "viza-admin",
9
+ "viza-super"
10
+ ]
11
+ }
12
+ };
@@ -14,6 +14,7 @@ export function registerGithubSecretsRestoreCommand(program) {
14
14
  .option("--infra", "Restore configuration for Modo-Infra hub repositories")
15
15
  .option("--builder", "Restore configuration for build/publish app repositories")
16
16
  .option("--deployer", "Restore configuration for deployer repositories (Modo-Front / Modo-Back)")
17
+ .option("--all", "Restore configuration for all targets (core, infra, builder, deployer)")
17
18
  .action(async (_opts, command) => {
18
19
  const fullOpts = getResolvedOptions(command);
19
20
  await restoreGithubSecretsCommand(fullOpts);
@@ -1,21 +1,7 @@
1
1
  import { resolveEnv } from "../../../../context/env.js";
2
2
  import { RUNTIME_HUB_INTENT } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza login aws`.
6
- * This is a CLI-only UX constraint for fail-fast validation.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- "dev": [
11
- "viza-admin",
12
- "viza-super"
13
- ],
14
- "prod": [
15
- "viza-admin",
16
- "viza-super"
17
- ]
18
- };
4
+ import { policy } from "./policy.js";
19
5
  /**
20
6
  * viza github secrets restore
21
7
  *
@@ -33,22 +19,29 @@ export async function restoreGithubSecretsCommand(options) {
33
19
  // Resolve allowed teams
34
20
  // - Dispatch mode: restrict by targetEnv
35
21
  // - Status mode: allow union of all env teams (read-only query)
36
- const allowedTeams = options.status === true && env === "dev"
37
- ? Array.from(new Set([
38
- ...TARGET_TEAMS.dev,
39
- ...TARGET_TEAMS.prod,
40
- ]))
41
- : TARGET_TEAMS[env];
22
+ const allowedTeams = Array.from(policy.byEnv[env]);
42
23
  // Resolve domain restore flags (forward to hub)
43
24
  const payload = {};
44
- if (options.core)
25
+ if (options.all) {
45
26
  payload.core = true;
46
- if (options.infra)
47
27
  payload.infra = true;
48
- if (options.builder)
49
28
  payload.builder = true;
50
- if (options.deployer)
51
29
  payload.deployer = true;
30
+ }
31
+ else {
32
+ if (options.core)
33
+ payload.core = true;
34
+ if (options.infra)
35
+ payload.infra = true;
36
+ if (options.builder)
37
+ payload.builder = true;
38
+ if (options.deployer)
39
+ payload.deployer = true;
40
+ }
41
+ // Fail fast if no domain flags were provided
42
+ if (Object.keys(payload).length === 0) {
43
+ throw new Error("No restore target specified. Use one of: --core, --infra, --builder, --deployer, or --all");
44
+ }
52
45
  // 5) Dispatch intent (freeze)
53
46
  await dispatchIntentAndWait({
54
47
  intent,
@@ -1,21 +1,7 @@
1
- import { resolveEnv } from "../../../../context/env.js";
1
+ import { getEnv } from "../../../../context/env.js";
2
2
  import { resolveHubIntent } from "../../../../context/hubIntent.js";
3
3
  import { dispatchIntentAndWait } from "../../../../core/dispatch.js";
4
- /**
5
- * Target teams for `viza login aws`.
6
- * This is a CLI-only UX constraint for fail-fast validation.
7
- * NOT a policy and MUST NOT be sent to gateway.
8
- */
9
- const TARGET_TEAMS = {
10
- "dev": [
11
- "viza-admin",
12
- "viza-super"
13
- ],
14
- "prod": [
15
- "viza-admin",
16
- "viza-super"
17
- ]
18
- };
4
+ import { policy } from "./policy.js";
19
5
  /**
20
6
  * viza login aws
21
7
  *
@@ -27,18 +13,12 @@ const TARGET_TEAMS = {
27
13
  * 5) Dispatch frozen intent to gateway
28
14
  */
29
15
  export async function deployCommandHubCommand(options) {
30
- // 1) Resolve environment
31
- const env = resolveEnv(options);
32
- const intent = resolveHubIntent(options.runner);
33
- // Resolve allowed teams
34
- // - Dispatch mode: restrict by targetEnv
35
- // - Status mode: allow union of all env teams (read-only query)
36
- const allowedTeams = options.status === true && env === "dev"
37
- ? Array.from(new Set([
38
- ...TARGET_TEAMS.dev,
39
- ...TARGET_TEAMS.prod,
40
- ]))
41
- : TARGET_TEAMS[env];
16
+ // 1) Resolve environment from global CLI context
17
+ const env = getEnv();
18
+ const intent = resolveHubIntent();
19
+ // Resolve allowed teams for the current environment only.
20
+ // CLI performs a fail-fast UX check but must still respect env boundaries.
21
+ const allowedTeams = Array.from(policy.byEnv[env]);
42
22
  // 5) Dispatch intent (freeze)
43
23
  await dispatchIntentAndWait({
44
24
  intent,
@@ -0,0 +1,12 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ dev: [
4
+ "viza-admin",
5
+ "viza-super"
6
+ ],
7
+ prod: [
8
+ "viza-admin",
9
+ "viza-super"
10
+ ]
11
+ }
12
+ };
@@ -8,9 +8,6 @@ export function registerCommandHubDeployCommand(program) {
8
8
  program
9
9
  .command("command-hub")
10
10
  .description("Deploy command hub worker to Cloudflare")
11
- .option("--prod", "Use production environment")
12
- .option("--dev", "Use development environment")
13
- .option("--runner <type>", "Execution runner (hub | deployer | backer)", "hub")
14
11
  .action(async (_opts, command) => {
15
12
  const fullOpts = getResolvedOptions(command);
16
13
  await deployCommandHubCommand(fullOpts);
@@ -2,24 +2,7 @@ import { resolveEnv } from "../../../context/env.js";
2
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
- /**
6
- * Target teams for `viza login aws`.
7
- * This is a CLI-only UX constraint for fail-fast validation.
8
- * NOT a policy and MUST NOT be sent to gateway.
9
- */
10
- const TARGET_TEAMS = {
11
- "dev": [
12
- "viza-deployer",
13
- "viza-manager",
14
- "viza-admin",
15
- "viza-super"
16
- ],
17
- "prod": [
18
- "viza-publisher",
19
- "viza-admin",
20
- "viza-super"
21
- ]
22
- };
5
+ import { policy } from "./policy.js";
23
6
  /**
24
7
  * viza login aws
25
8
  *
@@ -37,12 +20,7 @@ export async function loginAwsCommand(options) {
37
20
  // Resolve allowed teams
38
21
  // - Dispatch mode: restrict by targetEnv
39
22
  // - Status mode: allow union of all env teams (read-only query)
40
- const allowedTeams = options.status === true && env === "dev"
41
- ? Array.from(new Set([
42
- ...TARGET_TEAMS.dev,
43
- ...TARGET_TEAMS.prod,
44
- ]))
45
- : TARGET_TEAMS[env];
23
+ const allowedTeams = Array.from(policy.byEnv[env]);
46
24
  // 5) Dispatch intent (freeze)
47
25
  const result = await dispatchIntentAndWait({
48
26
  intent,
@@ -0,0 +1,15 @@
1
+ export const policy = {
2
+ byEnv: {
3
+ "dev": [
4
+ "viza-deployer",
5
+ "viza-manager",
6
+ "viza-admin",
7
+ "viza-super"
8
+ ],
9
+ "prod": [
10
+ "viza-publisher",
11
+ "viza-admin",
12
+ "viza-super"
13
+ ]
14
+ }
15
+ };
@@ -1,3 +1,11 @@
1
+ let currentEnv = "dev";
2
+ export function setEnv(env) {
3
+ currentEnv = env;
4
+ }
5
+ export function getEnv() {
6
+ return currentEnv;
7
+ }
8
+ // Optional helper if some legacy code still uses flags
1
9
  export function resolveEnv(flags, defaultEnv = "dev") {
2
10
  if (flags.prod && flags.dev) {
3
11
  throw new Error("Conflicting flags: --prod and --dev cannot be used together");
@@ -1,4 +1,11 @@
1
1
  // src/commands/_shared/hubIntent.ts
2
+ let currentRunner = "hub";
3
+ export function setHubIntent(runner) {
4
+ currentRunner = runner;
5
+ }
6
+ export function getRunner() {
7
+ return currentRunner;
8
+ }
2
9
  /**
3
10
  * Deploy infrastructure resources (hub layer)
4
11
  */
@@ -10,15 +17,16 @@ export const RESOURCE_DEPLOYER_INTENT_BY_ENV = "deployer";
10
17
  /**
11
18
  * Build & publish application layer
12
19
  */
13
- export const RESOURCE_BACKER_INTENT_BY_ENV = "backer";
20
+ export const RESOURCE_BACKER_INTENT_BY_ENV = "builder";
14
21
  /**
15
22
  * Runtime command hub (worker layer)
16
23
  * Single intent for both dev and prod (env derived at gateway)
17
24
  */
18
25
  export const RUNTIME_HUB_INTENT = "hub-worker";
19
26
  export function resolveHubIntent(runner) {
20
- switch (runner) {
21
- case "backer":
27
+ const r = runner ?? currentRunner;
28
+ switch (r) {
29
+ case "builder":
22
30
  return RESOURCE_BACKER_INTENT_BY_ENV;
23
31
  case "deployer":
24
32
  return RESOURCE_DEPLOYER_INTENT_BY_ENV;
@@ -0,0 +1,11 @@
1
+ import path from "node:path";
2
+ export function resolveBinaryContext() {
3
+ const bin = path.basename(process.argv[1]);
4
+ const env = bin.startsWith("xviza") ? "prod" : "dev";
5
+ let runner = "hub";
6
+ if (bin.includes("builder"))
7
+ runner = "builder";
8
+ if (bin.includes("deployer"))
9
+ runner = "deployer";
10
+ return { env, runner };
11
+ }
@@ -1 +1 @@
1
- export const RUNNER_TYPES = ["hub", "deployer", "backer"];
1
+ export const RUNNER_TYPES = ["hub", "deployer", "builder"];
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "viza",
3
- "version": "1.8.4",
3
+ "version": "1.8.12",
4
4
  "type": "module",
5
5
  "description": "Viza unified command line interface",
6
6
  "bin": {
7
- "viza": "dist/bin/viza.js"
7
+ "viza": "dist/bin/viza.js",
8
+ "viza-builder": "dist/bin/viza.js",
9
+ "viza-deployer": "dist/bin/viza.js",
10
+ "xviza": "dist/bin/viza.js",
11
+ "xviza-builder": "dist/bin/viza.js",
12
+ "xviza-deployer": "dist/bin/viza.js"
8
13
  },
9
14
  "files": [
10
15
  "dist"