AutoStart + compile fix

This commit is contained in:
Jean Ouina 2020-06-13 13:49:36 +02:00
parent 8009c6a2ed
commit de19c4815e
7 changed files with 94 additions and 7 deletions

View File

@ -51,9 +51,9 @@ async function main(){
console.info(`Minifying ${filepath} to ${newpath}`) console.info(`Minifying ${filepath} to ${newpath}`)
if(filepath.endsWith("git.js")){ if(filepath.endsWith("git.js")){
let commit = child_process.execSync("git rev-parse HEAD").toString() let commit = child_process.execSync("git rev-parse HEAD").toString().split("\n")[0].trim()
console.info(`Obtained commit ${commit} for the compilation`) console.info(`Obtained commit ${commit} for the build`)
await fs.promises.writeFile(newpath, terser.minify(fs.readFileSync(filepath, "utf8").replace(/"{commit}"/g, `"${commit.split("\n")[0]}"`)).code, "utf8") await fs.promises.writeFile(newpath, terser.minify(fs.readFileSync(filepath, "utf8").replace(/"{commit}"/g, `"${commit}"`)).code, "utf8")
}else{ }else{
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8") await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
} }
@ -70,6 +70,19 @@ async function main(){
}).then(() => { }).then(() => {
console.info(`Copied files and minified them from ${path.join(__dirname, "modules")}.`) console.info(`Copied files and minified them from ${path.join(__dirname, "modules")}.`)
}) })
await processNextDir(path.join(__dirname, "LightcordApi"), {
startDir: path.join(__dirname, "LightcordApi"),
newDir: path.join(__dirname, "distApp", "LightcordApi")
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
console.info(`Minifying ${filepath} to ${newpath}`)
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
}).then(() => {
console.info(`Copied files and minified them from ${path.join(__dirname, "LightcordApi")}.`)
})
await fs.promises.rmdirSync(path.join(__dirname, "distApp", "LightcordApi", "src"))
await fs.promises.unlink(path.join(__dirname, "distApp", "LightcordApi", "webpack.config.json"))
await fs.promises.unlink(path.join(__dirname, "distApp", "LightcordApi", "tsconfig.json"))
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "js"), {recursive: true}) fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "js"), {recursive: true})
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "css"), {recursive: true}) fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "css"), {recursive: true})

45
package-lock.json generated
View File

@ -36,6 +36,11 @@
"defer-to-connect": "^1.0.1" "defer-to-connect": "^1.0.1"
} }
}, },
"@types/auto-launch": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@types/auto-launch/-/auto-launch-5.0.1.tgz",
"integrity": "sha512-+KQ+/koZ7sJXnf5cnCANofY6yXAdYJNEoVZEuWcwJfuWbUp9u6l09I7KhwD+ivU+cdz7JId4V5ukxscWtHdSuw=="
},
"@types/events": { "@types/events": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
@ -104,6 +109,11 @@
"uri-js": "^4.2.2" "uri-js": "^4.2.2"
} }
}, },
"applescript": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/applescript/-/applescript-1.0.0.tgz",
"integrity": "sha1-u4evVoytA0pOSMS9r2Bno6JwExc="
},
"asn1": { "asn1": {
"version": "0.2.4", "version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
@ -122,6 +132,28 @@
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
}, },
"auto-launch": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/auto-launch/-/auto-launch-5.0.5.tgz",
"integrity": "sha512-ppdF4mihhYzMYLuCcx9H/c5TUOCev8uM7en53zWVQhyYAJrurd2bFZx3qQVeJKF2jrc7rsPRNN5cD+i23l6PdA==",
"requires": {
"applescript": "^1.0.0",
"mkdirp": "^0.5.1",
"path-is-absolute": "^1.0.0",
"untildify": "^3.0.2",
"winreg": "1.2.4"
},
"dependencies": {
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"requires": {
"minimist": "^1.2.5"
}
}
}
},
"aws-sign2": { "aws-sign2": {
"version": "0.7.0", "version": "0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
@ -767,8 +799,7 @@
"minimist": { "minimist": {
"version": "1.2.5", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"dev": true
}, },
"mkdirp": { "mkdirp": {
"version": "1.0.4", "version": "1.0.4",
@ -1162,6 +1193,11 @@
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true "dev": true
}, },
"untildify": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/untildify/-/untildify-3.0.3.tgz",
"integrity": "sha512-iSk/J8efr8uPT/Z4eSUywnqyrQU7DSdMfdqK4iWEaUVVmcP5JcnpRqmVMwcwcnmI1ATFNgC5V90u09tBynNFKA=="
},
"uri-js": { "uri-js": {
"version": "4.2.2", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
@ -1206,6 +1242,11 @@
"extsprintf": "^1.2.0" "extsprintf": "^1.2.0"
} }
}, },
"winreg": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz",
"integrity": "sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs="
},
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -14,6 +14,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"auto-launch": "^5.0.5",
"custom-electron-titlebar": "^3.2.2-hotfix62", "custom-electron-titlebar": "^3.2.2-hotfix62",
"glasstron": "0.0.3", "glasstron": "0.0.3",
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",
@ -30,6 +31,7 @@
"@types/rimraf": "^3.0.0", "@types/rimraf": "^3.0.0",
"@types/yauzl": "^2.9.1", "@types/yauzl": "^2.9.1",
"electron": "8.3.0", "electron": "8.3.0",
"@types/auto-launch": "^5.0.1",
"terser": "^4.7.0" "terser": "^4.7.0"
} }
} }

