@feigi/fleet-ctl 3.88.1 → 3.88.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/package.json +1 -1
- package/scripts/gh-aliased-read.mjs +15 -6
package/package.json
CHANGED
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
// body, `data.repository` holding every alias GitHub answered and `errors[]`
|
|
10
10
|
// naming each failed one by `path: ["repository", "<alias>"]`. So a body that
|
|
11
11
|
// carries an object `data.repository` is read alias by alias at any exit
|
|
12
|
-
// status, never as "the whole call failed".
|
|
12
|
+
// status, never as "the whole call failed". An `errors` that is present and
|
|
13
|
+
// not an array names no alias to trust or blame, so beside an object
|
|
14
|
+
// `data.repository` it leaves the whole batch unreachable as "malformed
|
|
15
|
+
// errors" with the value's JSON, cut to 80 characters — unless the call was
|
|
16
|
+
// killed or timed out, which keeps its bare reason; absent or null, it is no
|
|
17
|
+
// errors.
|
|
13
18
|
//
|
|
14
19
|
// `-F owner={owner} -F name={repo}` is filled in from the environment gh sees:
|
|
15
20
|
// an inherited GH_REPO outranks the repository the cwd is bound to, and a
|
|
@@ -39,9 +44,11 @@ export function how(r) {
|
|
|
39
44
|
* `{ unreachable }` — no usable answer, with the reason. Any other error
|
|
40
45
|
* naming an alias, an error naming no alias (it may
|
|
41
46
|
* belong to any of the batch), a null no NOT_FOUND
|
|
42
|
-
* explains, a missing alias,
|
|
43
|
-
*
|
|
44
|
-
*
|
|
47
|
+
* explains, a missing alias, an `errors` that is not
|
|
48
|
+
* an array beside an object repository ("malformed
|
|
49
|
+
* errors" and the value, or a killed call's bare
|
|
50
|
+
* reason), and an unparseable or absent body all land
|
|
51
|
+
* here: a failed lookup is not an answer.
|
|
45
52
|
*
|
|
46
53
|
* `field` and `selection` build each alias, `n<N>:<field>(number:<N>)<selection>`;
|
|
47
54
|
* `timeoutMs` bounds each `gh` call.
|
|
@@ -64,7 +71,8 @@ export function ghAliasedRead(numbers, { field, selection, timeoutMs }) {
|
|
|
64
71
|
}
|
|
65
72
|
const repo = body?.data?.repository;
|
|
66
73
|
const errors = body?.errors ?? [];
|
|
67
|
-
const
|
|
74
|
+
const isRepo = repo !== null && typeof repo === "object" && !Array.isArray(repo);
|
|
75
|
+
const answered = isRepo && Array.isArray(errors);
|
|
68
76
|
const nothing = new Set();
|
|
69
77
|
const refused = new Map();
|
|
70
78
|
let batchWide;
|
|
@@ -81,7 +89,8 @@ export function ghAliasedRead(numbers, { field, selection, timeoutMs }) {
|
|
|
81
89
|
for (const n of batch) {
|
|
82
90
|
const alias = `n${n}`;
|
|
83
91
|
const gone = (why) => out.set(n, { unreachable: why });
|
|
84
|
-
if (!
|
|
92
|
+
if (!isRepo) gone(unparseable === undefined ? how(r) : `${how(r)}: unparseable body: ${unparseable}`);
|
|
93
|
+
else if (!answered) gone(r.error || r.signal ? how(r) : `malformed errors: ${JSON.stringify(errors).slice(0, 80)}: ${how(r)}`);
|
|
85
94
|
else if (refused.has(alias)) gone(refused.get(alias));
|
|
86
95
|
else if (batchWide !== undefined) gone(batchWide);
|
|
87
96
|
else if (!Object.hasOwn(repo, alias)) gone(how(r));
|