Fix various bugs and toolchain
- Fix an issue where dist might not have the proper package.json - Fix an issue with PublicServers adding button to guild list - Fix the placement of BD in settings - Change default modal button to `primary` - Change restart prompts to have `danger` prop - Change tooltips to use `primary` rather than `black` - Remove VoiceMode - Remove DarkMode - Give a hover effect to the public servers button - Fix expanding icon in emote menu - Fix over-bolded text in setting descriptions
This commit is contained in:
+13
-8
@@ -2,11 +2,13 @@ const args = process.argv;
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const doSanityChecks = require("./validate");
|
||||
const buildPackage = require("./package");
|
||||
|
||||
const useBdRelease = args[2] && args[2].toLowerCase() === "release";
|
||||
const releaseInput = useBdRelease ? args[3] && args[3].toLowerCase() : args[2] && args[2].toLowerCase();
|
||||
const release = releaseInput === "canary" ? "Discord Canary" : releaseInput === "ptb" ? "Discord PTB" : "Discord";
|
||||
console.log(`Injecting into version ${release}`);
|
||||
|
||||
const bdPath = useBdRelease ? path.resolve(__dirname, "..", "dist", "betterdiscord.asar") : path.resolve(__dirname, "..", "dist");
|
||||
const discordPath = (function() {
|
||||
if (process.platform === "win32") {
|
||||
const basedir = path.join(process.env.LOCALAPPDATA, release.replace(/ /g, ""));
|
||||
@@ -27,8 +29,13 @@ const discordPath = (function() {
|
||||
}
|
||||
})();
|
||||
|
||||
doSanityChecks(bdPath);
|
||||
buildPackage(bdPath);
|
||||
console.log("");
|
||||
|
||||
console.log(`Injecting into ${release}`);
|
||||
if (!fs.existsSync(discordPath)) throw new Error(`Cannot find directory for ${release}`);
|
||||
console.log(`Found ${release} in ${discordPath}`);
|
||||
console.log(` ✅ Found ${release} in ${discordPath}`);
|
||||
|
||||
const appPath = path.join(discordPath, "app");
|
||||
const packageJson = path.join(appPath, "package.json");
|
||||
@@ -38,15 +45,13 @@ if (!fs.existsSync(appPath)) fs.mkdirSync(appPath);
|
||||
if (fs.existsSync(packageJson)) fs.unlinkSync(packageJson);
|
||||
if (fs.existsSync(indexJs)) fs.unlinkSync(indexJs);
|
||||
|
||||
const bdPath = useBdRelease ? path.resolve(__dirname, "..", "dist", "betterdiscord.asar") : path.resolve(__dirname, "..", "dist");
|
||||
|
||||
console.log(`Writing package.json`);
|
||||
fs.writeFileSync(packageJson, JSON.stringify({
|
||||
name: "betterdiscord",
|
||||
main: "index.js",
|
||||
}, null, 4));
|
||||
console.log(" ✅ Wrote package.json");
|
||||
|
||||
console.log(`Writing index.js`);
|
||||
fs.writeFileSync(indexJs, `require("${bdPath.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}");`);
|
||||
|
||||
console.log(" ✅ Wrote index.js");
|
||||
console.log("");
|
||||
console.log(`Injection successful, please restart ${release}.`);
|
||||
|
||||
+7
-37
@@ -2,45 +2,22 @@ const fs = require("fs");
|
||||
const path = require("path");
|
||||
const asar = require("asar");
|
||||
|
||||
const doSanityChecks = require("./validate");
|
||||
const buildPackage = require("./package");
|
||||
|
||||
const dist = path.join(__dirname, "..", "dist");
|
||||
const bundleFile = path.join(dist, "betterdiscord.asar");
|
||||
|
||||
const doSanityChecks = function() {
|
||||
console.log("Ensuring build validity");
|
||||
const files = [
|
||||
path.join(dist, "injector.js"),
|
||||
path.join(dist, "preload.js"),
|
||||
path.join(dist, "renderer.js")
|
||||
];
|
||||
|
||||
for (const file of files) {
|
||||
const exists = fs.existsSync(file);
|
||||
if (!exists) throw new Error(` ❌ File missing: ${file}`);
|
||||
console.log(` ✅ Found ${file}`);
|
||||
}
|
||||
};
|
||||
|
||||
const cleanOldAsar = function() {
|
||||
console.log("");
|
||||
console.log("Ensuring clean build");
|
||||
if (!fs.existsSync(bundleFile)) return console.log(" ✅ Nothing to clean up");
|
||||
fs.unlinkSync(bundleFile);
|
||||
console.log(` ✅ Removed old bundle ${bundleFile}`);
|
||||
};
|
||||
|
||||
const buildPackage = function() {
|
||||
console.log("Ensuring valid package.json");
|
||||
|
||||
const pkgFile = path.join(dist, "package.json");
|
||||
if (fs.existsSync(pkgFile)) {
|
||||
const currentPkg = require(pkgFile);
|
||||
if (currentPkg.name && currentPkg.main && currentPkg.main === "injector.js") return console.log(" ✅ Existing package.json is valid");
|
||||
console.log(" ⚠️ Existing package.json is invalid");
|
||||
}
|
||||
fs.writeFileSync(pkgFile, JSON.stringify({name: "betterdiscord", main: "injector.js"}));
|
||||
console.log(" ✅ Created new package.json");
|
||||
};
|
||||
|
||||
const makeBundle = function() {
|
||||
console.log("");
|
||||
console.log("Generating bundle");
|
||||
asar.createPackage(dist, bundleFile).then(() => {
|
||||
console.log(` ✅ Successfully created bundle ${bundleFile}`);
|
||||
@@ -49,14 +26,7 @@ const makeBundle = function() {
|
||||
});
|
||||
};
|
||||
|
||||
console.log("");
|
||||
doSanityChecks();
|
||||
|
||||
console.log("");
|
||||
doSanityChecks(dist);
|
||||
buildPackage(dist);
|
||||
cleanOldAsar();
|
||||
|
||||
console.log("");
|
||||
buildPackage();
|
||||
|
||||
console.log("");
|
||||
makeBundle();
|
||||
@@ -0,0 +1,16 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
module.exports = function(dist) {
|
||||
console.log("");
|
||||
console.log("Ensuring valid package.json");
|
||||
|
||||
const pkgFile = path.join(dist, "package.json");
|
||||
if (fs.existsSync(pkgFile)) {
|
||||
const currentPkg = require(pkgFile);
|
||||
if (currentPkg.name && currentPkg.main && currentPkg.main === "injector.js") return console.log(" ✅ Existing package.json is valid");
|
||||
console.log(" ⚠️ Existing package.json is invalid");
|
||||
}
|
||||
fs.writeFileSync(pkgFile, JSON.stringify({name: "betterdiscord", main: "injector.js"}));
|
||||
console.log(" ✅ Created new package.json");
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
module.exports = function(dist) {
|
||||
console.log("");
|
||||
console.log("Ensuring build validity");
|
||||
const files = [
|
||||
path.join(dist, "injector.js"),
|
||||
path.join(dist, "preload.js"),
|
||||
path.join(dist, "renderer.js")
|
||||
];
|
||||
|
||||
for (const file of files) {
|
||||
const exists = fs.existsSync(file);
|
||||
if (!exists) throw new Error(` ❌ File missing: ${file}`);
|
||||
console.log(` ✅ Found ${file}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user