Merge branch 'master' of https://github.com/Lightcord/Lightcord into master

This commit is contained in:
Jean Ouina 2020-10-26 13:18:21 +01:00
commit a20551529e
31 changed files with 395 additions and 44848 deletions

10
.gitignore vendored
View File

@ -108,7 +108,6 @@ builds
# must build typescript itself
dist
!BetterDiscordApp/dist
distApp
@ -121,3 +120,12 @@ discord-webrtc_0
# VS Code stuff
.vscode
# Compiled JS files
LightcordApi/js
DiscordJS/js
BetterDiscordApp/dist
downloaded_modules
workspace_modules
new_modules_version.json

View File

@ -14,7 +14,7 @@ jobs:
before_cache:
- rm -rf $ELECTRON_BUILDER_CACHE/wine
script:
- npm run devInstall:64
- npm run devInstall
- npm run build
# - stage: Windows Build
# os: windows

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
Name=Lightcord
Comment[fr_FR]=Un client Discord simple et personalisable
Comment=A simple - customizable - Discord Client
Exec=/opt/lightcord/Lightcord
Exec=/opt/Lightcord/Lightcord
Icon=lightcord
Terminal=false
Type=Application

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +0,0 @@
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

File diff suppressed because one or more lines are too long

179
Lightcord_installer.sh Normal file
View File

