@theholocron/cli 5.0.0-alpha.505 → 5.0.0-alpha.507
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 +4 -4
- package/dist/cli.mjs +489 -80
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-s8z09jI0.mjs → config-system-CHEJvjlB.mjs} +24 -1
- package/dist/{index-BeFKgg7I.d.mts → index-D_e9vKTW.d.mts} +116 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +10 -10
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",
|
|
@@ -2692,11 +2699,28 @@ function validateEnvironmentChoice(entry, what, required = true) {
|
|
|
2692
2699
|
const AREA_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
2693
2700
|
/** GitHub's longest label name is 50 characters, and `area:` takes five. */
|
|
2694
2701
|
const MAX_NAME = 45;
|
|
2702
|
+
/** GitHub's longest label name. */
|
|
2703
|
+
const MAX_LABEL = 50;
|
|
2704
|
+
/** `owner/name`, as GitHub spells a repository. */
|
|
2705
|
+
const REPOSITORY = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
2706
|
+
/** Checks one label-to-Type table and records each label (lower case) in `seen`, so no label is in two tables. */
|
|
2707
|
+
function validateKinds(key, table, seen) {
|
|
2708
|
+
for (const [label, type] of Object.entries(table ?? {})) {
|
|
2709
|
+
const at = `\`repo.labels.${key}.${label}\``;
|
|
2710
|
+
if (label.trim() === "" || label.length > MAX_LABEL) throw new ConfigError$1(`${at}: a label name is 1 to ${MAX_LABEL} characters`);
|
|
2711
|
+
if (typeof type !== "string" || type.trim() === "") throw new ConfigError$1(`${at} needs the name of an issue Type, such as "Bug"`);
|
|
2712
|
+
const lower = label.toLowerCase();
|
|
2713
|
+
const first = seen.get(lower);
|
|
2714
|
+
if (first !== void 0) throw new ConfigError$1(`${at}: ${JSON.stringify(label)} is already in \`${first}\``);
|
|
2715
|
+
seen.set(lower, `repo.labels.${key}.${label}`);
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2695
2718
|
/**
|
|
2696
2719
|
* Check `repo.labels` (spec `tech-github-area-labels`): each area name must be usable as the suffix of a label (letters,
|
|
2697
2720
|
* digits, `.`, `_` and `-`, at most 45 characters) and appear once whatever the case (GitHub's labels are
|
|
2698
2721
|
* case-insensitive), each area needs a list of patterns with at least one that includes a path, and each scope names a
|
|
2699
|
-
* declared area.
|
|
2722
|
+
* declared area. `kinds` and `fallbackKinds` map a label name (at most 50 characters, in one table only) to a Type name,
|
|
2723
|
+
* and `repos` lists `owner/name` repositories; whether a Type exists is the organization's to say, so the probe checks it.
|
|
2700
2724
|
*
|
|
2701
2725
|
* @param labels - `repo.labels`, if the config has it.
|
|
2702
2726
|
* @throws {ConfigError} Naming the path of the first problem found.
|
|
@@ -2724,6 +2748,12 @@ function validateRepoLabels(labels) {
|
|
|
2724
2748
|
throw new ConfigError$1(`${at} names the unknown area ${JSON.stringify(area)}; ${known.length > 0 ? `the declared areas are ${known.join(", ")}` : "`repo.labels.areas` declares none"}`);
|
|
2725
2749
|
}
|
|
2726
2750
|
}
|
|
2751
|
+
const kinds = /* @__PURE__ */ new Map();
|
|
2752
|
+
validateKinds("kinds", labels.kinds, kinds);
|
|
2753
|
+
validateKinds("fallbackKinds", labels.fallbackKinds, kinds);
|
|
2754
|
+
const repos = labels.repos ?? [];
|
|
2755
|
+
if (!Array.isArray(repos)) throw new ConfigError$1("`repo.labels.repos` is a list of `owner/name` repositories");
|
|
2756
|
+
for (const repo of repos) if (typeof repo !== "string" || !REPOSITORY.test(repo)) throw new ConfigError$1(`\`repo.labels.repos\` has ${JSON.stringify(repo)}, which is not an \`owner/name\` repository`);
|
|
2727
2757
|
}
|
|
2728
2758
|
// src/credentials-environments/repo-slug/repo-slug.ts
|
|
2729
2759
|
/**
|
|
@@ -4125,7 +4155,8 @@ async function provisionChannel(deps, spec) {
|
|
|
4125
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`);
|
|
4126
4156
|
}
|
|
4127
4157
|
const relay = spec.feeds?.errors;
|
|
4128
|
-
|
|
4158
|
+
const relays = spec.feeds?.relay ?? [];
|
|
4159
|
+
if ((relay || relays.length > 0) && !notifications.ensureWebhook) throw new Error(`\`${notifications.providerName}\` cannot create webhooks`);
|
|
4129
4160
|
if (dryRun) {
|
|
4130
4161
|
print(` ${style.skip(`would ensure channel ${spec.name}${where}`)}`);
|
|
4131
4162
|
if (tally) tally.skip += webhookCfg ? 2 : 1;
|
|
@@ -4138,6 +4169,10 @@ async function provisionChannel(deps, spec) {
|
|
|
4138
4169
|
print(` ${style.skip(`would ensure webhook ${relay.webhook} for the relay Worker (errors)`)}`);
|
|
4139
4170
|
if (tally) tally.skip++;
|
|
4140
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
|
+
}
|
|
4141
4176
|
return {
|
|
4142
4177
|
name: spec.name,
|
|
4143
4178
|
...spec.category ? { category: spec.category } : {},
|
|
@@ -4166,7 +4201,7 @@ async function provisionChannel(deps, spec) {
|
|
|
4166
4201
|
};
|
|
4167
4202
|
if (!webhookCfg) {
|
|
4168
4203
|
if (feed) await provisionFeed(deps, spec, feed, outcome);
|
|
4169
|
-
|
|
4204
|
+
await provisionRelayFeeds(deps, spec, outcome);
|
|
4170
4205
|
return outcome;
|
|
4171
4206
|
}
|
|
4172
4207
|
const hook = await notifications.ensureWebhook({
|
|
@@ -4209,15 +4244,20 @@ async function provisionChannel(deps, spec) {
|
|
|
4209
4244
|
}
|
|
4210
4245
|
if (hook.avatarError) throw new Error(`webhook ${webhookName} is ready but setting its avatar failed (${hook.avatarError})`);
|
|
4211
4246
|
if (feed) await provisionFeed(deps, spec, feed, outcome);
|
|
4212
|
-
|
|
4247
|
+
await provisionRelayFeeds(deps, spec, outcome);
|
|
4213
4248
|
return outcome;
|
|
4214
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
|
+
}
|
|
4215
4255
|
/**
|
|
4216
4256
|
* A dedicated webhook for the relay Worker. Its URL goes to the caller (which hands it to the Worker as a secret) and
|
|
4217
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
|
|
4218
4258
|
* person does not, and is reported rather than guessed at.
|
|
4219
4259
|
*/
|
|
4220
|
-
async function provisionRelayFeed(deps, spec, feed, outcome) {
|
|
4260
|
+
async function provisionRelayFeed(deps, spec, feed, outcome, source) {
|
|
4221
4261
|
const { notifications, print, tally } = deps;
|
|
4222
4262
|
const hook = await notifications.ensureWebhook({
|
|
4223
4263
|
channel: spec.name,
|
|
@@ -4232,13 +4272,18 @@ async function provisionRelayFeed(deps, spec, feed, outcome) {
|
|
|
4232
4272
|
if (done > 0) tally.ok += done;
|
|
4233
4273
|
else tally.skip++;
|
|
4234
4274
|
}
|
|
4235
|
-
|
|
4275
|
+
const recorded = {
|
|
4236
4276
|
name: feed.webhook,
|
|
4237
4277
|
created: hook.created,
|
|
4238
4278
|
...avatarSet ? { updated: ["avatar"] } : {}
|
|
4239
4279
|
};
|
|
4280
|
+
if (source === void 0) outcome.relayWebhook = recorded;
|
|
4281
|
+
else (outcome.relayWebhooks ??= []).push({
|
|
4282
|
+
source,
|
|
4283
|
+
...recorded
|
|
4284
|
+
});
|
|
4240
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`);
|
|
4241
|
-
deps.onRelayWebhook?.(hook.url);
|
|
4286
|
+
deps.onRelayWebhook?.(hook.url, source);
|
|
4242
4287
|
if (hook.avatarError) throw new Error(`webhook ${feed.webhook} is ready but setting its avatar failed (${hook.avatarError})`);
|
|
4243
4288
|
}
|
|
4244
4289
|
/**
|
|
@@ -6478,6 +6523,7 @@ async function runIssueUpdate(input) {
|
|
|
6478
6523
|
const milestone = input.milestone?.trim();
|
|
6479
6524
|
if (input.title !== void 0 && !title) problems.push("--title is empty");
|
|
6480
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");
|
|
6481
6527
|
const set = {
|
|
6482
6528
|
assignees: assignees.length > 0,
|
|
6483
6529
|
milestone: Boolean(milestone),
|
|
@@ -6498,7 +6544,7 @@ async function runIssueUpdate(input) {
|
|
|
6498
6544
|
...title ? { title } : {},
|
|
6499
6545
|
...input.body !== void 0 ? { body: input.body } : {},
|
|
6500
6546
|
...input.state ? { state: input.state } : {},
|
|
6501
|
-
...input.
|
|
6547
|
+
...input.stateReason ? { stateReason: input.stateReason } : {},
|
|
6502
6548
|
...addLabels.length > 0 ? { addLabels } : {},
|
|
6503
6549
|
...removeLabels.length > 0 ? { removeLabels } : {},
|
|
6504
6550
|
...assignees.length > 0 ? { assignees } : {},
|
|
@@ -6509,7 +6555,7 @@ async function runIssueUpdate(input) {
|
|
|
6509
6555
|
const details = [
|
|
6510
6556
|
...title ? ["title"] : [],
|
|
6511
6557
|
...input.body !== void 0 ? ["body"] : [],
|
|
6512
|
-
...input.state ? [`state: ${input.state}`] : [],
|
|
6558
|
+
...input.state ? [`state: ${input.state}${input.stateReason ? ` (${input.stateReason})` : ""}`] : [],
|
|
6513
6559
|
...addLabels.length > 0 ? [`add labels: ${addLabels.join(", ")}`] : [],
|
|
6514
6560
|
...removeLabels.length > 0 ? [`remove labels: ${removeLabels.join(", ")}`] : [],
|
|
6515
6561
|
...assignees.length > 0 ? [`assignee: ${assignees.join(", ")}`] : [],
|
|
@@ -6838,7 +6884,7 @@ async function abandonWork(a) {
|
|
|
6838
6884
|
}));
|
|
6839
6885
|
else rows.push(row$29("local branch", "skip", `no local branch is named for ${key}`));
|
|
6840
6886
|
if (dryRun) rows.push(row$29("issue", "skip", `would ask whether to close ${key} as not planned`));
|
|
6841
|
-
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`));
|
|
6842
6888
|
else if (await a.ask(`Close ${key} as not planned?`)) {
|
|
6843
6889
|
const close = await (input.updateIssue ?? runIssueUpdate)({
|
|
6844
6890
|
key,
|
|
@@ -7011,7 +7057,7 @@ function createProjectRows(print, logger) {
|
|
|
7011
7057
|
*/
|
|
7012
7058
|
const COMMAND$9 = "project status";
|
|
7013
7059
|
/** `#12`, `12`, `o/r#12` as a repository (or none) and a number; anything else (a Linear key) is undefined. */
|
|
7014
|
-
const parseKey = (key) => {
|
|
7060
|
+
const parseKey$1 = (key) => {
|
|
7015
7061
|
const m = /^(?:([^#\s]+)#|#)?(\d+)$/.exec(key.trim());
|
|
7016
7062
|
return m ? {
|
|
7017
7063
|
repo: m[1],
|
|
@@ -7038,11 +7084,11 @@ async function runProjectStatus(input) {
|
|
|
7038
7084
|
const board = await projects.find(options.owner, declared.name);
|
|
7039
7085
|
if (!board) return failed(`board ${declared.name}`, "the board does not exist or is closed; run `holocron setup project`");
|
|
7040
7086
|
const wanted = input.issue.trim();
|
|
7041
|
-
const parsed = parseKey(wanted);
|
|
7087
|
+
const parsed = parseKey$1(wanted);
|
|
7042
7088
|
const own = `${input.loaded.resolved.org ?? input.context.org ?? ""}/${input.loaded.resolved.name}`.toLowerCase();
|
|
7043
7089
|
const item = (await projects.items(options.owner, board, template)).find((i) => {
|
|
7044
7090
|
if (!parsed) return i.key.toLowerCase() === wanted.toLowerCase();
|
|
7045
|
-
const have = parseKey(i.key);
|
|
7091
|
+
const have = parseKey$1(i.key);
|
|
7046
7092
|
if (have?.number !== parsed.number) return false;
|
|
7047
7093
|
if (parsed.repo === void 0) return have.repo === void 0;
|
|
7048
7094
|
return (have.repo ?? own).toLowerCase() === parsed.repo.toLowerCase();
|
|
@@ -7109,6 +7155,75 @@ const projectStatusCommand = {
|
|
|
7109
7155
|
})).status === "fail") process.exitCode = 1;
|
|
7110
7156
|
}
|
|
7111
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
|
+
}
|
|
7112
7227
|
// src/commands/start-work/real-start-work-io/real-start-work-io.ts
|
|
7113
7228
|
/** The real git and file system {@link runStartWork} runs against; tests pass a fake. */
|
|
7114
7229
|
function createRealStartWorkIo() {
|
|
@@ -7123,6 +7238,18 @@ function createRealStartWorkIo() {
|
|
|
7123
7238
|
today: () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
7124
7239
|
};
|
|
7125
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
|
+
}
|
|
7126
7253
|
// src/commands/start-work/work-body/work-body.ts
|
|
7127
7254
|
/**
|
|
7128
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
|
|
@@ -7141,6 +7268,15 @@ function buildWorkBody(input) {
|
|
|
7141
7268
|
"- [ ] Green checks (`ci / Required checks`)"
|
|
7142
7269
|
].join("\n");
|
|
7143
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
|
+
}
|
|
7144
7280
|
// src/commands/start-work/work-slug/work-slug.ts
|
|
7145
7281
|
/** The longest slug taken from a title, cut at a word. */
|
|
7146
7282
|
const MAX_SLUG$1 = 40;
|
|
@@ -7296,6 +7432,7 @@ async function runStartWork(input) {
|
|
|
7296
7432
|
if (!issuesEntry) return fail(key, "the config has no `issues` provider to read the issue with");
|
|
7297
7433
|
const sourceEntry = input.noPr ? void 0 : input.loaded.resolved.providers.source;
|
|
7298
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;
|
|
7299
7436
|
const credentials = input.loaded.resolved.providers.credentials;
|
|
7300
7437
|
/* v8 ignore start -- the real loader is only built outside tests, which always inject one */
|
|
7301
7438
|
const loader = input.loader ?? new PluginLoader({
|
|
@@ -7303,6 +7440,7 @@ async function runStartWork(input) {
|
|
|
7303
7440
|
providers: {
|
|
7304
7441
|
issues: issuesEntry,
|
|
7305
7442
|
...sourceEntry ? { source: sourceEntry } : {},
|
|
7443
|
+
...projectsEntry ? { projects: projectsEntry } : {},
|
|
7306
7444
|
...credentials ? { credentials } : {}
|
|
7307
7445
|
}
|
|
7308
7446
|
}, input.context);
|
|
@@ -7462,7 +7600,7 @@ async function runStartWork(input) {
|
|
|
7462
7600
|
]) || "0");
|
|
7463
7601
|
if (ahead > 0) rows.push(row$28("first commit", "skip", `${branch} already has ${ahead} commit${ahead === 1 ? "" : "s"}`));
|
|
7464
7602
|
else {
|
|
7465
|
-
const trailer = `Refs ${key}`;
|
|
7603
|
+
const trailer = `Refs ${workReference(key)}`;
|
|
7466
7604
|
if (spec) {
|
|
7467
7605
|
if (dir !== root) io.write(join(dir, spec.rel), io.read(spec.abs));
|
|
7468
7606
|
io.git([
|
|
@@ -7500,12 +7638,26 @@ async function runStartWork(input) {
|
|
|
7500
7638
|
return finish();
|
|
7501
7639
|
}
|
|
7502
7640
|
if (source) try {
|
|
7503
|
-
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] : []])];
|
|
7504
7656
|
const mirrored = {
|
|
7505
7657
|
...record?.labels.length ? { labels: record.labels } : {},
|
|
7506
7658
|
...record?.milestone ? { milestone: record.milestone } : {},
|
|
7507
7659
|
...assignees.length > 0 ? { assignees } : {},
|
|
7508
|
-
...
|
|
7660
|
+
...projects.length > 0 ? { projects } : {}
|
|
7509
7661
|
};
|
|
7510
7662
|
const result = await source.createPullRequest({
|
|
7511
7663
|
title,
|
|
@@ -7513,7 +7665,7 @@ async function runStartWork(input) {
|
|
|
7513
7665
|
base,
|
|
7514
7666
|
draft: true,
|
|
7515
7667
|
body: buildWorkBody({
|
|
7516
|
-
issue: key,
|
|
7668
|
+
issue: workReference(key),
|
|
7517
7669
|
issueTitle: issue.summary,
|
|
7518
7670
|
...issue.url ? { issueUrl: issue.url } : {},
|
|
7519
7671
|
...spec ? { spec: spec.rel } : {}
|
|
@@ -10494,6 +10646,27 @@ function previewConfigOf(config) {
|
|
|
10494
10646
|
domain: config.domain
|
|
10495
10647
|
}) : null;
|
|
10496
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
|
+
}
|
|
10497
10670
|
// src/commands/notifications-setup/avatar-problem.ts
|
|
10498
10671
|
/**
|
|
10499
10672
|
* The first reason a picture cannot work, or undefined. `key` names it for the message (`feeds.errors.avatar`,
|
|
@@ -10521,6 +10694,14 @@ const relaySecretBinding = (source) => `COMLINK_${source.toUpperCase()}_SECRET`;
|
|
|
10521
10694
|
function wantsRelay(layout) {
|
|
10522
10695
|
return (layout.categories ?? []).some((c) => (c.channels ?? []).some((ch) => ch.feeds?.errors));
|
|
10523
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
|
+
}
|
|
10524
10705
|
/**
|
|
10525
10706
|
* The first reason the relay cannot be deployed, or undefined. One source has one webhook, so only one channel can be
|
|
10526
10707
|
* fed by it; and the Worker needs somewhere to answer.
|
|
@@ -10568,10 +10749,7 @@ async function deployRelay(input) {
|
|
|
10568
10749
|
const script = relay.script ?? "comlink";
|
|
10569
10750
|
await workers.deployScript(script, {
|
|
10570
10751
|
code,
|
|
10571
|
-
secrets:
|
|
10572
|
-
[relayWebhookBinding(input.source)]: input.webhook,
|
|
10573
|
-
...input.signingSecret ? { [relaySecretBinding(input.source)]: input.signingSecret } : {}
|
|
10574
|
-
},
|
|
10752
|
+
secrets: Object.fromEntries(input.sources.flatMap((s) => [[relayWebhookBinding(s.source), s.webhook], ...s.signingSecret ? [[relaySecretBinding(s.source), s.signingSecret]] : []])),
|
|
10575
10753
|
routes: [`${relay.host}/*`]
|
|
10576
10754
|
});
|
|
10577
10755
|
await dns.upsertRecord(relayZone(relay), {
|
|
@@ -10845,7 +11023,7 @@ const SETUP_ENVIRONMENTS = ["staging", "production"];
|
|
|
10845
11023
|
* set on one that exists. An environment that exists but is not expected is never a problem. With no provider and
|
|
10846
11024
|
* nothing named, nothing is declared; with no provider but some named, the row is a skip with the reason.
|
|
10847
11025
|
*/
|
|
10848
|
-
const ID$
|
|
11026
|
+
const ID$6 = "environments";
|
|
10849
11027
|
const TITLE$6 = "environments exist";
|
|
10850
11028
|
async function runDoctorEnvironments(input) {
|
|
10851
11029
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -10870,7 +11048,7 @@ async function runDoctorEnvironments(input) {
|
|
|
10870
11048
|
}
|
|
10871
11049
|
async function checkEnvironments(loader, named) {
|
|
10872
11050
|
const make = (status, detail, problems = []) => ({
|
|
10873
|
-
id: ID$
|
|
11051
|
+
id: ID$6,
|
|
10874
11052
|
title: TITLE$6,
|
|
10875
11053
|
status,
|
|
10876
11054
|
detail,
|
|
@@ -11475,7 +11653,7 @@ async function readWorkspaceMonitoring(context) {
|
|
|
11475
11653
|
return out;
|
|
11476
11654
|
}
|
|
11477
11655
|
// src/commands/doctor-monitoring/dashboard-rows/dashboard-rows.ts
|
|
11478
|
-
const ID$
|
|
11656
|
+
const ID$5 = "monitoring-dashboards";
|
|
11479
11657
|
const TITLE$5 = "monitoring dashboards match";
|
|
11480
11658
|
/** The tags as comparable text: sorted and de-duplicated. */
|
|
11481
11659
|
const tagsText = (tags) => [...new Set(tags)].sort().join(", ") || "none";
|
|
@@ -11508,7 +11686,7 @@ async function dashboardRows(monitoring) {
|
|
|
11508
11686
|
detail,
|
|
11509
11687
|
problems: []
|
|
11510
11688
|
});
|
|
11511
|
-
if (!monitoring.inspectDashboard) return [skip(ID$
|
|
11689
|
+
if (!monitoring.inspectDashboard) return [skip(ID$5, TITLE$5, "provider does not implement inspectDashboard")];
|
|
11512
11690
|
try {
|
|
11513
11691
|
const names = new Set(declared.map((d) => d.name));
|
|
11514
11692
|
const problems = [];
|
|
@@ -11519,13 +11697,13 @@ async function dashboardRows(monitoring) {
|
|
|
11519
11697
|
for (const other of have.others) if (!names.has(other)) extra.add(other);
|
|
11520
11698
|
}
|
|
11521
11699
|
const rows = [problems.length > 0 ? {
|
|
11522
|
-
id: ID$
|
|
11700
|
+
id: ID$5,
|
|
11523
11701
|
title: TITLE$5,
|
|
11524
11702
|
status: "fail",
|
|
11525
11703
|
detail: `${problems.length} problem(s)`,
|
|
11526
11704
|
problems
|
|
11527
11705
|
} : {
|
|
11528
|
-
id: ID$
|
|
11706
|
+
id: ID$5,
|
|
11529
11707
|
title: TITLE$5,
|
|
11530
11708
|
status: "ok",
|
|
11531
11709
|
detail: `${declared.length} of ${declared.length} match`,
|
|
@@ -11535,9 +11713,9 @@ async function dashboardRows(monitoring) {
|
|
|
11535
11713
|
return rows;
|
|
11536
11714
|
} catch (err) {
|
|
11537
11715
|
const noToken = missingTokenReason(err);
|
|
11538
|
-
if (noToken !== void 0) return [skip(ID$
|
|
11716
|
+
if (noToken !== void 0) return [skip(ID$5, TITLE$5, noToken)];
|
|
11539
11717
|
return [{
|
|
11540
|
-
id: ID$
|
|
11718
|
+
id: ID$5,
|
|
11541
11719
|
title: TITLE$5,
|
|
11542
11720
|
status: "fail",
|
|
11543
11721
|
detail: errorMessage(err),
|
|
@@ -11551,7 +11729,7 @@ async function dashboardRows(monitoring) {
|
|
|
11551
11729
|
* (a tag the config states is compared too; one it leaves out is not), and a heartbeat the account holds beyond the
|
|
11552
11730
|
* config is an `info` row (shown as skipped). Names only: the ping URL is never read here.
|
|
11553
11731
|
*/
|
|
11554
|
-
const ID$
|
|
11732
|
+
const ID$4 = "monitoring-heartbeats";
|
|
11555
11733
|
const TITLE$4 = "monitoring heartbeats match";
|
|
11556
11734
|
const show = (b) => new Map([
|
|
11557
11735
|
["period", `${b.period} ${b.periodUnit}`],
|
|
@@ -11563,7 +11741,7 @@ async function heartbeatRows(monitoring) {
|
|
|
11563
11741
|
const declared = monitoring.heartbeats ?? [];
|
|
11564
11742
|
if (declared.length === 0) return [];
|
|
11565
11743
|
const skip = (detail) => ({
|
|
11566
|
-
id: ID$
|
|
11744
|
+
id: ID$4,
|
|
11567
11745
|
title: TITLE$4,
|
|
11568
11746
|
status: "skip",
|
|
11569
11747
|
detail,
|
|
@@ -11588,13 +11766,13 @@ async function heartbeatRows(monitoring) {
|
|
|
11588
11766
|
}));
|
|
11589
11767
|
}
|
|
11590
11768
|
const rows = [problems.length > 0 ? {
|
|
11591
|
-
id: ID$
|
|
11769
|
+
id: ID$4,
|
|
11592
11770
|
title: TITLE$4,
|
|
11593
11771
|
status: "fail",
|
|
11594
11772
|
detail: `${problems.length} problem(s)`,
|
|
11595
11773
|
problems
|
|
11596
11774
|
} : {
|
|
11597
|
-
id: ID$
|
|
11775
|
+
id: ID$4,
|
|
11598
11776
|
title: TITLE$4,
|
|
11599
11777
|
status: "ok",
|
|
11600
11778
|
detail: `${declared.length} of ${declared.length} match`,
|
|
@@ -11603,7 +11781,7 @@ async function heartbeatRows(monitoring) {
|
|
|
11603
11781
|
const declaredNames = new Set(declared.map((b) => b.name));
|
|
11604
11782
|
const extras = [...have.keys()].filter((name) => !declaredNames.has(name)).sort();
|
|
11605
11783
|
if (extras.length > 0) rows.push({
|
|
11606
|
-
id: `${ID$
|
|
11784
|
+
id: `${ID$4}-extra`,
|
|
11607
11785
|
title: "heartbeats beyond the config",
|
|
11608
11786
|
status: "skip",
|
|
11609
11787
|
detail: `info: the account also holds ${extras.length}: ${extras.join(", ")}`,
|
|
@@ -11614,7 +11792,7 @@ async function heartbeatRows(monitoring) {
|
|
|
11614
11792
|
const noToken = missingTokenReason(err);
|
|
11615
11793
|
if (noToken !== void 0) return [skip(noToken)];
|
|
11616
11794
|
return [{
|
|
11617
|
-
id: ID$
|
|
11795
|
+
id: ID$4,
|
|
11618
11796
|
title: TITLE$4,
|
|
11619
11797
|
status: "fail",
|
|
11620
11798
|
detail: errorMessage(err),
|
|
@@ -11719,7 +11897,7 @@ async function statusPageRows(monitoring) {
|
|
|
11719
11897
|
return rows;
|
|
11720
11898
|
}
|
|
11721
11899
|
// src/commands/doctor-monitoring/undeclared-check-rows/undeclared-check-rows.ts
|
|
11722
|
-
const ID$
|
|
11900
|
+
const ID$3 = "monitoring-undeclared";
|
|
11723
11901
|
const TITLE$3 = "checks no config declares";
|
|
11724
11902
|
function undeclaredCheckRows({ monitoring, workspace, have }) {
|
|
11725
11903
|
if (have === void 0) return [];
|
|
@@ -11730,7 +11908,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
|
|
|
11730
11908
|
].flatMap((x) => x.tags));
|
|
11731
11909
|
if (tags.size === 0) return [];
|
|
11732
11910
|
const row = (status, detail) => [{
|
|
11733
|
-
id: ID$
|
|
11911
|
+
id: ID$3,
|
|
11734
11912
|
title: TITLE$3,
|
|
11735
11913
|
status,
|
|
11736
11914
|
detail,
|
|
@@ -11768,7 +11946,7 @@ function undeclaredCheckRows({ monitoring, workspace, have }) {
|
|
|
11768
11946
|
* Out of scope: the alert channel and its subscriptions (the notification layout declares those, see
|
|
11769
11947
|
* `doctor notifications`) and any check that a message really arrives.
|
|
11770
11948
|
*/
|
|
11771
|
-
const ID$
|
|
11949
|
+
const ID$2 = "monitoring-checks";
|
|
11772
11950
|
const TITLE$2 = "monitoring checks match";
|
|
11773
11951
|
async function runDoctorMonitoring(input) {
|
|
11774
11952
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -11808,14 +11986,14 @@ async function runDoctorMonitoring(input) {
|
|
|
11808
11986
|
/** The checks row and, when it read them, the checks the account holds (the one read `monitoring-undeclared` reuses). */
|
|
11809
11987
|
async function checkRow(loader) {
|
|
11810
11988
|
const skip = (detail) => ({ row: {
|
|
11811
|
-
id: ID$
|
|
11989
|
+
id: ID$2,
|
|
11812
11990
|
title: TITLE$2,
|
|
11813
11991
|
status: "skip",
|
|
11814
11992
|
detail,
|
|
11815
11993
|
problems: []
|
|
11816
11994
|
} });
|
|
11817
11995
|
const none = () => ({ row: {
|
|
11818
|
-
id: ID$
|
|
11996
|
+
id: ID$2,
|
|
11819
11997
|
title: TITLE$2,
|
|
11820
11998
|
status: "ok",
|
|
11821
11999
|
detail: "none declared",
|
|
@@ -11833,7 +12011,7 @@ async function checkRow(loader) {
|
|
|
11833
12011
|
const problems = compareChecks(monitoring.checks, have);
|
|
11834
12012
|
if (problems.length > 0) return {
|
|
11835
12013
|
row: {
|
|
11836
|
-
id: ID$
|
|
12014
|
+
id: ID$2,
|
|
11837
12015
|
title: TITLE$2,
|
|
11838
12016
|
status: "fail",
|
|
11839
12017
|
detail: `${problems.length} problem(s)`,
|
|
@@ -11844,7 +12022,7 @@ async function checkRow(loader) {
|
|
|
11844
12022
|
const n = monitoring.checks.length;
|
|
11845
12023
|
return {
|
|
11846
12024
|
row: {
|
|
11847
|
-
id: ID$
|
|
12025
|
+
id: ID$2,
|
|
11848
12026
|
title: TITLE$2,
|
|
11849
12027
|
status: "ok",
|
|
11850
12028
|
detail: `${n} of ${n} match`,
|
|
@@ -11856,7 +12034,7 @@ async function checkRow(loader) {
|
|
|
11856
12034
|
const noToken = missingTokenReason(err);
|
|
11857
12035
|
if (noToken !== void 0) return skip(noToken);
|
|
11858
12036
|
return { row: {
|
|
11859
|
-
id: ID$
|
|
12037
|
+
id: ID$2,
|
|
11860
12038
|
title: TITLE$2,
|
|
11861
12039
|
status: "fail",
|
|
11862
12040
|
detail: errorMessage(err),
|
|
@@ -12249,6 +12427,167 @@ function roleTeamProblem(layout) {
|
|
|
12249
12427
|
seen.set(key, role.team);
|
|
12250
12428
|
}
|
|
12251
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
|
+
}
|
|
12252
12591
|
// src/commands/read-repo-text/read-repo-text.ts
|
|
12253
12592
|
/** A text file named in a config is a few paragraphs; this only keeps a wrong file from filling memory. */
|
|
12254
12593
|
const MAX_REPO_TEXT_BYTES = 102400;
|
|
@@ -12489,7 +12828,7 @@ function forumLayoutProblem(layout) {
|
|
|
12489
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`;
|
|
12490
12829
|
continue;
|
|
12491
12830
|
}
|
|
12492
|
-
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`;
|
|
12493
12832
|
if (channel.defaultReaction !== void 0) {
|
|
12494
12833
|
const problem = reactionProblem("`defaultReaction`", channel.defaultReaction);
|
|
12495
12834
|
if (problem) return `${where}: ${problem}`;
|
|
@@ -12680,28 +13019,36 @@ async function runNotificationsSetup(input$1) {
|
|
|
12680
13019
|
let errors;
|
|
12681
13020
|
let workers;
|
|
12682
13021
|
let dns;
|
|
12683
|
-
|
|
12684
|
-
|
|
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);
|
|
12685
13027
|
if (early) return refuse(early);
|
|
12686
|
-
|
|
12687
|
-
["errors", "an `errors` provider (the tracker whose alerts it carries)"],
|
|
13028
|
+
const needs = [
|
|
12688
13029
|
["workers", "a `workers` provider (where it runs)"],
|
|
12689
|
-
["dns", "a `dns` provider (for its host)"]
|
|
12690
|
-
|
|
12691
|
-
|
|
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");
|
|
12692
13036
|
workers = loader.get("workers");
|
|
12693
13037
|
dns = loader.get("dns");
|
|
12694
|
-
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);
|
|
12695
13040
|
if (clash) return refuse(clash);
|
|
12696
13041
|
}
|
|
12697
13042
|
const feedAvatarsOf = (channel) => channel.feeds?.monitoring ? feedAvatarOf(layout, channel.feeds.monitoring, monitoring) : [];
|
|
12698
13043
|
const errorsAvatarsOf = (channel) => channel.feeds?.errors ? feedAvatarOf(layout, channel.feeds.errors) : [];
|
|
13044
|
+
const relayFeedsOf = (channel) => genericRelayFeeds(layout).filter((f) => f.channel === channel);
|
|
12699
13045
|
const avatars = /* @__PURE__ */ new Map();
|
|
12700
13046
|
const read = input$1.loadAvatar ?? ((source) => loadAvatar(source, input$1.context.repoRoot));
|
|
12701
13047
|
for (const channel of (layout.categories ?? []).flatMap((c) => c.channels ?? [])) for (const sources of [
|
|
12702
13048
|
channelWebhookAvatars(layout, channel),
|
|
12703
13049
|
feedAvatarsOf(channel),
|
|
12704
|
-
errorsAvatarsOf(channel)
|
|
13050
|
+
errorsAvatarsOf(channel),
|
|
13051
|
+
...relayFeedsOf(channel).map((f) => feedAvatarOf(layout, f.feed))
|
|
12705
13052
|
]) {
|
|
12706
13053
|
const key = JSON.stringify(sources);
|
|
12707
13054
|
if (sources.length > 0 && !avatars.has(key)) try {
|
|
@@ -12781,7 +13128,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
12781
13128
|
};
|
|
12782
13129
|
}
|
|
12783
13130
|
}
|
|
12784
|
-
|
|
13131
|
+
const relayWebhooks = /* @__PURE__ */ new Map();
|
|
12785
13132
|
const tally = {
|
|
12786
13133
|
ok: 0,
|
|
12787
13134
|
skip: 0
|
|
@@ -12900,7 +13247,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
12900
13247
|
notifications,
|
|
12901
13248
|
...secrets ? { secrets } : {},
|
|
12902
13249
|
...monitoring ? { monitoring } : {},
|
|
12903
|
-
onRelayWebhook: (url) => void (
|
|
13250
|
+
onRelayWebhook: (url, source) => void relayWebhooks.set(source ?? errors.providerName, url),
|
|
12904
13251
|
scope: scope ?? { kind: "repo" },
|
|
12905
13252
|
dryRun,
|
|
12906
13253
|
print,
|
|
@@ -12914,12 +13261,17 @@ async function runNotificationsSetup(input$1) {
|
|
|
12914
13261
|
...channel.tags ? { tags: channel.tags } : {},
|
|
12915
13262
|
...channel.defaultReaction ? { defaultReaction: channel.defaultReaction } : {},
|
|
12916
13263
|
...webhook ? { webhook } : {},
|
|
12917
|
-
...channel.feeds?.monitoring || channel.feeds?.errors ? { feeds: {
|
|
12918
|
-
...channel.feeds
|
|
13264
|
+
...channel.feeds?.monitoring || channel.feeds?.errors || relayFeedsOf(channel).length > 0 ? { feeds: {
|
|
13265
|
+
...channel.feeds?.monitoring ? { monitoring: {
|
|
12919
13266
|
...monitoringFeed(channel.name, channel.feeds.monitoring, monitoring),
|
|
12920
13267
|
...feedAvatarsOf(channel).length > 0 ? { avatar: avatars.get(JSON.stringify(feedAvatarsOf(channel))) } : {}
|
|
12921
13268
|
} } : {},
|
|
12922
|
-
...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: {
|
|
12923
13275
|
webhook: errorsFeedWebhook(channel.feeds.errors, errors),
|
|
12924
13276
|
...errorsAvatarsOf(channel).length > 0 ? { avatar: avatars.get(JSON.stringify(errorsAvatarsOf(channel))) } : {}
|
|
12925
13277
|
} } : {}
|
|
@@ -12932,11 +13284,11 @@ async function runNotificationsSetup(input$1) {
|
|
|
12932
13284
|
});
|
|
12933
13285
|
});
|
|
12934
13286
|
}
|
|
12935
|
-
if (
|
|
13287
|
+
if (workers && dns && (wantsErrors || wantsAnyRelay(layout))) {
|
|
12936
13288
|
print(`\n${style.header("Relay")}`);
|
|
12937
13289
|
const tracker = layout.relay.errors;
|
|
12938
|
-
|
|
12939
|
-
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 () => {
|
|
12940
13292
|
const integration = tracker.integration ?? "Comlink";
|
|
12941
13293
|
const rule = tracker.rule ?? "Errors to Discord (Comlink)";
|
|
12942
13294
|
if (dryRun) {
|
|
@@ -12953,7 +13305,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
12953
13305
|
...tracker.frequency ? { frequency: tracker.frequency } : {}
|
|
12954
13306
|
}
|
|
12955
13307
|
});
|
|
12956
|
-
|
|
13308
|
+
if (result.clientSecret) signingSecrets.set(errors.providerName, result.clientSecret);
|
|
12957
13309
|
for (const [what, name, outcome] of [[
|
|
12958
13310
|
"integration",
|
|
12959
13311
|
integration,
|
|
@@ -12969,20 +13321,50 @@ async function runNotificationsSetup(input$1) {
|
|
|
12969
13321
|
print(` ${(changed ? style.success : style.skip)(`${verb} ${errors.providerName} ${what} ${name}${detail}`)}`);
|
|
12970
13322
|
made(changed);
|
|
12971
13323
|
}
|
|
12972
|
-
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`)}`);
|
|
12973
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
|
+
}
|
|
12974
13347
|
await attempt(`relay ${layout.relay.host}`, async () => {
|
|
12975
13348
|
if (dryRun) {
|
|
12976
13349
|
print(` ${style.skip(`would deploy the relay Worker at ${layout.relay.host}`)}`);
|
|
12977
13350
|
tally.skip++;
|
|
12978
13351
|
return;
|
|
12979
13352
|
}
|
|
12980
|
-
|
|
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)");
|
|
12981
13365
|
const deployed = await deployRelay({
|
|
12982
13366
|
relay: layout.relay,
|
|
12983
|
-
|
|
12984
|
-
webhook: relayWebhook,
|
|
12985
|
-
...signingSecret ? { signingSecret } : {},
|
|
13367
|
+
sources: bindings,
|
|
12986
13368
|
repoRoot: input$1.context.repoRoot,
|
|
12987
13369
|
workers,
|
|
12988
13370
|
dns,
|
|
@@ -12990,6 +13372,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
12990
13372
|
});
|
|
12991
13373
|
print(` ${style.success(`deployed ${deployed.script} at ${deployed.host}`)}`);
|
|
12992
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`);
|
|
12993
13376
|
});
|
|
12994
13377
|
}
|
|
12995
13378
|
if (layout.server || layout.welcome || layout.onboarding || (layout.pinned?.length ?? 0) > 0 || layout.application || layout.everyone) {
|
|
@@ -13881,16 +14264,20 @@ async function answers(url, doFetch) {
|
|
|
13881
14264
|
async function relayChecks(input) {
|
|
13882
14265
|
const { layout } = input;
|
|
13883
14266
|
const relay = layout.relay;
|
|
13884
|
-
if (!relay?.host || !
|
|
13885
|
-
|
|
14267
|
+
if (!relay?.host || !wantsAnyRelay(layout)) return [];
|
|
14268
|
+
const generic = genericRelayFeeds(layout);
|
|
14269
|
+
if (!input.errors && wantsRelay(layout) && !wantsRelaySources(layout)) return [
|
|
13886
14270
|
skipRow$1(ANSWERS_ID, ANSWERS_TITLE, input.errorsMissingReason),
|
|
13887
14271
|
skipRow$1(WORKER_ID, WORKER_TITLE, input.errorsMissingReason),
|
|
13888
14272
|
skipRow$1(BINDINGS_ID, BINDINGS_TITLE, input.errorsMissingReason),
|
|
13889
14273
|
skipRow$1(WEBHOOK_ID, WEBHOOK_TITLE, input.errorsMissingReason)
|
|
13890
14274
|
];
|
|
13891
|
-
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;
|
|
13892
14278
|
const rows = [];
|
|
13893
|
-
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`));
|
|
13894
14281
|
const script = relay.script ?? "comlink";
|
|
13895
14282
|
const route = `${relay.host}/*`;
|
|
13896
14283
|
const skipWorker = (reason) => [skipRow$1(WORKER_ID, WORKER_TITLE, reason), skipRow$1(BINDINGS_ID, BINDINGS_TITLE, reason)];
|
|
@@ -13901,30 +14288,42 @@ async function relayChecks(input) {
|
|
|
13901
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)}`));
|
|
13902
14289
|
else {
|
|
13903
14290
|
const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
|
|
13904
|
-
const wanted = [relayWebhookBinding(
|
|
14291
|
+
const wanted = ids.flatMap((id) => [relayWebhookBinding(id), relaySecretBinding(id)]);
|
|
13905
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`));
|
|
13906
14293
|
}
|
|
13907
14294
|
} catch (err) {
|
|
13908
14295
|
const reason = missingTokenReason(err);
|
|
13909
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));
|
|
13910
14297
|
}
|
|
13911
|
-
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));
|
|
13912
14300
|
return rows;
|
|
13913
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
|
+
}
|
|
13914
14309
|
/** The error feed's webhook is on its channel, with a picture when the layout or the provider gives one. */
|
|
13915
14310
|
function webhookRow(input, source) {
|
|
13916
14311
|
if (!input.found) return skipRow$1(WEBHOOK_ID, WEBHOOK_TITLE, "not checked: could not read the server");
|
|
13917
14312
|
const channel = input.layout.categories.flatMap((cat) => cat.channels ?? []).find((c) => c.feeds?.errors);
|
|
13918
14313
|
const feed = channel.feeds.errors;
|
|
13919
14314
|
const name = errorsFeedWebhook(feed, { providerName: source });
|
|
13920
|
-
|
|
13921
|
-
|
|
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)}`;
|
|
13922
14321
|
const problems = [];
|
|
13923
14322
|
if (!where) problems.push(`${label}: no channel to hold the feed webhook`);
|
|
13924
14323
|
else if (where.webhooksError) problems.push(`${label}: could not list its webhooks (${shown$2(where.webhooksError)})`);
|
|
13925
14324
|
else if (!where.webhooks.some((w) => same$3(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
|
|
13926
|
-
else if (
|
|
13927
|
-
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)}`);
|
|
13928
14327
|
}
|
|
13929
14328
|
// src/commands/sentry-relay-checks/sentry-relay-checks.ts
|
|
13930
14329
|
const INTEGRATION_ID = "relay-integration";
|
|
@@ -14511,6 +14910,11 @@ async function runDoctorNotifications(input) {
|
|
|
14511
14910
|
errors: loader.has("errors") ? loader.get("errors") : void 0,
|
|
14512
14911
|
errorsMissingReason: whyMissing(loader, "errors", "no `errors` provider is configured")
|
|
14513
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
|
+
}));
|
|
14514
14918
|
const withHook = (layout.categories ?? []).flatMap((cat) => (cat.channels ?? []).filter((c) => c.webhook).map((channel) => ({
|
|
14515
14919
|
cat,
|
|
14516
14920
|
channel
|
|
@@ -18733,12 +19137,12 @@ function declaredWorkers(input) {
|
|
|
18733
19137
|
const declared = [];
|
|
18734
19138
|
for (const layout of input.layouts) {
|
|
18735
19139
|
const relay = layout.relay;
|
|
18736
|
-
if (!relay?.host || !
|
|
19140
|
+
if (!relay?.host || !wantsAnyRelay(layout)) continue;
|
|
18737
19141
|
declared.push({
|
|
18738
19142
|
label: "relay",
|
|
18739
19143
|
script: relay.script ?? "comlink",
|
|
18740
19144
|
host: relay.host,
|
|
18741
|
-
bindings: input.errors ? [
|
|
19145
|
+
bindings: [...input.errors && wantsRelay(layout) ? [input.errors.providerName] : [], ...genericRelayFeeds(layout).map((f) => f.source)].flatMap((source) => [relayWebhookBinding(source), relaySecretBinding(source)])
|
|
18742
19146
|
});
|
|
18743
19147
|
}
|
|
18744
19148
|
const proxied = input.wiki?.proxyConfig?.() ? input.wiki.dnsRecord?.() : null;
|
|
@@ -24246,7 +24650,7 @@ async function runIssueCreate(input) {
|
|
|
24246
24650
|
const summary = details.length > 0 ? ` (${details.join("; ")})` : "";
|
|
24247
24651
|
if (dryRun) {
|
|
24248
24652
|
print(` ${title}`);
|
|
24249
|
-
for (const line of
|
|
24653
|
+
for (const line of body ? body.split("\n").slice(0, PREVIEW_LINES) : []) print(` ${style.skip(line)}`);
|
|
24250
24654
|
print("");
|
|
24251
24655
|
return finish([row$6(title, "skip", `would file the issue${summary}`)]);
|
|
24252
24656
|
}
|
|
@@ -34931,6 +35335,10 @@ const issueUpdateCommand = {
|
|
|
34931
35335
|
type: "string",
|
|
34932
35336
|
choices: ["open", "closed"],
|
|
34933
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)"
|
|
34934
35342
|
}).option("add-label", {
|
|
34935
35343
|
type: "string",
|
|
34936
35344
|
array: true,
|
|
@@ -34984,6 +35392,7 @@ const issueUpdateCommand = {
|
|
|
34984
35392
|
...argv.title !== void 0 ? { title: String(argv.title) } : {},
|
|
34985
35393
|
...body !== void 0 ? { body } : {},
|
|
34986
35394
|
...argv.state ? { state: argv.state } : {},
|
|
35395
|
+
...argv.stateReason ? { stateReason: argv.stateReason } : {},
|
|
34987
35396
|
...argv.addLabel ? { addLabels: argv.addLabel.map(String) } : {},
|
|
34988
35397
|
...argv.removeLabel ? { removeLabels: argv.removeLabel.map(String) } : {},
|
|
34989
35398
|
...argv.assignee ? { assignees: argv.assignee.map(String) } : {},
|