gcb-client 0.7.1 → 0.8.1
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/CHANGELOG.md +23 -2
- package/bin/gcb.js +6 -6
- package/lib/commands/gh.d.ts +3 -3
- package/lib/commands/gh.d.ts.map +1 -1
- package/lib/commands/gh.js +95 -47
- package/lib/commands/gh.js.map +1 -1
- package/lib/commands/host-submit.d.ts +8 -8
- package/lib/commands/host-submit.d.ts.map +1 -1
- package/lib/commands/host-submit.js +32 -22
- package/lib/commands/host-submit.js.map +1 -1
- package/lib/commands/logs.d.ts +2 -2
- package/lib/commands/logs.d.ts.map +1 -1
- package/lib/commands/logs.js +17 -11
- package/lib/commands/logs.js.map +1 -1
- package/lib/commands/pr.d.ts +2 -2
- package/lib/commands/pr.d.ts.map +1 -1
- package/lib/commands/pr.js +186 -69
- package/lib/commands/pr.js.map +1 -1
- package/lib/commands/probe.d.ts +2 -2
- package/lib/commands/probe.d.ts.map +1 -1
- package/lib/commands/probe.js +19 -13
- package/lib/commands/probe.js.map +1 -1
- package/lib/commands/remotes.d.ts +24 -21
- package/lib/commands/remotes.d.ts.map +1 -1
- package/lib/commands/remotes.js +71 -53
- package/lib/commands/remotes.js.map +1 -1
- package/lib/commands/repo.d.ts.map +1 -1
- package/lib/commands/repo.js +26 -16
- package/lib/commands/repo.js.map +1 -1
- package/lib/commands/setup.d.ts +7 -7
- package/lib/commands/setup.d.ts.map +1 -1
- package/lib/commands/setup.js +38 -27
- package/lib/commands/setup.js.map +1 -1
- package/lib/helper.d.ts +27 -27
- package/lib/helper.d.ts.map +1 -1
- package/lib/helper.js +82 -66
- package/lib/helper.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -8
- package/lib/index.js.map +1 -1
- package/lib/primary.d.ts +5 -5
- package/lib/primary.d.ts.map +1 -1
- package/lib/primary.js +5 -5
- package/lib/primary.js.map +1 -1
- package/package.json +10 -10
|
@@ -6,16 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { existsSync } from 'node:fs';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
|
-
import { ANSWER_TIMEOUT_MS, channelDir, findGitDir, readHostBroker, readResult, removeResult, requestProblems, waitForResult, writeRequest, } from 'gcb-core';
|
|
10
|
-
import { fail, getGhAction, say } from 'gcb-core';
|
|
9
|
+
import { ANSWER_TIMEOUT_MS, channelDir, findGitDir, readHostBroker, readResult, removeResult, requestProblems, waitForResult, writeRequest, fail, getGhAction, say, } from 'gcb-core';
|
|
11
10
|
/**
|
|
12
11
|
* Explain why a host-broker request produced no answer.
|
|
13
12
|
*
|
|
14
|
-
* @param dir -
|
|
15
|
-
* @param id -
|
|
13
|
+
* @param dir - The channel directory.
|
|
14
|
+
* @param id - The request id.
|
|
16
15
|
* @param noun - `pull request` or `issue`.
|
|
17
|
-
* @param timeoutMs -
|
|
18
|
-
* @returns
|
|
16
|
+
* @param timeoutMs - The wait that elapsed.
|
|
17
|
+
* @returns The message to show the caller.
|
|
19
18
|
*/
|
|
20
19
|
export function noAnswerMessage(dir, id, noun, timeoutMs) {
|
|
21
20
|
const pending = existsSync(join(dir, `${id}.json`));
|
|
@@ -40,12 +39,14 @@ const KINDS = {
|
|
|
40
39
|
/** Write, wait for and return one host-broker answer. */
|
|
41
40
|
async function exchange(request, timeoutMs = ANSWER_TIMEOUT_MS, claimedTimeoutMs) {
|
|
42
41
|
const problems = requestProblems(request);
|
|
43
|
-
if (problems.length > 0)
|
|
42
|
+
if (problems.length > 0) {
|
|
44
43
|
fail(problems.join('; '));
|
|
44
|
+
}
|
|
45
45
|
const { noun, needed } = KINDS[request.kind ?? 'pull-request'];
|
|
46
46
|
const gitDir = findGitDir(process.cwd());
|
|
47
|
-
if (gitDir === undefined)
|
|
47
|
+
if (gitDir === undefined) {
|
|
48
48
|
fail('--as-user needs a git repository: run it from the checkout');
|
|
49
|
+
}
|
|
49
50
|
const dir = channelDir(gitDir);
|
|
50
51
|
const hostBroker = readHostBroker(dir);
|
|
51
52
|
if (hostBroker === undefined) {
|
|
@@ -54,7 +55,8 @@ async function exchange(request, timeoutMs = ANSWER_TIMEOUT_MS, claimedTimeoutMs
|
|
|
54
55
|
' if one is already running, restart it from this gcb-host version\n' +
|
|
55
56
|
' or drop --as-user to do it as the app instead');
|
|
56
57
|
}
|
|
57
|
-
if (needed !== undefined &&
|
|
58
|
+
if (needed !== undefined &&
|
|
59
|
+
!(Array.isArray(hostBroker.kinds) && hostBroker.kinds.includes(needed))) {
|
|
58
60
|
fail(`the host broker does not advertise ${needed} support; restart it from this gcb-host version`);
|
|
59
61
|
}
|
|
60
62
|
let id;
|
|
@@ -67,12 +69,14 @@ async function exchange(request, timeoutMs = ANSWER_TIMEOUT_MS, claimedTimeoutMs
|
|
|
67
69
|
const configured = Number(process.env['GCB_HOST_TIMEOUT_MS']);
|
|
68
70
|
if (Number.isInteger(configured) && configured > 0) {
|
|
69
71
|
timeoutMs = configured;
|
|
70
|
-
if (claimedTimeoutMs !== undefined)
|
|
72
|
+
if (claimedTimeoutMs !== undefined) {
|
|
71
73
|
claimedTimeoutMs = Math.min(claimedTimeoutMs, configured);
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
let answer = await waitForAnswer(dir, id, timeoutMs, claimedTimeoutMs);
|
|
74
|
-
if (answer === undefined)
|
|
77
|
+
if (answer === undefined) {
|
|
75
78
|
answer = await waitForResult(dir, id, 300, 50);
|
|
79
|
+
}
|
|
76
80
|
if (answer === undefined) {
|
|
77
81
|
const waited = claimedTimeoutMs !== undefined && existsSync(join(dir, `${id}.json.working`))
|
|
78
82
|
? claimedTimeoutMs
|
|
@@ -93,49 +97,55 @@ async function waitForAnswer(dir, id, queueTimeoutMs, claimedTimeoutMs) {
|
|
|
93
97
|
let claimedDeadline;
|
|
94
98
|
for (;;) {
|
|
95
99
|
const answer = readResult(dir, id);
|
|
96
|
-
if (answer !== undefined)
|
|
100
|
+
if (answer !== undefined) {
|
|
97
101
|
return answer;
|
|
102
|
+
}
|
|
98
103
|
const now = Date.now();
|
|
99
104
|
if (claimedTimeoutMs !== undefined && existsSync(join(dir, `${id}.json.working`))) {
|
|
100
105
|
claimedDeadline ??= now + claimedTimeoutMs;
|
|
101
|
-
if (now >= claimedDeadline)
|
|
106
|
+
if (now >= claimedDeadline) {
|
|
102
107
|
return undefined;
|
|
108
|
+
}
|
|
103
109
|
}
|
|
104
110
|
else if (now >= queueDeadline) {
|
|
105
111
|
return undefined;
|
|
106
112
|
}
|
|
107
|
-
await new Promise(
|
|
113
|
+
await new Promise(done => setTimeout(done, 50));
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
111
117
|
* Write, wait for and report one host-broker request.
|
|
112
118
|
*
|
|
113
|
-
* @param request -
|
|
114
|
-
* @param success -
|
|
119
|
+
* @param request - The validated request.
|
|
120
|
+
* @param success - Formats the success line from the answer.
|
|
115
121
|
* @returns 0 after the answer is reported.
|
|
116
122
|
*/
|
|
117
123
|
export async function submitToHostBroker(request, success) {
|
|
118
124
|
const answer = await exchange(request);
|
|
119
|
-
if (answer.error !== undefined)
|
|
125
|
+
if (answer.error !== undefined) {
|
|
120
126
|
fail(`the host broker could not do it: ${answer.error}`);
|
|
127
|
+
}
|
|
121
128
|
say(success(answer));
|
|
122
129
|
return 0;
|
|
123
130
|
}
|
|
124
131
|
/**
|
|
125
132
|
* Run one catalogued action through the host broker and forward its output.
|
|
126
133
|
*
|
|
127
|
-
* @param request -
|
|
128
|
-
* @returns
|
|
134
|
+
* @param request - The validated action request.
|
|
135
|
+
* @returns The child's exit status as 0 or 1.
|
|
129
136
|
*/
|
|
130
137
|
export async function submitActionToHostBroker(request) {
|
|
131
138
|
const action = getGhAction(request.action);
|
|
132
139
|
const answer = await exchange(request, ANSWER_TIMEOUT_MS, action.timeoutSeconds * 1_000 + 30_000);
|
|
133
|
-
if (answer.error !== undefined)
|
|
140
|
+
if (answer.error !== undefined) {
|
|
134
141
|
fail(`the host broker could not do it: ${answer.error}`);
|
|
135
|
-
|
|
142
|
+
}
|
|
143
|
+
if (answer.stdout !== undefined && answer.stdout !== '') {
|
|
136
144
|
process.stdout.write(answer.stdout);
|
|
137
|
-
|
|
145
|
+
}
|
|
146
|
+
if (answer.stderr !== undefined && answer.stderr !== '') {
|
|
138
147
|
process.stderr.write(answer.stderr);
|
|
148
|
+
}
|
|
139
149
|
return answer.code === 0 ? 0 : 1;
|
|
140
150
|
}
|
|
141
151
|
//# sourceMappingURL=host-submit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-submit.js","sourceRoot":"","sources":["../../src/commands/host-submit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"host-submit.js","sourceRoot":"","sources":["../../src/commands/host-submit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,GAAG,GACJ,MAAM,UAAU,CAAA;AAGjB;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,EAAU,EAAE,IAAY,EAAE,SAAiB;IACtF,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAA;IAC3D,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QACzB,OAAO,CACL,wBAAwB,EAAE,qCAAqC;YA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,MAAM,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAClC,CAAC"}
|
package/lib/commands/logs.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare const LOGS_USAGE = "Usage: gcb logs [options]\n\nRead a workflow
|
|
|
3
3
|
/**
|
|
4
4
|
* Run the `logs` command.
|
|
5
5
|
*
|
|
6
|
-
* @param argv -
|
|
7
|
-
* @returns
|
|
6
|
+
* @param argv - Arguments after the command name.
|
|
7
|
+
* @returns The process exit code: 0 read, 1 refused, 3 unreachable.
|
|
8
8
|
*/
|
|
9
9
|
export declare function runLogs(argv: readonly string[]): Promise<number>;
|
|
10
10
|
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAqBA,6BAA6B;AAC7B,eAAO,MAAM,UAAU,4lBAWtB,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAyEtE"}
|
package/lib/commands/logs.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { fail, parseArgs, say } from 'gcb-core';
|
|
1
2
|
/**
|
|
2
3
|
* `logs` — read one workflow job's log through the broker.
|
|
3
4
|
*
|
|
4
5
|
* The credential never leaves the broker. The broker mints a read-only, single-repository token
|
|
5
|
-
* narrowed to `actions: read`, fetches the log itself, and answers with the text: the agent gets
|
|
6
|
-
* log without ever holding something that could read anything else.
|
|
6
|
+
* narrowed to `actions: read`, fetches the log itself, and answers with the text: the agent gets
|
|
7
|
+
* the log without ever holding something that could read anything else.
|
|
7
8
|
*
|
|
8
9
|
* Exit codes: 0 read, 1 refused, 3 broker unreachable.
|
|
9
10
|
*/
|
|
10
11
|
import { requestOverSocket, resolveSocketPath } from '../helper.js';
|
|
11
|
-
import { fail, parseArgs, say } from 'gcb-core';
|
|
12
12
|
/**
|
|
13
13
|
* How long to wait for the broker.
|
|
14
14
|
*
|
|
@@ -32,15 +32,17 @@ Read a workflow job log through the broker, without the credential ever reaching
|
|
|
32
32
|
/**
|
|
33
33
|
* Run the `logs` command.
|
|
34
34
|
*
|
|
35
|
-
* @param argv -
|
|
36
|
-
* @returns
|
|
35
|
+
* @param argv - Arguments after the command name.
|
|
36
|
+
* @returns The process exit code: 0 read, 1 refused, 3 unreachable.
|
|
37
37
|
*/
|
|
38
38
|
export async function runLogs(argv) {
|
|
39
39
|
const args = parseArgs(argv, { booleans: ['help', 'no-proxy'] });
|
|
40
|
-
if (args.has('no-proxy') && args.value('proxy') !== undefined)
|
|
40
|
+
if (args.has('no-proxy') && args.value('proxy') !== undefined) {
|
|
41
41
|
fail('--proxy and --no-proxy are mutually exclusive');
|
|
42
|
-
|
|
42
|
+
}
|
|
43
|
+
if (args.has('proxy') && args.value('proxy') === undefined) {
|
|
43
44
|
fail('--proxy needs a value');
|
|
45
|
+
}
|
|
44
46
|
const proxy = args.has('no-proxy') ? null : args.value('proxy');
|
|
45
47
|
if (args.has('help') || args.has('h')) {
|
|
46
48
|
say(LOGS_USAGE);
|
|
@@ -48,20 +50,24 @@ export async function runLogs(argv) {
|
|
|
48
50
|
}
|
|
49
51
|
const socketPath = resolveSocketPath(args.value('socket'), process.env);
|
|
50
52
|
const hostArg = args.value('host');
|
|
51
|
-
if (args.has('host') && hostArg === undefined)
|
|
53
|
+
if (args.has('host') && hostArg === undefined) {
|
|
52
54
|
fail('--host needs a value');
|
|
53
|
-
|
|
55
|
+
}
|
|
56
|
+
if (hostArg === '') {
|
|
54
57
|
fail('--host needs a value');
|
|
58
|
+
}
|
|
55
59
|
const host = hostArg ?? 'github.com';
|
|
56
60
|
const repo = args.value('repo');
|
|
57
61
|
const rawJob = args.value('job');
|
|
58
62
|
if (!socketPath) {
|
|
59
63
|
fail('no broker socket: pass --socket, set GIT_BROKER_SOCKET, or run `gcb setup`');
|
|
60
64
|
}
|
|
61
|
-
if (!repo)
|
|
65
|
+
if (!repo) {
|
|
62
66
|
fail('--repo is required (e.g. owner/name)');
|
|
63
|
-
|
|
67
|
+
}
|
|
68
|
+
if (!rawJob) {
|
|
64
69
|
fail('--job is required (the workflow job id, which is also the check run id)');
|
|
70
|
+
}
|
|
65
71
|
const jobId = Number(rawJob);
|
|
66
72
|
if (!Number.isInteger(jobId) || jobId <= 0) {
|
|
67
73
|
fail(`--job must be a positive integer, got ${JSON.stringify(rawJob)}`);
|
package/lib/commands/logs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE/C;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEnE;;;;;GAKG;AACH,MAAM,eAAe,GAAG,MAAM,CAAA;AAE9B,6BAA6B;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;CAWzB,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAuB;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;IAChE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,KAAK,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AI,GAAG,QAAQ,CAAC,GAAG,IAAI,EAAE,CAAA;IAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAA;IAC7E,OAAO,CAAC,CAAA;AACV,CAAC"}
|
package/lib/commands/pr.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare const PR_USAGE = "Usage: gcb pr [options]\n\nOpen, update or insp
|
|
|
3
3
|
/**
|
|
4
4
|
* Run the `pr` command.
|
|
5
5
|
*
|
|
6
|
-
* @param argv -
|
|
7
|
-
* @returns
|
|
6
|
+
* @param argv - Arguments after the command name.
|
|
7
|
+
* @returns The process exit code: 0 done, 1 refused, 3 unreachable.
|
|
8
8
|
*/
|
|
9
9
|
export declare function runPr(argv: readonly string[]): Promise<number>;
|
|
10
10
|
//# sourceMappingURL=pr.d.ts.map
|
package/lib/commands/pr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../src/commands/pr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../src/commands/pr.ts"],"names":[],"mappings":"AAyDA,2BAA2B;AAC3B,eAAO,MAAM,QAAQ,28GAsDpB,CAAA;AA6CD;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAghBpE"}
|