@bussolabs/closeyourit-cli 0.0.2
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/README.md +99 -0
- package/bin/run.js +2 -0
- package/dist/base.d.ts +34 -0
- package/dist/base.js +85 -0
- package/dist/commands/errors/list.d.ts +11 -0
- package/dist/commands/errors/list.js +36 -0
- package/dist/commands/errors/mute.d.ts +12 -0
- package/dist/commands/errors/mute.js +22 -0
- package/dist/commands/errors/reopen.d.ts +12 -0
- package/dist/commands/errors/reopen.js +22 -0
- package/dist/commands/errors/resolve.d.ts +12 -0
- package/dist/commands/errors/resolve.js +22 -0
- package/dist/commands/errors/show.d.ts +12 -0
- package/dist/commands/errors/show.js +23 -0
- package/dist/commands/errors/unmute.d.ts +12 -0
- package/dist/commands/errors/unmute.js +22 -0
- package/dist/commands/groups/create.d.ts +12 -0
- package/dist/commands/groups/create.js +31 -0
- package/dist/commands/groups/list.d.ts +9 -0
- package/dist/commands/groups/list.js +19 -0
- package/dist/commands/invitations/create.d.ts +12 -0
- package/dist/commands/invitations/create.js +38 -0
- package/dist/commands/invitations/list.d.ts +9 -0
- package/dist/commands/invitations/list.js +24 -0
- package/dist/commands/invitations/revoke.d.ts +9 -0
- package/dist/commands/invitations/revoke.js +20 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.js +63 -0
- package/dist/commands/logout.d.ts +6 -0
- package/dist/commands/logout.js +17 -0
- package/dist/commands/members/list.d.ts +9 -0
- package/dist/commands/members/list.js +24 -0
- package/dist/commands/metrics/list.d.ts +11 -0
- package/dist/commands/metrics/list.js +36 -0
- package/dist/commands/metrics/show.d.ts +12 -0
- package/dist/commands/metrics/show.js +23 -0
- package/dist/commands/projects/create.d.ts +15 -0
- package/dist/commands/projects/create.js +49 -0
- package/dist/commands/projects/list.d.ts +9 -0
- package/dist/commands/projects/list.js +19 -0
- package/dist/commands/projects/set-environments.d.ts +11 -0
- package/dist/commands/projects/set-environments.js +42 -0
- package/dist/commands/projects/show.d.ts +9 -0
- package/dist/commands/projects/show.js +22 -0
- package/dist/commands/roles/create.d.ts +13 -0
- package/dist/commands/roles/create.js +36 -0
- package/dist/commands/roles/delete.d.ts +9 -0
- package/dist/commands/roles/delete.js +21 -0
- package/dist/commands/roles/list.d.ts +9 -0
- package/dist/commands/roles/list.js +23 -0
- package/dist/commands/roles/show.d.ts +9 -0
- package/dist/commands/roles/show.js +25 -0
- package/dist/commands/roles/update.d.ts +14 -0
- package/dist/commands/roles/update.js +44 -0
- package/dist/commands/teams/add-member.d.ts +10 -0
- package/dist/commands/teams/add-member.js +26 -0
- package/dist/commands/teams/create.d.ts +16 -0
- package/dist/commands/teams/create.js +50 -0
- package/dist/commands/teams/delete.d.ts +9 -0
- package/dist/commands/teams/delete.js +21 -0
- package/dist/commands/teams/list.d.ts +9 -0
- package/dist/commands/teams/list.js +27 -0
- package/dist/commands/teams/remove-member.d.ts +10 -0
- package/dist/commands/teams/remove-member.js +26 -0
- package/dist/commands/teams/show.d.ts +9 -0
- package/dist/commands/teams/show.js +27 -0
- package/dist/commands/teams/update.d.ts +17 -0
- package/dist/commands/teams/update.js +54 -0
- package/dist/commands/tickets/create.d.ts +18 -0
- package/dist/commands/tickets/create.js +51 -0
- package/dist/commands/tickets/list.d.ts +10 -0
- package/dist/commands/tickets/list.js +24 -0
- package/dist/commands/tickets/show.d.ts +12 -0
- package/dist/commands/tickets/show.js +23 -0
- package/dist/commands/tokens/create.d.ts +11 -0
- package/dist/commands/tokens/create.js +34 -0
- package/dist/commands/tokens/list.d.ts +9 -0
- package/dist/commands/tokens/list.js +25 -0
- package/dist/commands/tokens/revoke.d.ts +12 -0
- package/dist/commands/tokens/revoke.js +22 -0
- package/dist/commands/tokens/rotate.d.ts +12 -0
- package/dist/commands/tokens/rotate.js +28 -0
- package/dist/commands/whoami.d.ts +6 -0
- package/dist/commands/whoami.js +19 -0
- package/dist/errors/error-codes.d.ts +35 -0
- package/dist/errors/error-codes.js +40 -0
- package/dist/lib/api.d.ts +28 -0
- package/dist/lib/api.js +81 -0
- package/dist/lib/browser.d.ts +2 -0
- package/dist/lib/browser.js +32 -0
- package/dist/lib/config.d.ts +20 -0
- package/dist/lib/config.js +93 -0
- package/dist/lib/device-flow.d.ts +28 -0
- package/dist/lib/device-flow.js +62 -0
- package/dist/lib/output.d.ts +4 -0
- package/dist/lib/output.js +21 -0
- package/oclif.manifest.json +1954 -0
- package/opencli.json +229 -0
- package/package.json +34 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class InvitationsRevoke extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Invitation id (UUID)', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Revoke a pending invitation';
|
|
10
|
+
static examples = ['<%= config.bin %> invitations revoke <invitation-uuid>'];
|
|
11
|
+
async run() {
|
|
12
|
+
const { args } = await this.parse(InvitationsRevoke);
|
|
13
|
+
await this.api.delete(`/cli/v1/invitations/${args.id}`);
|
|
14
|
+
if (!this.jsonEnabled()) {
|
|
15
|
+
this.log(`Invitation revoked: ${args.id}`);
|
|
16
|
+
}
|
|
17
|
+
return { revoked: args.id };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = InvitationsRevoke;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../base';
|
|
2
|
+
export default class Login extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
'api-url': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../base");
|
|
5
|
+
const api_1 = require("../lib/api");
|
|
6
|
+
const config_1 = require("../lib/config");
|
|
7
|
+
const browser_1 = require("../lib/browser");
|
|
8
|
+
const device_flow_1 = require("../lib/device-flow");
|
|
9
|
+
class Login extends base_1.BaseCommand {
|
|
10
|
+
static description = 'Authenticate via the device flow and store your CLI token';
|
|
11
|
+
static examples = ['<%= config.bin %> login', '<%= config.bin %> login --api-url https://staging.closeyour.it'];
|
|
12
|
+
static flags = {
|
|
13
|
+
'api-url': core_1.Flags.string({ description: 'Backend base URL to authenticate against (persisted)' }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { flags } = await this.parse(Login);
|
|
17
|
+
if (flags['api-url']) {
|
|
18
|
+
this.cfg.apiUrl = flags['api-url'];
|
|
19
|
+
(0, config_1.saveConfig)(this.cfg);
|
|
20
|
+
}
|
|
21
|
+
const clientName = `closeyourit-cli/${this.config.version} (${process.platform} ${process.arch})`;
|
|
22
|
+
const authorization = await (0, device_flow_1.startDeviceFlow)(this.cfg.apiUrl, clientName);
|
|
23
|
+
if (!this.jsonEnabled()) {
|
|
24
|
+
this.log('');
|
|
25
|
+
this.log('To authorize this CLI, open:');
|
|
26
|
+
this.log(` ${authorization.verification_uri}`);
|
|
27
|
+
this.log('');
|
|
28
|
+
this.log('and enter the code:');
|
|
29
|
+
this.log('');
|
|
30
|
+
this.log(` ${authorization.user_code}`);
|
|
31
|
+
this.log('');
|
|
32
|
+
this.log('Opening your browser…');
|
|
33
|
+
}
|
|
34
|
+
(0, browser_1.openUrl)(authorization.verification_uri_complete);
|
|
35
|
+
const result = await (0, device_flow_1.pollDeviceToken)(this.cfg.apiUrl, authorization.device_code, {
|
|
36
|
+
interval: authorization.interval,
|
|
37
|
+
expiresIn: authorization.expires_in,
|
|
38
|
+
onPending: () => {
|
|
39
|
+
if (!this.jsonEnabled())
|
|
40
|
+
process.stderr.write('.');
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
this.cfg.token = result.access_token;
|
|
44
|
+
(0, config_1.saveConfig)(this.cfg);
|
|
45
|
+
// Enrich the local config with identity (account + organization).
|
|
46
|
+
this.api = new api_1.CliApi(this.cfg);
|
|
47
|
+
const who = await this.api.get('/cli/v1/whoami');
|
|
48
|
+
const account = who.data.account;
|
|
49
|
+
const organization = who.data.organization;
|
|
50
|
+
if (account)
|
|
51
|
+
this.cfg.account = { id: account.id, name: account.name, email: account.email };
|
|
52
|
+
if (organization) {
|
|
53
|
+
this.cfg.organization = { id: organization.id, name: organization.name, slug: organization.slug };
|
|
54
|
+
}
|
|
55
|
+
(0, config_1.saveConfig)(this.cfg);
|
|
56
|
+
if (!this.jsonEnabled()) {
|
|
57
|
+
this.log('');
|
|
58
|
+
this.log(`Logged in as ${this.cfg.account?.email ?? 'unknown'} · ${this.cfg.organization?.name ?? 'no organization'}`);
|
|
59
|
+
}
|
|
60
|
+
return { account: this.cfg.account, organization: this.cfg.organization, token: result.token };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.default = Login;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../base");
|
|
4
|
+
const config_1 = require("../lib/config");
|
|
5
|
+
class Logout extends base_1.BaseCommand {
|
|
6
|
+
static description = 'Clear the locally stored token and identity';
|
|
7
|
+
static examples = ['<%= config.bin %> logout'];
|
|
8
|
+
async run() {
|
|
9
|
+
(0, config_1.clearToken)();
|
|
10
|
+
if (!this.jsonEnabled()) {
|
|
11
|
+
this.log('Logged out. Local credentials cleared.');
|
|
12
|
+
this.log('To revoke the token on the server, visit /account/cli/tokens.');
|
|
13
|
+
}
|
|
14
|
+
return { ok: true };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = Logout;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class MembersList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
page: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../../base");
|
|
4
|
+
const output_1 = require("../../lib/output");
|
|
5
|
+
class MembersList extends base_1.BaseCommand {
|
|
6
|
+
static description = 'List the members of your organization (to resolve emails to account ids)';
|
|
7
|
+
static examples = ['<%= config.bin %> members list', '<%= config.bin %> members list --json'];
|
|
8
|
+
static flags = { ...base_1.pageFlag };
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(MembersList);
|
|
11
|
+
const res = await this.api.get(`/cli/v1/members?page=${flags.page}`);
|
|
12
|
+
const members = res.data ?? [];
|
|
13
|
+
if (!this.jsonEnabled()) {
|
|
14
|
+
this.log((0, output_1.renderTable)(['EMAIL', 'NAME', 'ROLE', 'ACCOUNT_ID'], members.map((member) => [
|
|
15
|
+
String(member.email ?? ''),
|
|
16
|
+
String(member.name ?? ''),
|
|
17
|
+
String(member.membership_role ?? ''),
|
|
18
|
+
String(member.account_id ?? ''),
|
|
19
|
+
])));
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = MembersList;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class MetricsList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
kind: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
page: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
project: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class MetricsList extends base_1.BaseCommand {
|
|
7
|
+
static description = 'List performance metric groups (slow queries/methods) for a project';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> metrics list --project acme-api',
|
|
10
|
+
'<%= config.bin %> metrics list -p acme-api --kind sql --json',
|
|
11
|
+
];
|
|
12
|
+
static flags = {
|
|
13
|
+
...base_1.projectFlag,
|
|
14
|
+
...base_1.pageFlag,
|
|
15
|
+
kind: core_1.Flags.string({ description: 'Filter by metric kind (e.g. sql, method)' }),
|
|
16
|
+
};
|
|
17
|
+
async run() {
|
|
18
|
+
const { flags } = await this.parse(MetricsList);
|
|
19
|
+
const projectId = await this.resolveProjectId(flags.project);
|
|
20
|
+
const query = new URLSearchParams({ page: String(flags.page) });
|
|
21
|
+
if (flags.kind)
|
|
22
|
+
query.set('kind', flags.kind);
|
|
23
|
+
const res = await this.api.get(`/cli/v1/projects/${projectId}/metric_groups?${query.toString()}`);
|
|
24
|
+
const groups = res.data ?? [];
|
|
25
|
+
if (!this.jsonEnabled()) {
|
|
26
|
+
this.log((0, output_1.renderTable)(['ID', 'KIND', 'NAME', 'COUNT'], groups.map((group) => [
|
|
27
|
+
String(group.id ?? ''),
|
|
28
|
+
String(group.kind ?? ''),
|
|
29
|
+
String(group.name ?? group.title ?? ''),
|
|
30
|
+
String(group.samples_count ?? group.count ?? ''),
|
|
31
|
+
])));
|
|
32
|
+
}
|
|
33
|
+
return res;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = MetricsList;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class MetricsShow extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
project: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class MetricsShow extends base_1.BaseCommand {
|
|
7
|
+
static description = 'Show a single metric group';
|
|
8
|
+
static examples = ['<%= config.bin %> metrics show <group-id> --project acme-api'];
|
|
9
|
+
static args = {
|
|
10
|
+
id: core_1.Args.string({ description: 'Metric group id', required: true }),
|
|
11
|
+
};
|
|
12
|
+
static flags = { ...base_1.projectFlag };
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(MetricsShow);
|
|
15
|
+
const projectId = await this.resolveProjectId(flags.project);
|
|
16
|
+
const res = await this.api.get(`/cli/v1/projects/${projectId}/metric_groups/${args.id}`);
|
|
17
|
+
if (!this.jsonEnabled()) {
|
|
18
|
+
this.log((0, output_1.renderRecord)(res.data ?? {}));
|
|
19
|
+
}
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = MetricsShow;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ProjectsCreate extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
color: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
group: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
key: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class ProjectsCreate extends base_1.BaseCommand {
|
|
7
|
+
static args = {
|
|
8
|
+
name: core_1.Args.string({ description: 'Project name', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Create a project (optionally inside a group)';
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> projects create driverone-rails --key DRRA',
|
|
13
|
+
'<%= config.bin %> projects create driverone-rails --group DriverOne --key DRRA',
|
|
14
|
+
'<%= config.bin %> projects create driverone-flutter -g <group-uuid> -k DRFL',
|
|
15
|
+
];
|
|
16
|
+
static flags = {
|
|
17
|
+
color: core_1.Flags.string({ description: 'Color label' }),
|
|
18
|
+
description: core_1.Flags.string({ description: 'Free-form description' }),
|
|
19
|
+
group: core_1.Flags.string({ char: 'g', description: 'Group id (UUID) or name to place the project in' }),
|
|
20
|
+
key: core_1.Flags.string({
|
|
21
|
+
char: 'k',
|
|
22
|
+
description: 'Project key (uppercase A-Z0-9, unique per org; derived from the name if omitted)',
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
async run() {
|
|
26
|
+
const { args, flags } = await this.parse(ProjectsCreate);
|
|
27
|
+
const body = { name: args.name };
|
|
28
|
+
if (flags.key !== undefined)
|
|
29
|
+
body.key = flags.key;
|
|
30
|
+
if (flags.color !== undefined)
|
|
31
|
+
body.color = flags.color;
|
|
32
|
+
if (flags.description !== undefined)
|
|
33
|
+
body.description = flags.description;
|
|
34
|
+
if (flags.group !== undefined) {
|
|
35
|
+
// UUID → group_id; otherwise treat as a group name (resolved server-side within the org).
|
|
36
|
+
if (base_1.UUID_RE.test(flags.group))
|
|
37
|
+
body.group_id = flags.group;
|
|
38
|
+
else
|
|
39
|
+
body.group_name = flags.group;
|
|
40
|
+
}
|
|
41
|
+
const res = await this.api.post('/cli/v1/projects', body);
|
|
42
|
+
if (!this.jsonEnabled()) {
|
|
43
|
+
this.log('Project created:');
|
|
44
|
+
this.log((0, output_1.renderRecord)(res.data ?? {}));
|
|
45
|
+
}
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = ProjectsCreate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ProjectsList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
page: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../../base");
|
|
4
|
+
const output_1 = require("../../lib/output");
|
|
5
|
+
class ProjectsList extends base_1.BaseCommand {
|
|
6
|
+
static description = 'List the projects visible to you';
|
|
7
|
+
static examples = ['<%= config.bin %> projects list', '<%= config.bin %> projects list --page 2 --json'];
|
|
8
|
+
static flags = { ...base_1.pageFlag };
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(ProjectsList);
|
|
11
|
+
const res = await this.api.get(`/cli/v1/projects?page=${flags.page}`);
|
|
12
|
+
const projects = res.data ?? [];
|
|
13
|
+
if (!this.jsonEnabled()) {
|
|
14
|
+
this.log((0, output_1.renderTable)(['KEY', 'NAME', 'ID'], projects.map((project) => [String(project.key ?? ''), String(project.name ?? ''), String(project.id ?? '')])));
|
|
15
|
+
}
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = ProjectsList;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ProjectsSetEnvironments extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
code: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
'environment-id': import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
project: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class ProjectsSetEnvironments extends base_1.BaseCommand {
|
|
6
|
+
static description = 'Declare the environments a project receives data from (replaces the current set)';
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%= config.bin %> projects set-environments --project legalbloom-rails --code production',
|
|
9
|
+
'<%= config.bin %> projects set-environments -p LBRA --code production --code staging',
|
|
10
|
+
];
|
|
11
|
+
static flags = {
|
|
12
|
+
...base_1.projectFlag,
|
|
13
|
+
code: core_1.Flags.string({
|
|
14
|
+
description: 'Environment code, e.g. production (repeatable)',
|
|
15
|
+
multiple: true,
|
|
16
|
+
default: [],
|
|
17
|
+
}),
|
|
18
|
+
'environment-id': core_1.Flags.string({
|
|
19
|
+
description: 'Environment id / UUID (repeatable)',
|
|
20
|
+
multiple: true,
|
|
21
|
+
default: [],
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { flags } = await this.parse(ProjectsSetEnvironments);
|
|
26
|
+
const projectId = await this.resolveProjectId(flags.project);
|
|
27
|
+
const res = await this.api.put(`/cli/v1/projects/${projectId}/environments`, { codes: flags.code, environment_ids: flags['environment-id'] });
|
|
28
|
+
const envs = res.data ?? [];
|
|
29
|
+
if (!this.jsonEnabled()) {
|
|
30
|
+
if (envs.length === 0) {
|
|
31
|
+
this.log('Project now declares no environments.');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.log('Declared environments:');
|
|
35
|
+
for (const e of envs)
|
|
36
|
+
this.log(` ${e.code}${e.label ? ` — ${e.label}` : ''}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return res;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = ProjectsSetEnvironments;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ProjectsShow extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class ProjectsShow extends base_1.BaseCommand {
|
|
7
|
+
static description = 'Show a single project by id or key';
|
|
8
|
+
static examples = ['<%= config.bin %> projects show acme-api', '<%= config.bin %> projects show <uuid> --json'];
|
|
9
|
+
static args = {
|
|
10
|
+
id: core_1.Args.string({ description: 'Project id (UUID) or key', required: true }),
|
|
11
|
+
};
|
|
12
|
+
async run() {
|
|
13
|
+
const { args } = await this.parse(ProjectsShow);
|
|
14
|
+
const projectId = await this.resolveProjectId(args.id);
|
|
15
|
+
const res = await this.api.get(`/cli/v1/projects/${projectId}`);
|
|
16
|
+
if (!this.jsonEnabled()) {
|
|
17
|
+
this.log((0, output_1.renderRecord)(res.data ?? {}));
|
|
18
|
+
}
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = ProjectsShow;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class RolesCreate extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
color: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
permission: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<unknown>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class RolesCreate extends base_1.BaseCommand {
|
|
7
|
+
static args = {
|
|
8
|
+
name: core_1.Args.string({ description: 'Role name', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Create an RBAC role (a named bundle of permission keys)';
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> roles create Client --permission tickets.edit --permission tickets.assign',
|
|
13
|
+
];
|
|
14
|
+
static flags = {
|
|
15
|
+
color: core_1.Flags.string({ description: 'Color label' }),
|
|
16
|
+
permission: core_1.Flags.string({ description: 'Permission key from the catalog (repeatable)', multiple: true }),
|
|
17
|
+
};
|
|
18
|
+
async run() {
|
|
19
|
+
const { args, flags } = await this.parse(RolesCreate);
|
|
20
|
+
const body = { name: args.name };
|
|
21
|
+
if (flags.color !== undefined)
|
|
22
|
+
body.color = flags.color;
|
|
23
|
+
if (flags.permission !== undefined)
|
|
24
|
+
body.permission_keys = flags.permission;
|
|
25
|
+
const res = await this.api.post('/cli/v1/roles', body);
|
|
26
|
+
if (!this.jsonEnabled()) {
|
|
27
|
+
const data = res.data ?? {};
|
|
28
|
+
this.log('Role created:');
|
|
29
|
+
this.log((0, output_1.renderRecord)(data));
|
|
30
|
+
const keys = Array.isArray(data.permission_keys) ? data.permission_keys : [];
|
|
31
|
+
this.log(`permissions: ${keys.length > 0 ? keys.join(', ') : '-'}`);
|
|
32
|
+
}
|
|
33
|
+
return res;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = RolesCreate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class RolesDelete extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
role: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class RolesDelete extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
role: core_1.Args.string({ description: 'Role id (UUID) or name', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Delete a role (its assignments to teams and accounts are removed)';
|
|
10
|
+
static examples = ['<%= config.bin %> roles delete Client'];
|
|
11
|
+
async run() {
|
|
12
|
+
const { args } = await this.parse(RolesDelete);
|
|
13
|
+
const id = await this.resolveRoleId(args.role);
|
|
14
|
+
await this.api.delete(`/cli/v1/roles/${id}`);
|
|
15
|
+
if (!this.jsonEnabled()) {
|
|
16
|
+
this.log(`Role deleted: ${args.role}`);
|
|
17
|
+
}
|
|
18
|
+
return { deleted: id };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = RolesDelete;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class RolesList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
page: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../../base");
|
|
4
|
+
const output_1 = require("../../lib/output");
|
|
5
|
+
class RolesList extends base_1.BaseCommand {
|
|
6
|
+
static description = 'List the RBAC roles in your organization';
|
|
7
|
+
static examples = ['<%= config.bin %> roles list', '<%= config.bin %> roles list --json'];
|
|
8
|
+
static flags = { ...base_1.pageFlag };
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(RolesList);
|
|
11
|
+
const res = await this.api.get(`/cli/v1/roles?page=${flags.page}`);
|
|
12
|
+
const roles = res.data ?? [];
|
|
13
|
+
if (!this.jsonEnabled()) {
|
|
14
|
+
this.log((0, output_1.renderTable)(['NAME', 'PERMISSIONS', 'ID'], roles.map((role) => [
|
|
15
|
+
String(role.name ?? ''),
|
|
16
|
+
String((Array.isArray(role.permission_keys) ? role.permission_keys : []).length),
|
|
17
|
+
String(role.id ?? ''),
|
|
18
|
+
])));
|
|
19
|
+
}
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = RolesList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class RolesShow extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
role: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class RolesShow extends base_1.BaseCommand {
|
|
7
|
+
static args = {
|
|
8
|
+
role: core_1.Args.string({ description: 'Role id (UUID) or name', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Show a role by id or name (with its permission keys)';
|
|
11
|
+
static examples = ['<%= config.bin %> roles show Client'];
|
|
12
|
+
async run() {
|
|
13
|
+
const { args } = await this.parse(RolesShow);
|
|
14
|
+
const id = await this.resolveRoleId(args.role);
|
|
15
|
+
const res = await this.api.get(`/cli/v1/roles/${id}`);
|
|
16
|
+
if (!this.jsonEnabled()) {
|
|
17
|
+
const data = res.data ?? {};
|
|
18
|
+
this.log((0, output_1.renderRecord)(data));
|
|
19
|
+
const keys = Array.isArray(data.permission_keys) ? data.permission_keys : [];
|
|
20
|
+
this.log(`permissions: ${keys.length > 0 ? keys.join(', ') : '-'}`);
|
|
21
|
+
}
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = RolesShow;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class RolesUpdate extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
role: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
color: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
permission: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<unknown>;
|
|
14
|
+
}
|