View File

@ -1,3 +1,29 @@
import autoLaunch from "auto-launch"
const autoStart = new autoLaunch({
name: "Lightcord"
})
export default {
install(callback){
autoStart.enable()
.then(callback, callback)
},
isInstalled(callback){
autoStart.isEnabled()
.then(callback)
},
uninstall(callback){
autoStart.disable()
.then(callback, callback)
},
update(callback){
autoStart.enable()
.then(callback, callback)
}
}
/*
let autoStart let autoStart
if(process.platform === "win32"){ if(process.platform === "win32"){
@ -8,4 +34,4 @@ if(process.platform === "win32"){
autoStart = require("./linux") autoStart = require("./linux")
} }
export default autoStart as typeof import("./win32") export default autoStart as typeof import("./win32")*/

View File

@ -50,12 +50,15 @@ function hasArgvFlag(flag) {
//Transform main thread into async //Transform main thread into async
(async function Main(){ (async function Main(){
await electron.app.whenReady() await electron.app.whenReady()
console.log(`Initializing Lightcord.`) console.log(`Initializing Lightcord.`)
console.log(`Version: ${buildInfo.version} console.log(`Version: ${buildInfo.version}
releaseChannel: ${buildInfo.releaseChannel} releaseChannel: ${buildInfo.releaseChannel}
commit: ${buildInfo.commit}`) commit: ${buildInfo.commit}`)
if(!electron.app.commandLine.hasSwitch('enable-transparent-visuals'))electron.app.commandLine.appendSwitch('enable-transparent-visuals'); if(!electron.app.commandLine.hasSwitch('enable-transparent-visuals'))electron.app.commandLine.appendSwitch('enable-transparent-visuals');
electron.app.setAppUserModelId(Constants.APP_ID); electron.app.setAppUserModelId(Constants.APP_ID);
let coreModule let coreModule
create(() => { create(() => {
const startMinimized = hasArgvFlag('--start-minimized'); const startMinimized = hasArgvFlag('--start-minimized');

View File

@ -7,6 +7,7 @@ const regExe = process.env.SystemRoot ? path.join(process.env.SystemRoot, 'Syste
// and the output from standard out. // and the output from standard out.
export function spawn(command: string, args: child_process.SpawnOptionsWithoutStdio, callback: (arg0: Error, arg1: string) => void) { export function spawn(command: string, args: child_process.SpawnOptionsWithoutStdio, callback: (arg0: Error, arg1: string) => void) {
let stdout = ''; let stdout = '';
console.log(`[\x1b[33mDEBUG\x1b[0m] Spawning "${command} with args`, args)
let spawnedProcess: child_process.ChildProcessWithoutNullStreams; let spawnedProcess: child_process.ChildProcessWithoutNullStreams;
try { try {

View File

@ -11,6 +11,7 @@
}, },
"exclude": [ "exclude": [
"./DiscordJS", "./DiscordJS",
"./LightcordApi" "./LightcordApi",
"./distApp"
] ]
} }