reporter: improve display (#3220)

This commit is contained in:
v 2025-02-12 19:10:05 +01:00 committed by GitHub
parent 591751449e
commit 146a2ac77d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,14 +54,17 @@ async function maybeGetError(handle: JSHandle): Promise<string | undefined> {
.catch(() => undefined); .catch(() => undefined);
} }
const report = { interface PatchInfo {
badPatches: [] as {
plugin: string; plugin: string;
type: string; type: string;
id: string; id: string;
match: string; match: string;
error?: string; error?: string;
}[], };
const report = {
badPatches: [] as PatchInfo[],
slowPatches: [] as PatchInfo[],
badStarts: [] as { badStarts: [] as {
plugin: string; plugin: string;
error: string; error: string;
@ -132,9 +135,22 @@ async function printReport() {
console.log(); console.log();
if (process.env.WEBHOOK_URL) { if (process.env.WEBHOOK_URL) {
const body = JSON.stringify({ const patchesToEmbed = (title: string, patches: PatchInfo[], color: number) => ({
username: "Vencord Reporter" + (CANARY ? " (Canary)" : ""), title,
embeds: [ color,
description: patches.map(p => {
const lines = [
`**__${p.plugin} (${p.type}):__**`,
`ID: \`${p.id}\``,
`Match: ${toCodeBlock(p.match, "Match: ".length, true)}`
];
if (p.error) lines.push(`Error: ${toCodeBlock(p.error, "Error: ".length, true)}`);
return lines.join("\n");
}).join("\n\n"),
});
const embeds = [
{ {
author: { author: {
name: `Discord ${CANARY ? "Canary" : "Stable"} (${metaData.buildNumber})`, name: `Discord ${CANARY ? "Canary" : "Stable"} (${metaData.buildNumber})`,
@ -143,25 +159,14 @@ async function printReport() {
}, },
color: CANARY ? 0xfbb642 : 0x5865f2 color: CANARY ? 0xfbb642 : 0x5865f2
}, },
{ report.badPatches.length > 0 && patchesToEmbed("Bad Patches", report.badPatches, 0xff0000),
title: "Bad Patches", report.slowPatches.length > 0 && patchesToEmbed("Slow Patches", report.slowPatches, 0xf0b232),
description: report.badPatches.map(p => { report.badWebpackFinds.length > 0 && {
const lines = [
`**__${p.plugin} (${p.type}):__**`,
`ID: \`${p.id}\``,
`Match: ${toCodeBlock(p.match, "Match: ".length, true)}`
];
if (p.error) lines.push(`Error: ${toCodeBlock(p.error, "Error: ".length, true)}`);
return lines.join("\n");
}).join("\n\n") || "None",
color: report.badPatches.length ? 0xff0000 : 0x00ff00
},
{
title: "Bad Webpack Finds", title: "Bad Webpack Finds",
description: report.badWebpackFinds.map(f => toCodeBlock(f, 0, true)).join("\n") || "None", description: report.badWebpackFinds.map(f => toCodeBlock(f, 0, true)).join("\n") || "None",
color: report.badWebpackFinds.length ? 0xff0000 : 0x00ff00 color: 0xff0000
}, },
{ report.badStarts.length > 0 && {
title: "Bad Starts", title: "Bad Starts",
description: report.badStarts.map(p => { description: report.badStarts.map(p => {
const lines = [ const lines = [
@ -171,14 +176,26 @@ async function printReport() {
return lines.join("\n"); return lines.join("\n");
} }
).join("\n\n") || "None", ).join("\n\n") || "None",
color: report.badStarts.length ? 0xff0000 : 0x00ff00 color: 0xff0000
}, },
{ report.otherErrors.length > 0 && {
title: "Discord Errors", title: "Discord Errors",
description: report.otherErrors.length ? toCodeBlock(report.otherErrors.join("\n"), 0, true) : "None", description: report.otherErrors.length ? toCodeBlock(report.otherErrors.join("\n"), 0, true) : "None",
color: report.otherErrors.length ? 0xff0000 : 0x00ff00 color: 0xff0000
} }
] ].filter(Boolean);
if (embeds.length === 1) {
embeds.push({
title: "No issues found",
description: "Seems like everything is working fine (for now) <:shipit:1330992641466433556>",
color: 0x00ff00
});
}
const body = JSON.stringify({
username: "Vencord Reporter" + (CANARY ? " (Canary)" : ""),
embeds
}); });
const headers = { const headers = {
@ -245,14 +262,17 @@ page.on("console", async e => {
switch (tag) { switch (tag) {
case "WebpackInterceptor:": case "WebpackInterceptor:":
const patchFailMatch = message.match(/Patch by (.+?) (had no effect|errored|found no module|took [\d.]+?ms) \(Module id is (.+?)\): (.+)/)!; const patchFailMatch = message.match(/Patch by (.+?) (had no effect|errored|found no module) \(Module id is (.+?)\): (.+)/);
if (!patchFailMatch) break; const patchSlowMatch = message.match(/Patch by (.+?) (took [\d.]+?ms) \(Module id is (.+?)\): (.+)/);
const match = patchFailMatch ?? patchSlowMatch;
if (!match) break;
logStderr(await getText()); logStderr(await getText());
process.exitCode = 1; process.exitCode = 1;
const [, plugin, type, id, regex] = patchFailMatch; const [, plugin, type, id, regex] = match;
report.badPatches.push({ const list = patchFailMatch ? report.badPatches : report.slowPatches;
list.push({
plugin, plugin,
type, type,
id, id,