@theholocron/cli 5.0.0-alpha.506 → 5.0.0-alpha.508
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 +3 -3
- package/dist/cli.mjs +465 -79
- package/dist/cli.mjs.map +1 -1
- package/dist/{index-_Md7AlPB.d.mts → index-D_e9vKTW.d.mts} +102 -6
- package/dist/index.d.mts +2 -2
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/presets.d.mts +1 -1
- package/package.json +13 -13
package/dist/cli.mjs
CHANGED
|
@@ -871,6 +871,13 @@ const issueUpdateEntry = {
|
|
|
871
871
|
choices: ["open", "closed"],
|
|
872
872
|
message: "State:"
|
|
873
873
|
},
|
|
874
|
+
{
|
|
875
|
+
key: "stateReason",
|
|
876
|
+
flag: "--state-reason",
|
|
877
|
+
type: "select",
|
|
878
|
+
choices: ["completed", "not_planned"],
|
|
879
|
+
message: "Closed as (with --state closed):"
|
|
880
|
+
},
|
|
874
881
|
{
|
|
875
882
|
key: "addLabel",
|
|
876
883
|
flag: "--add-label",
|
|
@@ -4148,7 +4155,8 @@ async function provisionChannel(deps, spec) {
|
|
|
4148
4155
|
if (webhookCfg && feed.webhook.toLowerCase() === webhookName.toLowerCase()) throw new Error(`channel ${spec.name}: the monitoring webhook and the channel's own webhook are both named ${webhookName} — rename one`);
|
|
4149
4156
|
}
|
|
4150
4157
|
const relay = spec.feeds?.errors;
|
|
4151
|
-
|
|
4158
|
+
const relays = spec.feeds?.relay ?? [];
|
|
4159
|
+
if ((relay || relays.length > 0) && !notifications.ensureWebhook) throw new Error(`\`${notifications.providerName}\` cannot create webhooks`);
|
|
4152
4160
|
if (dryRun) {
|
|
4153
4161
|
print(` ${style.skip(`would ensure channel ${spec.name}${where}`)}`);
|
|
4154
4162
|
if (tally) tally.skip += webhookCfg ? 2 : 1;
|
|
@@ -4161,6 +4169,10 @@ async function provisionChannel(deps, spec) {
|
|
|
4161
4169
|
print(` ${style.skip(`would ensure webhook ${relay.webhook} for the relay Worker (errors)`)}`);
|
|
4162
4170
|
if (tally) tally.skip++;
|
|
4163
4171
|
}
|
|
4172
|
+
for (const other of relays) {
|
|
4173
|
+
print(` ${style.skip(`would ensure webhook ${other.webhook} for the relay Worker (${other.source})`)}`);
|
|
4174
|
+
if (tally) tally.skip++;
|
|
4175
|
+
}
|
|
4164
4176
|
return {
|
|
4165
4177
|
name: spec.name,
|
|
4166
4178
|
...spec.category ? { category: spec.category } : {},
|
|
@@ -4189,7 +4201,7 @@ async function provisionChannel(deps, spec) {
|
|
|
4189
4201
|
};
|
|
4190
4202
|
if (!webhookCfg) {
|
|
4191
4203
|
if (feed) await provisionFeed(deps, spec, feed, outcome);
|
|
4192
|
-
|
|
4204
|
+
await provisionRelayFeeds(deps, spec, outcome);
|
|
4193
4205
|
return outcome;
|
|
4194
4206
|
}
|
|
4195
4207
|
const hook = await notifications.ensureWebhook({
|
|
@@ -4232,15 +4244,20 @@ async function provisionChannel(deps, spec) {
|
|
|
4232
4244
|
}
|
|
4233
4245
|
if (hook.avatarError) throw new Error(`webhook ${webhookName} is ready but setting its avatar failed (${hook.avatarError})`);
|
|
4234
4246
|
if (feed) await provisionFeed(deps, spec, feed, outcome);
|
|
4235
|
-
|
|
4247
|
+
await provisionRelayFeeds(deps, spec, outcome);
|
|
4236
4248
|
return outcome;
|
|
4237
4249
|
}
|
|
4250
|
+
/** The relay webhooks of a channel: the error tracker's, then one for each other source it carries. */
|
|
4251
|
+
async function provisionRelayFeeds(deps, spec, outcome) {
|
|
4252
|
+
if (spec.feeds?.errors) await provisionRelayFeed(deps, spec, spec.feeds.errors, outcome);
|
|
4253
|
+
for (const other of spec.feeds?.relay ?? []) await provisionRelayFeed(deps, spec, other, outcome, other.source);
|
|
4254
|
+
}
|
|
4238
4255
|
/**
|
|
4239
4256
|
* A dedicated webhook for the relay Worker. Its URL goes to the caller (which hands it to the Worker as a secret) and
|
|
4240
4257
|
* nowhere else. The bot's own webhook hands its URL out on every read, so a re-run gets it again; one made by a
|
|
4241
4258
|
* person does not, and is reported rather than guessed at.
|
|
4242
4259
|
*/
|
|
4243
|
-
async function provisionRelayFeed(deps, spec, feed, outcome) {
|
|
4260
|
+
async function provisionRelayFeed(deps, spec, feed, outcome, source) {
|
|
4244
4261
|
const { notifications, print, tally } = deps;
|
|
4245
4262
|
const hook = await notifications.ensureWebhook({
|
|
4246
4263
|
channel: spec.name,
|
|
@@ -4255,13 +4272,18 @@ async function provisionRelayFeed(deps, spec, feed, outcome) {
|
|
|
4255
4272
|
if (done > 0) tally.ok += done;
|
|
4256
4273
|
else tally.skip++;
|
|
4257
4274
|
}
|
|
4258
|
-
|
|
4275
|
+
const recorded = {
|
|
4259
4276
|
name: feed.webhook,
|
|
4260
4277
|
created: hook.created,
|
|
4261
4278
|
...avatarSet ? { updated: ["avatar"] } : {}
|
|
4262
4279
|
};
|
|
4280
|
+
if (source === void 0) outcome.relayWebhook = recorded;
|
|
4281
|
+
else (outcome.relayWebhooks ??= []).push({
|
|
4282
|
+
source,
|
|
4283
|
+
...recorded
|
|
4284
|
+
});
|
|
4263
4285
|
if (!hook.url) throw new Error(`webhook ${feed.webhook} already exists and its URL cannot be read back, so the relay cannot post through it — delete it in the provider and re-run`);
|
|
4264
|
-
deps.onRelayWebhook?.(hook.url);
|
|
4286
|
+
deps.onRelayWebhook?.(hook.url, source);
|
|
4265
4287
|
if (hook.avatarError) throw new Error(`webhook ${feed.webhook} is ready but setting its avatar failed (${hook.avatarError})`);
|
|
4266
4288
|
}
|
|
4267
4289
|
/**
|
|
@@ -6501,6 +6523,7 @@ async function runIssueUpdate(input) {
|
|
|
6501
6523
|
const milestone = input.milestone?.trim();
|
|
6502
6524
|
if (input.title !== void 0 && !title) problems.push("--title is empty");
|
|
6503
6525
|
if (input.milestone !== void 0 && !milestone) problems.push("--milestone is empty");
|
|
6526
|
+
if (input.stateReason && input.state !== "closed") problems.push("--state-reason needs --state closed; an issue that is open or left as it is has no reason");
|
|
6504
6527
|
const set = {
|
|
6505
6528
|
assignees: assignees.length > 0,
|
|
6506
6529
|
milestone: Boolean(milestone),
|
|
@@ -6521,7 +6544,7 @@ async function runIssueUpdate(input) {
|
|
|
6521
6544
|
...title ? { title } : {},
|
|
6522
6545
|
...input.body !== void 0 ? { body: input.body } : {},
|
|
6523
6546
|
...input.state ? { state: input.state } : {},
|
|
6524
|
-
...input.
|
|
6547
|
+
...input.stateReason ? { stateReason: input.stateReason } : {},
|
|
6525
6548
|
...addLabels.length > 0 ? { addLabels } : {},
|
|
6526
6549
|
...removeLabels.length > 0 ? { removeLabels } : {},
|
|
6527
6550
|
...assignees.length > 0 ? { assignees } : {},
|
|
@@ -6532,7 +6555,7 @@ async function runIssueUpdate(input) {
|
|
|
6532
6555
|
const details = [
|
|
6533
6556
|
...title ? ["title"] : [],
|
|
6534
6557
|
...input.body !== void 0 ? ["body"] : [],
|
|
6535
|
-
...input.state ? [`state: ${input.state}`] : [],
|
|
6558
|
+
...input.state ? [`state: ${input.state}${input.stateReason ? ` (${input.stateReason})` : ""}`] : [],
|
|
6536
6559
|
...addLabels.length > 0 ? [`add labels: ${addLabels.join(", ")}`] : [],
|
|
6537
6560
|
...removeLabels.length > 0 ? [`remove labels: ${removeLabels.join(", ")}`] : [],
|
|
6538
6561
|
...assignees.length > 0 ? [`assignee: ${assignees.join(", ")}`] : [],
|
|
@@ -6861,7 +6884,7 @@ async function abandonWork(a) {
|
|
|
6861
6884
|
}));
|
|
6862
6885
|
else rows.push(row$29("local branch", "skip", `no local branch is named for ${key}`));
|
|
6863
6886
|
if (dryRun) rows.push(row$29("issue", "skip", `would ask whether to close ${key} as not planned`));
|
|
6864
|
-
else if (input.yes) rows.push(row$29("issue", "skip", `${key} left open: --yes does not close an issue; run \`holocron update issue ${key} --state closed\` to close it`));
|
|
6887
|
+
else if (input.yes) rows.push(row$29("issue", "skip", `${key} left open: --yes does not close an issue; run \`holocron update issue ${key} --state closed --state-reason not_planned\` to close it as not planned`));
|
|
6865
6888
|
else if (await a.ask(`Close ${key} as not planned?`)) {
|
|
6866
6889
|
const close = await (input.updateIssue ?? runIssueUpdate)({
|
|
6867
6890
|
key,
|
|
@@ -7034,7 +7057,7 @@ function createProjectRows(print, logger) {
|
|
|
7034
7057
|
*/
|
|
7035
7058
|
const COMMAND$9 = "project status";
|
|
7036
7059
|
/** `#12`, `12`, `o/r#12` as a repository (or none) and a number; anything else (a Linear key) is undefined. */
|
|
7037
|
-
const parseKey = (key) => {
|
|
7060
|
+
const parseKey$1 = (key) => {
|
|
7038
7061
|
const m = /^(?:([^#\s]+)#|#)?(\d+)$/.exec(key.trim());
|
|
7039
7062
|
return m ? {
|
|
7040
7063
|
repo: m[1],
|
|
@@ -7061,11 +7084,11 @@ async function runProjectStatus(input) {
|
|
|
7061
7084
|
const board = await projects.find(options.owner, declared.name);
|
|
7062
7085
|
if (!board) return failed(`board ${declared.name}`, "the board does not exist or is closed; run `holocron setup project`");
|
|
7063
7086
|
const wanted = input.issue.trim();
|
|
7064
|
-
const parsed = parseKey(wanted);
|
|
7087
|
+
const parsed = parseKey$1(wanted);
|
|
7065
7088
|
const own = `${input.loaded.resolved.org ?? input.context.org ?? ""}/${input.loaded.resolved.name}`.toLowerCase();
|
|
7066
7089
|
const item = (await projects.items(options.owner, board, template)).find((i) => {
|
|
7067
7090
|
if (!parsed) return i.key.toLowerCase() === wanted.toLowerCase();
|
|
7068
|
-
const have = parseKey(i.key);
|
|
7091
|
+
const have = parseKey$1(i.key);
|
|
7069
7092
|
if (have?.number !== parsed.number) return false;
|
|
7070
7093
|
if (parsed.repo === void 0) return have.repo === void 0;
|
|
7071
7094
|
return (have.repo ?? own).toLowerCase() === parsed.repo.toLowerCase();
|
|
@@ -7132,6 +7155,75 @@ const projectStatusCommand = {
|
|
|
7132
7155
|
})).status === "fail") process.exitCode = 1;
|
|
7133
7156
|
}
|
|
7134
7157
|
};
|
|
7158
|
+
// src/commands/start-work/issue-boards/issue-boards.ts
|
|
7159
|
+
/** `#12`, `12`, `o/r#12` as a repository (or none) and a number; anything else (a Linear key) is undefined. */
|
|
7160
|
+
const parseKey = (key) => {
|
|
7161
|
+
const m = /^(?:([^#\s]+)#|#)?(\d+)$/.exec(key.trim());
|
|
7162
|
+
return m ? {
|
|
7163
|
+
repo: m[1],
|
|
7164
|
+
number: Number(m[2])
|
|
7165
|
+
} : void 0;
|
|
7166
|
+
};
|
|
7167
|
+
/**
|
|
7168
|
+
* The declared boards (`providers.projects.boards`) that hold an issue, so `start work` can put its pull request on
|
|
7169
|
+
* the same ones. The issue is found the way `project status` finds it: by number in this repository, or by the
|
|
7170
|
+
* key's own text for a tracker whose keys are not numbers. A provider that cannot list items, a board that is not
|
|
7171
|
+
* there or a read that fails is a `problem`, never a throw, because a board the pull request cannot join is a row and
|
|
7172
|
+
* not a failed run.
|
|
7173
|
+
*/
|
|
7174
|
+
async function readIssueBoards(input) {
|
|
7175
|
+
const opened = await openBoardContext({
|
|
7176
|
+
loaded: input.loaded,
|
|
7177
|
+
context: input.context,
|
|
7178
|
+
loader: input.loader,
|
|
7179
|
+
...input.templatesIo ? { io: input.templatesIo } : {}
|
|
7180
|
+
});
|
|
7181
|
+
if (!opened.ok) return {
|
|
7182
|
+
boards: [],
|
|
7183
|
+
problem: [opened.reason, ...opened.problems].join("; ")
|
|
7184
|
+
};
|
|
7185
|
+
const { projects, owner, boards: declared, templates } = opened.context;
|
|
7186
|
+
if (!projects.items) return {
|
|
7187
|
+
boards: [],
|
|
7188
|
+
problem: `the \`${projects.providerName}\` provider cannot list a board's items`
|
|
7189
|
+
};
|
|
7190
|
+
const own = `${input.loaded.resolved.org ?? input.context.org ?? ""}/${input.loaded.resolved.name}`.toLowerCase();
|
|
7191
|
+
const wanted = input.keys.map((k) => ({
|
|
7192
|
+
text: k.trim().toLowerCase(),
|
|
7193
|
+
parsed: parseKey(k)
|
|
7194
|
+
}));
|
|
7195
|
+
const holds = (itemKey) => {
|
|
7196
|
+
const have = parseKey(itemKey);
|
|
7197
|
+
return wanted.some((w) => {
|
|
7198
|
+
if (!have || !w.parsed) return itemKey.trim().toLowerCase() === w.text;
|
|
7199
|
+
if (have.number !== w.parsed.number) return false;
|
|
7200
|
+
return (have.repo ?? own).toLowerCase() === (w.parsed.repo ?? own).toLowerCase();
|
|
7201
|
+
});
|
|
7202
|
+
};
|
|
7203
|
+
const names = [];
|
|
7204
|
+
const problems = [];
|
|
7205
|
+
for (const board of declared) {
|
|
7206
|
+
const template = templates[board.template];
|
|
7207
|
+
if (!template) {
|
|
7208
|
+
problems.push(`board ${board.name}: there is no template named "${board.template}"`);
|
|
7209
|
+
continue;
|
|
7210
|
+
}
|
|
7211
|
+
try {
|
|
7212
|
+
const found = await projects.find(owner, board.name);
|
|
7213
|
+
if (!found) {
|
|
7214
|
+
problems.push(`board ${board.name}: it does not exist or is closed`);
|
|
7215
|
+
continue;
|
|
7216
|
+
}
|
|
7217
|
+
if ((await projects.items(owner, found, template)).some((item) => holds(item.key))) names.push(board.name);
|
|
7218
|
+
} catch (err) {
|
|
7219
|
+
problems.push(`board ${board.name}: ${describeError(err)}`);
|
|
7220
|
+
}
|
|
7221
|
+
}
|
|
7222
|
+
return {
|
|
7223
|
+
boards: names,
|
|
7224
|
+
...problems.length > 0 ? { problem: problems.join("; ") } : {}
|
|
7225
|
+
};
|
|
7226
|
+
}
|
|
7135
7227
|
// src/commands/start-work/real-start-work-io/real-start-work-io.ts
|
|
7136
7228
|
/** The real git and file system {@link runStartWork} runs against; tests pass a fake. */
|
|
7137
7229
|
function createRealStartWorkIo() {
|
|
@@ -7146,6 +7238,18 @@ function createRealStartWorkIo() {
|
|
|
7146
7238
|
today: () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
7147
7239
|
};
|
|
7148
7240
|
}
|
|
7241
|
+
// src/commands/start-work/work-assignee/work-assignee.ts
|
|
7242
|
+
/**
|
|
7243
|
+
* The login a pull request can be assigned to for an issue's assignee. A user carries a `login` when the tracker is not
|
|
7244
|
+
* the one that hosts the pull request and a mapping found it; when the issue and the pull request are in the same
|
|
7245
|
+
* tracker (GitHub both) the user's `id` is the login. `undefined` when there is none to use (a Linear assignee with
|
|
7246
|
+
* no mapping), so the pull request is left unassigned rather than guessed.
|
|
7247
|
+
*/
|
|
7248
|
+
function workAssignee(user, issuesProvider, sourceProvider) {
|
|
7249
|
+
if (!user) return void 0;
|
|
7250
|
+
if (user.login) return user.login;
|
|
7251
|
+
return issuesProvider === sourceProvider ? user.id : void 0;
|
|
7252
|
+
}
|
|
7149
7253
|
// src/commands/start-work/work-body/work-body.ts
|
|
7150
7254
|
/**
|
|
7151
7255
|
* The first body of the work's pull request: the links to the issue and the spec file and the four definition-of-done
|
|
@@ -7164,6 +7268,15 @@ function buildWorkBody(input) {
|
|
|
7164
7268
|
"- [ ] Green checks (`ci / Required checks`)"
|
|
7165
7269
|
].join("\n");
|
|
7166
7270
|
}
|
|
7271
|
+
// src/commands/start-work/work-reference/work-reference.ts
|
|
7272
|
+
/**
|
|
7273
|
+
* How a commit trailer or a pull request names an issue so the tracker links it. GitHub links `#2500`, not `2500`, so a
|
|
7274
|
+
* bare number gets the `#`; `#12`, `owner/repo#12` and a tracker's own key (`ENG-42`) are kept as they are.
|
|
7275
|
+
*/
|
|
7276
|
+
function workReference(key) {
|
|
7277
|
+
const trimmed = key.trim();
|
|
7278
|
+
return /^\d+$/.test(trimmed) ? `#${trimmed}` : trimmed;
|
|
7279
|
+
}
|
|
7167
7280
|
// src/commands/start-work/work-slug/work-slug.ts
|
|
7168
7281
|
/** The longest slug taken from a title, cut at a word. */
|
|
7169
7282
|
const MAX_SLUG$1 = 40;
|
|
@@ -7319,6 +7432,7 @@ async function runStartWork(input) {
|
|
|
7319
7432
|
if (!issuesEntry) return fail(key, "the config has no `issues` provider to read the issue with");
|
|
7320
7433
|
const sourceEntry = input.noPr ? void 0 : input.loaded.resolved.providers.source;
|
|
7321
7434
|
if (!input.noPr && !sourceEntry) return fail(key, "the config has no `source` provider to open the pull request with");
|
|
7435
|
+
const projectsEntry = input.noPr ? void 0 : input.loaded.resolved.providers.projects;
|
|
7322
7436
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
7323
7437
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
7324
7438
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -7326,6 +7440,7 @@ async function runStartWork(input) {
|
|
|
7326
7440
|
providers: {
|
|
7327
7441
|
issues: issuesEntry,
|
|
7328
7442
|
...sourceEntry ? { source: sourceEntry } : {},
|
|
7443
|
+
...projectsEntry ? { projects: projectsEntry } : {},
|
|
7329
7444
|
...credentials ? { credentials } : {}
|
|
7330
7445
|
}
|
|
7331
7446
|
}, input.context);
|
|
@@ -7485,7 +7600,7 @@ async function runStartWork(input) {
|
|
|
7485
7600
|
]) || "0");
|
|
7486
7601
|
if (ahead > 0) rows.push(row$28("first commit", "skip", `${branch} already has ${ahead} commit${ahead === 1 ? "" : "s"}`));
|
|
7487
7602
|
else {
|
|
7488
|
-
const trailer = `Refs ${key}`;
|
|
7603
|
+
const trailer = `Refs ${workReference(key)}`;
|
|
7489
7604
|
if (spec) {
|
|
7490
7605
|
if (dir !== root) io.write(join(dir, spec.rel), io.read(spec.abs));
|
|
7491
7606
|
io.git([
|
|
@@ -7523,12 +7638,26 @@ async function runStartWork(input) {
|
|
|
7523
7638
|
return finish();
|
|
7524
7639
|
}
|
|
7525
7640
|
if (source) try {
|
|
7526
|
-
const
|
|
7641
|
+
const issueAssignee = workAssignee(record?.assignee ?? issue.assignee, issues.providerName, source.providerName);
|
|
7642
|
+
const assignees = [.../* @__PURE__ */ new Set([...issueAssignee ? [issueAssignee] : [], ...input.assignees ?? []])];
|
|
7643
|
+
let issueBoards = [];
|
|
7644
|
+
if (projectsEntry) {
|
|
7645
|
+
const read = await readIssueBoards({
|
|
7646
|
+
loaded: input.loaded,
|
|
7647
|
+
context: input.context,
|
|
7648
|
+
loader,
|
|
7649
|
+
keys: [key, issue.key],
|
|
7650
|
+
...input.templatesIo ? { templatesIo: input.templatesIo } : {}
|
|
7651
|
+
});
|
|
7652
|
+
issueBoards = read.boards;
|
|
7653
|
+
if (read.problem) rows.push(row$28("boards", "skip", `the pull request is not put on the issue's boards: ${read.problem}`));
|
|
7654
|
+
}
|
|
7655
|
+
const projects = [.../* @__PURE__ */ new Set([...issueBoards, ...input.project ? [input.project] : []])];
|
|
7527
7656
|
const mirrored = {
|
|
7528
7657
|
...record?.labels.length ? { labels: record.labels } : {},
|
|
7529
7658
|
...record?.milestone ? { milestone: record.milestone } : {},
|
|
7530
7659
|
...assignees.length > 0 ? { assignees } : {},
|
|
7531
|
-
...
|
|
7660
|
+
...projects.length > 0 ? { projects } : {}
|
|
7532
7661
|
};
|
|
7533
7662
|
const result = await source.createPullRequest({
|
|
7534
7663
|
title,
|
|
@@ -7536,7 +7665,7 @@ async function runStartWork(input) {
|
|
|
7536
7665
|
base,
|
|
7537
7666
|
draft: true,
|
|
7538
7667
|
body: buildWorkBody({
|
|
7539
|
-
issue: key,
|
|
7668
|
+
issue: workReference(key),
|
|
7540
7669
|
issueTitle: issue.summary,
|
|
7541
7670
|
...issue.url ? { issueUrl: issue.url } : {},
|
|
7542
7671
|
...spec ? { spec: spec.rel } : {}
|
|
@@ -10517,6 +10646,27 @@ function previewConfigOf(config) {
|
|
|
10517
10646
|
domain: config.domain
|
|
10518
10647
|
}) : null;
|
|
10519
10648
|
}
|
|
10649
|
+
// src/commands/relay-sources/relay-feed-webhook.ts
|
|
10650
|
+
const capitalised$1 = (name) => name.charAt(0).toUpperCase() + name.slice(1);
|
|
10651
|
+
/** The name of a channel's dedicated webhook for a source: the feed's own, else the id, capitalised (`Vercel`). */
|
|
10652
|
+
function relayFeedWebhook(source, feed) {
|
|
10653
|
+
return (typeof feed === "object" ? feed.webhook : void 0) ?? capitalised$1(source);
|
|
10654
|
+
}
|
|
10655
|
+
// src/commands/relay-sources/generic-relay-feeds.ts
|
|
10656
|
+
/** Every `feeds.relay` entry of the layout that is switched on, in layout order. The error tracker's feed is not one. */
|
|
10657
|
+
function genericRelayFeeds(layout) {
|
|
10658
|
+
const feeds = [];
|
|
10659
|
+
for (const category of layout.categories ?? []) for (const channel of category.channels ?? []) for (const [source, feed] of Object.entries(channel.feeds?.relay ?? {})) {
|
|
10660
|
+
if (!feed) continue;
|
|
10661
|
+
feeds.push({
|
|
10662
|
+
source,
|
|
10663
|
+
channel,
|
|
10664
|
+
feed,
|
|
10665
|
+
webhook: relayFeedWebhook(source, feed)
|
|
10666
|
+
});
|
|
10667
|
+
}
|
|
10668
|
+
return feeds;
|
|
10669
|
+
}
|
|
10520
10670
|
// src/commands/notifications-setup/avatar-problem.ts
|
|
10521
10671
|
/**
|
|
10522
10672
|
* The first reason a picture cannot work, or undefined. `key` names it for the message (`feeds.errors.avatar`,
|
|
@@ -10544,6 +10694,14 @@ const relaySecretBinding = (source) => `COMLINK_${source.toUpperCase()}_SECRET`;
|
|
|
10544
10694
|
function wantsRelay(layout) {
|
|
10545
10695
|
return (layout.categories ?? []).some((c) => (c.channels ?? []).some((ch) => ch.feeds?.errors));
|
|
10546
10696
|
}
|
|
10697
|
+
/** Whether any channel in the layout carries a relay source other than the error tracker's (`feeds.relay`). */
|
|
10698
|
+
function wantsRelaySources(layout) {
|
|
10699
|
+
return genericRelayFeeds(layout).length > 0;
|
|
10700
|
+
}
|
|
10701
|
+
/** Whether the Worker has anything to carry: the error tracker's alerts or another relay source. */
|
|
10702
|
+
function wantsAnyRelay(layout) {
|
|
10703
|
+
return wantsRelay(layout) || wantsRelaySources(layout);
|
|
10704
|
+
}
|
|
10547
10705
|
/**
|
|
10548
10706
|
* The first reason the relay cannot be deployed, or undefined. One source has one webhook, so only one channel can be
|
|
10549
10707
|
* fed by it; and the Worker needs somewhere to answer.
|
|
@@ -10591,10 +10749,7 @@ async function deployRelay(input) {
|
|
|
10591
10749
|
const script = relay.script ?? "comlink";
|
|
10592
10750
|
await workers.deployScript(script, {
|
|
10593
10751
|
code,
|
|
10594
|
-
secrets:
|
|
10595
|
-
[relayWebhookBinding(input.source)]: input.webhook,
|
|
10596
|
-
...input.signingSecret ? { [relaySecretBinding(input.source)]: input.signingSecret } : {}
|
|
10597
|
-
},
|
|
10752
|
+
secrets: Object.fromEntries(input.sources.flatMap((s) => [[relayWebhookBinding(s.source), s.webhook], ...s.signingSecret ? [[relaySecretBinding(s.source), s.signingSecret]] : []])),
|
|
10598
10753
|
routes: [`${relay.host}/*`]
|
|
10599
10754
|
});
|
|
10600
10755
|
await dns.upsertRecord(relayZone(relay), {
|
|
@@ -10868,7 +11023,7 @@ const SETUP_ENVIRONMENTS = ["staging", "production"];
|
|
|
10868
11023
|
* set on one that exists. An environment that exists but is not expected is never a problem. With no provider and
|
|
10869
11024
|
* nothing named, nothing is declared; with no provider but some named, the row is a skip with the reason.
|
|
10870
11025
|
*/
|
|
10871
|
-
const ID$
|
|
11026
|
+
const ID$6 = "environments";
|
|
10872
11027
|
const TITLE$6 = "environments exist";
|
|
10873
11028
|
async function runDoctorEnvironments(input) {
|
|
10874
11029
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -10893,7 +11048,7 @@ async function runDoctorEnvironments(input) {
|
|
|
10893
11048
|
}
|
|
10894
11049
|
async function checkEnvironments(loader, named) {
|
|
10895
11050
|
const make = (status, detail, problems = []) => ({
|
|
10896
|
-
id: ID$
|
|
11051
|
+
id: ID$6,
|
|
10897
11052
|
title: TITLE$6,
|
|
10898
11053
|
status,
|
|
10899
11054
|
detail,
|
|
@@ -11498,7 +11653,7 @@ async function readWorkspaceMonitoring(context) {
|
|
|
11498
11653
|
return out;
|
|
11499
11654
|
}
|
|
11500
11655
|
// src/commands/doctor-monitoring/dashboard-rows/dashboard-rows.ts
|
|
11501
|
-
const ID$
|
|
11656
|
+
const ID$5 = "monitoring-dashboards";
|
|
11502
11657
|
const TITLE$5 = "monitoring dashboards match";
|
|
11503
11658
|
/** The tags as comparable text: sorted and de-duplicated. */
|
|
11504
11659
|
const tagsText = (tags) => [...new Set(tags)].sort().join(", ") || "none";
|
|
@@ -11531,7 +11686,7 @@ async function dashboardRows(monitoring) {
|
|
|
11531
11686
|
detail,
|
|
11532
11687
|
problems: []
|
|
11533
11688
|
});
|
|
11534
|
-
if (!monitoring.inspectDashboard) return [skip(ID$
|
|
11689
|
+
if (!monitoring.inspectDashboard) return [skip(ID$5, TITLE$5, "provider does not implement inspectDashboard")];
|
|
11535
11690
|
try {
|
|
11536
11691
|
const names = new Set(declared.map((d) => d.name));
|
|
11537
11692
|
const problems = [];
|
|
@@ -11542,13 +11697,13 @@ async function dashboardRows(monitoring) {
|
|
|
11542
11697
|
for (const other of have.others) if (!names.has(other)) extra.add(other);
|
|
11543
11698
|
}
|
|
11544
11699
|
const rows = [problems.length > 0 ? {
|
|
11545
|
-
id: ID$
|
|
11700
|
+
id: ID$5,
|
|
11546
11701
|
title: TITLE$5,
|
|
11547
11702
|
status: "fail",
|
|
11548
11703
|
detail: `${problems.length} problem(s)`,
|
|
11549
11704
|
problems
|
|
11550
11705
|
} : {
|
|
11551
|
-
id: ID$
|
|
11706
|
+
id: ID$5,
|
|
11552
11707
|
title: TITLE$5,
|
|
11553
11708
|
status: "ok",
|
|
11554
11709
|
detail: `${declared.length} of ${declared.length} match`,
|
|
@@ -11558,9 +11713,9 @@ async function dashboardRows(monitoring) {
|
|
|
11558
11713
|
return rows;
|
|
11559
11714
|
} catch (err) {
|
|
11560
11715
|
const noToken = missingTokenReason(err);
|
|
11561
|
-
if (noToken !== void 0) return [skip(ID$
|
|
11716
|
+
if (noToken !== void 0) return [skip(ID$5, TITLE$5, noToken)];
|
|
11562
11717
|
return [{
|
|
11563
|
-
id: ID$
|
|
11718
|
+
id: ID$5,
|
|
11564
11719
|
title: TITLE$5,
|
|
11565
11720
|
status: "fail",
|
|
11566
11721
|
detail: errorMessage(err),
|
|
@@ -11574,7 +11729,7 @@ async function dashboardRows(monitoring) {
|
|
|
11574
11729
|
* (a tag the config states is compared too; one it leaves out is not), and a heartbeat the account holds beyond the
|
|
11575
11730
|
* config is an `info` row (shown as skipped). Names only: the ping URL is never read here.
|
|
11576
11731
|
*/
|
|
11577
|
-
const ID$
|
|
11732
|
+
const ID$4 = "monitoring-heartbeats";
|
|
11578
11733
|
const TITLE$4 = "monitoring heartbeats match";
|
|
11579
11734
|
const show = (b) => new Map([
|
|
11580
11735
|
["period", `${b.period} ${b.periodUnit}`],
|
|
@@ -11586,7 +11741,7 @@ async function heartbeatRows(monitoring) {
|
|
|
11586
11741
|
const declared = monitoring.heartbeats ?? [];
|
|
11587
11742
|
if (declared.length === 0) return [];
|
|
11588
11743
|
const skip = (detail) => ({
|
|
11589
|
-
id: ID$
|
|
11744
|
+
id: ID$4,
|
|
11590
11745
|
title: TITLE$4,
|
|
11591
11746
|
status: "skip",
|
|
11592
11747
|
detail,
|
|
@@ -11611,13 +11766,13 @@ async function heartbeatRows(monitoring) {
|
|
|
11611
11766
|
}));
|
|
11612
11767
|
}
|
|
11613
11768
|
const rows = [problems.length > 0 ? {
|
|
11614
|
-
id: ID$
|
|
11769
|
+
id: ID$4,
|
|
11615
11770
|
title: TITLE$4,
|
|
11616
11771
|
status: "fail",
|
|
11617
11772
|
detail: `${problems.length} problem(s)`,
|
|
11618
11773
|
problems
|
|
11619
11774
|
} : {
|
|
11620
|
-
id: ID$
|
|
11775
|
+
id: ID$4,
|
|
11621
11776
|
title: TITLE$4,
|
|
11622
11777
|
status: "ok",
|
|
11623
11778
|
detail: `${declared.length} of ${declared.length} match`,
|
|
@@ -11626,7 +11781,7 @@ async function heartbeatRows(monitoring) {
|
|
|
11626
11781
|
const declaredNames = new Set(declared.map((b) => b.name));
|
|
11627
11782
|
const extras = [...have.keys()].filter((name) => !declaredNames.has(name)).sort();
|
|
11628
11783
|
if (extras.length > 0) rows.push({
|
|
11629
|
-
id: `${ID$
|
|
11784
|
+
id: `${ID$4}-extra`,
|
|
11630
11785
|
title: "heartbeats beyond the config",
|
|
11631
11786
|
status: "skip",
|
|
11632
11787
|
detail: `info: the account also holds ${extras.length}: ${extras.join(", ")}`,
|
|
@@ -11637,7 +11792,7 @@ async function heartbeatRows(monitoring) {
|
|
|
11637
11792
|
const noToken = missingTokenReason(err);
|
|
11638
11793
|
if (noToken !== void 0) return [skip(noToken)];
|
|
11639
11794
|
return [{
|
|
11640
|
-
id: ID$
|
|
11795
|
+
id: ID$4,
|
|
11641
11796
|
title: TITLE$4,
|
|
11642
11797
|
status: "fail",
|
|
11643
11798
|
detail: errorMessage(err),
|
|
@@ -11742,7 +11897,7 @@ async function statusPageRows(monitoring) {
|
|
|
11742
11897
|
return rows;
|
|
11743
11898
|
}
|
|
11744
11899
|
// src/commands/doctor-monitoring/undeclared-check-rows/undeclared-check-rows.ts
|
|
11745
|
-
const ID$
|
|
11900
|
+
const ID$3 = "monitoring-undeclared";
|
|
11746
11901
|
const TITLE$3 = "checks no config declares";
|
|
11747
11902
|
function undeclaredCheckRows({ monitoring, workspace, have }) {
|
|
11748
11903
|
if (have === void 0) return [];
|
|
@@ -11753,7 +11908,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
|
|
|
11753
11908
|
].flatMap((x) => x.tags));
|
|
11754
11909
|
if (tags.size === 0) return [];
|
|
11755
11910
|
const row = (status, detail) => [{
|
|
11756
|
-
id: ID$
|
|
11911
|
+
id: ID$3,
|
|
11757
11912
|
title: TITLE$3,
|
|
11758
11913
|
status,
|
|
11759
11914
|
detail,
|
|
@@ -11791,7 +11946,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
|
|
|
11791
11946
|
* Out of scope: the alert channel and its subscriptions (the notification layout declares those, see
|
|
11792
11947
|
* `doctor notifications`) and any check that a message really arrives.
|
|
11793
11948
|
*/
|
|
11794
|
-
const ID$
|
|
11949
|
+
const ID$2 = "monitoring-checks";
|
|
11795
11950
|
const TITLE$2 = "monitoring checks match";
|
|
11796
11951
|
async function runDoctorMonitoring(input) {
|
|
11797
11952
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -11831,14 +11986,14 @@ async function runDoctorMonitoring(input) {
|
|
|
11831
11986
|
/** The checks row and, when it read them, the checks the account holds (the one read `monitoring-undeclared` reuses). */
|
|
11832
11987
|
async function checkRow(loader) {
|
|
11833
11988
|
const skip = (detail) => ({ row: {
|
|
11834
|
-
id: ID$
|
|
11989
|
+
id: ID$2,
|
|
11835
11990
|
title: TITLE$2,
|
|
11836
11991
|
status: "skip",
|
|
11837
11992
|
detail,
|
|
11838
11993
|
problems: []
|
|
11839
11994
|
} });
|
|
11840
11995
|
const none = () => ({ row: {
|
|
11841
|
-
id: ID$
|
|
11996
|
+
id: ID$2,
|
|
11842
11997
|
title: TITLE$2,
|
|
11843
11998
|
status: "ok",
|
|
11844
11999
|
detail: "none declared",
|
|
@@ -11856,7 +12011,7 @@ async function checkRow(loader) {
|
|
|
11856
12011
|
const problems = compareChecks(monitoring.checks, have);
|
|
11857
12012
|
if (problems.length > 0) return {
|
|
11858
12013
|
row: {
|
|
11859
|
-
id: ID$
|
|
12014
|
+
id: ID$2,
|
|
11860
12015
|
title: TITLE$2,
|
|
11861
12016
|
status: "fail",
|
|
11862
12017
|
detail: `${problems.length} problem(s)`,
|
|
@@ -11867,7 +12022,7 @@ async function checkRow(loader) {
|
|
|
11867
12022
|
const n = monitoring.checks.length;
|
|
11868
12023
|
return {
|
|
11869
12024
|
row: {
|
|
11870
|
-
id: ID$
|
|
12025
|
+
id: ID$2,
|
|
11871
12026
|
title: TITLE$2,
|
|
11872
12027
|
status: "ok",
|
|
11873
12028
|
detail: `${n} of ${n} match`,
|
|
@@ -11879,7 +12034,7 @@ async function checkRow(loader) {
|
|
|
11879
12034
|
const noToken = missingTokenReason(err);
|
|
11880
12035
|
if (noToken !== void 0) return skip(noToken);
|
|
11881
12036
|
return { row: {
|
|
11882
|
-
id: ID$
|
|
12037
|
+
id: ID$2,
|
|
11883
12038
|
title: TITLE$2,
|
|
11884
12039
|
status: "fail",
|
|
11885
12040
|
detail: errorMessage(err),
|
|
@@ -12272,6 +12427,167 @@ function roleTeamProblem(layout) {
|
|
|
12272
12427
|
seen.set(key, role.team);
|
|
12273
12428
|
}
|
|
12274
12429
|
}
|
|
12430
|
+
// src/commands/relay-sources/declared-relay-sources.ts
|
|
12431
|
+
/** The sources `relay.sources` declares, in the order written. */
|
|
12432
|
+
function declaredRelaySources(layout) {
|
|
12433
|
+
return Object.entries(layout.relay?.sources ?? {}).map(([id, spec]) => ({
|
|
12434
|
+
id,
|
|
12435
|
+
spec
|
|
12436
|
+
}));
|
|
12437
|
+
}
|
|
12438
|
+
// src/commands/relay-sources/ensure-relay-source.ts
|
|
12439
|
+
/**
|
|
12440
|
+
* Make or adopt the vendor's webhook for one relay source through its provider, and report it like the rest of
|
|
12441
|
+
* `setup`. The provider is given a fresh secret to use only if the vendor lets the caller choose and it makes the
|
|
12442
|
+
* webhook now. Nothing the vendor returns as a secret is printed; the caller hands it to the Worker. `--dry-run` asks
|
|
12443
|
+
* the provider nothing. Throws when the provider cannot make a webhook, or when it fails.
|
|
12444
|
+
*/
|
|
12445
|
+
async function ensureRelaySource(source, provider, input, run) {
|
|
12446
|
+
const { id, spec } = source;
|
|
12447
|
+
const name = spec.name ?? id.charAt(0).toUpperCase() + id.slice(1);
|
|
12448
|
+
const url = `https://${input.host}/${id}`;
|
|
12449
|
+
if (!provider.ensureRelaySource) throw new Error(`the \`${provider.providerName}\` provider cannot make a webhook for relay source ${id}`);
|
|
12450
|
+
if (run.dryRun) {
|
|
12451
|
+
run.print(` ${style.skip(`would ensure the ${provider.providerName} webhook ${name} for ${url}`)}`);
|
|
12452
|
+
run.made(false);
|
|
12453
|
+
return { todo: [] };
|
|
12454
|
+
}
|
|
12455
|
+
const result = await provider.ensureRelaySource({
|
|
12456
|
+
source: id,
|
|
12457
|
+
url,
|
|
12458
|
+
name,
|
|
12459
|
+
...spec.events ? { events: spec.events } : {},
|
|
12460
|
+
...spec.scope ? { scope: spec.scope } : {},
|
|
12461
|
+
...spec.options ? { options: spec.options } : {},
|
|
12462
|
+
secret: input.newSecret()
|
|
12463
|
+
});
|
|
12464
|
+
const changed = result.created || result.updated.length > 0;
|
|
12465
|
+
const verb = result.created ? "created" : changed ? "updated" : "exists ";
|
|
12466
|
+
const detail = result.updated.length > 0 ? `: ${result.updated.join(", ")}` : "";
|
|
12467
|
+
run.print(` ${(changed ? style.success : style.skip)(`${verb} ${provider.providerName} webhook ${name}${detail}`)}`);
|
|
12468
|
+
run.made(changed);
|
|
12469
|
+
if (!result.secret) run.print(result.created ? ` ${style.warn(`${provider.providerName} made the webhook but gave no signing secret for ${id}: set COMLINK_${id.toUpperCase()}_SECRET on the Worker yourself`)}` : ` ${style.skip(`${provider.providerName} gave no signing secret for ${id}, so the Worker keeps the one it has`)}`);
|
|
12470
|
+
return {
|
|
12471
|
+
...result.secret ? { secret: result.secret } : {},
|
|
12472
|
+
todo: result.todo ?? []
|
|
12473
|
+
};
|
|
12474
|
+
}
|
|
12475
|
+
// src/commands/relay-sources/new-relay-secret.ts
|
|
12476
|
+
/**
|
|
12477
|
+
* A fresh signing secret for a vendor that lets the caller choose it: 32 random bytes as hex. A credential: it goes to
|
|
12478
|
+
* the provider that makes the webhook and to the Worker, and is never printed or logged.
|
|
12479
|
+
*/
|
|
12480
|
+
function newRelaySecret() {
|
|
12481
|
+
return randomBytes(32).toString("hex");
|
|
12482
|
+
}
|
|
12483
|
+
// src/commands/relay-sources/relay-source-checks.ts
|
|
12484
|
+
const shown$6 = (s) => sanitizeDetail(s);
|
|
12485
|
+
const missingFrom = (wanted, held) => wanted && held ? wanted.filter((w) => !held.includes(w)) : [];
|
|
12486
|
+
/**
|
|
12487
|
+
* The steps of `doctor notifications` that check each relay source's webhook at the vendor (`relay-source:<id>`): it
|
|
12488
|
+
* exists for the relay's URL, is on, and carries every event and scope the layout declares (extra ones are left alone).
|
|
12489
|
+
* Read-only, and the signing secret is never read. No rows unless the layout declares `relay.sources`; a provider that
|
|
12490
|
+
* is missing, cannot read its webhook or has no token is a skip, never a failure.
|
|
12491
|
+
*/
|
|
12492
|
+
async function relaySourceChecks(input) {
|
|
12493
|
+
const { layout } = input;
|
|
12494
|
+
const host = layout.relay?.host;
|
|
12495
|
+
const rows = [];
|
|
12496
|
+
for (const { id, spec } of declaredRelaySources(layout)) {
|
|
12497
|
+
const rowId = `relay-source:${id}`;
|
|
12498
|
+
const title = `${shown$6(id)} webhook at the vendor posts to the relay`;
|
|
12499
|
+
if (!host) {
|
|
12500
|
+
rows.push(skipRow$1(rowId, title, "no `relay.host` is declared"));
|
|
12501
|
+
continue;
|
|
12502
|
+
}
|
|
12503
|
+
const provider = input.provider(spec.capability);
|
|
12504
|
+
if (!provider) {
|
|
12505
|
+
rows.push(skipRow$1(rowId, title, input.missingReason(spec.capability)));
|
|
12506
|
+
continue;
|
|
12507
|
+
}
|
|
12508
|
+
if (!provider.inspectRelaySource) {
|
|
12509
|
+
rows.push(skipRow$1(rowId, title, `the \`${provider.providerName}\` provider cannot read its webhooks`));
|
|
12510
|
+
continue;
|
|
12511
|
+
}
|
|
12512
|
+
const url = `https://${host}/${id}`;
|
|
12513
|
+
try {
|
|
12514
|
+
const state = await provider.inspectRelaySource({
|
|
12515
|
+
source: id,
|
|
12516
|
+
url,
|
|
12517
|
+
name: spec.name ?? id.charAt(0).toUpperCase() + id.slice(1),
|
|
12518
|
+
...spec.events ? { events: spec.events } : {},
|
|
12519
|
+
...spec.scope ? { scope: spec.scope } : {},
|
|
12520
|
+
...spec.options ? { options: spec.options } : {}
|
|
12521
|
+
});
|
|
12522
|
+
const problems = [];
|
|
12523
|
+
if (!state.exists) problems.push(`no ${shown$6(provider.providerName)} webhook posts to ${shown$6(url)}`);
|
|
12524
|
+
else {
|
|
12525
|
+
if (state.enabled === false) problems.push("the webhook is switched off");
|
|
12526
|
+
const events = missingFrom(spec.events, state.events);
|
|
12527
|
+
if (events.length > 0) problems.push(`not subscribed to ${events.map(shown$6).join(", ")}`);
|
|
12528
|
+
const scope = missingFrom(spec.scope, state.scope);
|
|
12529
|
+
if (scope.length > 0) problems.push(`does not cover ${scope.map(shown$6).join(", ")}`);
|
|
12530
|
+
if (state.hasSecret === false) problems.push("the webhook has no signing secret");
|
|
12531
|
+
}
|
|
12532
|
+
rows.push(resultRow(rowId, title, problems, `${shown$6(provider.providerName)} posts to ${shown$6(url)}`));
|
|
12533
|
+
} catch (err) {
|
|
12534
|
+
const noToken = missingTokenReason(err);
|
|
12535
|
+
rows.push(noToken !== void 0 ? skipRow$1(rowId, title, noToken) : resultRow(rowId, title, [shown$6(describeError(err))], ""));
|
|
12536
|
+
}
|
|
12537
|
+
}
|
|
12538
|
+
return rows;
|
|
12539
|
+
}
|
|
12540
|
+
// src/commands/relay-sources/relay-sources-problem.ts
|
|
12541
|
+
/** The capabilities a relay source may name (see `RelaySourceCapability`). */
|
|
12542
|
+
const RELAY_SOURCE_CAPABILITIES = [
|
|
12543
|
+
"deployment",
|
|
12544
|
+
"dns",
|
|
12545
|
+
"vault",
|
|
12546
|
+
"auth",
|
|
12547
|
+
"workers"
|
|
12548
|
+
];
|
|
12549
|
+
/** An id is a URL path segment and part of a Worker binding name, so it is lower-case letters and digits. */
|
|
12550
|
+
const ID$1 = /^[a-z][a-z0-9]*$/;
|
|
12551
|
+
/**
|
|
12552
|
+
* The first reason the layout's relay sources cannot work, or undefined. `errorsSource` is the error tracker's id when a
|
|
12553
|
+
* channel is fed by it, since the tracker's binding names are taken. Pure: it reads the layout and nothing else.
|
|
12554
|
+
*/
|
|
12555
|
+
function relaySourcesProblem(layout, errorsSource) {
|
|
12556
|
+
const declared = declaredRelaySources(layout);
|
|
12557
|
+
const feeds = genericRelayFeeds(layout);
|
|
12558
|
+
if (declared.length === 0 && feeds.length === 0) return void 0;
|
|
12559
|
+
if (!layout.relay?.host) return "relay sources need `relay.host` — where the relay Worker answers";
|
|
12560
|
+
const ids = new Set(declared.map((d) => d.id));
|
|
12561
|
+
for (const { id, spec } of declared) {
|
|
12562
|
+
if (!ID$1.test(id)) return `relay source \`${id}\`: the id must be lower-case letters and digits, starting with a letter (it is a path and part of a binding name)`;
|
|
12563
|
+
if (errorsSource !== void 0 && id === errorsSource) return `relay source \`${id}\` is the error tracker's own source — it is set up by \`relay.errors\`, not \`relay.sources\``;
|
|
12564
|
+
if (!RELAY_SOURCE_CAPABILITIES.includes(spec?.capability)) return `relay source \`${id}\`: \`capability\` must be one of ${RELAY_SOURCE_CAPABILITIES.join(", ")}`;
|
|
12565
|
+
for (const key of ["events", "scope"]) {
|
|
12566
|
+
const list = spec[key];
|
|
12567
|
+
if (list !== void 0 && !(Array.isArray(list) && list.every((item) => typeof item === "string"))) return `relay source \`${id}\`: \`${key}\` must be a list of strings`;
|
|
12568
|
+
}
|
|
12569
|
+
}
|
|
12570
|
+
const carriedBy = /* @__PURE__ */ new Map();
|
|
12571
|
+
for (const { source, channel, feed } of feeds) {
|
|
12572
|
+
if (!ids.has(source)) return `channel \`${channel.name}\`: \`feeds.relay.${source}\` names no source — declare it in \`relay.sources\``;
|
|
12573
|
+
const other = carriedBy.get(source);
|
|
12574
|
+
if (other !== void 0) return `channels \`${other}\` and \`${channel.name}\` both carry relay source \`${source}\`, but one source posts to one channel — feed one`;
|
|
12575
|
+
carriedBy.set(source, channel.name);
|
|
12576
|
+
const picture = avatarProblem(channel.name, `feeds.relay.${source}.avatar`, typeof feed === "object" ? feed.avatar : void 0);
|
|
12577
|
+
if (picture) return picture;
|
|
12578
|
+
}
|
|
12579
|
+
for (const { id } of declared) if (!carriedBy.has(id)) return `relay source \`${id}\` is carried by no channel — add \`feeds.relay.${id}\` to one`;
|
|
12580
|
+
for (const { channel } of feeds) {
|
|
12581
|
+
const names = /* @__PURE__ */ new Map();
|
|
12582
|
+
const own = (typeof channel.webhook === "object" ? channel.webhook.name : void 0) ?? channel.name;
|
|
12583
|
+
if (channel.webhook) names.set(own.toLowerCase(), "the channel's own webhook");
|
|
12584
|
+
for (const mine of feeds.filter((f) => f.channel === channel)) {
|
|
12585
|
+
const clash = names.get(mine.webhook.toLowerCase());
|
|
12586
|
+
if (clash !== void 0) return `channel \`${channel.name}\`: the webhook for relay source \`${mine.source}\` and ${clash} are both named ${mine.webhook} — rename one`;
|
|
12587
|
+
names.set(mine.webhook.toLowerCase(), `the webhook for relay source \`${mine.source}\``);
|
|
12588
|
+
}
|
|
12589
|
+
}
|
|
12590
|
+
}
|
|
12275
12591
|
// src/commands/read-repo-text/read-repo-text.ts
|
|
12276
12592
|
/** A text file named in a config is a few paragraphs; this only keeps a wrong file from filling memory. */
|
|
12277
12593
|
const MAX_REPO_TEXT_BYTES = 102400;
|
|
@@ -12512,7 +12828,7 @@ function forumLayoutProblem(layout) {
|
|
|
12512
12828
|
if (channel.feeds?.prs) return `${where}: \`feeds.prs\` belongs to a forum, where each pull request is a post -- set \`kind: "forum"\` or remove it`;
|
|
12513
12829
|
continue;
|
|
12514
12830
|
}
|
|
12515
|
-
if (channel.webhook || channel.feeds?.monitoring || channel.feeds?.errors) return `${where}: a forum takes no \`webhook\` or the \`monitoring\` and \`errors\` feeds; its conversations are posts`;
|
|
12831
|
+
if (channel.webhook || channel.feeds?.monitoring || channel.feeds?.errors || Object.values(channel.feeds?.relay ?? {}).some(Boolean)) return `${where}: a forum takes no \`webhook\` or the \`monitoring\` and \`errors\` feeds (nor \`relay\` ones); its conversations are posts`;
|
|
12516
12832
|
if (channel.defaultReaction !== void 0) {
|
|
12517
12833
|
const problem = reactionProblem("`defaultReaction`", channel.defaultReaction);
|
|
12518
12834
|
if (problem) return `${where}: ${problem}`;
|
|
@@ -12703,28 +13019,36 @@ async function runNotificationsSetup(input$1) {
|
|
|
12703
13019
|
let errors;
|
|
12704
13020
|
let workers;
|
|
12705
13021
|
let dns;
|
|
12706
|
-
|
|
12707
|
-
|
|
13022
|
+
const sourceProviders = /* @__PURE__ */ new Map();
|
|
13023
|
+
const declaredSources = declaredRelaySources(layout);
|
|
13024
|
+
const wantsErrors = wantsRelay(layout);
|
|
13025
|
+
if (wantsAnyRelay(layout) || declaredSources.length > 0) {
|
|
13026
|
+
const early = relayProblem(layout) ?? relaySourcesProblem(layout);
|
|
12708
13027
|
if (early) return refuse(early);
|
|
12709
|
-
|
|
12710
|
-
["errors", "an `errors` provider (the tracker whose alerts it carries)"],
|
|
13028
|
+
const needs = [
|
|
12711
13029
|
["workers", "a `workers` provider (where it runs)"],
|
|
12712
|
-
["dns", "a `dns` provider (for its host)"]
|
|
12713
|
-
|
|
12714
|
-
|
|
13030
|
+
["dns", "a `dns` provider (for its host)"],
|
|
13031
|
+
...wantsErrors ? [["errors", "an `errors` provider (the tracker whose alerts it carries)"]] : []
|
|
13032
|
+
];
|
|
13033
|
+
for (const { id, spec } of declaredSources) needs.push([spec.capability, `a \`${spec.capability}\` provider (it makes the ${id} webhook)`]);
|
|
13034
|
+
for (const [key, what] of needs) if (!loader.has(key)) return refuse(whyMissing(loader, key, `the relay Worker needs ${what} — add one`));
|
|
13035
|
+
if (wantsErrors) errors = loader.get("errors");
|
|
12715
13036
|
workers = loader.get("workers");
|
|
12716
13037
|
dns = loader.get("dns");
|
|
12717
|
-
const
|
|
13038
|
+
for (const { id, spec } of declaredSources) sourceProviders.set(id, loader.get(spec.capability));
|
|
13039
|
+
const clash = relayProblem(layout, errors, monitoring) ?? relaySourcesProblem(layout, errors?.providerName);
|
|
12718
13040
|
if (clash) return refuse(clash);
|
|
12719
13041
|
}
|
|
12720
13042
|
const feedAvatarsOf = (channel) => channel.feeds?.monitoring ? feedAvatarOf(layout, channel.feeds.monitoring, monitoring) : [];
|
|
12721
13043
|
const errorsAvatarsOf = (channel) => channel.feeds?.errors ? feedAvatarOf(layout, channel.feeds.errors) : [];
|
|
13044
|
+
const relayFeedsOf = (channel) => genericRelayFeeds(layout).filter((f) => f.channel === channel);
|
|
12722
13045
|
const avatars = /* @__PURE__ */ new Map();
|
|
12723
13046
|
const read = input$1.loadAvatar ?? ((source) => loadAvatar(source, input$1.context.repoRoot));
|
|
12724
13047
|
for (const channel of (layout.categories ?? []).flatMap((c) => c.channels ?? [])) for (const sources of [
|
|
12725
13048
|
channelWebhookAvatars(layout, channel),
|
|
12726
13049
|
feedAvatarsOf(channel),
|
|
12727
|
-
errorsAvatarsOf(channel)
|
|
13050
|
+
errorsAvatarsOf(channel),
|
|
13051
|
+
...relayFeedsOf(channel).map((f) => feedAvatarOf(layout, f.feed))
|
|
12728
13052
|
]) {
|
|
12729
13053
|
const key = JSON.stringify(sources);
|
|
12730
13054
|
if (sources.length > 0 && !avatars.has(key)) try {
|
|
@@ -12804,7 +13128,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
12804
13128
|
};
|
|
12805
13129
|
}
|
|
12806
13130
|
}
|
|
12807
|
-
|
|
13131
|
+
const relayWebhooks = /* @__PURE__ */ new Map();
|
|
12808
13132
|
const tally = {
|
|
12809
13133
|
ok: 0,
|
|
12810
13134
|
skip: 0
|
|
@@ -12923,7 +13247,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
12923
13247
|
notifications,
|
|
12924
13248
|
...secrets ? { secrets } : {},
|
|
12925
13249
|
...monitoring ? { monitoring } : {},
|
|
12926
|
-
onRelayWebhook: (url) => void (
|
|
13250
|
+
onRelayWebhook: (url, source) => void relayWebhooks.set(source ?? errors.providerName, url),
|
|
12927
13251
|
scope: scope ?? { kind: "repo" },
|
|
12928
13252
|
dryRun,
|
|
12929
13253
|
print,
|
|
@@ -12937,12 +13261,17 @@ async function runNotificationsSetup(input$1) {
|
|
|
12937
13261
|
...channel.tags ? { tags: channel.tags } : {},
|
|
12938
13262
|
...channel.defaultReaction ? { defaultReaction: channel.defaultReaction } : {},
|
|
12939
13263
|
...webhook ? { webhook } : {},
|
|
12940
|
-
...channel.feeds?.monitoring || channel.feeds?.errors ? { feeds: {
|
|
12941
|
-
...channel.feeds
|
|
13264
|
+
...channel.feeds?.monitoring || channel.feeds?.errors || relayFeedsOf(channel).length > 0 ? { feeds: {
|
|
13265
|
+
...channel.feeds?.monitoring ? { monitoring: {
|
|
12942
13266
|
...monitoringFeed(channel.name, channel.feeds.monitoring, monitoring),
|
|
12943
13267
|
...feedAvatarsOf(channel).length > 0 ? { avatar: avatars.get(JSON.stringify(feedAvatarsOf(channel))) } : {}
|
|
12944
13268
|
} } : {},
|
|
12945
|
-
...channel.
|
|
13269
|
+
...relayFeedsOf(channel).length > 0 ? { relay: relayFeedsOf(channel).map((f) => ({
|
|
13270
|
+
source: f.source,
|
|
13271
|
+
webhook: f.webhook,
|
|
13272
|
+
...feedAvatarOf(layout, f.feed).length > 0 ? { avatar: avatars.get(JSON.stringify(feedAvatarOf(layout, f.feed))) } : {}
|
|
13273
|
+
})) } : {},
|
|
13274
|
+
...channel.feeds?.errors ? { errors: {
|
|
12946
13275
|
webhook: errorsFeedWebhook(channel.feeds.errors, errors),
|
|
12947
13276
|
...errorsAvatarsOf(channel).length > 0 ? { avatar: avatars.get(JSON.stringify(errorsAvatarsOf(channel))) } : {}
|
|
12948
13277
|
} } : {}
|
|
@@ -12955,11 +13284,11 @@ async function runNotificationsSetup(input$1) {
|
|
|
12955
13284
|
});
|
|
12956
13285
|
});
|
|
12957
13286
|
}
|
|
12958
|
-
if (
|
|
13287
|
+
if (workers && dns && (wantsErrors || wantsAnyRelay(layout))) {
|
|
12959
13288
|
print(`\n${style.header("Relay")}`);
|
|
12960
13289
|
const tracker = layout.relay.errors;
|
|
12961
|
-
|
|
12962
|
-
if (tracker && errors.ensureRelay) await attempt(`${errors.providerName} alert relay`, async () => {
|
|
13290
|
+
const signingSecrets = /* @__PURE__ */ new Map();
|
|
13291
|
+
if (errors && tracker && errors.ensureRelay) await attempt(`${errors.providerName} alert relay`, async () => {
|
|
12963
13292
|
const integration = tracker.integration ?? "Comlink";
|
|
12964
13293
|
const rule = tracker.rule ?? "Errors to Discord (Comlink)";
|
|
12965
13294
|
if (dryRun) {
|
|
@@ -12976,7 +13305,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
12976
13305
|
...tracker.frequency ? { frequency: tracker.frequency } : {}
|
|
12977
13306
|
}
|
|
12978
13307
|
});
|
|
12979
|
-
|
|
13308
|
+
if (result.clientSecret) signingSecrets.set(errors.providerName, result.clientSecret);
|
|
12980
13309
|
for (const [what, name, outcome] of [[
|
|
12981
13310
|
"integration",
|
|
12982
13311
|
integration,
|
|
@@ -12992,20 +13321,50 @@ async function runNotificationsSetup(input$1) {
|
|
|
12992
13321
|
print(` ${(changed ? style.success : style.skip)(`${verb} ${errors.providerName} ${what} ${name}${detail}`)}`);
|
|
12993
13322
|
made(changed);
|
|
12994
13323
|
}
|
|
12995
|
-
if (!
|
|
13324
|
+
if (!result.clientSecret) print(` ${style.warn(`${errors.providerName} did not give the integration's signing secret (it may only show it once, when the integration is made), so the Worker keeps the one it has. To set it: copy it from the integration's page, add it to Doppler as COMLINK_${errors.providerName.toUpperCase()}_SECRET and run holocron sync secrets --env prod`)}`);
|
|
12996
13325
|
});
|
|
13326
|
+
for (const source of declaredSources) {
|
|
13327
|
+
const provider = sourceProviders.get(source.id);
|
|
13328
|
+
await attempt(`${provider.providerName} relay source ${source.id}`, async () => {
|
|
13329
|
+
const ensured = await ensureRelaySource(source, provider, {
|
|
13330
|
+
host: layout.relay.host,
|
|
13331
|
+
newSecret: newRelaySecret
|
|
13332
|
+
}, {
|
|
13333
|
+
print,
|
|
13334
|
+
made,
|
|
13335
|
+
dryRun
|
|
13336
|
+
});
|
|
13337
|
+
if (ensured.secret) signingSecrets.set(source.id, ensured.secret);
|
|
13338
|
+
for (const todo of ensured.todo) {
|
|
13339
|
+
print(` ${style.fail(`${provider.providerName} relay source ${source.id}: ${todo}`)}`);
|
|
13340
|
+
report.failures.push({
|
|
13341
|
+
step: `${provider.providerName} relay source ${source.id}`,
|
|
13342
|
+
message: todo
|
|
13343
|
+
});
|
|
13344
|
+
}
|
|
13345
|
+
});
|
|
13346
|
+
}
|
|
12997
13347
|
await attempt(`relay ${layout.relay.host}`, async () => {
|
|
12998
13348
|
if (dryRun) {
|
|
12999
13349
|
print(` ${style.skip(`would deploy the relay Worker at ${layout.relay.host}`)}`);
|
|
13000
13350
|
tally.skip++;
|
|
13001
13351
|
return;
|
|
13002
13352
|
}
|
|
13003
|
-
|
|
13353
|
+
const wanted = [...errors ? [errors.providerName] : [], ...declaredSources.map((d) => d.id)];
|
|
13354
|
+
const bindings = wanted.flatMap((source) => {
|
|
13355
|
+
const webhook = relayWebhooks.get(source);
|
|
13356
|
+
const signingSecret = signingSecrets.get(source);
|
|
13357
|
+
return webhook ? [{
|
|
13358
|
+
source,
|
|
13359
|
+
webhook,
|
|
13360
|
+
...signingSecret ? { signingSecret } : {}
|
|
13361
|
+
}] : [];
|
|
13362
|
+
});
|
|
13363
|
+
const missing = wanted.filter((source) => !relayWebhooks.has(source));
|
|
13364
|
+
if (bindings.length === 0) throw new Error("no relay webhook to give the Worker (its channel failed above)");
|
|
13004
13365
|
const deployed = await deployRelay({
|
|
13005
13366
|
relay: layout.relay,
|
|
13006
|
-
|
|
13007
|
-
webhook: relayWebhook,
|
|
13008
|
-
...signingSecret ? { signingSecret } : {},
|
|
13367
|
+
sources: bindings,
|
|
13009
13368
|
repoRoot: input$1.context.repoRoot,
|
|
13010
13369
|
workers,
|
|
13011
13370
|
dns,
|
|
@@ -13013,6 +13372,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
13013
13372
|
});
|
|
13014
13373
|
print(` ${style.success(`deployed ${deployed.script} at ${deployed.host}`)}`);
|
|
13015
13374
|
tally.ok++;
|
|
13375
|
+
if (missing.length > 0) throw new Error(`no relay webhook for ${missing.join(", ")} (its channel failed above), so the Worker has none`);
|
|
13016
13376
|
});
|
|
13017
13377
|
}
|
|
13018
13378
|
if (layout.server || layout.welcome || layout.onboarding || (layout.pinned?.length ?? 0) > 0 || layout.application || layout.everyone) {
|
|
@@ -13904,16 +14264,20 @@ async function answers(url, doFetch) {
|
|
|
13904
14264
|
async function relayChecks(input) {
|
|
13905
14265
|
const { layout } = input;
|
|
13906
14266
|
const relay = layout.relay;
|
|
13907
|
-
if (!relay?.host || !
|
|
13908
|
-
|
|
14267
|
+
if (!relay?.host || !wantsAnyRelay(layout)) return [];
|
|
14268
|
+
const generic = genericRelayFeeds(layout);
|
|
14269
|
+
if (!input.errors && wantsRelay(layout) && !wantsRelaySources(layout)) return [
|
|
13909
14270
|
skipRow$1(ANSWERS_ID, ANSWERS_TITLE, input.errorsMissingReason),
|
|
13910
14271
|
skipRow$1(WORKER_ID, WORKER_TITLE, input.errorsMissingReason),
|
|
13911
14272
|
skipRow$1(BINDINGS_ID, BINDINGS_TITLE, input.errorsMissingReason),
|
|
13912
14273
|
skipRow$1(WEBHOOK_ID, WEBHOOK_TITLE, input.errorsMissingReason)
|
|
13913
14274
|
];
|
|
13914
|
-
const source = input.errors
|
|
14275
|
+
const source = input.errors?.providerName;
|
|
14276
|
+
const ids = [...source ? [source] : [], ...generic.map((f) => f.source)];
|
|
14277
|
+
const doFetch = input.fetch ?? fetch;
|
|
13915
14278
|
const rows = [];
|
|
13916
|
-
rows.push(resultRow(ANSWERS_ID, ANSWERS_TITLE, await answers(`https://${relay.host}/${source}`,
|
|
14279
|
+
if (wantsRelay(layout)) rows.push(source ? resultRow(ANSWERS_ID, ANSWERS_TITLE, await answers(`https://${relay.host}/${source}`, doFetch), `https://${shown$2(relay.host)}/${shown$2(source)} answered 401`) : skipRow$1(ANSWERS_ID, ANSWERS_TITLE, input.errorsMissingReason));
|
|
14280
|
+
for (const { source: id } of generic) rows.push(resultRow(`${ANSWERS_ID}:${id}`, ANSWERS_TITLE, await answers(`https://${relay.host}/${id}`, doFetch), `https://${shown$2(relay.host)}/${shown$2(id)} answered 401`));
|
|
13917
14281
|
const script = relay.script ?? "comlink";
|
|
13918
14282
|
const route = `${relay.host}/*`;
|
|
13919
14283
|
const skipWorker = (reason) => [skipRow$1(WORKER_ID, WORKER_TITLE, reason), skipRow$1(BINDINGS_ID, BINDINGS_TITLE, reason)];
|
|
@@ -13924,30 +14288,42 @@ async function relayChecks(input) {
|
|
|
13924
14288
|
if (!state.exists) rows.push(resultRow(WORKER_ID, WORKER_TITLE, [`no Worker named ${shown$2(script)}`], ""), skipRow$1(BINDINGS_ID, BINDINGS_TITLE, `not checked: no Worker named ${shown$2(script)}`));
|
|
13925
14289
|
else {
|
|
13926
14290
|
const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
|
|
13927
|
-
const wanted = [relayWebhookBinding(
|
|
14291
|
+
const wanted = ids.flatMap((id) => [relayWebhookBinding(id), relaySecretBinding(id)]);
|
|
13928
14292
|
rows.push(resultRow(WORKER_ID, WORKER_TITLE, state.routes.some((r) => same$3(r, route)) ? [] : [`${shown$2(script)} has no route ${shown$2(route)}`], `${shown$2(script)} serves ${shown$2(route)}`), resultRow(BINDINGS_ID, BINDINGS_TITLE, wanted.filter((n) => !bound.has(n)).map((n) => `${n}: not bound`), `${wanted.length} of ${wanted.length} bound`));
|
|
13929
14293
|
}
|
|
13930
14294
|
} catch (err) {
|
|
13931
14295
|
const reason = missingTokenReason(err);
|
|
13932
14296
|
rows.push(...reason === void 0 ? [resultRow(WORKER_ID, WORKER_TITLE, [shown$2(describeError(err))], ""), skipRow$1(BINDINGS_ID, BINDINGS_TITLE, "not checked: could not read the Worker")] : skipWorker(reason));
|
|
13933
14297
|
}
|
|
13934
|
-
rows.push(webhookRow(input, source));
|
|
14298
|
+
if (wantsRelay(layout)) rows.push(source ? webhookRow(input, source) : skipRow$1(WEBHOOK_ID, WEBHOOK_TITLE, input.errorsMissingReason));
|
|
14299
|
+
for (const feed of generic) rows.push(genericWebhookRow(input, feed));
|
|
13935
14300
|
return rows;
|
|
13936
14301
|
}
|
|
14302
|
+
/** A relay source's webhook is on its channel, with a picture when the layout or the provider gives one. */
|
|
14303
|
+
function genericWebhookRow(input, feed) {
|
|
14304
|
+
const id = `${WEBHOOK_ID}:${feed.source}`;
|
|
14305
|
+
const title = `${shown$2(feed.source)} feed webhook exists and has a picture`;
|
|
14306
|
+
if (!input.found) return skipRow$1(id, title, "not checked: could not read the server");
|
|
14307
|
+
return webhookProblems(input, id, title, feed.channel.name, feed.webhook, feedAvatarOf(input.layout, feed.feed));
|
|
14308
|
+
}
|
|
13937
14309
|
/** The error feed's webhook is on its channel, with a picture when the layout or the provider gives one. */
|
|
13938
14310
|
function webhookRow(input, source) {
|
|
13939
14311
|
if (!input.found) return skipRow$1(WEBHOOK_ID, WEBHOOK_TITLE, "not checked: could not read the server");
|
|
13940
14312
|
const channel = input.layout.categories.flatMap((cat) => cat.channels ?? []).find((c) => c.feeds?.errors);
|
|
13941
14313
|
const feed = channel.feeds.errors;
|
|
13942
14314
|
const name = errorsFeedWebhook(feed, { providerName: source });
|
|
13943
|
-
|
|
13944
|
-
|
|
14315
|
+
return webhookProblems(input, WEBHOOK_ID, WEBHOOK_TITLE, channel.name, name, feedAvatarOf(input.layout, feed));
|
|
14316
|
+
}
|
|
14317
|
+
/** The one rule both feeds follow: the channel exists, lists the webhook and, when a picture is wanted, the picture is on it. */
|
|
14318
|
+
function webhookProblems(input, id, title, channelName, name, avatar) {
|
|
14319
|
+
const where = input.found.channels.find((c) => same$3(c.name, channelName));
|
|
14320
|
+
const label = `#${shown$2(channelName)}`;
|
|
13945
14321
|
const problems = [];
|
|
13946
14322
|
if (!where) problems.push(`${label}: no channel to hold the feed webhook`);
|
|
13947
14323
|
else if (where.webhooksError) problems.push(`${label}: could not list its webhooks (${shown$2(where.webhooksError)})`);
|
|
13948
14324
|
else if (!where.webhooks.some((w) => same$3(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
|
|
13949
|
-
else if (
|
|
13950
|
-
return resultRow(
|
|
14325
|
+
else if (avatar.length > 0 && !where.webhookAvatars?.some((w) => same$3(w, name))) problems.push(`${label}: webhook ${shown$2(name)} has no picture`);
|
|
14326
|
+
return resultRow(id, title, problems, `${label}: ${shown$2(name)}`);
|
|
13951
14327
|
}
|
|
13952
14328
|
// src/commands/sentry-relay-checks/sentry-relay-checks.ts
|
|
13953
14329
|
const INTEGRATION_ID = "relay-integration";
|
|
@@ -14534,6 +14910,11 @@ async function runDoctorNotifications(input) {
|
|
|
14534
14910
|
errors: loader.has("errors") ? loader.get("errors") : void 0,
|
|
14535
14911
|
errorsMissingReason: whyMissing(loader, "errors", "no `errors` provider is configured")
|
|
14536
14912
|
}));
|
|
14913
|
+
checks.push(...await relaySourceChecks({
|
|
14914
|
+
layout,
|
|
14915
|
+
provider: (capability) => loader.has(capability) ? loader.get(capability) : void 0,
|
|
14916
|
+
missingReason: (capability) => whyMissing(loader, capability, `no \`${capability}\` provider is configured`)
|
|
14917
|
+
}));
|
|
14537
14918
|
const withHook = (layout.categories ?? []).flatMap((cat) => (cat.channels ?? []).filter((c) => c.webhook).map((channel) => ({
|
|
14538
14919
|
cat,
|
|
14539
14920
|
channel
|
|
@@ -18756,12 +19137,12 @@ function declaredWorkers(input) {
|
|
|
18756
19137
|
const declared = [];
|
|
18757
19138
|
for (const layout of input.layouts) {
|
|
18758
19139
|
const relay = layout.relay;
|
|
18759
|
-
if (!relay?.host || !
|
|
19140
|
+
if (!relay?.host || !wantsAnyRelay(layout)) continue;
|
|
18760
19141
|
declared.push({
|
|
18761
19142
|
label: "relay",
|
|
18762
19143
|
script: relay.script ?? "comlink",
|
|
18763
19144
|
host: relay.host,
|
|
18764
|
-
bindings: input.errors ? [
|
|
19145
|
+
bindings: [...input.errors && wantsRelay(layout) ? [input.errors.providerName] : [], ...genericRelayFeeds(layout).map((f) => f.source)].flatMap((source) => [relayWebhookBinding(source), relaySecretBinding(source)])
|
|
18765
19146
|
});
|
|
18766
19147
|
}
|
|
18767
19148
|
const proxied = input.wiki?.proxyConfig?.() ? input.wiki.dnsRecord?.() : null;
|
|
@@ -24269,7 +24650,7 @@ async function runIssueCreate(input) {
|
|
|
24269
24650
|
const summary = details.length > 0 ? ` (${details.join("; ")})` : "";
|
|
24270
24651
|
if (dryRun) {
|
|
24271
24652
|
print(` ${title}`);
|
|
24272
|
-
for (const line of
|
|
24653
|
+
for (const line of body ? body.split("\n").slice(0, PREVIEW_LINES) : []) print(` ${style.skip(line)}`);
|
|
24273
24654
|
print("");
|
|
24274
24655
|
return finish([row$6(title, "skip", `would file the issue${summary}`)]);
|
|
24275
24656
|
}
|
|
@@ -34954,6 +35335,10 @@ const issueUpdateCommand = {
|
|
|
34954
35335
|
type: "string",
|
|
34955
35336
|
choices: ["open", "closed"],
|
|
34956
35337
|
describe: "Open or close the issue"
|
|
35338
|
+
}).option("state-reason", {
|
|
35339
|
+
type: "string",
|
|
35340
|
+
choices: ["completed", "not_planned"],
|
|
35341
|
+
describe: "Why it was closed, with --state closed (GitHub; other trackers ignore it)"
|
|
34957
35342
|
}).option("add-label", {
|
|
34958
35343
|
type: "string",
|
|
34959
35344
|
array: true,
|
|
@@ -35007,6 +35392,7 @@ const issueUpdateCommand = {
|
|
|
35007
35392
|
...argv.title !== void 0 ? { title: String(argv.title) } : {},
|
|
35008
35393
|
...body !== void 0 ? { body } : {},
|
|
35009
35394
|
...argv.state ? { state: argv.state } : {},
|
|
35395
|
+
...argv.stateReason ? { stateReason: argv.stateReason } : {},
|
|
35010
35396
|
...argv.addLabel ? { addLabels: argv.addLabel.map(String) } : {},
|
|
35011
35397
|
...argv.removeLabel ? { removeLabels: argv.removeLabel.map(String) } : {},
|
|
35012
35398
|
...argv.assignee ? { assignees: argv.assignee.map(String) } : {},
|