[Building] Ship changelog changes info in build (see changelog for further detail)

pull/36/head
Oj18 3 years ago
parent 86ed08f77b
commit 0864fdf9de

@ -4,6 +4,7 @@
- ### Features
- CSS Cache, GooseMod now caches Modules' CSS so most styling will appear as soon as GooseMod begins to inject. This works by detecting CSS which is currently injected and then caching it in local storage during client use, which is then loaded quickly at the start of GooseMod injection
- GooseMod changelog info is now included in builds instead of depending on online API
- ### Main Settings
- Made separate "Utilities" section

@ -1,6 +1,6 @@
#!/bin/sh
rm -rf ./dist
rm -rf dist
npx parcel build src/index.js
@ -11,5 +11,11 @@ echo $hash
sed -i "s/<hash>/$hash/g" dist/index.js
changelog="$(node building/generate.js)"
echo $changelog
sed -i "s/<changelog>/$changelog/g" dist/index.js
# Remove the auto-added map comment line as to not trigger the client trying to get the map
sed -i '$ d' dist/index.js

@ -0,0 +1,71 @@
import { readFileSync, writeFileSync } from 'fs';
const changelog = readFileSync('CHANGELOG.md', 'utf8');
const firstRelease = changelog.split(/^##/m)[1].trim();
const split = firstRelease.split('\n');
let versionHeader = split[0];
const headerSplit = versionHeader.split(' ');
const version = headerSplit[0];
const date = headerSplit[1].replace(/[\[\]]/g, '');
let body = split.slice(2).map((x) => x.trim().replace('- ', '')).filter((x) => x.length > 0);
body = body.map((x, i) => {
if (x.startsWith('###')) {
x = x.replace('### ', '');
let type;
switch (x.toLowerCase()) {
case 'fixes': {
type = 'fixed';
break;
}
case 'tweaks': {
type = 'progress';
break;
}
/*case 'features': {
type = 'added';
break;
}*/
default: {
type = 'added'; // 'progress';
break;
}
}
x = `${i !== 0 ? '\n' : ''}${x} {${type}${i === 0 ? ' marginTop' : ''}}\n======================\n`;
} else {
const split = x.split(/,/);
if (split.length === 1) {
x = `* **${x}.**`;
} else {
const main = split[0].trim();
let sub = split.slice(1).join(', ').trim();
sub = sub[0].toUpperCase() + sub.substring(1);
x = `* **${main}.** ${sub}.`;
}
}
return x;
});
const json = {
version,
date,
body: body.join('\n')
};
console.log(JSON.stringify(json).replaceAll(`\\"`, `\\\\\\"`).replaceAll(`"`, `\\\\\\"`).replaceAll(`\\n`, `\\\\\\\\n`));
// writeFileSync('../out/latestChangelogRelease.json', JSON.stringify(json));

@ -1,7 +1,6 @@
import sleep from '../util/sleep';
const image = 'https://media.discordapp.net/attachments/756146058924392542/771374562184658944/2018-11-14-11-36-30-1200x800.png';
let changelogURL;
let version, generated;
@ -9,7 +8,6 @@ let goosemodScope = {};
export const setThisScope = (scope) => {
goosemodScope = scope;
changelogURL = `${goosemodScope.moduleStoreAPI.apiBaseURL}/latestChangelogRelease.json?_=${Date.now()}`;
};
export const show = async () => {
@ -33,7 +31,7 @@ export const show = async () => {
};
export const generate = async () => {
const changelog = await (await fetch(changelogURL)).json();
const changelog = JSON.parse("<changelog>");
version = changelog.version;

Loading…
Cancel
Save