automate.ax 0.1.3
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/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/automation/actions.d.ts +200 -0
- package/dist/automation/actions.d.ts.map +1 -0
- package/dist/automation/actions.js +286 -0
- package/dist/automation/automation.d.ts +16 -0
- package/dist/automation/automation.d.ts.map +1 -0
- package/dist/automation/automation.js +10 -0
- package/dist/automation/integrations.d.ts +63 -0
- package/dist/automation/integrations.d.ts.map +1 -0
- package/dist/automation/integrations.js +58 -0
- package/dist/automation/runtime.d.ts +73 -0
- package/dist/automation/runtime.d.ts.map +1 -0
- package/dist/automation/runtime.js +92 -0
- package/dist/automation/signal.d.ts +58 -0
- package/dist/automation/signal.d.ts.map +1 -0
- package/dist/automation/signal.js +80 -0
- package/dist/automation/subscribe.d.ts +10 -0
- package/dist/automation/subscribe.d.ts.map +1 -0
- package/dist/automation/subscribe.js +16 -0
- package/dist/cli/command-names.d.ts +46 -0
- package/dist/cli/command-names.d.ts.map +1 -0
- package/dist/cli/command-names.js +46 -0
- package/dist/cli/commands/accept.d.ts +20 -0
- package/dist/cli/commands/accept.d.ts.map +1 -0
- package/dist/cli/commands/accept.js +42 -0
- package/dist/cli/commands/debug.d.ts +4 -0
- package/dist/cli/commands/debug.d.ts.map +1 -0
- package/dist/cli/commands/debug.js +52 -0
- package/dist/cli/commands/deploy.d.ts +24 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +292 -0
- package/dist/cli/commands/login.d.ts +20 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +145 -0
- package/dist/cli/commands/logout.d.ts +4 -0
- package/dist/cli/commands/logout.d.ts.map +1 -0
- package/dist/cli/commands/logout.js +32 -0
- package/dist/cli/commands/me.d.ts +4 -0
- package/dist/cli/commands/me.d.ts.map +1 -0
- package/dist/cli/commands/me.js +48 -0
- package/dist/cli/commands/org-api-key-create.d.ts +26 -0
- package/dist/cli/commands/org-api-key-create.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-create.js +51 -0
- package/dist/cli/commands/org-api-key-delete.d.ts +33 -0
- package/dist/cli/commands/org-api-key-delete.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-delete.js +57 -0
- package/dist/cli/commands/org-api-key-list.d.ts +16 -0
- package/dist/cli/commands/org-api-key-list.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-list.js +58 -0
- package/dist/cli/commands/org-api-key-rename.d.ts +32 -0
- package/dist/cli/commands/org-api-key-rename.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-rename.js +54 -0
- package/dist/cli/commands/org-api-key.d.ts +2 -0
- package/dist/cli/commands/org-api-key.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key.js +18 -0
- package/dist/cli/commands/org-billing.d.ts +16 -0
- package/dist/cli/commands/org-billing.d.ts.map +1 -0
- package/dist/cli/commands/org-billing.js +78 -0
- package/dist/cli/commands/org-create.d.ts +20 -0
- package/dist/cli/commands/org-create.d.ts.map +1 -0
- package/dist/cli/commands/org-create.js +64 -0
- package/dist/cli/commands/org-delete.d.ts +27 -0
- package/dist/cli/commands/org-delete.d.ts.map +1 -0
- package/dist/cli/commands/org-delete.js +53 -0
- package/dist/cli/commands/org-invite.d.ts +39 -0
- package/dist/cli/commands/org-invite.d.ts.map +1 -0
- package/dist/cli/commands/org-invite.js +66 -0
- package/dist/cli/commands/org-leave.d.ts +27 -0
- package/dist/cli/commands/org-leave.d.ts.map +1 -0
- package/dist/cli/commands/org-leave.js +56 -0
- package/dist/cli/commands/org-list.d.ts +4 -0
- package/dist/cli/commands/org-list.d.ts.map +1 -0
- package/dist/cli/commands/org-list.js +36 -0
- package/dist/cli/commands/org-remove.d.ts +33 -0
- package/dist/cli/commands/org-remove.d.ts.map +1 -0
- package/dist/cli/commands/org-remove.js +66 -0
- package/dist/cli/commands/org-rename.d.ts +26 -0
- package/dist/cli/commands/org-rename.d.ts.map +1 -0
- package/dist/cli/commands/org-rename.js +58 -0
- package/dist/cli/commands/org-show.d.ts +16 -0
- package/dist/cli/commands/org-show.d.ts.map +1 -0
- package/dist/cli/commands/org-show.js +48 -0
- package/dist/cli/commands/org-upgrade.d.ts +42 -0
- package/dist/cli/commands/org-upgrade.d.ts.map +1 -0
- package/dist/cli/commands/org-upgrade.js +171 -0
- package/dist/cli/commands/org.d.ts +2 -0
- package/dist/cli/commands/org.d.ts.map +1 -0
- package/dist/cli/commands/org.js +32 -0
- package/dist/cli/commands/project-create.d.ts +27 -0
- package/dist/cli/commands/project-create.d.ts.map +1 -0
- package/dist/cli/commands/project-create.js +61 -0
- package/dist/cli/commands/project-delete.d.ts +27 -0
- package/dist/cli/commands/project-delete.d.ts.map +1 -0
- package/dist/cli/commands/project-delete.js +55 -0
- package/dist/cli/commands/project-list.d.ts +17 -0
- package/dist/cli/commands/project-list.d.ts.map +1 -0
- package/dist/cli/commands/project-list.js +89 -0
- package/dist/cli/commands/project-rename.d.ts +26 -0
- package/dist/cli/commands/project-rename.d.ts.map +1 -0
- package/dist/cli/commands/project-rename.js +60 -0
- package/dist/cli/commands/project-show.d.ts +16 -0
- package/dist/cli/commands/project-show.d.ts.map +1 -0
- package/dist/cli/commands/project-show.js +37 -0
- package/dist/cli/commands/project.d.ts +2 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/project.js +20 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +63 -0
- package/dist/cli/lib/api-client.d.ts +3 -0
- package/dist/cli/lib/api-client.d.ts.map +1 -0
- package/dist/cli/lib/api-client.js +14 -0
- package/dist/cli/lib/auth-client.d.ts +80 -0
- package/dist/cli/lib/auth-client.d.ts.map +1 -0
- package/dist/cli/lib/auth-client.js +61 -0
- package/dist/cli/lib/automation-build.d.ts +30 -0
- package/dist/cli/lib/automation-build.d.ts.map +1 -0
- package/dist/cli/lib/automation-build.js +90 -0
- package/dist/cli/lib/config-dir.d.ts +47 -0
- package/dist/cli/lib/config-dir.d.ts.map +1 -0
- package/dist/cli/lib/config-dir.js +146 -0
- package/dist/cli/lib/detail-block.d.ts +16 -0
- package/dist/cli/lib/detail-block.d.ts.map +1 -0
- package/dist/cli/lib/detail-block.js +25 -0
- package/dist/cli/lib/env.d.ts +4 -0
- package/dist/cli/lib/env.d.ts.map +1 -0
- package/dist/cli/lib/env.js +7 -0
- package/dist/cli/lib/hijack-clack-logger.d.ts +2 -0
- package/dist/cli/lib/hijack-clack-logger.d.ts.map +1 -0
- package/dist/cli/lib/hijack-clack-logger.js +8 -0
- package/dist/cli/lib/io.d.ts +19 -0
- package/dist/cli/lib/io.d.ts.map +1 -0
- package/dist/cli/lib/io.js +87 -0
- package/dist/cli/lib/json-output.d.ts +9 -0
- package/dist/cli/lib/json-output.d.ts.map +1 -0
- package/dist/cli/lib/json-output.js +12 -0
- package/dist/cli/lib/organization-detail-block.d.ts +30 -0
- package/dist/cli/lib/organization-detail-block.d.ts.map +1 -0
- package/dist/cli/lib/organization-detail-block.js +72 -0
- package/dist/cli/lib/project-config.d.ts +10 -0
- package/dist/cli/lib/project-config.d.ts.map +1 -0
- package/dist/cli/lib/project-config.js +21 -0
- package/dist/cli/lib/spinner.d.ts +18 -0
- package/dist/cli/lib/spinner.d.ts.map +1 -0
- package/dist/cli/lib/spinner.js +111 -0
- package/dist/cli/usage.d.ts +9 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +468 -0
- package/dist/cli/utils.d.ts +291 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +561 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +5 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +9 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/package.json +92 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { log } from "@clack/prompts";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
import { commandNames } from "../command-names.js";
|
|
5
|
+
import { apiClient } from "../lib/api-client.js";
|
|
6
|
+
import { createCommandRun, ORG_OPT, orgOptsSchema, output, promptableOption, requireAuthenticatedSession, safelyPromptTextWithValidation, sessionIntro, useOrganization, } from "../utils.js";
|
|
7
|
+
import { accent, dimmed } from "../lib/io.js";
|
|
8
|
+
import { clearSpinner, startSpinner, withSpinner } from "../lib/spinner.js";
|
|
9
|
+
/** Organization roles assignable through an invitation. */
|
|
10
|
+
const roles = ["member", "admin", "owner"];
|
|
11
|
+
/** Arguments accepted by the organization invitation command. */
|
|
12
|
+
const inviteOrgOptsSchema = orgOptsSchema.extend({
|
|
13
|
+
email: promptableOption(z.email(), "email"),
|
|
14
|
+
role: z.enum(roles).default("member"),
|
|
15
|
+
});
|
|
16
|
+
export const orgInviteCommand = defineCommand({
|
|
17
|
+
meta: {
|
|
18
|
+
name: commandNames.org.invite,
|
|
19
|
+
description: "Invite a member to an organization",
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
email: {
|
|
23
|
+
type: "positional",
|
|
24
|
+
description: "Email address to invite",
|
|
25
|
+
required: false,
|
|
26
|
+
},
|
|
27
|
+
role: {
|
|
28
|
+
type: "enum",
|
|
29
|
+
options: [...roles],
|
|
30
|
+
description: `Role to assign (${roles.join(", ")})`,
|
|
31
|
+
alias: ["r"],
|
|
32
|
+
default: "member",
|
|
33
|
+
},
|
|
34
|
+
...ORG_OPT,
|
|
35
|
+
},
|
|
36
|
+
run: createCommandRun(inviteOrgOptsSchema, inviteMember),
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Invites a user to the resolved organization by email.
|
|
40
|
+
*
|
|
41
|
+
* @param opts - Validated organization, email, and role options.
|
|
42
|
+
* @throws When the organization's seat limit has been reached.
|
|
43
|
+
*/
|
|
44
|
+
export async function inviteMember(opts) {
|
|
45
|
+
const session = await requireAuthenticatedSession("invite organization members");
|
|
46
|
+
output.normal(() => sessionIntro(session));
|
|
47
|
+
const org = await useOrganization(opts, { whenEmpty: "prompt-create" });
|
|
48
|
+
if (!(await withSpinner("Checking seat limit", () => apiClient.org.canInvite({ organizationId: org.id })))) {
|
|
49
|
+
throw new Error(`Seat limit reached. Run \`${commandNames.root} ${commandNames.org.root} ${commandNames.org.upgrade} -o ${org.id}\` to add more members.`);
|
|
50
|
+
}
|
|
51
|
+
const email = opts.email ??
|
|
52
|
+
(await safelyPromptTextWithValidation({
|
|
53
|
+
message: "Who should we invite?",
|
|
54
|
+
placeholder: "john@example.com",
|
|
55
|
+
}, z.email(), "email"));
|
|
56
|
+
startSpinner(`Inviting ${accent(email)}`);
|
|
57
|
+
const invitation = await apiClient.org.invite({
|
|
58
|
+
email,
|
|
59
|
+
role: opts.role,
|
|
60
|
+
organizationId: org.id,
|
|
61
|
+
});
|
|
62
|
+
clearSpinner();
|
|
63
|
+
output
|
|
64
|
+
.normal(() => log.success(`Invited ${accent(email)} as ${dimmed(opts.role)} to ${accent(org.name)}`))
|
|
65
|
+
.json(invitation);
|
|
66
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
/** Arguments accepted by the organization leave command. */
|
|
3
|
+
declare const leaveOrgOptsSchema: z.ZodObject<{
|
|
4
|
+
org: z.ZodOptional<z.ZodString>;
|
|
5
|
+
yes: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const orgLeaveCommand: import("citty").CommandDef<{
|
|
8
|
+
readonly yes: {
|
|
9
|
+
readonly type: "boolean";
|
|
10
|
+
readonly description: "Skip confirmation prompt";
|
|
11
|
+
readonly alias: ["y"];
|
|
12
|
+
readonly default: false;
|
|
13
|
+
};
|
|
14
|
+
readonly org: {
|
|
15
|
+
type: "string";
|
|
16
|
+
description: string;
|
|
17
|
+
alias: string[];
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Removes the current user from the resolved organization.
|
|
22
|
+
*
|
|
23
|
+
* @param opts - Validated organization selector and confirmation options.
|
|
24
|
+
*/
|
|
25
|
+
export declare function leaveOrganization(opts: z.infer<typeof leaveOrgOptsSchema>): Promise<void>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=org-leave.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org-leave.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/org-leave.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAA;AAgBnB,4DAA4D;AAC5D,QAAA,MAAM,kBAAkB;;;iBAEtB,CAAA;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;EAe1B,CAAA;AAEF;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,iBAgCzC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { confirm, log } from "@clack/prompts";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
import { commandNames } from "../command-names.js";
|
|
5
|
+
import { apiClient } from "../lib/api-client.js";
|
|
6
|
+
import { createCommandRun, ORG_OPT, orgOptsSchema, output, safelyPrompt, sessionIntro, useOrganization, useSession, } from "../utils.js";
|
|
7
|
+
import { accent } from "../lib/io.js";
|
|
8
|
+
import { clearSpinner, startSpinner } from "../lib/spinner.js";
|
|
9
|
+
/** Arguments accepted by the organization leave command. */
|
|
10
|
+
const leaveOrgOptsSchema = orgOptsSchema.extend({
|
|
11
|
+
yes: z.boolean().default(false),
|
|
12
|
+
});
|
|
13
|
+
export const orgLeaveCommand = defineCommand({
|
|
14
|
+
meta: {
|
|
15
|
+
name: commandNames.org.leave,
|
|
16
|
+
description: "Leave an organization",
|
|
17
|
+
},
|
|
18
|
+
args: {
|
|
19
|
+
...ORG_OPT,
|
|
20
|
+
yes: {
|
|
21
|
+
type: "boolean",
|
|
22
|
+
description: "Skip confirmation prompt",
|
|
23
|
+
alias: ["y"],
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
run: createCommandRun(leaveOrgOptsSchema, leaveOrganization),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Removes the current user from the resolved organization.
|
|
31
|
+
*
|
|
32
|
+
* @param opts - Validated organization selector and confirmation options.
|
|
33
|
+
*/
|
|
34
|
+
export async function leaveOrganization(opts) {
|
|
35
|
+
const session = await useSession();
|
|
36
|
+
output.normal(() => sessionIntro(session));
|
|
37
|
+
const org = await useOrganization(opts);
|
|
38
|
+
if (!opts.yes) {
|
|
39
|
+
if (!(await safelyPrompt(() => confirm({
|
|
40
|
+
message: `Are you sure you want to leave ${accent(org.name)}?`,
|
|
41
|
+
initialValue: false,
|
|
42
|
+
}), "--yes"))) {
|
|
43
|
+
output.json({ cancelled: true });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
startSpinner("Leaving organization");
|
|
48
|
+
await apiClient.org.leave({ organizationId: org.id });
|
|
49
|
+
clearSpinner();
|
|
50
|
+
output
|
|
51
|
+
.normal(() => log.success(`Left ${accent(org.name)}`))
|
|
52
|
+
.json({
|
|
53
|
+
left: true,
|
|
54
|
+
organization: org,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org-list.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/org-list.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,cAAc,qDAMzB,CAAA;AAEF,8EAA8E;AAC9E,wBAAsB,iBAAiB,kBA0BtC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { log } from "@clack/prompts";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import { commandNames } from "../command-names.js";
|
|
4
|
+
import { apiClient } from "../lib/api-client.js";
|
|
5
|
+
import { createCommandRun, output, pluralize, sessionIntro, useSession, } from "../utils.js";
|
|
6
|
+
import { accent } from "../lib/io.js";
|
|
7
|
+
import { renderOrganizationDetailBlock } from "../lib/organization-detail-block.js";
|
|
8
|
+
import { clearSpinner, startSpinner } from "../lib/spinner.js";
|
|
9
|
+
export const orgListCommand = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: commandNames.org.list,
|
|
12
|
+
description: "List all organizations",
|
|
13
|
+
},
|
|
14
|
+
run: createCommandRun(null, listOrganizations),
|
|
15
|
+
});
|
|
16
|
+
/** Lists organizations for the current session, including the user's role. */
|
|
17
|
+
export async function listOrganizations() {
|
|
18
|
+
const session = await useSession();
|
|
19
|
+
output.normal(() => sessionIntro(session));
|
|
20
|
+
startSpinner("Fetching organizations");
|
|
21
|
+
const organizations = await apiClient.org.list();
|
|
22
|
+
clearSpinner();
|
|
23
|
+
output
|
|
24
|
+
.normal(() => {
|
|
25
|
+
if (organizations.length === 0) {
|
|
26
|
+
log.warn("You don't belong to any organizations.");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
log.message(`${accent(organizations.length)} ${pluralize(organizations.length, "organization")}`);
|
|
30
|
+
for (const org of organizations) {
|
|
31
|
+
log.info(renderOrganizationDetailBlock(org, { includeRole: true }));
|
|
32
|
+
}
|
|
33
|
+
log.message();
|
|
34
|
+
})
|
|
35
|
+
.json(organizations);
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
/** Arguments accepted by the organization member removal command. */
|
|
3
|
+
declare const removeOrgOptsSchema: z.ZodObject<{
|
|
4
|
+
org: z.ZodOptional<z.ZodString>;
|
|
5
|
+
member: z.ZodPrefault<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
yes: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const orgRemoveCommand: import("citty").CommandDef<{
|
|
9
|
+
readonly org: {
|
|
10
|
+
type: "string";
|
|
11
|
+
description: string;
|
|
12
|
+
alias: string[];
|
|
13
|
+
};
|
|
14
|
+
readonly member: {
|
|
15
|
+
readonly type: "positional";
|
|
16
|
+
readonly description: "Email or member ID to remove";
|
|
17
|
+
readonly required: false;
|
|
18
|
+
};
|
|
19
|
+
readonly yes: {
|
|
20
|
+
readonly type: "boolean";
|
|
21
|
+
readonly description: "Skip confirmation prompt";
|
|
22
|
+
readonly alias: ["y"];
|
|
23
|
+
readonly default: false;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Removes a member from the resolved organization.
|
|
28
|
+
*
|
|
29
|
+
* @param opts - Validated organization, member, and confirmation options.
|
|
30
|
+
*/
|
|
31
|
+
export declare function removeMember(opts: z.infer<typeof removeOrgOptsSchema>): Promise<void>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=org-remove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org-remove.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/org-remove.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAA;AAkBnB,qEAAqE;AACrE,QAAA,MAAM,mBAAmB;;;;iBAGvB,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;EAoB3B,CAAA;AAEF;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,iBA6C3E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { confirm, log } from "@clack/prompts";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
import { commandNames } from "../command-names.js";
|
|
5
|
+
import { apiClient } from "../lib/api-client.js";
|
|
6
|
+
import { createCommandRun, ORG_OPT, orgOptsSchema, output, promptableOption, requireAuthenticatedSession, safelyPrompt, safelyPromptTextWithValidation, sessionIntro, useOrganization, } from "../utils.js";
|
|
7
|
+
import { accent } from "../lib/io.js";
|
|
8
|
+
import { clearSpinner, startSpinner } from "../lib/spinner.js";
|
|
9
|
+
/** Arguments accepted by the organization member removal command. */
|
|
10
|
+
const removeOrgOptsSchema = orgOptsSchema.extend({
|
|
11
|
+
member: promptableOption(z.string().min(1), "member"),
|
|
12
|
+
yes: z.boolean().default(false),
|
|
13
|
+
});
|
|
14
|
+
export const orgRemoveCommand = defineCommand({
|
|
15
|
+
meta: {
|
|
16
|
+
name: commandNames.org.remove,
|
|
17
|
+
description: "Remove a member from an organization",
|
|
18
|
+
},
|
|
19
|
+
args: {
|
|
20
|
+
member: {
|
|
21
|
+
type: "positional",
|
|
22
|
+
description: "Email or member ID to remove",
|
|
23
|
+
required: false,
|
|
24
|
+
},
|
|
25
|
+
yes: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
description: "Skip confirmation prompt",
|
|
28
|
+
alias: ["y"],
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
...ORG_OPT,
|
|
32
|
+
},
|
|
33
|
+
run: createCommandRun(removeOrgOptsSchema, removeMember),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Removes a member from the resolved organization.
|
|
37
|
+
*
|
|
38
|
+
* @param opts - Validated organization, member, and confirmation options.
|
|
39
|
+
*/
|
|
40
|
+
export async function removeMember(opts) {
|
|
41
|
+
const session = await requireAuthenticatedSession("remove organization members");
|
|
42
|
+
output.normal(() => sessionIntro(session));
|
|
43
|
+
const org = await useOrganization(opts);
|
|
44
|
+
const member = opts.member ??
|
|
45
|
+
(await safelyPromptTextWithValidation({
|
|
46
|
+
message: "Which member should we remove?",
|
|
47
|
+
}, z.string().min(1), "member"));
|
|
48
|
+
if (!opts.yes) {
|
|
49
|
+
if (!(await safelyPrompt(() => confirm({
|
|
50
|
+
message: `Remove ${accent(member)} from ${accent(org.name)}?`,
|
|
51
|
+
initialValue: false,
|
|
52
|
+
}), "--yes"))) {
|
|
53
|
+
output.json({ cancelled: true });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
startSpinner(`Removing ${accent(member)}`);
|
|
58
|
+
await apiClient.org.remove({
|
|
59
|
+
memberIdOrEmail: member,
|
|
60
|
+
organizationId: org.id,
|
|
61
|
+
});
|
|
62
|
+
clearSpinner();
|
|
63
|
+
output
|
|
64
|
+
.normal(() => log.success(`Removed ${accent(member)} from ${accent(org.name)}`))
|
|
65
|
+
.json({ removed: true, member, organization: org });
|
|
66
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
/** Arguments accepted by the organization rename command. */
|
|
3
|
+
declare const renameOrgOptsSchema: z.ZodObject<{
|
|
4
|
+
org: z.ZodOptional<z.ZodString>;
|
|
5
|
+
name: z.ZodPrefault<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const orgRenameCommand: import("citty").CommandDef<{
|
|
8
|
+
readonly name: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "New name for the organization";
|
|
11
|
+
readonly alias: ["n"];
|
|
12
|
+
};
|
|
13
|
+
readonly org: {
|
|
14
|
+
type: "string";
|
|
15
|
+
description: string;
|
|
16
|
+
alias: string[];
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Renames an organization without changing its internal authentication slug.
|
|
21
|
+
*
|
|
22
|
+
* @param opts - Validated organization selector and optional new name.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renameOrganization(opts: z.infer<typeof renameOrgOptsSchema>): Promise<void>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=org-rename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org-rename.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/org-rename.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAA;AAkBnB,6DAA6D;AAC7D,QAAA,MAAM,mBAAmB;;;iBAEvB,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;EAc3B,CAAA;AAEF;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,iBAoB1C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { log } from "@clack/prompts";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import { commandNames } from "../command-names.js";
|
|
4
|
+
import { apiClient } from "../lib/api-client.js";
|
|
5
|
+
import { createCommandRun, ORG_OPT, orgOptsSchema, output, promptableOption, REASONABLE_NAME_SCHEMA, requireAuthenticatedSession, safelyPromptTextWithValidation, sessionIntro, useOrganization, } from "../utils.js";
|
|
6
|
+
import { accent, dimmed } from "../lib/io.js";
|
|
7
|
+
import { clearSpinner, startSpinner } from "../lib/spinner.js";
|
|
8
|
+
/** Arguments accepted by the organization rename command. */
|
|
9
|
+
const renameOrgOptsSchema = orgOptsSchema.extend({
|
|
10
|
+
name: promptableOption(REASONABLE_NAME_SCHEMA, "--name"),
|
|
11
|
+
});
|
|
12
|
+
export const orgRenameCommand = defineCommand({
|
|
13
|
+
meta: {
|
|
14
|
+
name: commandNames.org.rename,
|
|
15
|
+
description: "Rename an organization",
|
|
16
|
+
},
|
|
17
|
+
args: {
|
|
18
|
+
...ORG_OPT,
|
|
19
|
+
name: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "New name for the organization",
|
|
22
|
+
alias: ["n"],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
run: createCommandRun(renameOrgOptsSchema, renameOrganization),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Renames an organization without changing its internal authentication slug.
|
|
29
|
+
*
|
|
30
|
+
* @param opts - Validated organization selector and optional new name.
|
|
31
|
+
*/
|
|
32
|
+
export async function renameOrganization(opts) {
|
|
33
|
+
const session = await requireAuthenticatedSession("rename an organization");
|
|
34
|
+
output.normal(() => sessionIntro(session));
|
|
35
|
+
const org = await useOrganization(opts);
|
|
36
|
+
const newName = opts.name ?? (await promptName(org.name));
|
|
37
|
+
startSpinner("Renaming organization");
|
|
38
|
+
await apiClient.org.update({
|
|
39
|
+
organizationId: org.id,
|
|
40
|
+
name: newName,
|
|
41
|
+
});
|
|
42
|
+
clearSpinner();
|
|
43
|
+
output
|
|
44
|
+
.normal(() => log.success(`Renamed ${dimmed(org.name)} to ${accent(newName)}`))
|
|
45
|
+
.json({ ...org, name: newName });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Prompts for and validates a replacement organization name.
|
|
49
|
+
*
|
|
50
|
+
* @param currentName - Current organization name used as the prompt default.
|
|
51
|
+
*/
|
|
52
|
+
async function promptName(currentName) {
|
|
53
|
+
return await safelyPromptTextWithValidation({
|
|
54
|
+
message: "What should the new organization name be?",
|
|
55
|
+
placeholder: currentName,
|
|
56
|
+
defaultValue: currentName,
|
|
57
|
+
}, REASONABLE_NAME_SCHEMA, "--name");
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { orgOptsSchema } from "../utils.js";
|
|
3
|
+
export declare const orgShowCommand: import("citty").CommandDef<{
|
|
4
|
+
readonly org: {
|
|
5
|
+
type: "string";
|
|
6
|
+
description: string;
|
|
7
|
+
alias: string[];
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Displays details for a resolved organization.
|
|
12
|
+
*
|
|
13
|
+
* @param opts - Validated options selecting the organization.
|
|
14
|
+
*/
|
|
15
|
+
export declare function showOrganization(opts: z.infer<typeof orgOptsSchema>): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=org-show.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org-show.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/org-show.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAA;AAMnB,OAAO,EAGL,aAAa,EAKd,oBAAgB;AAEjB,eAAO,MAAM,cAAc;;;;;;EASzB,CAAA;AAEF;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,iBAuCzE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { log } from "@clack/prompts";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import { commandNames } from "../command-names.js";
|
|
4
|
+
import { apiClient } from "../lib/api-client.js";
|
|
5
|
+
import { dimmed } from "../lib/io.js";
|
|
6
|
+
import { renderOrganizationDetailBlock } from "../lib/organization-detail-block.js";
|
|
7
|
+
import { clearSpinner, startSpinner } from "../lib/spinner.js";
|
|
8
|
+
import { createCommandRun, ORG_OPT, orgOptsSchema, output, sessionIntro, useOrganization, useSession, } from "../utils.js";
|
|
9
|
+
export const orgShowCommand = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: commandNames.org.show,
|
|
12
|
+
description: "Show organization details",
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
...ORG_OPT,
|
|
16
|
+
},
|
|
17
|
+
run: createCommandRun(orgOptsSchema, showOrganization),
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Displays details for a resolved organization.
|
|
21
|
+
*
|
|
22
|
+
* @param opts - Validated options selecting the organization.
|
|
23
|
+
*/
|
|
24
|
+
export async function showOrganization(opts) {
|
|
25
|
+
const session = await useSession();
|
|
26
|
+
output.normal(() => sessionIntro(session));
|
|
27
|
+
const { id: organizationId } = await useOrganization(opts);
|
|
28
|
+
startSpinner("Fetching details");
|
|
29
|
+
const org = await apiClient.org.get({ organizationId });
|
|
30
|
+
clearSpinner();
|
|
31
|
+
output
|
|
32
|
+
.normal(() => {
|
|
33
|
+
const pendingInvites = org.invitations.filter((i) => i.status === "pending");
|
|
34
|
+
log.info(renderOrganizationDetailBlock(org));
|
|
35
|
+
log.message([
|
|
36
|
+
`Members (${org.members.length}):`,
|
|
37
|
+
...org.members.map((m) => ` ${m.email.startsWith("temp@") ? "Anonymous" : m.email}${m.userId === session.user.id ? dimmed ` (you)` : ""} - ${dimmed(m.role)}`),
|
|
38
|
+
].join("\n"));
|
|
39
|
+
if (pendingInvites.length > 0) {
|
|
40
|
+
log.message([
|
|
41
|
+
`Pending invitations (${pendingInvites.length}):`,
|
|
42
|
+
...pendingInvites.map((i) => ` ${i.email} - ${dimmed(i.role)}`),
|
|
43
|
+
].join("\n"));
|
|
44
|
+
}
|
|
45
|
+
log.message();
|
|
46
|
+
})
|
|
47
|
+
.json(org);
|
|
48
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { useOrganization } from "../utils.js";
|
|
3
|
+
/** Arguments accepted by the organization upgrade command. */
|
|
4
|
+
declare const upgradeOrgOptsSchema: z.ZodObject<{
|
|
5
|
+
org: z.ZodOptional<z.ZodString>;
|
|
6
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
pro: "pro";
|
|
8
|
+
enterprise: "enterprise";
|
|
9
|
+
}>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
type ResolvedOrganization = Awaited<ReturnType<typeof useOrganization>>;
|
|
12
|
+
export declare const orgUpgradeCommand: import("citty").CommandDef<{
|
|
13
|
+
readonly plan: {
|
|
14
|
+
readonly type: "enum";
|
|
15
|
+
readonly options: ["pro", "enterprise"];
|
|
16
|
+
readonly description: "Plan to upgrade to";
|
|
17
|
+
readonly alias: ["p"];
|
|
18
|
+
};
|
|
19
|
+
readonly org: {
|
|
20
|
+
type: "string";
|
|
21
|
+
description: string;
|
|
22
|
+
alias: string[];
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Starts Checkout for Pro or prints Enterprise contact details.
|
|
27
|
+
*
|
|
28
|
+
* @param opts - Validated organization and target plan options.
|
|
29
|
+
* @param options - Presentation options for callers composing CLI flows.
|
|
30
|
+
* @param options.printSessionIntro - Whether to print the authenticated user.
|
|
31
|
+
*/
|
|
32
|
+
export declare function upgradeOrganization(opts: z.infer<typeof upgradeOrgOptsSchema>, options?: {
|
|
33
|
+
printSessionIntro?: boolean;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Prints and opens the Enterprise upgrade mailto link.
|
|
37
|
+
*
|
|
38
|
+
* @param org - Organization whose details should prefill the message.
|
|
39
|
+
*/
|
|
40
|
+
export declare function printEnterpriseContact(org: ResolvedOrganization): void;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=org-upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org-upgrade.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/org-upgrade.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,KAAK,CAAA;AAInB,OAAO,EAOL,eAAe,EAChB,oBAAgB;AASjB,8DAA8D;AAC9D,QAAA,MAAM,oBAAoB;;;;;;iBAExB,CAAA;AAEF,KAAK,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAA;AAEvE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAe5B,CAAA;AAEF;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,EAC1C,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,iBAqF9C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,oBAAoB,QAqB/D"}
|