@vizamodo/viza-cli 1.4.28 → 1.4.35

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.
@@ -3,6 +3,7 @@ import { getCliVersion } from "../core/version.js";
3
3
  import { registerGlobalOptions } from "./options.js";
4
4
  import { registerLoginCommand } from "../commands/login/register.js";
5
5
  import { registerBootstrapCommand } from "../commands/bootstrap/register.js";
6
+ import { whoamiCommand } from "../commands/whoami/index.js";
6
7
  export function createProgram() {
7
8
  const program = new Command();
8
9
  program
@@ -12,5 +13,9 @@ export function createProgram() {
12
13
  registerGlobalOptions(program);
13
14
  registerBootstrapCommand(program);
14
15
  registerLoginCommand(program);
16
+ program
17
+ .command("whoami")
18
+ .description("Show current GitHub identity and Viza team memberships (local only)")
19
+ .action(whoamiCommand);
15
20
  return program;
16
21
  }
@@ -0,0 +1,69 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import chalk from "chalk";
4
+ const execFileAsync = promisify(execFile);
5
+ // ⚠️ UX-only role descriptions (NOT security enforcement)
6
+ const TEAM_DESCRIPTIONS = {
7
+ "viza-designer": "Product designer. Full access to sign in, view, edit, and delete designs in Figma.",
8
+ "viza-deployer": "Software developer. Builds mobile / IoT / web applications and deploys resources to the DEV environment on AWS / Cloudflare.",
9
+ "viza-manager": "Engineering manager. Manages GitHub resources and can grant or revoke access for developers and designers.",
10
+ "viza-publisher": "Release manager. Deploys resources to the PRODUCTION environment on AWS / Cloudflare and publishes Android / iOS applications.",
11
+ "viza-billing": "Billing administrator. Views, adds, and manages billing information across Figma, AWS, Cloudflare, and GitHub.",
12
+ "viza-admin": "System administrator. Deploys to both DEV and PROD environments and manages access for publishers, managers, and billing roles.",
13
+ "viza-super": "Super administrator. Highest authority with full deployment and access control privileges, including system administrators.",
14
+ };
15
+ const AUTH_ORG = "Modo-Auth";
16
+ async function getGithubLogin() {
17
+ const { stdout } = await execFileAsync("gh", ["api", "user", "--jq", ".login"]);
18
+ return stdout.trim();
19
+ }
20
+ async function getUserTeams(login) {
21
+ const { stdout } = await execFileAsync("gh", [
22
+ "api",
23
+ "user/teams",
24
+ "--paginate",
25
+ "--jq",
26
+ `.[] | select(.organization.login=="${AUTH_ORG}") | .slug`,
27
+ ]);
28
+ return stdout
29
+ .split("\n")
30
+ .map((s) => s.trim())
31
+ .filter(Boolean);
32
+ }
33
+ export async function whoamiCommand() {
34
+ process.stdout.write("\u001b[2J\u001b[3J\u001b[H");
35
+ console.log(chalk.cyanBright("👤 Viza WhoAmI"));
36
+ console.log(chalk.gray("─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"));
37
+ let login;
38
+ let teams;
39
+ try {
40
+ login = await getGithubLogin();
41
+ }
42
+ catch {
43
+ console.error(chalk.red("❌ Unable to resolve GitHub identity. Are you logged in via `gh auth login`?"));
44
+ process.exit(1);
45
+ }
46
+ try {
47
+ teams = await getUserTeams(login);
48
+ }
49
+ catch {
50
+ console.error(chalk.red("❌ Unable to resolve GitHub team membership."));
51
+ process.exit(1);
52
+ }
53
+ console.log(`${chalk.gray("GitHub User:")} ${chalk.magentaBright.bold(login)}`);
54
+ console.log();
55
+ if (teams.length === 0) {
56
+ console.log(chalk.yellow("⚠️ You are not a member of any Viza teams."));
57
+ return;
58
+ }
59
+ console.log(chalk.gray("Teams & Capabilities:"));
60
+ console.log(chalk.gray("─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"));
61
+ for (const team of teams) {
62
+ console.log(chalk.green(`✓ ${team}`));
63
+ const description = TEAM_DESCRIPTIONS[team] ?? "Chưa có mô tả quyền cho nhóm này.";
64
+ console.log(chalk.gray(` ${description}`));
65
+ console.log();
66
+ }
67
+ console.log(chalk.gray("ℹ️ Capabilities shown above are UX hints only.\n" +
68
+ " Actual permissions are enforced server-side."));
69
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/viza-cli",
3
- "version": "1.4.28",
3
+ "version": "1.4.35",
4
4
  "type": "module",
5
5
  "description": "Viza unified command line interface",
6
6
  "bin": {