Merge pull request #34 from hormelcookies/new-build-process
New build process
This commit is contained in:
commit
b7dde7b725
|
@ -117,4 +117,7 @@ discord-last-webrtc_0
|
|||
discord-webrtc_0
|
||||
|
||||
# macOS Stuff
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
|
||||
# VS Code stuff
|
||||
.vscode
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -13,6 +13,7 @@
|
|||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
||||
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-convert": "^1.9.0"
|
||||
}
|
||||
|
@ -20,12 +21,14 @@
|
|||
"big.js": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ=="
|
||||
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==",
|
||||
"dev": true
|
||||
},
|
||||
"braces": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fill-range": "^7.0.1"
|
||||
}
|
||||
|
@ -34,6 +37,7 @@
|
|||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
||||
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^3.2.1",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
|
@ -44,6 +48,7 @@
|
|||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "1.1.3"
|
||||
}
|
||||
|
@ -51,22 +56,26 @@
|
|||
"color-name": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
|
||||
"dev": true
|
||||
},
|
||||
"emojis-list": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz",
|
||||
"integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q=="
|
||||
"integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==",
|
||||
"dev": true
|
||||
},
|
||||
"enhanced-resolve": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.2.0.tgz",
|
||||
"integrity": "sha512-S7eiFb/erugyd1rLb6mQ3Vuq+EXHv5cpCkNqqIkYkBgN2QdFnyCZzFBleqwGEx4lgNGYij81BWnCrFNK7vxvjQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"memory-fs": "^0.5.0",
|
||||
|
@ -77,6 +86,7 @@
|
|||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
|
||||
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"prr": "~1.0.1"
|
||||
}
|
||||
|
@ -84,12 +94,14 @@
|
|||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
||||
"dev": true
|
||||
},
|
||||
"fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
}
|
||||
|
@ -97,32 +109,38 @@
|
|||
"graceful-fs": {
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
|
||||
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
|
||||
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==",
|
||||
"dev": true
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
|
||||
"dev": true
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"dev": true
|
||||
},
|
||||
"is-number": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||
"dev": true
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
|
||||
"dev": true
|
||||
},
|
||||
"json5": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
|
||||
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "^1.2.0"
|
||||
}
|
||||
|
@ -131,6 +149,7 @@
|
|||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz",
|
||||
"integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"big.js": "^5.2.2",
|
||||
"emojis-list": "^3.0.0",
|
||||
|
@ -141,6 +160,7 @@
|
|||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz",
|
||||
"integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"errno": "^0.1.3",
|
||||
"readable-stream": "^2.0.1"
|
||||
|
@ -150,6 +170,7 @@
|
|||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz",
|
||||
"integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"braces": "^3.0.1",
|
||||
"picomatch": "^2.0.5"
|
||||
|
@ -158,27 +179,32 @@
|
|||
"minimist": {
|
||||
"version": "1.2.5",
|
||||
"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
|
||||
},
|
||||
"picomatch": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
|
||||
"integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg=="
|
||||
"integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
|
||||
"dev": true
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
|
||||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
|
||||
"dev": true
|
||||
},
|
||||
"prr": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
|
||||
"integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY="
|
||||
"integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=",
|
||||
"dev": true
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.7",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
|
||||
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
|
@ -192,17 +218,20 @@
|
|||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"dev": true
|
||||
},
|
||||
"semver": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||
"dev": true
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
|
@ -211,6 +240,7 @@
|
|||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^3.0.0"
|
||||
}
|
||||
|
@ -218,12 +248,14 @@
|
|||
"tapable": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz",
|
||||
"integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA=="
|
||||
"integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==",
|
||||
"dev": true
|
||||
},
|
||||
"to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-number": "^7.0.0"
|
||||
}
|
||||
|
@ -232,6 +264,7 @@
|
|||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-7.0.5.tgz",
|
||||
"integrity": "sha512-zXypEIT6k3oTc+OZNx/cqElrsbBtYqDknf48OZos0NQ3RTt045fBIU8RRSu+suObBzYB355aIPGOe/3kj9h7Ig==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.3.0",
|
||||
"enhanced-resolve": "^4.0.0",
|
||||
|
@ -249,7 +282,8 @@
|
|||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,64 +0,0 @@
|
|||
const fs = require("fs")
|
||||
const fsAsync = fs.promises
|
||||
const yazl = require("yazl")
|
||||
const __path = require("path")
|
||||
|
||||
const buildsPaths = __path.join(__dirname, "builds")
|
||||
const folders = [
|
||||
"lightcord-win32-ia32",
|
||||
"lightcord-linux-x64",
|
||||
"lightcord-darwin-x64"
|
||||
]
|
||||
folders.forEach(folder => {
|
||||
const path = __path.join(buildsPaths, folder)
|
||||
if(!fs.existsSync(path))return console.warn(`\x1b[33mCan't pack build ${folder} because it doesn't exist.\x1b[0m`)
|
||||
const zipPath = __path.join(buildsPaths, folder+".zip")
|
||||
if(fs.existsSync(zipPath)){
|
||||
console.warn(`Deleting ${zipPath}.`)
|
||||
fs.unlinkSync(zipPath)
|
||||
}
|
||||
const zip = new yazl.ZipFile()
|
||||
zip.outputStream.pipe(fs.createWriteStream(zipPath))
|
||||
|
||||
const platform = folder.split("-")[1]
|
||||
processNextDir(path, zip, platform)
|
||||
.then(() => {
|
||||
console.log(`Zipped ${platform}.`)
|
||||
zip.end()
|
||||
})
|
||||
})
|
||||
|
||||
async function processNextDir(dir, zip, platform, bpath = dir){
|
||||
if(dir.replace(bpath, ""))zip.addEmptyDirectory(dir.replace(bpath, "").slice(1))
|
||||
await Promise.all(fs.readdirSync(dir, {withFileTypes: true})
|
||||
.map(async file => {
|
||||
let path = __path.join(dir, file.name)
|
||||
if(file.isDirectory()){
|
||||
return await processNextDir(path, zip, platform, bpath)
|
||||
}else if(file.isFile()){
|
||||
if(!path.includes("node_modules")){
|
||||
if(platform === "win32"){
|
||||
if(file.name.endsWith("_linux.node"))return
|
||||
if(file.name.endsWith("_darwin.node"))return
|
||||
if(file.name.endsWith(".dylib"))return
|
||||
if(file.name.endsWith(".so.4"))return
|
||||
}else if(platform === "linux"){
|
||||
if(file.name.endsWith("_win32.node"))return
|
||||
if(file.name.endsWith("_darwin.node"))return
|
||||
if(file.name.endsWith(".dylib"))return
|
||||
if(file.name.endsWith(".dll"))return
|
||||
}else if(platform === "darwin"){
|
||||
if(file.name.endsWith("_linux.node"))return
|
||||
if(file.name.endsWith("_win32.node"))return
|
||||
if(file.name.endsWith(".dll"))return
|
||||
if(file.name.endsWith(".so.4"))return
|
||||
}
|
||||
}
|
||||
let stat = fs.statSync(path)
|
||||
zip.addBuffer(await fsAsync.readFile(path), __path.relative(bpath, path), {
|
||||
mode: stat.mode,
|
||||
mtime: stat.mtime
|
||||
})
|
||||
}
|
||||
}))
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
'use strict';
|
||||
/*
|
||||
This is a hack to get around the issues with electron-builder not including nested node_modules.
|
||||
We do this by simply making the asar ourselves using the parameters from the build.
|
||||
This takes the asar file that we have created, unpacks it, then copies in the nested node_modules
|
||||
directories from the app directory.
|
||||
|
||||
This also preserves any asar unpacked files that you may have had in the build, and unpacks any
|
||||
nested node_modules files that might have been unpacked as well.
|
||||
|
||||
This also assumes that you have some sort of beforeBuild hook that already trims and massages the
|
||||
nested node_modules files to be what you want; if not, you may have some bloat (and some potential
|
||||
breakage)
|
||||
*/
|
||||
|
||||
// Make sure you have these in your devDependencies in your root project.
|
||||
const glob = require('fast-glob');
|
||||
const fs = require('fs-extra');
|
||||
const { promisify } = require('util')
|
||||
const rimraf = promisify(require('rimraf'))
|
||||
const asar = require('asar');
|
||||
const micromatch = require("micromatch")
|
||||
const { join } = require("path")
|
||||
|
||||
const commonExclude = [
|
||||
"!**/{test,__tests__,tests,powered-test,example,examples,CHANGELOG.md,README.md,README,readme.md,readme}",
|
||||
"!**/*.d.ts",
|
||||
"!**/.bin",
|
||||
"!**/*.{iml,o,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,xproj}",
|
||||
"!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,.gitignore,.gitattributes}",
|
||||
"!**/{__pycache__,thumbs.db,.flowconfig,.idea,.vs,.nyc_output}",
|
||||
"!**/{appveyor.yml,.travis.yml,circle.yml}",
|
||||
"!**/{npm-debug.log,yarn.lock,.yarn-integrity,.yarn-metadata.json}"
|
||||
]
|
||||
|
||||
function concatUnique(a,b) {
|
||||
if (!Array.isArray(a) || !Array.isArray(b)){
|
||||
throw Error("both parameters must be arrays")
|
||||
}
|
||||
let arr = a.concat(b)
|
||||
let seen = {};
|
||||
return arr.filter(function(item) {
|
||||
return seen.hasOwnProperty(item) ? false : (seen[item] = true);
|
||||
});
|
||||
}
|
||||
|
||||
// we're using the platform-specific parameters over the global parameters.
|
||||
function globalOrPlatformParam(local,global){
|
||||
if (typeof local != 'undefined' && local.length != 0){
|
||||
return local;
|
||||
} else if (typeof global != 'undefined' && global.length != 0){
|
||||
return global;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function globalOrPlatformArrayParam(local, global){
|
||||
let param = globalOrPlatformParam(local, global) || []
|
||||
if (typeof param == "string"){
|
||||
param = [param]
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
exports.default = async function afterPackHook(context){
|
||||
// Get build parameters from the context.
|
||||
const appDir = context.packager.info._appDir
|
||||
const platform = context.packager.platform.nodeName
|
||||
const globalFilesParam = context.packager.info._configuration.files;
|
||||
const platformFilesParam = context.packager.platformSpecificBuildOptions.files
|
||||
const globalUnpackAsarParam = context.packager.info._configuration.asarUnpack;
|
||||
const platformUnpackAsarParam = context.packager.platformSpecificBuildOptions.asarUnpack;
|
||||
|
||||
let resourcesDir = join(context.appOutDir, "resources")
|
||||
// exception for resources dir for mac; win and linux use the same directory.
|
||||
if (platform == "darwin"){
|
||||
resourcesDir = join(context.appOutDir, context.packager.appInfo.productFilename + ".app", "Contents", "Resources")
|
||||
}
|
||||
|
||||
const asarAppUnpackedDir = join(resourcesDir, "app.asar.unpacked")
|
||||
|
||||
// The Platform-specific build options override the common config, so attempt to use those first.
|
||||
let globPatterns = globalOrPlatformArrayParam(platformFilesParam, globalFilesParam)
|
||||
|
||||
// electron-builder automatically adds this to the files parameter, so we have to too
|
||||
if (!globPatterns.includes("**/*")){
|
||||
globPatterns.push("**/*")
|
||||
}
|
||||
|
||||
// Add the common exclusions to the patterns
|
||||
globPatterns = concatUnique(globPatterns,commonExclude);
|
||||
|
||||
// Find all the nested node_modules files in the app directory
|
||||
let nestedNMFiles = glob.sync("+(**/node_modules/**/*|!node_modules/**/*)", {cwd: appDir, dot:true})
|
||||
|
||||
// filter out the ones not matched by the file globs in the builder config
|
||||
let filteredNestedFiles = micromatch(nestedNMFiles, globPatterns, {matchBase:true})
|
||||
|
||||
// This is the directory we're copying everything to, to create the asar
|
||||
let asarAppDir = join(resourcesDir, "app")
|
||||
|
||||
// Get a listing of all the files in the app.asar.unpacked dir, so we can create a franken-glob
|
||||
// to pass to asar when packing.
|
||||
let unpackedFileList = glob.sync("**/*", {cwd:asarAppUnpackedDir, dot:true})
|
||||
let unpackPattern = "{"
|
||||
unpackedFileList.forEach((file,idx,arr)=>{
|
||||
unpackPattern += join(asarAppDir, file) + ','
|
||||
})
|
||||
|
||||
// Get any user-defined asarUnpack patterns in case we need to unpack some hoisted node_modules,
|
||||
// and add any to the pattern.
|
||||
let userUnpackGlob = globalOrPlatformArrayParam(platformUnpackAsarParam, globalUnpackAsarParam)
|
||||
let nestedFilesToUnpack = micromatch(nestedNMFiles, userUnpackGlob, {matchBase:true})
|
||||
nestedFilesToUnpack.forEach((file)=>{
|
||||
unpackPattern += join(asarAppDir, file) + ','
|
||||
})
|
||||
// trailing commas don't matter in this pattern.
|
||||
unpackPattern += '}'
|
||||
|
||||
// Combine the nested files to unpack with the filtered nested files, as electron-builder
|
||||
// sometimes does weird things when file globs and the asarUnpack globs are used together;
|
||||
// Files that don't match the file globs but do match the asarUnpack glob are included in the build.
|
||||
let nestedFilesToCopy = concatUnique(filteredNestedFiles, nestedFilesToUnpack);
|
||||
|
||||
// Now we have the necessary file lists, create the asar.
|
||||
|
||||
// Unpack everything in app.asar to the resources/app dir.
|
||||
// This also copies all the files in 'app.asar.unpacked' to here as well.
|
||||
asar.extractAll(join(resourcesDir, "app.asar"), asarAppDir)
|
||||
await rimraf(join(resourcesDir, "app.asar"))
|
||||
await rimraf(asarAppUnpackedDir)
|
||||
|
||||
// Copy the nested node_modules files to the extracted directory.
|
||||
nestedFilesToCopy.forEach((file)=>{
|
||||
fs.copySync(join(appDir, file), join(asarAppDir, file))
|
||||
})
|
||||
// build the asar
|
||||
await asar.createPackageWithOptions(asarAppDir, join(resourcesDir, "app.asar"), {unpack: unpackPattern})
|
||||
await rimraf(asarAppDir)
|
||||
|
||||
return true
|
||||
};
|
7
build.js
7
build.js
|
@ -8,6 +8,11 @@ const includeSourcesMaps = true
|
|||
|
||||
let fs = require("fs")
|
||||
|
||||
exports.default = async function beforeBuild(context){
|
||||
await main()
|
||||
return true
|
||||
}
|
||||
|
||||
console.log = (...args) => {
|
||||
process.stdout.write(Buffer.from(util.formatWithOptions({colors: true}, ...args)+"\n", "binary").toString("utf8"))
|
||||
}
|
||||
|
@ -256,7 +261,7 @@ async function main(){
|
|||
let packageJSON = require("./package.json")
|
||||
packageJSON.scripts["build:electron_linux"] = packageJSON.scripts["build:electron_linux"].replace("./distApp", ".")
|
||||
packageJSON.scripts["build:electron_win"] = packageJSON.scripts["build:electron_win"].replace("./distApp", ".")
|
||||
packageJSON.scripts["build:electron_darwin"] = packageJSON.scripts["build:electron_darwin"].replace("./distApp", ".")
|
||||
packageJSON.scripts["build:electron_mac"] = packageJSON.scripts["build:electron_mac"].replace("./distApp", ".")
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, "distApp", "package.json"), JSON.stringify(packageJSON), "utf8")
|
||||
|
||||
|
|
18
compile.js
18
compile.js
|
@ -14,17 +14,29 @@ spawnSync("npm run build", join(__dirname, "LightcordApi"))
|
|||
spawnSync("npm run build-prod", join(__dirname, "LightcordApi"))
|
||||
spawnSync("tsc", join(__dirname, "LightcordApi"))
|
||||
|
||||
var exitedWithErrorProcessList = [];
|
||||
|
||||
function spawnSync(args, cwd){
|
||||
args = args.split(" ")
|
||||
function spawnSync(cmdString, cwd){
|
||||
let args = cmdString.split(" ")
|
||||
let command = args.shift()
|
||||
return spawn(command, args, {
|
||||
cwd: cwd || process.cwd(),
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
})
|
||||
}).on("error", (err) => {
|
||||
const DIRSTRING = cwd != undefined ? cwd : process.env.PWD
|
||||
console.log("Error while running " + cmdString + " in target directory " + DIRSTRING)
|
||||
console.error(err)
|
||||
exitedWithErrorProcessList.push({cmd: cmdString, cwd: DIRSTRING})
|
||||
})
|
||||
}
|
||||
|
||||
process.on("beforeExit", () => {
|
||||
if (exitedWithErrorProcessList.length != 0){
|
||||
console.error("Commands exited with errors:\n")
|
||||
exitedWithErrorProcessList.forEach((val)=>{
|
||||
console.error("\tcommand:\t\t" + val.cmd + "\n\ttarget directory:\t" + val.cwd + "\n")
|
||||
});
|
||||
}
|
||||
console.log(`Exiting compilation`)
|
||||
})
|
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
appId: com.lightcord.app
|
||||
productName: Lightcord
|
||||
directories:
|
||||
app: distApp
|
||||
output: builds
|
||||
# This is to get around the bug in electron-builder with not including nested node_modules.
|
||||
afterPack: "afterpack.js"
|
||||
win:
|
||||
target:
|
||||
- target: zip
|
||||
arch:
|
||||
- ia32
|
||||
- target: portable
|
||||
arch:
|
||||
- ia32
|
||||
icon: app.ico
|
||||
publisherName: Lightcord
|
||||
files:
|
||||
- "**/*"
|
||||
- "!**/*.ts"
|
||||
- "!**/*.so"
|
||||
- "!**/*.4"
|
||||
- "!**/*.dylib"
|
||||
- "!**/*_darwin.node"
|
||||
- "!**/*_linux.node"
|
||||
asarUnpack:
|
||||
- "**/*.node"
|
||||
- "**/*.dll"
|
||||
linux:
|
||||
target:
|
||||
- target: zip
|
||||
arch:
|
||||
- x64
|
||||
- target: AppImage
|
||||
arch:
|
||||
- x64
|
||||
icon: discord.png
|
||||
files:
|
||||
- "**/*"
|
||||
- "!**/*.ts"
|
||||
- "!**/*.dll"
|
||||
- "!**/*.dylib"
|
||||
- "!**/discord*.node"
|
||||
- "**/*_linux.node"
|
||||
asarUnpack:
|
||||
- "**/*_linux.node"
|
||||
- "**/*.so.4"
|
||||
mac:
|
||||
target:
|
||||
- target: zip
|
||||
arch:
|
||||
- x64
|
||||
icon: app_icon_darwin.icns
|
||||
files:
|
||||
- "**/*"
|
||||
- "!**/*.ts"
|
||||
- "!**/*.dll"
|
||||
- "!**/*.so"
|
||||
- "!**/*.4"
|
||||
- "!**/discord*.node"
|
||||
- "**/*_darwin.node"
|
||||
asarUnpack:
|
||||
- "**/*_darwin.node"
|
||||
- "**/*.dylib"
|
||||
|
|
@ -4,6 +4,20 @@ const path = require("path")
|
|||
|
||||
const MODULES_DIRNAME = path.join(__dirname, "modules")
|
||||
|
||||
var exitedWithErrorProcessList = [];
|
||||
|
||||
function spawnNpmInstallProcess (targetDir) {
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: targetDir,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.log("Error while running 'npm i' in target directory " + targetDir)
|
||||
console.error(err)
|
||||
exitedWithErrorProcessList.push(targetDir)
|
||||
})
|
||||
}
|
||||
|
||||
fs.readdirSync(MODULES_DIRNAME, {withFileTypes: true})
|
||||
.forEach(e => {
|
||||
if(!e.isDirectory())return
|
||||
|
@ -12,43 +26,26 @@ fs.readdirSync(MODULES_DIRNAME, {withFileTypes: true})
|
|||
if(e.name === "discord_spellcheck")return
|
||||
|
||||
console.log(`Installing modules in ${e.name}.`)
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: MODULE_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
spawnNpmInstallProcess(MODULE_DIRNAME)
|
||||
})
|
||||
|
||||
|
||||
const MODULE_DIRNAME = path.join(__dirname, "modules", "discord_desktop_core", "core")
|
||||
const BETTERDISCORD_DIRNAME = path.join(__dirname, "BetterDiscordApp")
|
||||
const DISCORDJS_DIRNAME = path.join(__dirname, "DiscordJS")
|
||||
const LIGHTCORDAPI_DIRNAME = path.join(__dirname, "LightcordApi")
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: MODULE_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
spawnNpmInstallProcess(MODULE_DIRNAME)
|
||||
spawnNpmInstallProcess(BETTERDISCORD_DIRNAME)
|
||||
spawnNpmInstallProcess(LIGHTCORDAPI_DIRNAME)
|
||||
spawnNpmInstallProcess(DISCORDJS_DIRNAME)
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: BETTERDISCORD_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: DISCORDJS_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
process.on("beforeExit", () => {
|
||||
if (exitedWithErrorProcessList.length != 0){
|
||||
console.error("Failed to run 'npm install' on:\n")
|
||||
exitedWithErrorProcessList.forEach((val)=>{
|
||||
console.error(val)
|
||||
});
|
||||
}
|
||||
console.error();
|
||||
})
|
|
@ -373,13 +373,20 @@ function launchMainAppWindow(isVisible) {
|
|||
|
||||
if(!settings.get("NO_WINDOWS_BOUND", false))applyWindowBoundsToConfig(mainWindowOptions);
|
||||
|
||||
mainWindow = new electron.BrowserWindow(mainWindowOptions);
|
||||
mainWindow = new glasstron.BrowserWindow(mainWindowOptions);
|
||||
mainWindowId = mainWindow.id;
|
||||
global.mainWindowId = mainWindowId;
|
||||
if(settings.get("GLASSTRON", true)){
|
||||
let blurType = mainWindow.blurType
|
||||
mainWindow.blurType = settings.get("GLASSTRON_BLUR", "blurbehind")
|
||||
mainWindow.setVibrancy("fullscreen-ui")
|
||||
mainWindow.setBlur(true)
|
||||
try {
|
||||
mainWindow.setBlur(true)
|
||||
} catch (e){
|
||||
console.error(e)
|
||||
console.error("Could not setBlur(), transparency effects will not work.")
|
||||
mainWindow.blurType = blurType
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow.webContents.session.webRequest.onHeadersReceived(function(details, callback) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
|
@ -7,18 +7,17 @@
|
|||
"compile": "node compile.js",
|
||||
"test": "npm run compile && electron .",
|
||||
"run": "electron .",
|
||||
"start": "electron .",
|
||||
"build": "npm run build:minify && npm run build:electron && npm run build:after",
|
||||
"build": "npm run build:minify && npm run build:electron",
|
||||
"build:electron": "node build_electron.js",
|
||||
"build:electron_win": "electron-packager ./distApp --ignore=\"(distApp|builds|\\.ts|\\.so\\.4|\\.dylib)\" --arch=ia32 --win32metadata.ProductName=\"Lightcord\" --win32metadata.CompanyName=\"Lightcord\" --protocol=discord --platform=\"win32\" --out=builds --icon=app.ico --executable-name=\"Lightcord\" --asar.unpack='*.{node,dll}' --overwrite",
|
||||
"build:electron_linux": "electron-packager ./distApp --ignore=\"(distApp|builds|\\.ts|\\.dll|\\.dylib)\" --arch=x64 --protocol=discord --platform=\"linux\" --out=builds --icon=app.ico --executable-name=\"Lightcord\" --asar.unpack='*.{node,so.4}' --overwrite",
|
||||
"build:electron_darwin": "electron-packager ./distApp --ignore\"(distApp|builds|\\.ts\\.so\\.4\\.dll)\" --arch=x64 --protocol=discord --platform=\"darwin\" --out=builds --icon=app_icon_darwin.icns --executable-name=\"Lightcord\" --asar.unpack='*.{node,dylib}' --overwrite",
|
||||
"build:electron_win": "electron-builder build --config electron-builder.yaml --win",
|
||||
"build:electron_linux": "electron-builder build --config electron-builder.yaml --linux",
|
||||
"build:electron_mac": "electron-builder build --config electron-builder.yaml --mac",
|
||||
"start": "electron .",
|
||||
"build:minify": "node build.js",
|
||||
"build:after": "node afterbuild.js",
|
||||
"clean": "node scripts/clean.js",
|
||||
"clean:all": "node scripts/clean.js --all",
|
||||
"devInstall": "npm i --save-dev --arch=ia32 electron@8.5.0 && node installSubModules.js && echo \"Everything is installed. You should be able to do `npm run test` to compile everything and launch.\"",
|
||||
"devInstall:64": "npm i --save-dev --arch=x64 electron@8.5.0 && node installSubModules.js && echo \"Everything is installed. You should be able to do `npm run test` to compile everything and launch.\"",
|
||||
"devInstall": "npm i --save-dev --arch=ia32 electron@8.5.0 && node installSubModules.js && echo \"Everything is installed. You should be able to do npm run test to compile everything and launch.\"",
|
||||
"devInstall:64": "npm i --save-dev --arch=x64 electron@8.5.0 && node installSubModules.js && echo \"Everything is installed. You should be able to do npm run test to compile everything and launch.\"",
|
||||
"versions": "echo Electron: && electron -v && echo Typescript: && tsc -v"
|
||||
},
|
||||
"author": "JeanOUINA",
|
||||
|
@ -38,6 +37,7 @@
|
|||
"devDependencies": {
|
||||
"@types/auto-launch": "^5.0.1",
|
||||
"@types/electron-devtools-installer": "^2.2.0",
|
||||
"@types/micromatch": "^4.0.1",
|
||||
"@types/mkdirp": "^1.0.0",
|
||||
"@types/node": "12.12.39",
|
||||
"@types/rimraf": "^3.0.0",
|
||||
|
@ -46,8 +46,10 @@
|
|||
"asar": "^3.0.3",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"electron": "^8.5.0",
|
||||
"electron-builder": "^22.8.0",
|
||||
"fast-glob": "^3.2.4",
|
||||
"fs-extra": "^9.0.1",
|
||||
"micromatch": "^4.0.2",
|
||||
"terser": "^4.7.0",
|
||||
"typescript": "^3.9.7",
|
||||
"yazl": "^2.5.1"
|
||||
|
|
Loading…
Reference in New Issue