2023-06-23 10:52:03 +00:00
|
|
|
import platform from "platform";
|
2020-10-10 23:32:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a bug report template in Markdown.
|
|
|
|
* @param location The location this template will apply to.
|
|
|
|
* @param trxVersion The Tildes ReExtended version to include in the template.
|
|
|
|
*/
|
|
|
|
export function createReportTemplate(
|
2023-06-23 10:52:03 +00:00
|
|
|
location: "gitlab" | "tildes",
|
2022-02-23 13:52:06 +00:00
|
|
|
trxVersion: string,
|
2020-10-10 23:32:27 +00:00
|
|
|
): string {
|
2023-06-25 10:00:43 +00:00
|
|
|
let introText = "Thank you for taking the time to report a bug!";
|
|
|
|
introText += "\n Please make sure the information below is correct.";
|
2020-10-10 23:32:27 +00:00
|
|
|
|
2023-06-25 10:00:43 +00:00
|
|
|
if (location === "gitlab") {
|
|
|
|
introText += "\n Don't forget to set a title for the issue!";
|
2020-10-10 23:32:27 +00:00
|
|
|
}
|
|
|
|
|
2023-06-23 10:52:03 +00:00
|
|
|
const layout = platform.layout ?? "<unknown>";
|
|
|
|
const name = platform.name ?? "<unknown>";
|
|
|
|
const os = platform.os?.toString() ?? "<unknown>";
|
|
|
|
const version = platform.version ?? "<unknown>";
|
2020-10-10 23:32:27 +00:00
|
|
|
|
|
|
|
// Set the headers using HTML tags, these can't be with #-style Markdown
|
|
|
|
// headers as they'll be interpreted as an ID instead of Markdown content.
|
|
|
|
let reportTemplate = `<h2>Bug Report</h2>
|
|
|
|
<!--
|
|
|
|
${introText}
|
|
|
|
-->
|
|
|
|
<h3>Info</h3>\n
|
|
|
|
| Type | Value |
|
|
|
|
|------|-------|
|
|
|
|
| Extension Version | ${trxVersion} |
|
|
|
|
| Operating System | ${os} |
|
|
|
|
| Browser | ${name} ${version} (${layout}) |\n`;
|
|
|
|
|
|
|
|
// The platform manufacturer and product can be null in certain cases (such as
|
|
|
|
// desktops) so only when they're both not null include them.
|
|
|
|
if (platform.manufacturer !== null && platform.product !== null) {
|
|
|
|
const manufacturer: string = platform.manufacturer!;
|
|
|
|
const product: string = platform.product!;
|
|
|
|
reportTemplate += `| Device | ${manufacturer} ${product} |\n`;
|
|
|
|
}
|
|
|
|
|
2023-06-25 10:00:43 +00:00
|
|
|
reportTemplate += `\n
|
2020-10-10 23:32:27 +00:00
|
|
|
<!--
|
|
|
|
Please explain in sufficient detail what the problem is. When possible,
|
2023-06-25 10:00:43 +00:00
|
|
|
including an image or video showing the problem also helps immensely, but it's
|
|
|
|
not required.
|
2020-10-10 23:32:27 +00:00
|
|
|
-->\n\n\n`;
|
|
|
|
|
|
|
|
return reportTemplate;
|
|
|
|
}
|