@agentuity/cli 0.1.7 → 0.1.9
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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +68 -4
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/skills/generator.d.ts.map +1 -1
- package/dist/cmd/ai/skills/generator.js +9 -1
- package/dist/cmd/ai/skills/generator.js.map +1 -1
- package/dist/cmd/build/vite/agent-discovery.d.ts.map +1 -1
- package/dist/cmd/build/vite/agent-discovery.js +159 -16
- package/dist/cmd/build/vite/agent-discovery.js.map +1 -1
- package/dist/cmd/build/vite/docs-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/docs-generator.js +8 -4
- package/dist/cmd/build/vite/docs-generator.js.map +1 -1
- package/dist/cmd/build/vite/metadata-generator.js +1 -1
- package/dist/cmd/build/vite/metadata-generator.js.map +1 -1
- package/dist/cmd/build/vite/registry-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/registry-generator.js +27 -4
- package/dist/cmd/build/vite/registry-generator.js.map +1 -1
- package/dist/cmd/build/vite/server-bundler.d.ts.map +1 -1
- package/dist/cmd/build/vite/server-bundler.js.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.js +5 -2
- package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
- package/dist/cmd/canary/index.d.ts.map +1 -1
- package/dist/cmd/canary/index.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +13 -2
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/sandbox/create.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/create.js +15 -0
- package/dist/cmd/cloud/sandbox/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/get.js +17 -0
- package/dist/cmd/cloud/sandbox/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/index.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/index.js +2 -0
- package/dist/cmd/cloud/sandbox/index.js.map +1 -1
- package/dist/cmd/cloud/sandbox/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/list.js +12 -5
- package/dist/cmd/cloud/sandbox/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/run.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/run.js +11 -0
- package/dist/cmd/cloud/sandbox/run.js.map +1 -1
- package/dist/cmd/cloud/sandbox/runtime/index.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/runtime/index.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/runtime/index.js +19 -0
- package/dist/cmd/cloud/sandbox/runtime/index.js.map +1 -0
- package/dist/cmd/cloud/sandbox/runtime/list.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/runtime/list.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/runtime/list.js +68 -0
- package/dist/cmd/cloud/sandbox/runtime/list.js.map +1 -0
- package/dist/cmd/cloud/sandbox/snapshot/create.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/create.js +36 -5
- package/dist/cmd/cloud/sandbox/snapshot/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/list.js +4 -0
- package/dist/cmd/cloud/sandbox/snapshot/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/tag.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/tag.js +10 -0
- package/dist/cmd/cloud/sandbox/snapshot/tag.js.map +1 -1
- package/dist/cmd/git/account/add.js +1 -1
- package/dist/cmd/git/account/add.js.map +1 -1
- package/dist/cmd/git/account/list.js +1 -1
- package/dist/cmd/git/account/list.js.map +1 -1
- package/dist/cmd/git/account/remove.js +1 -1
- package/dist/cmd/git/account/remove.js.map +1 -1
- package/dist/cmd/git/api.d.ts.map +1 -0
- package/dist/cmd/git/api.js.map +1 -0
- package/dist/cmd/git/link.js +1 -1
- package/dist/cmd/git/link.js.map +1 -1
- package/dist/cmd/git/list.js +1 -1
- package/dist/cmd/git/list.js.map +1 -1
- package/dist/cmd/git/status.js +1 -1
- package/dist/cmd/git/status.js.map +1 -1
- package/dist/cmd/git/unlink.js +1 -1
- package/dist/cmd/git/unlink.js.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +0 -1
- package/dist/cmd/index.js.map +1 -1
- package/dist/cmd/project/auth/generate.js.map +1 -1
- package/dist/cmd/project/auth/init.js.map +1 -1
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -0
- package/dist/config.js.map +1 -1
- package/dist/utils/dependency-checker.d.ts.map +1 -1
- package/dist/utils/dependency-checker.js +5 -1
- package/dist/utils/dependency-checker.js.map +1 -1
- package/package.json +6 -6
- package/src/cli.ts +89 -4
- package/src/cmd/ai/skills/generator.ts +9 -1
- package/src/cmd/build/vite/agent-discovery.ts +209 -16
- package/src/cmd/build/vite/docs-generator.ts +8 -4
- package/src/cmd/build/vite/metadata-generator.ts +1 -1
- package/src/cmd/build/vite/registry-generator.ts +29 -4
- package/src/cmd/build/vite/server-bundler.ts +1 -4
- package/src/cmd/build/vite/vite-asset-server-config.ts +5 -2
- package/src/cmd/canary/index.ts +3 -1
- package/src/cmd/cloud/deploy.ts +15 -1
- package/src/cmd/cloud/sandbox/create.ts +15 -0
- package/src/cmd/cloud/sandbox/get.ts +17 -0
- package/src/cmd/cloud/sandbox/index.ts +2 -0
- package/src/cmd/cloud/sandbox/list.ts +12 -5
- package/src/cmd/cloud/sandbox/run.ts +11 -0
- package/src/cmd/cloud/sandbox/runtime/index.ts +20 -0
- package/src/cmd/cloud/sandbox/runtime/list.ts +75 -0
- package/src/cmd/cloud/sandbox/snapshot/create.ts +44 -5
- package/src/cmd/cloud/sandbox/snapshot/get.ts +1 -1
- package/src/cmd/cloud/sandbox/snapshot/list.ts +4 -0
- package/src/cmd/cloud/sandbox/snapshot/tag.ts +14 -0
- package/src/cmd/git/account/add.ts +1 -1
- package/src/cmd/git/account/list.ts +1 -1
- package/src/cmd/git/account/remove.ts +1 -1
- package/src/cmd/git/link.ts +1 -1
- package/src/cmd/git/list.ts +1 -1
- package/src/cmd/git/status.ts +1 -1
- package/src/cmd/git/unlink.ts +1 -1
- package/src/cmd/index.ts +0 -1
- package/src/cmd/project/auth/generate.ts +4 -4
- package/src/cmd/project/auth/init.ts +2 -2
- package/src/cmd/project/template-flow.ts +3 -3
- package/src/config.ts +10 -0
- package/src/utils/dependency-checker.ts +6 -2
- package/dist/cmd/integration/api.d.ts.map +0 -1
- package/dist/cmd/integration/api.js.map +0 -1
- package/dist/cmd/integration/github/connect.d.ts +0 -2
- package/dist/cmd/integration/github/connect.d.ts.map +0 -1
- package/dist/cmd/integration/github/connect.js +0 -197
- package/dist/cmd/integration/github/connect.js.map +0 -1
- package/dist/cmd/integration/github/disconnect.d.ts +0 -2
- package/dist/cmd/integration/github/disconnect.d.ts.map +0 -1
- package/dist/cmd/integration/github/disconnect.js +0 -121
- package/dist/cmd/integration/github/disconnect.js.map +0 -1
- package/dist/cmd/integration/github/index.d.ts +0 -2
- package/dist/cmd/integration/github/index.d.ts.map +0 -1
- package/dist/cmd/integration/github/index.js +0 -21
- package/dist/cmd/integration/github/index.js.map +0 -1
- package/dist/cmd/integration/index.d.ts +0 -2
- package/dist/cmd/integration/index.d.ts.map +0 -1
- package/dist/cmd/integration/index.js +0 -16
- package/dist/cmd/integration/index.js.map +0 -1
- package/src/cmd/integration/github/connect.ts +0 -242
- package/src/cmd/integration/github/disconnect.ts +0 -149
- package/src/cmd/integration/github/index.ts +0 -21
- package/src/cmd/integration/index.ts +0 -16
- /package/dist/cmd/{integration → git}/api.d.ts +0 -0
- /package/dist/cmd/{integration → git}/api.js +0 -0
- /package/src/cmd/{integration → git}/api.ts +0 -0
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { createSubcommand } from '../../../types';
|
|
2
|
-
import * as tui from '../../../tui';
|
|
3
|
-
import { getCommand } from '../../../command-prefix';
|
|
4
|
-
import { getAPIBaseURL } from '../../../api';
|
|
5
|
-
import { ErrorCode } from '../../../errors';
|
|
6
|
-
import { listOrganizations } from '@agentuity/server';
|
|
7
|
-
import enquirer from 'enquirer';
|
|
8
|
-
import {
|
|
9
|
-
startGithubIntegration,
|
|
10
|
-
pollForGithubIntegration,
|
|
11
|
-
getGithubIntegrationStatus,
|
|
12
|
-
getExistingGithubIntegrations,
|
|
13
|
-
copyGithubIntegration,
|
|
14
|
-
} from '../api';
|
|
15
|
-
|
|
16
|
-
export const connectSubcommand = createSubcommand({
|
|
17
|
-
name: 'connect',
|
|
18
|
-
description: 'Connect your GitHub account to enable automatic deployments',
|
|
19
|
-
tags: ['mutating', 'creates-resource', 'slow', 'api-intensive'],
|
|
20
|
-
idempotent: false,
|
|
21
|
-
requires: { auth: true, apiClient: true },
|
|
22
|
-
examples: [
|
|
23
|
-
{
|
|
24
|
-
command: getCommand('integration github connect'),
|
|
25
|
-
description: 'Connect GitHub to your organization',
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
|
|
29
|
-
async handler(ctx) {
|
|
30
|
-
const { logger, apiClient } = ctx;
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
// Fetch organizations
|
|
34
|
-
const orgs = await tui.spinner({
|
|
35
|
-
message: 'Fetching organizations...',
|
|
36
|
-
clearOnSuccess: true,
|
|
37
|
-
callback: () => listOrganizations(apiClient),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (orgs.length === 0) {
|
|
41
|
-
tui.fatal('No organizations found for your account');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Check GitHub status for each org
|
|
45
|
-
const orgStatuses = await tui.spinner({
|
|
46
|
-
message: 'Checking GitHub integration status...',
|
|
47
|
-
clearOnSuccess: true,
|
|
48
|
-
callback: async () => {
|
|
49
|
-
const statuses = await Promise.all(
|
|
50
|
-
orgs.map(async (org) => {
|
|
51
|
-
const status = await getGithubIntegrationStatus(apiClient, org.id);
|
|
52
|
-
return {
|
|
53
|
-
...org,
|
|
54
|
-
connected: status.connected,
|
|
55
|
-
integrations: status.integrations,
|
|
56
|
-
};
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
return statuses;
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// Sort orgs alphabetically
|
|
64
|
-
const sortedOrgs = [...orgStatuses].sort((a, b) => a.name.localeCompare(b.name));
|
|
65
|
-
|
|
66
|
-
// Build choices showing integration count
|
|
67
|
-
const choices = sortedOrgs.map((org) => {
|
|
68
|
-
const count = org.integrations.length;
|
|
69
|
-
const suffix =
|
|
70
|
-
count > 0 ? tui.muted(` (${count} GitHub account${count > 1 ? 's' : ''})`) : '';
|
|
71
|
-
return {
|
|
72
|
-
name: org.name,
|
|
73
|
-
message: `${org.name}${suffix}`,
|
|
74
|
-
value: org.id,
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Show picker
|
|
79
|
-
const response = await enquirer.prompt<{ orgName: string }>({
|
|
80
|
-
type: 'select',
|
|
81
|
-
name: 'orgName',
|
|
82
|
-
message: 'Select an organization to connect',
|
|
83
|
-
choices,
|
|
84
|
-
result(name: string) {
|
|
85
|
-
// @ts-expect-error - this.map exists at runtime
|
|
86
|
-
return this.map(name)[name];
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const orgId = response.orgName;
|
|
91
|
-
const selectedOrg = sortedOrgs.find((o) => o.id === orgId);
|
|
92
|
-
const orgDisplay = selectedOrg ? selectedOrg.name : orgId;
|
|
93
|
-
const initialCount = selectedOrg?.integrations.length ?? 0;
|
|
94
|
-
|
|
95
|
-
// Check if user has existing GitHub integrations in other orgs
|
|
96
|
-
const existingIntegrations = await tui.spinner({
|
|
97
|
-
message: 'Checking for existing GitHub connections...',
|
|
98
|
-
clearOnSuccess: true,
|
|
99
|
-
callback: () => getExistingGithubIntegrations(apiClient, orgId),
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Filter out integrations already connected to target org
|
|
103
|
-
const alreadyConnectedNames = new Set(
|
|
104
|
-
selectedOrg?.integrations.map((i) => i.githubAccountName) ?? []
|
|
105
|
-
);
|
|
106
|
-
const availableIntegrations = existingIntegrations.filter(
|
|
107
|
-
(i) => !alreadyConnectedNames.has(i.githubAccountName)
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
if (availableIntegrations.length > 0) {
|
|
111
|
-
tui.newline();
|
|
112
|
-
|
|
113
|
-
// Build checkbox choices
|
|
114
|
-
const integrationChoices = availableIntegrations.map((i) => ({
|
|
115
|
-
name: i.id,
|
|
116
|
-
message: `${i.githubAccountName} ${tui.muted(`(from ${i.orgName})`)}`,
|
|
117
|
-
}));
|
|
118
|
-
|
|
119
|
-
console.log(tui.muted('Press enter with none selected to connect a new account'));
|
|
120
|
-
tui.newline();
|
|
121
|
-
|
|
122
|
-
const selectResponse = await enquirer.prompt<{ integrationIds: string[] }>({
|
|
123
|
-
type: 'multiselect',
|
|
124
|
-
name: 'integrationIds',
|
|
125
|
-
message: 'Select GitHub accounts to connect',
|
|
126
|
-
choices: integrationChoices,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
if (selectResponse.integrationIds.length > 0) {
|
|
130
|
-
const selectedIntegrations = availableIntegrations.filter((i) =>
|
|
131
|
-
selectResponse.integrationIds.includes(i.id)
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const accountNames = selectedIntegrations.map((i) => i.githubAccountName).join(', ');
|
|
135
|
-
|
|
136
|
-
// Confirm
|
|
137
|
-
const confirmResponse = await enquirer.prompt<{ confirm: boolean }>({
|
|
138
|
-
type: 'confirm',
|
|
139
|
-
name: 'confirm',
|
|
140
|
-
message: `Connect ${tui.bold(accountNames)} to ${tui.bold(orgDisplay)}?`,
|
|
141
|
-
initial: true,
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
if (confirmResponse.confirm) {
|
|
145
|
-
await tui.spinner({
|
|
146
|
-
message: `Copying ${selectedIntegrations.length} GitHub connection${selectedIntegrations.length > 1 ? 's' : ''}...`,
|
|
147
|
-
clearOnSuccess: true,
|
|
148
|
-
callback: async () => {
|
|
149
|
-
for (const integration of selectedIntegrations) {
|
|
150
|
-
await copyGithubIntegration(apiClient, integration.orgId, orgId);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
tui.newline();
|
|
156
|
-
tui.success(`GitHub connected to ${tui.bold(orgDisplay)}`);
|
|
157
|
-
tui.newline();
|
|
158
|
-
console.log(
|
|
159
|
-
'You can now link repositories to your projects for automatic deployments.'
|
|
160
|
-
);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const startResult = await tui.spinner({
|
|
167
|
-
message: 'Getting GitHub authorization URL...',
|
|
168
|
-
clearOnSuccess: true,
|
|
169
|
-
callback: () => startGithubIntegration(apiClient, orgId),
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
if (!startResult) {
|
|
173
|
-
tui.error('Failed to get GitHub authorization URL');
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const { shortId } = startResult;
|
|
178
|
-
const apiBaseUrl = getAPIBaseURL(ctx.config);
|
|
179
|
-
const url = `${apiBaseUrl}/github/connect/${shortId}`;
|
|
180
|
-
|
|
181
|
-
const copied = await tui.copyToClipboard(url);
|
|
182
|
-
|
|
183
|
-
tui.newline();
|
|
184
|
-
if (copied) {
|
|
185
|
-
console.log('GitHub authorization URL copied to clipboard! Open it in your browser:');
|
|
186
|
-
} else {
|
|
187
|
-
console.log('Open this URL in your browser to authorize GitHub access:');
|
|
188
|
-
}
|
|
189
|
-
tui.newline();
|
|
190
|
-
console.log(` ${tui.link(url)}`);
|
|
191
|
-
tui.newline();
|
|
192
|
-
console.log(tui.muted('Press Enter to open in your browser, or Ctrl+C to cancel'));
|
|
193
|
-
tui.newline();
|
|
194
|
-
|
|
195
|
-
const result = await tui.spinner({
|
|
196
|
-
type: 'countdown',
|
|
197
|
-
message: 'Waiting for GitHub authorization',
|
|
198
|
-
timeoutMs: 600000, // 10 minutes
|
|
199
|
-
clearOnSuccess: true,
|
|
200
|
-
onEnterPress: () => {
|
|
201
|
-
const platform = process.platform;
|
|
202
|
-
if (platform === 'win32') {
|
|
203
|
-
Bun.spawn(['cmd', '/c', 'start', '', url], {
|
|
204
|
-
stdout: 'ignore',
|
|
205
|
-
stderr: 'ignore',
|
|
206
|
-
});
|
|
207
|
-
} else {
|
|
208
|
-
const command = platform === 'darwin' ? 'open' : 'xdg-open';
|
|
209
|
-
Bun.spawn([command, url], { stdout: 'ignore', stderr: 'ignore' });
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
callback: async () => {
|
|
213
|
-
return await pollForGithubIntegration(apiClient, orgId, initialCount);
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
tui.newline();
|
|
218
|
-
if (result.connected) {
|
|
219
|
-
tui.success(`GitHub connected to ${tui.bold(orgDisplay)}`);
|
|
220
|
-
tui.newline();
|
|
221
|
-
console.log(
|
|
222
|
-
'You can now link repositories to your projects for automatic deployments.'
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
} catch (error) {
|
|
226
|
-
// Handle user cancellation (Ctrl+C) - enquirer throws empty string or Error with empty message
|
|
227
|
-
const isCancel =
|
|
228
|
-
error === '' ||
|
|
229
|
-
(error instanceof Error &&
|
|
230
|
-
(error.message === '' || error.message === 'User cancelled'));
|
|
231
|
-
|
|
232
|
-
if (isCancel) {
|
|
233
|
-
tui.newline();
|
|
234
|
-
tui.info('Cancelled');
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
logger.trace(error);
|
|
239
|
-
logger.fatal('GitHub integration failed: %s', error, ErrorCode.INTEGRATION_FAILED);
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { createSubcommand } from '../../../types';
|
|
2
|
-
import * as tui from '../../../tui';
|
|
3
|
-
import { getCommand } from '../../../command-prefix';
|
|
4
|
-
import { ErrorCode } from '../../../errors';
|
|
5
|
-
import { listOrganizations } from '@agentuity/server';
|
|
6
|
-
import enquirer from 'enquirer';
|
|
7
|
-
import {
|
|
8
|
-
getGithubIntegrationStatus,
|
|
9
|
-
disconnectGithubIntegration,
|
|
10
|
-
type GithubIntegration,
|
|
11
|
-
} from '../api';
|
|
12
|
-
|
|
13
|
-
export const disconnectSubcommand = createSubcommand({
|
|
14
|
-
name: 'disconnect',
|
|
15
|
-
description: 'Disconnect a GitHub account from your organization',
|
|
16
|
-
tags: ['mutating', 'destructive', 'slow'],
|
|
17
|
-
idempotent: false,
|
|
18
|
-
requires: { auth: true, apiClient: true },
|
|
19
|
-
examples: [
|
|
20
|
-
{
|
|
21
|
-
command: getCommand('integration github disconnect'),
|
|
22
|
-
description: 'Disconnect a GitHub account from your organization',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
|
|
26
|
-
async handler(ctx) {
|
|
27
|
-
const { logger, apiClient } = ctx;
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
// Fetch organizations
|
|
31
|
-
const orgs = await tui.spinner({
|
|
32
|
-
message: 'Fetching organizations...',
|
|
33
|
-
clearOnSuccess: true,
|
|
34
|
-
callback: () => listOrganizations(apiClient),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (orgs.length === 0) {
|
|
38
|
-
tui.fatal('No organizations found for your account');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Check GitHub status for each org
|
|
42
|
-
const orgStatuses = await tui.spinner({
|
|
43
|
-
message: 'Checking GitHub integration status...',
|
|
44
|
-
clearOnSuccess: true,
|
|
45
|
-
callback: async () => {
|
|
46
|
-
const statuses = await Promise.all(
|
|
47
|
-
orgs.map(async (org) => {
|
|
48
|
-
const status = await getGithubIntegrationStatus(apiClient, org.id);
|
|
49
|
-
return {
|
|
50
|
-
...org,
|
|
51
|
-
connected: status.connected,
|
|
52
|
-
integrations: status.integrations,
|
|
53
|
-
};
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
return statuses;
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Flatten all integrations across orgs
|
|
61
|
-
const allIntegrations: Array<{
|
|
62
|
-
orgId: string;
|
|
63
|
-
orgName: string;
|
|
64
|
-
integration: GithubIntegration;
|
|
65
|
-
}> = [];
|
|
66
|
-
|
|
67
|
-
for (const org of orgStatuses) {
|
|
68
|
-
for (const integration of org.integrations) {
|
|
69
|
-
allIntegrations.push({
|
|
70
|
-
orgId: org.id,
|
|
71
|
-
orgName: org.name,
|
|
72
|
-
integration,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (allIntegrations.length === 0) {
|
|
78
|
-
tui.newline();
|
|
79
|
-
tui.info('No GitHub accounts are connected.');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Build choices showing GitHub account and org
|
|
84
|
-
const choices = allIntegrations.map((item) => ({
|
|
85
|
-
name: `${tui.bold(item.integration.githubAccountName)} ${tui.muted(`(${item.integration.githubAccountType})`)} → ${tui.bold(item.orgName)}`,
|
|
86
|
-
value: `${item.orgId}:${item.integration.id}`,
|
|
87
|
-
}));
|
|
88
|
-
|
|
89
|
-
// Show picker
|
|
90
|
-
const response = await enquirer.prompt<{ selection: string }>({
|
|
91
|
-
type: 'select',
|
|
92
|
-
name: 'selection',
|
|
93
|
-
message: 'Select a GitHub account to disconnect',
|
|
94
|
-
choices,
|
|
95
|
-
result(name: string) {
|
|
96
|
-
// Return the value (IDs) instead of the display name
|
|
97
|
-
const choice = choices.find((c) => c.name === name);
|
|
98
|
-
return choice?.value ?? name;
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const colonIdx = response.selection.indexOf(':');
|
|
103
|
-
if (colonIdx === -1) {
|
|
104
|
-
logger.fatal('Invalid selection format');
|
|
105
|
-
}
|
|
106
|
-
const orgId = response.selection.slice(0, colonIdx);
|
|
107
|
-
const integrationId = response.selection.slice(colonIdx + 1);
|
|
108
|
-
const selected = allIntegrations.find(
|
|
109
|
-
(i) => i.orgId === orgId && i.integration.id === integrationId
|
|
110
|
-
);
|
|
111
|
-
const displayName = selected
|
|
112
|
-
? `${tui.bold(selected.integration.githubAccountName)} from ${tui.bold(selected.orgName)}`
|
|
113
|
-
: response.selection;
|
|
114
|
-
|
|
115
|
-
// Confirm
|
|
116
|
-
const confirmed = await tui.confirm(`Are you sure you want to disconnect ${displayName}?`);
|
|
117
|
-
|
|
118
|
-
if (!confirmed) {
|
|
119
|
-
tui.newline();
|
|
120
|
-
tui.info('Cancelled');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
await tui.spinner({
|
|
125
|
-
message: 'Disconnecting GitHub...',
|
|
126
|
-
clearOnSuccess: true,
|
|
127
|
-
callback: () => disconnectGithubIntegration(apiClient, orgId, integrationId),
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
tui.newline();
|
|
131
|
-
tui.success(`Disconnected ${displayName}`);
|
|
132
|
-
} catch (error) {
|
|
133
|
-
// Handle user cancellation (Ctrl+C)
|
|
134
|
-
const isCancel =
|
|
135
|
-
error === '' ||
|
|
136
|
-
(error instanceof Error &&
|
|
137
|
-
(error.message === '' || error.message === 'User cancelled'));
|
|
138
|
-
|
|
139
|
-
if (isCancel) {
|
|
140
|
-
tui.newline();
|
|
141
|
-
tui.info('Cancelled');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
logger.trace(error);
|
|
146
|
-
logger.fatal('GitHub disconnect failed: %s', error, ErrorCode.INTEGRATION_FAILED);
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createCommand } from '../../../types';
|
|
2
|
-
import { getCommand } from '../../../command-prefix';
|
|
3
|
-
import { connectSubcommand } from './connect';
|
|
4
|
-
import { disconnectSubcommand } from './disconnect';
|
|
5
|
-
|
|
6
|
-
export const githubCommand = createCommand({
|
|
7
|
-
name: 'github',
|
|
8
|
-
description: 'GitHub integration commands',
|
|
9
|
-
tags: ['requires-auth'],
|
|
10
|
-
examples: [
|
|
11
|
-
{
|
|
12
|
-
command: getCommand('integration github connect'),
|
|
13
|
-
description: 'Connect GitHub to your organization',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
command: getCommand('integration github disconnect'),
|
|
17
|
-
description: 'Disconnect GitHub from your organization',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
subcommands: [connectSubcommand, disconnectSubcommand],
|
|
21
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createCommand } from '../../types';
|
|
2
|
-
import { getCommand } from '../../command-prefix';
|
|
3
|
-
import { githubCommand } from './github';
|
|
4
|
-
|
|
5
|
-
export const command = createCommand({
|
|
6
|
-
name: 'integration',
|
|
7
|
-
description: 'Manage integrations with external services',
|
|
8
|
-
tags: ['requires-auth'],
|
|
9
|
-
examples: [
|
|
10
|
-
{
|
|
11
|
-
command: getCommand('integration github connect'),
|
|
12
|
-
description: 'Connect GitHub to your organization',
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
subcommands: [githubCommand],
|
|
16
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|