mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-29 19:11:51 +00:00
Sets prettier to run on the repo (#91379)
## About The Pull Request Prettier (an auto formatter) is set to only run within the tgui folder currently. This removes that limitation, allowing it to automatically format all supported files in the repo (.js, .html, .yml [etc](https://prettier.io/docs/)) I made a few exceptions for bundled and generated files ## Why It's Good For The Game I'm of the opinion that code should look uniform and am lazy enough to want CTRL-S to format files without having to think beyond that ## Changelog
This commit is contained in:
@@ -4,80 +4,79 @@ const REGEX_CHANGELOG_LINE = /^(\w+): (.+)$/;
|
||||
|
||||
const CHANGELOG_KEYS_TO_ENTRY = {};
|
||||
for (const [types, entry] of changelogConfig.CHANGELOG_ENTRIES) {
|
||||
const entryWithChangelogKey = {
|
||||
...entry,
|
||||
changelogKey: types[0],
|
||||
};
|
||||
const entryWithChangelogKey = {
|
||||
...entry,
|
||||
changelogKey: types[0],
|
||||
};
|
||||
|
||||
for (const type of types) {
|
||||
CHANGELOG_KEYS_TO_ENTRY[type] = entryWithChangelogKey;
|
||||
}
|
||||
for (const type of types) {
|
||||
CHANGELOG_KEYS_TO_ENTRY[type] = entryWithChangelogKey;
|
||||
}
|
||||
}
|
||||
|
||||
function parseChangelogBody(lines, openTag) {
|
||||
const [changelogOpening] = lines.splice(0, 1);
|
||||
const [changelogOpening] = lines.splice(0, 1);
|
||||
|
||||
const author =
|
||||
changelogOpening.substring(openTag.length).trim() || undefined;
|
||||
const author = changelogOpening.substring(openTag.length).trim() || undefined;
|
||||
|
||||
const changelog = {
|
||||
author,
|
||||
changes: [],
|
||||
};
|
||||
const changelog = {
|
||||
author,
|
||||
changes: [],
|
||||
};
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.trim().length === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const line of lines) {
|
||||
if (line.trim().length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const closeTag of changelogConfig.CHANGELOG_CLOSE_TAGS) {
|
||||
if (line.startsWith(closeTag)) {
|
||||
return changelog;
|
||||
}
|
||||
}
|
||||
for (const closeTag of changelogConfig.CHANGELOG_CLOSE_TAGS) {
|
||||
if (line.startsWith(closeTag)) {
|
||||
return changelog;
|
||||
}
|
||||
}
|
||||
|
||||
const match = line.match(REGEX_CHANGELOG_LINE);
|
||||
if (match) {
|
||||
const [_, type, description] = match;
|
||||
const match = line.match(REGEX_CHANGELOG_LINE);
|
||||
if (match) {
|
||||
const [_, type, description] = match;
|
||||
|
||||
const entry = CHANGELOG_KEYS_TO_ENTRY[type];
|
||||
const entry = CHANGELOG_KEYS_TO_ENTRY[type];
|
||||
|
||||
if (!entry || entry.placeholders.includes(description)) {
|
||||
continue;
|
||||
}
|
||||
if (!entry || entry.placeholders.includes(description)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry) {
|
||||
changelog.changes.push({
|
||||
type: entry,
|
||||
description,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const lastChange = changelog.changes[changelog.changes.length - 1];
|
||||
if (lastChange) {
|
||||
lastChange.description += `\n${line}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entry) {
|
||||
changelog.changes.push({
|
||||
type: entry,
|
||||
description,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const lastChange = changelog.changes[changelog.changes.length - 1];
|
||||
if (lastChange) {
|
||||
lastChange.description += `\n${line}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changelog;
|
||||
return changelog;
|
||||
}
|
||||
|
||||
export function parseChangelog(text) {
|
||||
if(text == null) {
|
||||
return undefined;
|
||||
}
|
||||
const lines = text.split("\n").map((line) => line.trim());
|
||||
if (text == null) {
|
||||
return undefined;
|
||||
}
|
||||
const lines = text.split("\n").map((line) => line.trim());
|
||||
|
||||
for (let index = 0; index < lines.length; index++) {
|
||||
const line = lines[index];
|
||||
for (let index = 0; index < lines.length; index++) {
|
||||
const line = lines[index];
|
||||
|
||||
for (const openTag of changelogConfig.CHANGELOG_OPEN_TAGS) {
|
||||
if (line.startsWith(openTag)) {
|
||||
return parseChangelogBody(lines.slice(index), openTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const openTag of changelogConfig.CHANGELOG_OPEN_TAGS) {
|
||||
if (line.startsWith(openTag)) {
|
||||
return parseChangelogBody(lines.slice(index), openTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user