@switchboard.spot/cli 0.2.3 → 0.2.5

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,55 +0,0 @@
1
- /**
2
- * Organization invitation commands.
3
- */
4
-
5
- import { accountRequest } from "../client.js";
6
- import { emit, globalFlags, printList } from "../output.js";
7
-
8
- export function registerOrgCommands(program) {
9
- const org = program.command("org").description("Organization and team");
10
-
11
- org
12
- .command("invitations")
13
- .description("List pending invitations")
14
- .action(async (_opts, cmd) => {
15
- const flags = globalFlags(cmd);
16
- const { data } = await accountRequest("GET", "/invitations", { json: flags.json });
17
- if (flags.json) {
18
- emit(data, flags);
19
- } else {
20
- printList("Pending invitations:", data.data || [], (i) =>
21
- ` ${i.email} (${i.role}) token=${i.token}`,
22
- );
23
- }
24
- });
25
-
26
- org
27
- .command("invite")
28
- .description("Invite a member by email")
29
- .requiredOption("--email <email>")
30
- .action(async (opts, cmd) => {
31
- const flags = globalFlags(cmd);
32
- const { data } = await accountRequest("POST", "/invitations", {
33
- body: { email: opts.email },
34
- json: flags.json,
35
- });
36
- emit(
37
- flags.json ? data : `Invited ${data.email}. Token: ${data.token}`,
38
- flags,
39
- );
40
- });
41
-
42
- org
43
- .command("accept <token>")
44
- .description("Accept an invitation")
45
- .action(async (token, _opts, cmd) => {
46
- const flags = globalFlags(cmd);
47
- const { data } = await accountRequest("POST", `/invitations/${token}/accept`, {
48
- json: flags.json,
49
- });
50
- emit(
51
- flags.json ? data : `Joined organization ${data.name}`,
52
- flags,
53
- );
54
- });
55
- }
@@ -1,92 +0,0 @@
1
- /**
2
- * Workspace management commands.
3
- */
4
-
5
- import { accountRequest } from "../client.js";
6
- import { emit, globalFlags, printList } from "../output.js";
7
-
8
- export function registerWorkspacesCommands(program) {
9
- const workspaces = program.command("workspaces").description("Workspaces");
10
-
11
- workspaces
12
- .command("list")
13
- .description("List workspaces")
14
- .option("--trash <filter>", "active, deleted, or all", "active")
15
- .action(async (opts, cmd) => {
16
- const flags = globalFlags(cmd);
17
- const { data } = await accountRequest("GET", `/workspaces?trash=${opts.trash}`, {
18
- json: flags.json,
19
- });
20
- if (flags.json) {
21
- emit(data, flags);
22
- } else {
23
- printList("Workspaces:", data.data || [], (w) => ` ${w.id} ${w.name} (${w.slug})`);
24
- }
25
- });
26
-
27
- workspaces
28
- .command("show <id>")
29
- .description("Show a workspace")
30
- .option("--trash <filter>", "active, deleted, or all", "active")
31
- .action(async (id, opts, cmd) => {
32
- const flags = globalFlags(cmd);
33
- const { data } = await accountRequest("GET", `/workspaces/${id}?trash=${opts.trash}`, {
34
- json: flags.json,
35
- });
36
- emit(flags.json ? data : JSON.stringify(data, null, 2), flags);
37
- });
38
-
39
- workspaces
40
- .command("create")
41
- .description("Create a workspace")
42
- .requiredOption("--name <name>")
43
- .requiredOption("--slug <slug>")
44
- .action(async (opts, cmd) => {
45
- const flags = globalFlags(cmd);
46
- const { data } = await accountRequest("POST", "/workspaces", {
47
- body: { name: opts.name, slug: opts.slug },
48
- json: flags.json,
49
- });
50
- emit(flags.json ? data : `Created workspace ${data.name} (${data.id})`, flags);
51
- });
52
-
53
- workspaces
54
- .command("update <id>")
55
- .description("Update a workspace")
56
- .option("--name <name>")
57
- .option("--slug <slug>")
58
- .action(async (id, opts, cmd) => {
59
- const flags = globalFlags(cmd);
60
- const body = {};
61
- if (opts.name) body.name = opts.name;
62
- if (opts.slug) body.slug = opts.slug;
63
-
64
- const { data } = await accountRequest("PATCH", `/workspaces/${id}`, {
65
- body,
66
- json: flags.json,
67
- });
68
- emit(flags.json ? data : `Updated workspace ${data.name}`, flags);
69
- });
70
-
71
- workspaces
72
- .command("delete <id>")
73
- .description("Delete a workspace")
74
- .action(async (id, _opts, cmd) => {
75
- const flags = globalFlags(cmd);
76
- const { data } = await accountRequest("DELETE", `/workspaces/${id}`, {
77
- json: flags.json,
78
- });
79
- emit(flags.json ? data : `Deleted workspace ${data.name}`, flags);
80
- });
81
-
82
- workspaces
83
- .command("restore <id>")
84
- .description("Restore a deleted workspace")
85
- .action(async (id, _opts, cmd) => {
86
- const flags = globalFlags(cmd);
87
- const { data } = await accountRequest("POST", `/workspaces/${id}/restore`, {
88
- json: flags.json,
89
- });
90
- emit(flags.json ? data : `Restored workspace ${data.name}`, flags);
91
- });
92
- }