refactor install and build scripts
Change devInstall to use a script instead of a one-liner Move all scripts to "scripts" directory.
This commit is contained in:
parent
d0b3b73a85
commit
0816b1ef12
|
@ -125,3 +125,7 @@ discord-webrtc_0
|
||||||
LightcordApi/js
|
LightcordApi/js
|
||||||
DiscordJS/js
|
DiscordJS/js
|
||||||
BetterDiscordApp/dist
|
BetterDiscordApp/dist
|
||||||
|
|
||||||
|
downloaded_modules
|
||||||
|
workspace_modules
|
||||||
|
new_modules_version.json
|
|
@ -30,7 +30,7 @@ To run from source, follow these instructions:
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/Lightcord/Lightcord
|
git clone https://github.com/Lightcord/Lightcord
|
||||||
cd Lightcord
|
cd Lightcord
|
||||||
npm run devInstall # Mac/Linux, run "npm run devInstall:64"
|
npm run devInstall
|
||||||
npm test
|
npm test
|
||||||
```
|
```
|
||||||
*You will have to do that everytime you pull/clone*
|
*You will have to do that everytime you pull/clone*
|
||||||
|
|
|
@ -6,7 +6,7 @@ directories:
|
||||||
app: distApp
|
app: distApp
|
||||||
output: builds
|
output: builds
|
||||||
# This is to get around the bug in electron-builder with not including nested node_modules.
|
# This is to get around the bug in electron-builder with not including nested node_modules.
|
||||||
afterPack: "afterpack.js"
|
afterPack: "scripts/afterpack.js"
|
||||||
win:
|
win:
|
||||||
artifactName: ${name}-win32-${arch}.${ext}
|
artifactName: ${name}-win32-${arch}.${ext}
|
||||||
target:
|
target:
|
||||||
|
|
14
package.json
14
package.json
|
@ -4,22 +4,21 @@
|
||||||
"description": "A simple - customizable - Discord Client.",
|
"description": "A simple - customizable - Discord Client.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "node compile.js",
|
"compile": "node scripts/compile.js",
|
||||||
"test": "npm run compile && electron .",
|
"test": "npm run compile && electron .",
|
||||||
"run": "electron .",
|
"run": "electron .",
|
||||||
"build": "npm run build:minify && npm run build:electron",
|
"build": "npm run build:minify && npm run build:electron",
|
||||||
"build:electron": "node build_electron.js",
|
"build:electron": "node scripts/build_electron.js",
|
||||||
"build:electron_win": "electron-builder build --win",
|
"build:electron_win": "electron-builder build --win",
|
||||||
"build:electron_linux": "electron-builder build --linux",
|
"build:electron_linux": "electron-builder build --linux",
|
||||||
"build:electron_mac": "electron-builder build --mac",
|
"build:electron_mac": "electron-builder build --mac",
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"build:minify": "node build.js",
|
"build:minify": "node scripts/build.js",
|
||||||
"clean": "node scripts/clean.js",
|
"clean": "node scripts/clean.js",
|
||||||
"clean:all": "node scripts/clean.js --all",
|
"clean:all": "node scripts/clean.js --all",
|
||||||
"devInstall": "npm i --save-dev --arch=ia32 electron@9.3.1 && node installSubModules.js && echo \"Everything is installed. You should be able to do npm test to compile everything and launch.\"",
|
"devInstall": "node scripts/devInstall.js",
|
||||||
"devInstall:64": "npm i --save-dev --arch=x64 electron@9.3.1 && node installSubModules.js && echo \"Everything is installed. You should be able to do npm test to compile everything and launch.\"",
|
|
||||||
"versions": "echo Electron: && electron -v && echo Typescript: && tsc -v",
|
"versions": "echo Electron: && electron -v && echo Typescript: && tsc -v",
|
||||||
"ci": "node ci-deploy"
|
"ci": "node scripts/ci-deploy"
|
||||||
},
|
},
|
||||||
"author": "JeanOUINA",
|
"author": "JeanOUINA",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -46,7 +45,8 @@
|
||||||
"@types/yauzl": "^2.9.1",
|
"@types/yauzl": "^2.9.1",
|
||||||
"asar": "^3.0.3",
|
"asar": "^3.0.3",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"electron": "9.3.1",
|
"dotenv": "^8.2.0",
|
||||||
|
"electron": "^9.3.1",
|
||||||
"electron-builder": "^22.8.0",
|
"electron-builder": "^22.8.0",
|
||||||
"fast-glob": "^3.2.4",
|
"fast-glob": "^3.2.4",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
|
|
|
@ -12,6 +12,7 @@ exports.default = async function beforeBuild(context){
|
||||||
await main()
|
await main()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
const PROJECT_DIR = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
console.log = (...args) => {
|
console.log = (...args) => {
|
||||||
process.stdout.write(Buffer.from(util.formatWithOptions({colors: true}, ...args)+"\n", "binary").toString("utf8"))
|
process.stdout.write(Buffer.from(util.formatWithOptions({colors: true}, ...args)+"\n", "binary").toString("utf8"))
|
||||||
|
@ -109,7 +110,7 @@ async function main(){
|
||||||
|
|
||||||
console.info("Reseting existent directory...")
|
console.info("Reseting existent directory...")
|
||||||
await fs.promises.rmdir("./distApp", {"recursive": true})
|
await fs.promises.rmdir("./distApp", {"recursive": true})
|
||||||
await fs.promises.mkdir(__dirname+"/distApp/dist", {"recursive": true})
|
await fs.promises.mkdir(PROJECT_DIR+"/distApp/dist", {"recursive": true})
|
||||||
|
|
||||||
console.info("Executing command `npm run compile`")
|
console.info("Executing command `npm run compile`")
|
||||||
child_process.execSync("npm run compile", {
|
child_process.execSync("npm run compile", {
|
||||||
|
@ -117,8 +118,8 @@ async function main(){
|
||||||
stdio: "inherit"
|
stdio: "inherit"
|
||||||
})
|
})
|
||||||
|
|
||||||
let startDir = path.join(__dirname, "./dist")
|
let startDir = path.join(PROJECT_DIR, "./dist")
|
||||||
let newDir = path.join(__dirname, "./distApp/dist")
|
let newDir = path.join(PROJECT_DIR, "./distApp/dist")
|
||||||
console.info("No error detected. Copying files from "+startDir+".")
|
console.info("No error detected. Copying files from "+startDir+".")
|
||||||
await fs.promises.mkdir(startDir, {recursive: true})
|
await fs.promises.mkdir(startDir, {recursive: true})
|
||||||
|
|
||||||
|
@ -137,19 +138,19 @@ async function main(){
|
||||||
console.info(`Copied files and minified them from ${startDir}.`)
|
console.info(`Copied files and minified them from ${startDir}.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
await processNextDir(path.join(__dirname, "modules"), {
|
await processNextDir(path.join(PROJECT_DIR, "modules"), {
|
||||||
startDir: path.join(__dirname, "modules"),
|
startDir: path.join(PROJECT_DIR, "modules"),
|
||||||
newDir: path.join(__dirname, "distApp", "modules"),
|
newDir: path.join(PROJECT_DIR, "distApp", "modules"),
|
||||||
exclude: /discord_spellcheck/g
|
exclude: /discord_spellcheck/g
|
||||||
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
|
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
|
||||||
console.info(`Minifying ${filepath} to ${newpath}`)
|
console.info(`Minifying ${filepath} to ${newpath}`)
|
||||||
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")
|
||||||
}, true).then(() => {
|
}, true).then(() => {
|
||||||
console.info(`Copied files and minified them from ${path.join(__dirname, "modules")}.`)
|
console.info(`Copied files and minified them from ${path.join(PROJECT_DIR, "modules")}.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
await Promise.all((await fs.promises.readdir(path.join(__dirname, "distApp", "modules"))).map(async mdl => {
|
await Promise.all((await fs.promises.readdir(path.join(PROJECT_DIR, "distApp", "modules"))).map(async mdl => {
|
||||||
let dir = path.join(__dirname, "distApp", "modules", mdl)
|
let dir = path.join(PROJECT_DIR, "distApp", "modules", mdl)
|
||||||
|
|
||||||
if(!fs.existsSync(path.join(dir, "package.json"))){
|
if(!fs.existsSync(path.join(dir, "package.json"))){
|
||||||
if(mdl === "discord_desktop_core"){
|
if(mdl === "discord_desktop_core"){
|
||||||
|
@ -167,48 +168,48 @@ async function main(){
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
await fs.promises.mkdir(path.join(__dirname, "distApp", "modules", "discord_spellcheck"), {recursive: true})
|
await fs.promises.mkdir(path.join(PROJECT_DIR, "distApp", "modules", "discord_spellcheck"), {recursive: true})
|
||||||
await processNextDir(path.join(__dirname, "modules", "discord_spellcheck"), {
|
await processNextDir(path.join(PROJECT_DIR, "modules", "discord_spellcheck"), {
|
||||||
startDir: path.join(__dirname, "modules", "discord_spellcheck"),
|
startDir: path.join(PROJECT_DIR, "modules", "discord_spellcheck"),
|
||||||
newDir: path.join(__dirname, "distApp", "modules", "discord_spellcheck")
|
newDir: path.join(PROJECT_DIR, "distApp", "modules", "discord_spellcheck")
|
||||||
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
|
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
|
||||||
console.info(`Minifying ${filepath} to ${newpath}`)
|
console.info(`Minifying ${filepath} to ${newpath}`)
|
||||||
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")
|
||||||
}, false).then(() => {
|
}, false).then(() => {
|
||||||
console.info(`Copied files and minified them from ${path.join(__dirname, "modules")}.`)
|
console.info(`Copied files and minified them from ${path.join(PROJECT_DIR, "modules")}.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
await processNextDir(path.join(__dirname, "LightcordApi"), {
|
await processNextDir(path.join(PROJECT_DIR, "LightcordApi"), {
|
||||||
startDir: path.join(__dirname, "LightcordApi"),
|
startDir: path.join(PROJECT_DIR, "LightcordApi"),
|
||||||
newDir: path.join(__dirname, "distApp", "LightcordApi"),
|
newDir: path.join(PROJECT_DIR, "distApp", "LightcordApi"),
|
||||||
exclude: /(src|webpack\.config\.js|tsconfig\.json|dist|docs)/g
|
exclude: /(src|webpack\.config\.js|tsconfig\.json|dist|docs)/g
|
||||||
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
||||||
await fs.promises.copyFile(filepath, newpath)
|
await fs.promises.copyFile(filepath, newpath)
|
||||||
}, true).then(() => {
|
}, true).then(() => {
|
||||||
console.info(`Copied files and minified them from ${path.join(__dirname, "LightcordApi")}.`)
|
console.info(`Copied files and minified them from ${path.join(PROJECT_DIR, "LightcordApi")}.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
child_process.execSync("npm install --only=prod", {
|
child_process.execSync("npm install --only=prod", {
|
||||||
encoding: "binary",
|
encoding: "binary",
|
||||||
cwd: path.join(__dirname, "distApp", "LightcordApi"),
|
cwd: path.join(PROJECT_DIR, "distApp", "LightcordApi"),
|
||||||
stdio: "inherit"
|
stdio: "inherit"
|
||||||
})
|
})
|
||||||
|
|
||||||
function processDJS(dir){
|
function processDJS(dir){
|
||||||
fs.mkdirSync(path.join(__dirname, "distApp", "DiscordJS", dir), {recursive: true})
|
fs.mkdirSync(path.join(PROJECT_DIR, "distApp", "DiscordJS", dir), {recursive: true})
|
||||||
return processNextDir(path.join(__dirname, "DiscordJS", dir), {
|
return processNextDir(path.join(PROJECT_DIR, "DiscordJS", dir), {
|
||||||
startDir: path.join(__dirname, "DiscordJS", dir),
|
startDir: path.join(PROJECT_DIR, "DiscordJS", dir),
|
||||||
newDir: path.join(__dirname, "distApp", "DiscordJS", dir),
|
newDir: path.join(PROJECT_DIR, "distApp", "DiscordJS", dir),
|
||||||
exclude: /node_modules/g
|
exclude: /node_modules/g
|
||||||
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
|
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
|
||||||
console.info(`Minifying ${filepath} to ${newpath}`)
|
console.info(`Minifying ${filepath} to ${newpath}`)
|
||||||
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")
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.info(`Copied files and minified them from ${path.join(__dirname, "DiscordJS", dir)}.`)
|
console.info(`Copied files and minified them from ${path.join(PROJECT_DIR, "DiscordJS", dir)}.`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
async function copyFileDJS(file){
|
async function copyFileDJS(file){
|
||||||
await fs.promises.writeFile(path.join(__dirname, "distApp", "DiscordJS", file), await fs.promises.readFile(path.join(__dirname, "DiscordJS", file)))
|
await fs.promises.writeFile(path.join(PROJECT_DIR, "distApp", "DiscordJS", file), await fs.promises.readFile(path.join(PROJECT_DIR, "DiscordJS", file)))
|
||||||
}
|
}
|
||||||
|
|
||||||
await processDJS("dist")
|
await processDJS("dist")
|
||||||
|
@ -216,13 +217,13 @@ async function main(){
|
||||||
|
|
||||||
child_process.execSync("npm install --only=prod", {
|
child_process.execSync("npm install --only=prod", {
|
||||||
encoding: "binary",
|
encoding: "binary",
|
||||||
cwd: path.join(__dirname, "distApp", "DiscordJS"),
|
cwd: path.join(PROJECT_DIR, "distApp", "DiscordJS"),
|
||||||
stdio: "inherit"
|
stdio: "inherit"
|
||||||
})
|
})
|
||||||
|
|
||||||
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "dist"), {recursive: true})
|
fs.mkdirSync(path.join(PROJECT_DIR, "distApp", "BetterDiscordApp", "dist"), {recursive: true})
|
||||||
const BDPackageJSON = require("./BetterDiscordApp/package.json")
|
const BDPackageJSON = require("../BetterDiscordApp/package.json")
|
||||||
fs.writeFileSync(path.join(__dirname, "distApp", "BetterDiscordApp", "package.json"), JSON.stringify(BDPackageJSON), "utf8")
|
fs.writeFileSync(path.join(PROJECT_DIR, "distApp", "BetterDiscordApp", "package.json"), JSON.stringify(BDPackageJSON), "utf8")
|
||||||
const files = [
|
const files = [
|
||||||
"index.min.js",
|
"index.min.js",
|
||||||
"style.min.css"
|
"style.min.css"
|
||||||
|
@ -231,21 +232,21 @@ async function main(){
|
||||||
files.push(e + ".map")
|
files.push(e + ".map")
|
||||||
})
|
})
|
||||||
files.forEach(e => {
|
files.forEach(e => {
|
||||||
const pth = path.join(__dirname, "BetterDiscordApp", "dist", e)
|
const pth = path.join(PROJECT_DIR, "BetterDiscordApp", "dist", e)
|
||||||
if(!fs.existsSync(pth))return console.error(`\x1b[31mFile ${pth} from betterdiscord does not exist.\x1b[0m`)
|
if(!fs.existsSync(pth))return console.error(`\x1b[31mFile ${pth} from betterdiscord does not exist.\x1b[0m`)
|
||||||
if(e.endsWith(".map")){
|
if(e.endsWith(".map")){
|
||||||
const data = JSON.parse(fs.readFileSync(pth, "utf8"))
|
const data = JSON.parse(fs.readFileSync(pth, "utf8"))
|
||||||
data.sourcesContent = []
|
data.sourcesContent = []
|
||||||
fs.writeFileSync(path.join(__dirname, "distApp", "BetterDiscordApp", "dist", e), JSON.stringify(data))
|
fs.writeFileSync(path.join(PROJECT_DIR, "distApp", "BetterDiscordApp", "dist", e), JSON.stringify(data))
|
||||||
}else{
|
}else{
|
||||||
fs.copyFileSync(pth, path.join(__dirname, "distApp", "BetterDiscordApp", "dist", e))
|
fs.copyFileSync(pth, path.join(PROJECT_DIR, "distApp", "BetterDiscordApp", "dist", e))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await fs.promises.mkdir(path.join(__dirname, "distApp", "splash", "videos"), {recursive: true})
|
await fs.promises.mkdir(path.join(PROJECT_DIR, "distApp", "splash", "videos"), {recursive: true})
|
||||||
await processNextDir(path.join(__dirname, "splash"), {
|
await processNextDir(path.join(PROJECT_DIR, "splash"), {
|
||||||
startDir: path.join(__dirname, "splash"),
|
startDir: path.join(PROJECT_DIR, "splash"),
|
||||||
newDir: path.join(__dirname, "distApp", "splash"),
|
newDir: path.join(PROJECT_DIR, "distApp", "splash"),
|
||||||
exclude: /node_modules/g
|
exclude: /node_modules/g
|
||||||
}, (filepath) => {
|
}, (filepath) => {
|
||||||
if(filepath.endsWith(".js"))return true
|
if(filepath.endsWith(".js"))return true
|
||||||
|
@ -254,21 +255,21 @@ async function main(){
|
||||||
console.info(`Minifying ${filepath} to ${newpath}`)
|
console.info(`Minifying ${filepath} to ${newpath}`)
|
||||||
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")
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.info(`Copied files and minified them from ${path.join(__dirname, "splash")}.`)
|
console.info(`Copied files and minified them from ${path.join(PROJECT_DIR, "splash")}.`)
|
||||||
})
|
})
|
||||||
fs.writeFileSync(path.join(__dirname, "distApp", "LICENSE"), fs.readFileSync(path.join(__dirname, "LICENSE")))
|
fs.writeFileSync(path.join(PROJECT_DIR, "distApp", "LICENSE"), fs.readFileSync(path.join(PROJECT_DIR, "LICENSE")))
|
||||||
|
|
||||||
let packageJSON = require("./package.json")
|
let packageJSON = require("../package.json")
|
||||||
packageJSON.scripts["build:electron_linux"] = packageJSON.scripts["build:electron_linux"].replace("./distApp", ".")
|
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_win"] = packageJSON.scripts["build:electron_win"].replace("./distApp", ".")
|
||||||
packageJSON.scripts["build:electron_mac"] = packageJSON.scripts["build:electron_mac"].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")
|
fs.writeFileSync(path.join(PROJECT_DIR, "distApp", "package.json"), JSON.stringify(packageJSON), "utf8")
|
||||||
|
|
||||||
console.info(`Installing ${Object.keys(packageJSON.dependencies).length} packages...`)
|
console.info(`Installing ${Object.keys(packageJSON.dependencies).length} packages...`)
|
||||||
child_process.execSync("npm install --only=prod", {
|
child_process.execSync("npm install --only=prod", {
|
||||||
encoding: "binary",
|
encoding: "binary",
|
||||||
cwd: path.join(__dirname, "distApp"),
|
cwd: path.join(PROJECT_DIR, "distApp"),
|
||||||
stdio: "inherit"
|
stdio: "inherit"
|
||||||
})
|
})
|
||||||
console.info("Build took "+(Date.now() - startTimestamp) +"ms.")
|
console.info("Build took "+(Date.now() - startTimestamp) +"ms.")
|
|
@ -3,6 +3,8 @@ const path = require("path")
|
||||||
const { existsSync, promises: fsPromises, createWriteStream } = require("fs")
|
const { existsSync, promises: fsPromises, createWriteStream } = require("fs")
|
||||||
const yazl = require("yazl")
|
const yazl = require("yazl")
|
||||||
|
|
||||||
|
const PROJECT_DIR = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
const supportedPlatforms = []
|
const supportedPlatforms = []
|
||||||
const Platforms = {
|
const Platforms = {
|
||||||
linux: {
|
linux: {
|
||||||
|
@ -27,8 +29,8 @@ const Platforms = {
|
||||||
name: "mac",
|
name: "mac",
|
||||||
experimental: true,
|
experimental: true,
|
||||||
run: async () => {
|
run: async () => {
|
||||||
const basePath = path.join(__dirname, "..", "lightcord-darwin-x64")
|
const basePath = path.join(PROJECT_DIR, "..", "lightcord-darwin-x64")
|
||||||
const nextPath = path.join(__dirname, "builds", "lightcord-darwin-x64")
|
const nextPath = path.join(PROJECT_DIR, "builds", "lightcord-darwin-x64")
|
||||||
if(existsSync(nextPath)){
|
if(existsSync(nextPath)){
|
||||||
console.log(`Cleaning ${nextPath}.`)
|
console.log(`Cleaning ${nextPath}.`)
|
||||||
await fsPromises.rmdir(nextPath, {recursive: true})
|
await fsPromises.rmdir(nextPath, {recursive: true})
|
||||||
|
@ -54,11 +56,11 @@ const Platforms = {
|
||||||
const asarUnpackPath = path.join(nextPath, "lightcord.app", "Contents", "Resources", "app.asar.unpacked")
|
const asarUnpackPath = path.join(nextPath, "lightcord.app", "Contents", "Resources", "app.asar.unpacked")
|
||||||
if(existsSync(asarUnpackPath))await fsPromises.rmdir(asarUnpackPath, {recursive: true})
|
if(existsSync(asarUnpackPath))await fsPromises.rmdir(asarUnpackPath, {recursive: true})
|
||||||
const asar = require("asar")
|
const asar = require("asar")
|
||||||
await asar.createPackageWithOptions(path.join(__dirname, "distApp"), asarPath, {
|
await asar.createPackageWithOptions(path.join(PROJECT_DIR, "distApp"), asarPath, {
|
||||||
unpack: "*.{node,dylib,so.4,dll}",
|
unpack: "*.{node,dylib,so.4,dll}",
|
||||||
unpackDir: asarUnpackPath
|
unpackDir: asarUnpackPath
|
||||||
})
|
})
|
||||||
const iconPath = path.join(__dirname, "discord.icns")
|
const iconPath = path.join(PROJECT_DIR, "discord.icns")
|
||||||
if(existsSync(iconPath)){
|
if(existsSync(iconPath)){
|
||||||
console.log(`Setting icon.`)
|
console.log(`Setting icon.`)
|
||||||
const newIconPath = path.join(nextPath, "lightcord.app", "Contents", "Resources", "electron.icns")
|
const newIconPath = path.join(nextPath, "lightcord.app", "Contents", "Resources", "electron.icns")
|
||||||
|
@ -66,11 +68,11 @@ const Platforms = {
|
||||||
}
|
}
|
||||||
console.log("zipping")
|
console.log("zipping")
|
||||||
const zip = new yazl.ZipFile();
|
const zip = new yazl.ZipFile();
|
||||||
zip.outputStream.pipe(createWriteStream(path.join(__dirname, "builds", "lightcord-darwin-x64.zip")))
|
zip.outputStream.pipe(createWriteStream(path.join(PROJECT_DIR, "builds", "lightcord-darwin-x64.zip")))
|
||||||
.on("close", function() {
|
.on("close", function() {
|
||||||
console.log("Finished zipping.");
|
console.log("Finished zipping.");
|
||||||
});
|
});
|
||||||
const startDir = path.join(__dirname, "builds", "lightcord-darwin-x64")
|
const startDir = path.join(PROJECT_DIR, "builds", "lightcord-darwin-x64")
|
||||||
async function nextDir2(dir){
|
async function nextDir2(dir){
|
||||||
for(let file of await fsPromises.readdir(dir, {withFileTypes: true})){
|
for(let file of await fsPromises.readdir(dir, {withFileTypes: true})){
|
||||||
if(file.isDirectory()){
|
if(file.isDirectory()){
|
||||||
|
@ -90,13 +92,13 @@ switch(process.platform){
|
||||||
case "win32":
|
case "win32":
|
||||||
supportedPlatforms.push(Platforms.win)
|
supportedPlatforms.push(Platforms.win)
|
||||||
supportedPlatforms.push(Platforms.linux)
|
supportedPlatforms.push(Platforms.linux)
|
||||||
if(existsSync(path.join(__dirname, "..", "lightcord-darwin-x64"))){
|
if(existsSync(path.join(PROJECT_DIR, "..", "lightcord-darwin-x64"))){
|
||||||
supportedPlatforms.push(Platforms.mac_experimental)
|
supportedPlatforms.push(Platforms.mac_experimental)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "linux":
|
case "linux":
|
||||||
supportedPlatforms.push(Platforms.linux)
|
supportedPlatforms.push(Platforms.linux)
|
||||||
if(existsSync(path.join(__dirname, "..", "lightcord-darwin-x64"))){
|
if(existsSync(path.join(PROJECT_DIR, "..", "lightcord-darwin-x64"))){
|
||||||
supportedPlatforms.push(Platforms.mac_experimental)
|
supportedPlatforms.push(Platforms.mac_experimental)
|
||||||
}
|
}
|
||||||
break
|
break
|
|
@ -1,4 +1,4 @@
|
||||||
const package = require("./package.json")
|
const package = require("../package.json")
|
||||||
const child_process = require("child_process")
|
const child_process = require("child_process")
|
||||||
|
|
||||||
const version = package.version+"-"+Date.now()+ "-" + child_process.execSync("git rev-parse HEAD").toString().split("\n")[0].trim().slice(0, 7)
|
const version = package.version+"-"+Date.now()+ "-" + child_process.execSync("git rev-parse HEAD").toString().split("\n")[0].trim().slice(0, 7)
|
|
@ -1,22 +1,24 @@
|
||||||
const spawn = require("cross-spawn")
|
const spawn = require("cross-spawn")
|
||||||
const { mkdirSync, existsSync } = require("fs")
|
const { mkdirSync, existsSync } = require("fs")
|
||||||
const { join } = require("path")
|
const { join, resolve } = require("path")
|
||||||
|
|
||||||
|
|
||||||
|
const PROJECT_DIR = resolve(__dirname, "..");
|
||||||
/** Main Project */
|
/** Main Project */
|
||||||
spawnSync("tsc")
|
spawnSync("tsc", PROJECT_DIR)
|
||||||
if (!existsSync(join(__dirname, "BetterDiscordApp", "dist"))){
|
|
||||||
mkdirSync(join(__dirname, "BetterDiscordApp", "dist"))
|
|
||||||
}
|
|
||||||
/** BetterDiscord */
|
/** BetterDiscord */
|
||||||
spawnSync("npm run build", join(__dirname, "BetterDiscordApp"))
|
if (!existsSync(join(PROJECT_DIR, "BetterDiscordApp", "dist"))){
|
||||||
spawnSync("npm run build-prod", join(__dirname, "BetterDiscordApp"))
|
mkdirSync(join(PROJECT_DIR, "BetterDiscordApp", "dist"))
|
||||||
spawnSync("npm run minify-css", join(__dirname, "BetterDiscordApp"))
|
}
|
||||||
|
spawnSync("npm run build", join(PROJECT_DIR, "BetterDiscordApp"))
|
||||||
|
spawnSync("npm run build-prod", join(PROJECT_DIR, "BetterDiscordApp"))
|
||||||
|
spawnSync("npm run minify-css", join(PROJECT_DIR, "BetterDiscordApp"))
|
||||||
/** DiscordJS */
|
/** DiscordJS */
|
||||||
spawnSync("npm run build", join(__dirname, "DiscordJS"))
|
spawnSync("npm run build", join(PROJECT_DIR, "DiscordJS"))
|
||||||
/** LightcordApi */
|
/** LightcordApi */
|
||||||
spawnSync("npm run build", join(__dirname, "LightcordApi"))
|
spawnSync("npm run build", join(PROJECT_DIR, "LightcordApi"))
|
||||||
spawnSync("npm run build-prod", join(__dirname, "LightcordApi"))
|
spawnSync("npm run build-prod", join(PROJECT_DIR, "LightcordApi"))
|
||||||
spawnSync("tsc", join(__dirname, "LightcordApi"))
|
spawnSync("tsc", join(PROJECT_DIR, "LightcordApi"))
|
||||||
|
|
||||||
var exitedWithErrorProcessList = [];
|
var exitedWithErrorProcessList = [];
|
||||||
|
|
||||||
|
@ -28,10 +30,10 @@ function spawnSync(cmdString, cwd){
|
||||||
env: process.env,
|
env: process.env,
|
||||||
stdio: "inherit"
|
stdio: "inherit"
|
||||||
}).on("error", (err) => {
|
}).on("error", (err) => {
|
||||||
const DIRSTRING = cwd != undefined ? cwd : process.env.PWD
|
const DIRSTRING = cwd || process.env.PWD
|
||||||
console.log("Error while running " + cmdString + " in target directory " + DIRSTRING)
|
console.error("Error while running " + cmdString + " in target directory " + DIRSTRING)
|
||||||
console.error(err)
|
console.error(err)
|
||||||
exitedWithErrorProcessList.push({cmd: cmdString, cwd: DIRSTRING})
|
exitedWithErrorProcessList.push({cmd: cmdString, cwd: DIRSTRING, err: err})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +42,7 @@ process.on("beforeExit", () => {
|
||||||
console.error("Commands exited with errors:\n")
|
console.error("Commands exited with errors:\n")
|
||||||
exitedWithErrorProcessList.forEach((val)=>{
|
exitedWithErrorProcessList.forEach((val)=>{
|
||||||
console.error("\tcommand:\t\t" + val.cmd + "\n\ttarget directory:\t" + val.cwd + "\n")
|
console.error("\tcommand:\t\t" + val.cmd + "\n\ttarget directory:\t" + val.cwd + "\n")
|
||||||
|
console.error(val.err)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(`Exiting compilation`)
|
console.log(`Exiting compilation`)
|
|
@ -0,0 +1,38 @@
|
||||||
|
//require('dotenv').config()
|
||||||
|
const { join } = require("path")
|
||||||
|
const PROJECT_DIRNAME=join(__dirname, "..")
|
||||||
|
const child_process = require("child_process")
|
||||||
|
|
||||||
|
let env = process.env
|
||||||
|
|
||||||
|
function spawnProcess(cmd, ...args) {
|
||||||
|
const postfix = cmd === "node" ? ".exe" : ".cmd"
|
||||||
|
cmd = process.platform === "win32" ? cmd + postfix : cmd
|
||||||
|
let result = child_process.spawnSync(cmd, args, {
|
||||||
|
cwd: PROJECT_DIRNAME,
|
||||||
|
env: env,
|
||||||
|
stdio: "inherit"
|
||||||
|
})
|
||||||
|
if (result.error){
|
||||||
|
console.error("error!")
|
||||||
|
console.error(result)
|
||||||
|
console.error(result.stderr)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
let result;
|
||||||
|
spawnProcess("npm", "rm", "electron")
|
||||||
|
spawnProcess("npm", "i")
|
||||||
|
if (process.platform === "win32"){
|
||||||
|
result = spawnProcess("npm", "i", "--save-dev", "--arch=ia32", "electron@9.3.1")
|
||||||
|
} else {
|
||||||
|
result = spawnProcess("npm", "i", "--save-dev", "--arch=x64", "electron@9.3.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
let runString = "`npm test`"
|
||||||
|
|
||||||
|
spawnProcess("node", join(PROJECT_DIRNAME,"scripts", "installSubModules.js"))
|
||||||
|
|
||||||
|
|
||||||
|
console.log("Everything is installed. You should be able to do "+runString+" to compile everything and launch.")
|
|
@ -4,8 +4,11 @@ const tmp = require("tmp")
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
const { join, dirname } = require("path")
|
const { join, dirname } = require("path")
|
||||||
|
const { resolve: resolvePath } = require("path")
|
||||||
const streamPipeline = util.promisify(require('stream').pipeline)
|
const streamPipeline = util.promisify(require('stream').pipeline)
|
||||||
|
|
||||||
|
const PROJECT_DIR = resolvePath(__dirname, "..");
|
||||||
|
|
||||||
const API_URL = "https://discord.com/api"
|
const API_URL = "https://discord.com/api"
|
||||||
const branch = "stable"
|
const branch = "stable"
|
||||||
const platforms = ["win", "linux", "osx"]
|
const platforms = ["win", "linux", "osx"]
|
||||||
|
@ -49,7 +52,7 @@ const patchedJS = []
|
||||||
resolve(zip)
|
resolve(zip)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const modulePath = join(__dirname, "modules", module)
|
const modulePath = join(PROJECT_DIR, "modules", module)
|
||||||
const exists = fs.existsSync(modulePath)
|
const exists = fs.existsSync(modulePath)
|
||||||
let hasNode = false
|
let hasNode = false
|
||||||
let hasBinaries = ["discord_hook", "discord_modules"].includes(module)
|
let hasBinaries = ["discord_hook", "discord_modules"].includes(module)
|
|
@ -2,7 +2,9 @@ const child_process = require("child_process")
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const path = require("path")
|
const path = require("path")
|
||||||
|
|
||||||
const MODULES_DIRNAME = path.join(__dirname, "modules")
|
const PROJECT_DIR = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
|
const MODULES_DIRNAME = path.join(PROJECT_DIR, "modules")
|
||||||
|
|
||||||
var exitedWithErrorProcessList = [];
|
var exitedWithErrorProcessList = [];
|
||||||
|
|
||||||
|
@ -30,10 +32,10 @@ fs.readdirSync(MODULES_DIRNAME, {withFileTypes: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const MODULE_DIRNAME = path.join(__dirname, "modules", "discord_desktop_core", "core")
|
const MODULE_DIRNAME = path.join(PROJECT_DIR, "modules", "discord_desktop_core", "core")
|
||||||
const BETTERDISCORD_DIRNAME = path.join(__dirname, "BetterDiscordApp")
|
const BETTERDISCORD_DIRNAME = path.join(PROJECT_DIR, "BetterDiscordApp")
|
||||||
const DISCORDJS_DIRNAME = path.join(__dirname, "DiscordJS")
|
const DISCORDJS_DIRNAME = path.join(PROJECT_DIR, "DiscordJS")
|
||||||
const LIGHTCORDAPI_DIRNAME = path.join(__dirname, "LightcordApi")
|
const LIGHTCORDAPI_DIRNAME = path.join(PROJECT_DIR, "LightcordApi")
|
||||||
|
|
||||||
spawnNpmInstallProcess(MODULE_DIRNAME)
|
spawnNpmInstallProcess(MODULE_DIRNAME)
|
||||||
spawnNpmInstallProcess(BETTERDISCORD_DIRNAME)
|
spawnNpmInstallProcess(BETTERDISCORD_DIRNAME)
|
Loading…
Reference in New Issue