@ -0,0 +1,179 @@
#!/bin/bash
# Original script by https://github.com/GermanBread
if [[ $TERM == dumb ]]; then
exit;
fi
if [[ $(whoami) != "root" ]] ; then
printf "[$(tput setaf 9 && tput blink)PANIC$(tput sgr0)] $(tput setaf 9)This script needs to run as root$(tput sgr0)\n";
exit;
fi
tput setaf 208
cat << "EOF"
_ _ _ _ _
| | (_)__ _| |_| |_ __ ___ _ _ __| |
| |__| / _` | ' \ _/ _/ _ \ '_/ _` |
|____|_\__, |_||_\__\__\___/_| \__,_|
|___/
Linux Installer and Updater
EOF
tput sgr0
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)This script depends on unzip! Install that package first!$(tput sgr0)\n";
printf "Please select\n";
printf "1: Install Lightcord\n";
printf "2: Uninstall Lightcord\n";
printf "3: Update Lightcord\n"
printf "4: Troubleshooting\n"
printf "\n";
#Repeat only if the user hasn't entered an integer...
while ! [[ $selection =~ ^[0-9]+$ ]];
do
read selection;
#if the entered value was not an integer, show this
if ! [[ $selection =~ ^[0-9]+$ ]]; then
sleep 1;
printf "$(tput setaf 9)Please try again$(tput sgr0)\n";
printf "1: Install Lightcord\n";
printf "2: Uninstall Lightcord\n";
printf "3: Update Lightcord\n"
printf "4: Troubleshooting\n"
printf "\n";
fi
done
case $selection in
1)
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Installing Lightcord$(tput sgr0)\n";
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Lightcord zip to $(pwd && tput sgr0)\n";
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
wget https://lightcord.org/api/v1/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x64.zip;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Unzipping$(tput sgr0)\n";
unzip lightcord-linux-x64.zip -d Lightcord;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting zip$(tput sgr0)\n";
rm lightcord-linux-x64.zip;
prev_pwd = pwd;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into $(pwd)/Lightcord$(tput sgr0)\n";
cd Lightcord;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Giving $(pwd)/lightcord executable execute permissions$(tput sgr0)\n";
chmod +x ./lightcord;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into ${prev_pwd}$(tput sgr0)\n";
cd ..;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving $(pwd)/Lightcord folder to /opt$(tput sgr0)\n";
mv Lightcord/ /opt/;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting $(pwd)/Lightcord folder$(tput sgr0)\n";
rm Lightcord/;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading lightcord.svg icon to $(pwd && tput sgr0)\n";
wget https://raw.githubusercontent.com/Lightcord/LightcordLogos/master/lightcord/lightcord.svg;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving $(pwd)/lightcord.svg file to /usr/share/pixmaps$(tput sgr0)\n";
mv lightcord.svg /usr/share/pixmaps;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Lightcord.desktop file to $(pwd && tput sgr0)\n";
wget https://raw.githubusercontent.com/Lightcord/Lightcord/master/Lightcord.desktop;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving $(pwd)/Lightcord.desktop file to /usr/share/applications$(tput sgr0)\n";
mv Lightcord.desktop /usr/share/applications;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Giving /usr/share/Lightcord.desktop execute permissions$(tput sgr0)\n";
chmod +x /usr/share/applications/Lightcord.desktop;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Cleaning up$(tput sgr0)\n";
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Installation complete\n";
;;
2)
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Uninstalling Lightcord$(tput sgr0)\n";
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /opt/Lightcord$(tput sgr0)\n";
rm -r /opt/Lightcord;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /usr/share/pixmaps/lightcord.svg$(tput sgr0)\n";
rm /usr/share/pixmaps/lightcord.svg;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /usr/share/Lightcord.desktop$(tput sgr0)\n";
rm /usr/share/applications/Lightcord.desktop;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /home/*/.local/share/applications/Lightcord.desktop$(tput sgr0)\n";
rm -f /home/*/.local/share/applications/Lightcord.desktop;
printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Uninstall complete\n";
;;
3)
#Uninstall
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Updating Lightcord$(tput sgr0)\n";
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Deleting /opt/Lightcord$(tput sgr0)\n";
rm -r /opt/Lightcord;
#Install
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Downloading Lightcord zip to $(pwd && tput sgr0)\n";
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
wget https://lightcord.org/api/v1/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x64.zip;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Unzipping$(tput sgr0)\n";
unzip lightcord-linux-x64.zip -d Lightcord;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting zip$(tput sgr0)\n";
rm lightcord-linux-x64.zip;
prev_pwd = pwd;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into $(pwd)/Lightcord$(tput sgr0)\n";
cd Lightcord;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Giving $(pwd)/lightcord executable execute permissions$(tput sgr0)\n";
chmod +x ./lightcord;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Changing directory into ${prev_pwd}$(tput sgr0)\n";
cd ..;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Moving $(pwd)/Lightcord folder to /opt$(tput sgr0)\n";
mv Lightcord/ /opt/;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Deleting $(pwd)/Lightcord folder$(tput sgr0)\n";
rm Lightcord/;
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Cleaning up$(tput sgr0)\n";
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Update complete\n";
;;
4)
printf "Please select\n";
printf "1: \"/opt/Lightcord/Lightcord not found\"\n";
printf "2: None of the above\n"
printf "\n";
#Repeat only if the user hasn't entered an integer...
while ! [[ $troubleshooting_selection =~ ^[0-9]+$ ]];
do
read troubleshooting_selection;
#if the entered value was not an integer, show this
if ! [[ $troubleshooting_selection =~ ^[0-9]+$ ]]; then
sleep 1;
printf "$(tput setaf 9)Please try again$(tput sgr0)\n";
printf "1: \"/opt/Lightcord/Lightcord not found\"\n";
printf "2: None of the above\n"
printf "\n";
fi
done
case $troubleshooting_selection in
1)
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 7)Modifying /usr/share/applications/Lightcord.desktop$(tput sgr0)\n";
sed -i 's/Lightcord\/Lightcord/Lightcord\/lightcord/' /usr/share/applications/Lightcord.desktop > /dev/null 2>&1;
sed -i 's/Lightcord\/Lightcord/Lightcord\/lightcord/' /home/*/.local/share/applications/Lightcord.desktop > /dev/null 2>&1;
printf "[$(tput setaf 10 && tput blink)FINISH$(tput sgr0)] Done\n";
;;
2)
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 15)Visit the official server for support: https://discord.gg/7eFff2A$(tput sgr0)\n";
;;
*)
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Exiting troubleshooting$(tput sgr0)\n";
;;
esac
;;
*)
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Exiting script$(tput sgr0)\n";
;;
esac

View File

@ -30,7 +30,7 @@ To run from source, follow these instructions:
```sh
git clone https://github.com/Lightcord/Lightcord
cd Lightcord
npm run devInstall # Mac/Linux, run "npm run devInstall:64"
npm run devInstall
npm test
```
*You will have to do that everytime you pull/clone*
@ -43,14 +43,23 @@ Then everytime you want to launch it just type in
npm run run
```
*You can find an experimental GNU/Linux tutorial in our Discord, or use the AUR*
*You can install on GNU/Linux with our install script or the AUR*
## AUR (unofficial)
https://aur.archlinux.org/packages/lightcord-bin/
If you don't know how to install from the AUR, you can follow [this](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_and_upgrading_packages) tutorial, but I would recommend using an AUR helper such as ``yay``.
You need to install the `base-devel` and `git` packages first
**For compilation** https://aur.archlinux.org/packages/lightcord-git/
`git clone https://aur.archlinux.org/lightcord-git.git && cd lightcord-git && makepkg -si`
**For precomiled binaries** https://aur.archlinux.org/packages/lightcord-bin/
`git clone https://aur.archlinux.org/lightcord-bin.git && cd lightcord-bin && makepkg -si`
An AUR helped such as `yay` can also be used
## Other linux distribution
You can also install it via this one-liner command. It will automatically :
You can also install it via this install script. It will automatically :
- Download the latest Lightcord stable release from the official dev server.
- Extract its file, and rename it to a more conventional ¨Lightcord¨ folder.
- Install the Lightcord files in /opt/.
@ -58,10 +67,11 @@ You can also install it via this one-liner command. It will automatically :
- Download an apropriate .desktop file and install it in /usr/share/applications.
- Add executions rights to the .desktop file to be able to launch Lightcord from it.
- Download the Lightcord icon in an .svg format, and will install it in /usr/share/pixmaps.
*Require administrator rights to install in /opt/ and for some files in /usr/.*
```
wget https://lightcord.org/api/v1/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x64.zip; unzip lightcord-linux-x64.zip -d Lightcord; rm lightcord-linux-x64.zip; cd Lightcord; chmod +x ./lightcord; cd ..; sudo mv Lightcord/ /opt/; rm Lightcord/; wget https://raw.githubusercontent.com/Lightcord/Lightcord/master/Lightcord.desktop; sudo mv Lightcord.desktop /usr/share/applications; chmod +x /usr/share/applications/Lightcord.desktop; wget https://raw.githubusercontent.com/Lightcord/LightcordLogos/master/lightcord/lightcord.svg; sudo mv lightcord.svg /usr/share/pixmaps; /opt/Lightcord/lightcord
```
## One-liner install script
*Please install the "unzip" package before executing this script as this script depends on it.*
- Run `rm -f Lightcord_installer.sh && wget https://raw.githubusercontent.com/Lightcord/Lightcord/master/Lightcord_installer.sh && clear && sudo bash Lightcord_installer.sh && rm -f Lightcord_installer.sh`
## Features
* **BetterDiscord** Themes/Plugins

View File

@ -1,42 +0,0 @@
const spawn = require("cross-spawn")
const { join } = require("path")
/** Main Project */
spawnSync("tsc")
/** BetterDiscord */
spawnSync("npm run build", join(__dirname, "BetterDiscordApp"))
spawnSync("npm run build-prod", join(__dirname, "BetterDiscordApp"))
spawnSync("npm run minify-css", join(__dirname, "BetterDiscordApp"))
/** DiscordJS */
spawnSync("npm run build", join(__dirname, "DiscordJS"))
/** LightcordApi */
spawnSync("npm run build", join(__dirname, "LightcordApi"))
spawnSync("npm run build-prod", join(__dirname, "LightcordApi"))
spawnSync("tsc", join(__dirname, "LightcordApi"))
var exitedWithErrorProcessList = [];
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`)
})

View File

@ -6,7 +6,7 @@ directories:
app: distApp
output: builds
# This is to get around the bug in electron-builder with not including nested node_modules.
afterPack: "afterpack.js"
afterPack: "scripts/afterpack.js"
win:
artifactName: ${name}-win32-${arch}.${ext}
target:

View File

@ -40,7 +40,12 @@ electron.ipcMain.on(APP_GET_RELEASE_CHANNEL_SYNC, event => {
electron.ipcMain.on(APP_GET_HOST_VERSION_SYNC, event => {
// hardcode because Discord could identify Lightcord or could simply bug.
event.returnValue = "0.0.308" //electron.app.getVersion();
if(process.platform === "darwin")
event.returnValue = "0.0.259";
else if(process.platform === "linux")
event.returnValue = "0.0.12";
else
event.returnValue = "0.0.308"; //electron.app.getVersion();
});
electron.ipcMain.handle(APP_GET_MODULE_VERSIONS, (() => {
@ -135,4 +140,4 @@ electron.ipcMain.handle(APP_GET_DEFAULT_DOUBLE_CLICK_ACTION, (() => {
return function (_x13) {
return _ref8.apply(this, arguments);
};
})());
})());

View File

@ -4,22 +4,21 @@
"description": "A simple - customizable - Discord Client.",
"main": "dist/index.js",
"scripts": {
"compile": "node compile.js",
"compile": "node scripts/compile.js",
"test": "npm run compile && electron .",
"run": "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_linux": "electron-builder build --linux",
"build:electron_mac": "electron-builder build --mac",
"start": "electron .",
"build:minify": "node build.js",
"build:minify": "node scripts/build.js",
"clean": "node scripts/clean.js",
"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: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.\"",
"devInstall": "node scripts/devInstall.js",
"versions": "echo Electron: && electron -v && echo Typescript: && tsc -v",
"ci": "node ci-deploy"
"ci": "node scripts/ci-deploy"
},
"author": "JeanOUINA",
"license": "MIT",
@ -46,7 +45,8 @@
"@types/yauzl": "^2.9.1",
"asar": "^3.0.3",
"cross-spawn": "^7.0.3",
"electron": "9.3.1",
"dotenv": "^8.2.0",
"electron": "^9.3.1",
"electron-builder": "^22.8.0",
"fast-glob": "^3.2.4",
"fs-extra": "^9.0.1",

View File

@ -12,6 +12,7 @@ exports.default = async function beforeBuild(context){
await main()
return true
}
const PROJECT_DIR = path.resolve(__dirname, "..");
console.log = (...args) => {
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...")
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`")
child_process.execSync("npm run compile", {
@ -117,8 +118,8 @@ async function main(){
stdio: "inherit"
})
let startDir = path.join(__dirname, "./dist")
let newDir = path.join(__dirname, "./distApp/dist")
let startDir = path.join(PROJECT_DIR, "./dist")
let newDir = path.join(PROJECT_DIR, "./distApp/dist")
console.info("No error detected. Copying files from "+startDir+".")
await fs.promises.mkdir(startDir, {recursive: true})
@ -137,19 +138,19 @@ async function main(){
console.info(`Copied files and minified them from ${startDir}.`)
})
await processNextDir(path.join(__dirname, "modules"), {
startDir: path.join(__dirname, "modules"),
newDir: path.join(__dirname, "distApp", "modules"),
await processNextDir(path.join(PROJECT_DIR, "modules"), {
startDir: path.join(PROJECT_DIR, "modules"),
newDir: path.join(PROJECT_DIR, "distApp", "modules"),
exclude: /discord_spellcheck/g
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
console.info(`Minifying ${filepath} to ${newpath}`)
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
}, 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 => {
let dir = path.join(__dirname, "distApp", "modules", mdl)
await Promise.all((await fs.promises.readdir(path.join(PROJECT_DIR, "distApp", "modules"))).map(async mdl => {
let dir = path.join(PROJECT_DIR, "distApp", "modules", mdl)
if(!fs.existsSync(path.join(dir, "package.json"))){
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 processNextDir(path.join(__dirname, "modules", "discord_spellcheck"), {
startDir: path.join(__dirname, "modules", "discord_spellcheck"),
newDir: path.join(__dirname, "distApp", "modules", "discord_spellcheck")
await fs.promises.mkdir(path.join(PROJECT_DIR, "distApp", "modules", "discord_spellcheck"), {recursive: true})
await processNextDir(path.join(PROJECT_DIR, "modules", "discord_spellcheck"), {
startDir: path.join(PROJECT_DIR, "modules", "discord_spellcheck"),
newDir: path.join(PROJECT_DIR, "distApp", "modules", "discord_spellcheck")
}, ((filepath) => filepath.endsWith(".js")), async (filepath, newpath) => {
console.info(`Minifying ${filepath} to ${newpath}`)
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
}, 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"), {
startDir: path.join(__dirname, "LightcordApi"),
newDir: path.join(__dirname, "distApp", "LightcordApi"),
await processNextDir(path.join(PROJECT_DIR, "LightcordApi"), {
startDir: path.join(PROJECT_DIR, "LightcordApi"),
newDir: path.join(PROJECT_DIR, "distApp", "LightcordApi"),
exclude: /(src|webpack\.config\.js|tsconfig\.json|dist|docs)/g
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
await fs.promises.copyFile(filepath, newpath)
}, 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", {
encoding: "binary",
cwd: path.join(__dirname, "distApp", "LightcordApi"),
cwd: path.join(PROJECT_DIR, "distApp", "LightcordApi"),
stdio: "inherit"
})
function processDJS(dir){
fs.mkdirSync(path.join(__dirname, "distApp", "DiscordJS", dir), {recursive: true})
return processNextDir(path.join(__dirname, "DiscordJS", dir), {
startDir: path.join(__dirname, "DiscordJS", dir),
newDir: path.join(__dirname, "distApp", "DiscordJS", dir),
fs.mkdirSync(path.join(PROJECT_DIR, "distApp", "DiscordJS", dir), {recursive: true})
return processNextDir(path.join(PROJECT_DIR, "DiscordJS", dir), {
startDir: path.join(PROJECT_DIR, "DiscordJS", dir),
newDir: path.join(PROJECT_DIR, "distApp", "DiscordJS", dir),
exclude: /node_modules/g
}, ((filepath) => filepath.endsWith(".js")), 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, "DiscordJS", dir)}.`)
console.info(`Copied files and minified them from ${path.join(PROJECT_DIR, "DiscordJS", dir)}.`)
})
}
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")
@ -216,13 +217,13 @@ async function main(){
child_process.execSync("npm install --only=prod", {
encoding: "binary",
cwd: path.join(__dirname, "distApp", "DiscordJS"),
cwd: path.join(PROJECT_DIR, "distApp", "DiscordJS"),
stdio: "inherit"
})
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "dist"), {recursive: true})
const BDPackageJSON = require("./BetterDiscordApp/package.json")
fs.writeFileSync(path.join(__dirname, "distApp", "BetterDiscordApp", "package.json"), JSON.stringify(BDPackageJSON), "utf8")
fs.mkdirSync(path.join(PROJECT_DIR, "distApp", "BetterDiscordApp", "dist"), {recursive: true})
const BDPackageJSON = require("../BetterDiscordApp/package.json")
fs.writeFileSync(path.join(PROJECT_DIR, "distApp", "BetterDiscordApp", "package.json"), JSON.stringify(BDPackageJSON), "utf8")
const files = [
"index.min.js",
"style.min.css"
@ -231,21 +232,21 @@ async function main(){
files.push(e + ".map")
})
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(e.endsWith(".map")){
const data = JSON.parse(fs.readFileSync(pth, "utf8"))
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{
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 processNextDir(path.join(__dirname, "splash"), {
startDir: path.join(__dirname, "splash"),
newDir: path.join(__dirname, "distApp", "splash"),
await fs.promises.mkdir(path.join(PROJECT_DIR, "distApp", "splash", "videos"), {recursive: true})
await processNextDir(path.join(PROJECT_DIR, "splash"), {
startDir: path.join(PROJECT_DIR, "splash"),
newDir: path.join(PROJECT_DIR, "distApp", "splash"),
exclude: /node_modules/g
}, (filepath) => {
if(filepath.endsWith(".js"))return true
@ -254,21 +255,21 @@ async function main(){
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, "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_win"] = packageJSON.scripts["build:electron_win"].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...`)
child_process.execSync("npm install --only=prod", {
encoding: "binary",
cwd: path.join(__dirname, "distApp"),
cwd: path.join(PROJECT_DIR, "distApp"),
stdio: "inherit"
})
console.info("Build took "+(Date.now() - startTimestamp) +"ms.")

View File

@ -3,6 +3,8 @@ const path = require("path")
const { existsSync, promises: fsPromises, createWriteStream } = require("fs")
const yazl = require("yazl")
const PROJECT_DIR = path.resolve(__dirname, "..");
const supportedPlatforms = []
const Platforms = {
linux: {
@ -27,8 +29,8 @@ const Platforms = {
name: "mac",
experimental: true,
run: async () => {
const basePath = path.join(__dirname, "..", "lightcord-darwin-x64")
const nextPath = path.join(__dirname, "builds", "lightcord-darwin-x64")
const basePath = path.join(PROJECT_DIR, "..", "lightcord-darwin-x64")
const nextPath = path.join(PROJECT_DIR, "builds", "lightcord-darwin-x64")
if(existsSync(nextPath)){
console.log(`Cleaning ${nextPath}.`)
await fsPromises.rmdir(nextPath, {recursive: true})
@ -54,11 +56,11 @@ const Platforms = {
const asarUnpackPath = path.join(nextPath, "lightcord.app", "Contents", "Resources", "app.asar.unpacked")
if(existsSync(asarUnpackPath))await fsPromises.rmdir(asarUnpackPath, {recursive: true})
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}",
unpackDir: asarUnpackPath
})
const iconPath = path.join(__dirname, "discord.icns")
const iconPath = path.join(PROJECT_DIR, "discord.icns")
if(existsSync(iconPath)){
console.log(`Setting icon.`)
const newIconPath = path.join(nextPath, "lightcord.app", "Contents", "Resources", "electron.icns")
@ -66,11 +68,11 @@ const Platforms = {
}
console.log("zipping")
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() {
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){
for(let file of await fsPromises.readdir(dir, {withFileTypes: true})){
if(file.isDirectory()){
@ -90,13 +92,13 @@ switch(process.platform){
case "win32":
supportedPlatforms.push(Platforms.win)
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)
}
break
case "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)
}
break

View File

@ -1,4 +1,4 @@
const package = require("./package.json")
const package = require("../package.json")
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)

View File

@ -22,15 +22,23 @@ var args = process.argv.slice(2);
let dirsToRemove;
const node_modules = glob.sync("+(**/node_modules|node_modules)", {absolute:true, onlyDirectories:true, cwd:projectDir})
const dist = join(projectDir, "dist");
const distApp = join(projectDir, "distApp");
const builds = join(projectDir, "builds");
const build_dirs = [
join(projectDir, "dist"),
join(projectDir, "distApp"),
join(projectDir, "builds"),
join(projectDir, "LightcordApi", "js"),
join(projectDir, "LightcordApi", "dist"),
join(projectDir, "DiscordJS", "js"),
join(projectDir, "DiscordJS", "dist"),
join(projectDir, "BetterDiscordApp", "js"),
join(projectDir, "BetterDiscordApp", "dist"),
]
// regular clean means removing only node_modules
dirsToRemove = node_modules;
// clean all means removing all dirs.
if (args[0] === "--all"){
dirsToRemove = node_modules.concat([dist, distApp, builds])
dirsToRemove = dirsToRemove.concat(build_dirs)
}
dirsToRemove.forEach((dir)=>{

49
scripts/compile.js Normal file
View File

@ -0,0 +1,49 @@
const spawn = require("cross-spawn")
const { mkdirSync, existsSync } = require("fs")
const { join, resolve } = require("path")
const PROJECT_DIR = resolve(__dirname, "..");
/** Main Project */
spawnSync("tsc", PROJECT_DIR)
/** BetterDiscord */
if (!existsSync(join(PROJECT_DIR, "BetterDiscordApp", "dist"))){
mkdirSync(join(PROJECT_DIR, "BetterDiscordApp", "dist"))
}
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 */
spawnSync("npm run build", join(PROJECT_DIR, "DiscordJS"))
/** LightcordApi */
spawnSync("npm run build", join(PROJECT_DIR, "LightcordApi"))
spawnSync("npm run build-prod", join(PROJECT_DIR, "LightcordApi"))
spawnSync("tsc", join(PROJECT_DIR, "LightcordApi"))
var exitedWithErrorProcessList = [];
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 || process.env.PWD
console.error("Error while running " + cmdString + " in target directory " + DIRSTRING)
console.error(err)
exitedWithErrorProcessList.push({cmd: cmdString, cwd: DIRSTRING, err: err})
})
}
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.error(val.err)
});
}
console.log(`Exiting compilation`)
})

38
scripts/devInstall.js Normal file
View File

@ -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.")

View File

@ -4,8 +4,11 @@ const tmp = require("tmp")
const fs = require("fs")
const util = require('util')
const { join, dirname } = require("path")
const { resolve: resolvePath } = require("path")
const streamPipeline = util.promisify(require('stream').pipeline)
const PROJECT_DIR = resolvePath(__dirname, "..");
const API_URL = "https://discord.com/api"
const branch = "stable"
const platforms = ["win", "linux", "osx"]
@ -49,7 +52,7 @@ const patchedJS = []
resolve(zip)
})
})
const modulePath = join(__dirname, "modules", module)
const modulePath = join(PROJECT_DIR, "modules", module)
const exists = fs.existsSync(modulePath)
let hasNode = false
let hasBinaries = ["discord_hook", "discord_modules"].includes(module)

View File

@ -2,7 +2,9 @@ const child_process = require("child_process")
const fs = require("fs")
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 = [];
@ -30,10 +32,10 @@ fs.readdirSync(MODULES_DIRNAME, {withFileTypes: true})
})
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")
const MODULE_DIRNAME = path.join(PROJECT_DIR, "modules", "discord_desktop_core", "core")
const BETTERDISCORD_DIRNAME = path.join(PROJECT_DIR, "BetterDiscordApp")
const DISCORDJS_DIRNAME = path.join(PROJECT_DIR, "DiscordJS")
const LIGHTCORDAPI_DIRNAME = path.join(PROJECT_DIR, "LightcordApi")
spawnNpmInstallProcess(MODULE_DIRNAME)
spawnNpmInstallProcess(BETTERDISCORD_DIRNAME)

View File

@ -2,7 +2,13 @@ import { getCommitID } from "./common/git"
const pak = require("../package.json")
export const releaseChannel:"stable"|"canary"|"ptb"|"development" = "stable"
export const version = "0.0.308"
export let version
if(process.platform === "darwin")
version = "0.0.259"
else if(process.platform === "linux")
version = "0.0.12"
else
version = "0.0.308"
export const commit = getCommitID()
export default {
releaseChannel,
@ -14,4 +20,4 @@ global["BuildInfo"] = {
releaseChannel,
version: pak.version,
commit
}
}