[WIP] package vencord as asar
This commit is contained in:
parent
80b493d7a8
commit
6cf2e0c2a5
25
.github/workflows/build.yml
vendored
25
.github/workflows/build.yml
vendored
|
@ -40,9 +40,26 @@ jobs:
|
||||||
- name: Generate plugin list
|
- name: Generate plugin list
|
||||||
run: pnpm generatePluginJson dist/plugins.json dist/plugin-readmes.json
|
run: pnpm generatePluginJson dist/plugins.json dist/plugin-readmes.json
|
||||||
|
|
||||||
- name: Clean up obsolete files
|
- name: Collect files to be released
|
||||||
run: |
|
run: |
|
||||||
rm -rf dist/*-unpacked dist/monaco Vencord.user.css vencordDesktopRenderer.css vencordDesktopRenderer.css.map
|
cd dist
|
||||||
|
mkdir release
|
||||||
|
|
||||||
|
cp browser/browser.* release
|
||||||
|
cp Vencord.user.{js,js.LEGAL.txt} release
|
||||||
|
|
||||||
|
# copy the plugin data jsons, the extension zips and the desktop/vesktop asars
|
||||||
|
cp *.{json,zip,asar} release
|
||||||
|
|
||||||
|
# legacy un-asared files
|
||||||
|
# FIXME: remove at some point
|
||||||
|
cp desktop/* release
|
||||||
|
for file in vesktop/*; do
|
||||||
|
filename=$(basename "$file")
|
||||||
|
cp "$file" "release/vencordDesktop${filename^}"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm release/package.json
|
||||||
|
|
||||||
- name: Get some values needed for the release
|
- name: Get some values needed for the release
|
||||||
id: release_values
|
id: release_values
|
||||||
|
@ -52,7 +69,7 @@ jobs:
|
||||||
- name: Upload DevBuild as release
|
- name: Upload DevBuild as release
|
||||||
if: github.repository == 'Vendicated/Vencord'
|
if: github.repository == 'Vendicated/Vencord'
|
||||||
run: |
|
run: |
|
||||||
gh release upload devbuild --clobber dist/*
|
gh release upload devbuild --clobber dist/release/*
|
||||||
gh release edit devbuild --title "DevBuild $RELEASE_TAG"
|
gh release edit devbuild --title "DevBuild $RELEASE_TAG"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
@ -69,7 +86,7 @@ jobs:
|
||||||
|
|
||||||
GLOBIGNORE=.git:.gitignore:README.md:LICENSE
|
GLOBIGNORE=.git:.gitignore:README.md:LICENSE
|
||||||
rm -rf *
|
rm -rf *
|
||||||
cp -r ../dist/* .
|
cp -r ../dist/release/* .
|
||||||
|
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "Builds for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
git commit -m "Builds for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
||||||
|
|
|
@ -16,6 +16,9 @@ importers:
|
||||||
|
|
||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@electron/asar':
|
||||||
|
specifier: ^3.2.10
|
||||||
|
version: 3.2.10
|
||||||
'@sapphi-red/web-noise-suppressor':
|
'@sapphi-red/web-noise-suppressor':
|
||||||
specifier: 0.3.3
|
specifier: 0.3.3
|
||||||
version: 0.3.3
|
version: 0.3.3
|
||||||
|
@ -210,6 +213,11 @@ packages:
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
postcss-selector-parser: ^6.0.10
|
postcss-selector-parser: ^6.0.10
|
||||||
|
|
||||||
|
'@electron/asar@3.2.10':
|
||||||
|
resolution: {integrity: sha512-mvBSwIBUeiRscrCeJE1LwctAriBj65eUDm0Pc11iE5gRwzkmsdbS7FnZ1XUWjpSeQWL1L5g12Fc/SchPM9DUOw==}
|
||||||
|
engines: {node: '>=10.12.0'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
'@esbuild-kit/cjs-loader@2.4.2':
|
'@esbuild-kit/cjs-loader@2.4.2':
|
||||||
resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==}
|
resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==}
|
||||||
|
|
||||||
|
@ -778,6 +786,10 @@ packages:
|
||||||
commander@2.20.3:
|
commander@2.20.3:
|
||||||
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||||
|
|
||||||
|
commander@5.1.0:
|
||||||
|
resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==}
|
||||||
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
component-emitter@1.3.0:
|
component-emitter@1.3.0:
|
||||||
resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==}
|
resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==}
|
||||||
|
|
||||||
|
@ -2553,6 +2565,12 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
postcss-selector-parser: 6.0.12
|
postcss-selector-parser: 6.0.12
|
||||||
|
|
||||||
|
'@electron/asar@3.2.10':
|
||||||
|
dependencies:
|
||||||
|
commander: 5.1.0
|
||||||
|
glob: 7.2.3
|
||||||
|
minimatch: 3.1.2
|
||||||
|
|
||||||
'@esbuild-kit/cjs-loader@2.4.2':
|
'@esbuild-kit/cjs-loader@2.4.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@esbuild-kit/core-utils': 3.1.0
|
'@esbuild-kit/core-utils': 3.1.0
|
||||||
|
@ -3129,6 +3147,8 @@ snapshots:
|
||||||
|
|
||||||
commander@2.20.3: {}
|
commander@2.20.3: {}
|
||||||
|
|
||||||
|
commander@5.1.0: {}
|
||||||
|
|
||||||
component-emitter@1.3.0: {}
|
component-emitter@1.3.0: {}
|
||||||
|
|
||||||
concat-map@0.0.1: {}
|
concat-map@0.0.1: {}
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { createPackage } from "@electron/asar";
|
||||||
import esbuild from "esbuild";
|
import esbuild from "esbuild";
|
||||||
import { readdir } from "fs/promises";
|
import { readdir, writeFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, watch } from "./common.mjs";
|
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, watch } from "./common.mjs";
|
||||||
|
@ -107,7 +108,7 @@ await Promise.all([
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...nodeCommonOpts,
|
...nodeCommonOpts,
|
||||||
entryPoints: ["src/main/index.ts"],
|
entryPoints: ["src/main/index.ts"],
|
||||||
outfile: "dist/patcher.js",
|
outfile: "dist/desktop/patcher.js",
|
||||||
footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") },
|
footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") },
|
||||||
sourcemap,
|
sourcemap,
|
||||||
define: {
|
define: {
|
||||||
|
@ -123,7 +124,7 @@ await Promise.all([
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...commonOpts,
|
...commonOpts,
|
||||||
entryPoints: ["src/Vencord.ts"],
|
entryPoints: ["src/Vencord.ts"],
|
||||||
outfile: "dist/renderer.js",
|
outfile: "dist/desktop/renderer.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
target: ["esnext"],
|
target: ["esnext"],
|
||||||
footer: { js: "//# sourceURL=VencordRenderer\n" + sourceMapFooter("renderer") },
|
footer: { js: "//# sourceURL=VencordRenderer\n" + sourceMapFooter("renderer") },
|
||||||
|
@ -142,7 +143,7 @@ await Promise.all([
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...nodeCommonOpts,
|
...nodeCommonOpts,
|
||||||
entryPoints: ["src/preload.ts"],
|
entryPoints: ["src/preload.ts"],
|
||||||
outfile: "dist/preload.js",
|
outfile: "dist/desktop/preload.js",
|
||||||
footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") },
|
footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") },
|
||||||
sourcemap,
|
sourcemap,
|
||||||
define: {
|
define: {
|
||||||
|
@ -156,8 +157,8 @@ await Promise.all([
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...nodeCommonOpts,
|
...nodeCommonOpts,
|
||||||
entryPoints: ["src/main/index.ts"],
|
entryPoints: ["src/main/index.ts"],
|
||||||
outfile: "dist/vencordDesktopMain.js",
|
outfile: "dist/vesktop/main.js",
|
||||||
footer: { js: "//# sourceURL=VencordDesktopMain\n" + sourceMapFooter("vencordDesktopMain") },
|
footer: { js: "//# sourceURL=VencordMain\n" + sourceMapFooter("main") },
|
||||||
sourcemap,
|
sourcemap,
|
||||||
define: {
|
define: {
|
||||||
...defines,
|
...defines,
|
||||||
|
@ -172,10 +173,10 @@ await Promise.all([
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...commonOpts,
|
...commonOpts,
|
||||||
entryPoints: ["src/Vencord.ts"],
|
entryPoints: ["src/Vencord.ts"],
|
||||||
outfile: "dist/vencordDesktopRenderer.js",
|
outfile: "dist/vesktop/renderer.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
target: ["esnext"],
|
target: ["esnext"],
|
||||||
footer: { js: "//# sourceURL=VencordDesktopRenderer\n" + sourceMapFooter("vencordDesktopRenderer") },
|
footer: { js: "//# sourceURL=VencordRenderer\n" + sourceMapFooter("renderer") },
|
||||||
globalName: "Vencord",
|
globalName: "Vencord",
|
||||||
sourcemap,
|
sourcemap,
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -191,8 +192,8 @@ await Promise.all([
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...nodeCommonOpts,
|
...nodeCommonOpts,
|
||||||
entryPoints: ["src/preload.ts"],
|
entryPoints: ["src/preload.ts"],
|
||||||
outfile: "dist/vencordDesktopPreload.js",
|
outfile: "dist/vesktop/preload.js",
|
||||||
footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("vencordDesktopPreload") },
|
footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") },
|
||||||
sourcemap,
|
sourcemap,
|
||||||
define: {
|
define: {
|
||||||
...defines,
|
...defines,
|
||||||
|
@ -207,3 +208,19 @@ await Promise.all([
|
||||||
if (!commonOpts.watch)
|
if (!commonOpts.watch)
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
writeFile("dist/desktop/package.json", JSON.stringify({
|
||||||
|
name: "vencord",
|
||||||
|
main: "patcher.js"
|
||||||
|
})),
|
||||||
|
writeFile("dist/vesktop/package.json", JSON.stringify({
|
||||||
|
name: "vencord",
|
||||||
|
main: "main.js"
|
||||||
|
}))
|
||||||
|
]);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
createPackage("dist/desktop", "dist/desktop.asar"),
|
||||||
|
createPackage("dist/vesktop", "dist/vesktop.asar")
|
||||||
|
]);
|
||||||
|
|
|
@ -73,26 +73,26 @@ await Promise.all(
|
||||||
minify: true,
|
minify: true,
|
||||||
format: "iife",
|
format: "iife",
|
||||||
outbase: "node_modules/monaco-editor/esm/",
|
outbase: "node_modules/monaco-editor/esm/",
|
||||||
outdir: "dist/monaco"
|
outdir: "dist/browser/monaco"
|
||||||
}),
|
}),
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
entryPoints: ["browser/monaco.ts"],
|
entryPoints: ["browser/monaco.ts"],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
minify: true,
|
minify: true,
|
||||||
format: "iife",
|
format: "iife",
|
||||||
outfile: "dist/monaco/index.js",
|
outfile: "dist/browser/monaco/index.js",
|
||||||
loader: {
|
loader: {
|
||||||
".ttf": "file"
|
".ttf": "file"
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
outfile: "dist/browser.js",
|
outfile: "dist/browser/browser.js",
|
||||||
footer: { js: "//# sourceURL=VencordWeb" }
|
footer: { js: "//# sourceURL=VencordWeb" }
|
||||||
}),
|
}),
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
outfile: "dist/extension.js",
|
outfile: "dist/browser/extension.js",
|
||||||
define: {
|
define: {
|
||||||
...commonOptions?.define,
|
...commonOptions?.define,
|
||||||
IS_EXTENSION: true,
|
IS_EXTENSION: true,
|
||||||
|
@ -148,9 +148,9 @@ async function loadDir(dir, basePath = "") {
|
||||||
*/
|
*/
|
||||||
async function buildExtension(target, files) {
|
async function buildExtension(target, files) {
|
||||||
const entries = {
|
const entries = {
|
||||||
"dist/Vencord.js": await readFile("dist/extension.js"),
|
"dist/Vencord.js": await readFile("dist/browser/extension.js"),
|
||||||
"dist/Vencord.css": await readFile("dist/extension.css"),
|
"dist/Vencord.css": await readFile("dist/browser/extension.css"),
|
||||||
...await loadDir("dist/monaco"),
|
...await loadDir("dist/browser/monaco"),
|
||||||
...Object.fromEntries(await Promise.all(RnNoiseFiles.map(async file =>
|
...Object.fromEntries(await Promise.all(RnNoiseFiles.map(async file =>
|
||||||
[`third-party/rnnoise/${file.replace(/^dist\//, "")}`, await readFile(`node_modules/@sapphi-red/web-noise-suppressor/${file}`)]
|
[`third-party/rnnoise/${file.replace(/^dist\//, "")}`, await readFile(`node_modules/@sapphi-red/web-noise-suppressor/${file}`)]
|
||||||
))),
|
))),
|
||||||
|
@ -171,13 +171,13 @@ async function buildExtension(target, files) {
|
||||||
|
|
||||||
await rm(target, { recursive: true, force: true });
|
await rm(target, { recursive: true, force: true });
|
||||||
await Promise.all(Object.entries(entries).map(async ([file, content]) => {
|
await Promise.all(Object.entries(entries).map(async ([file, content]) => {
|
||||||
const dest = join("dist", target, file);
|
const dest = join("dist/browser", target, file);
|
||||||
const parentDirectory = join(dest, "..");
|
const parentDirectory = join(dest, "..");
|
||||||
await mkdir(parentDirectory, { recursive: true });
|
await mkdir(parentDirectory, { recursive: true });
|
||||||
await writeFile(dest, content);
|
await writeFile(dest, content);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.info("Unpacked Extension written to dist/" + target);
|
console.info("Unpacked Extension written to dist/browser/" + target);
|
||||||
}
|
}
|
||||||
|
|
||||||
const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content => {
|
const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content => {
|
||||||
|
@ -200,12 +200,14 @@ if (!process.argv.includes("--skip-extension")) {
|
||||||
buildExtension("firefox-unpacked", ["background.js", "content.js", "manifestv2.json", "icon.png"]),
|
buildExtension("firefox-unpacked", ["background.js", "content.js", "manifestv2.json", "icon.png"]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Zip.sync.zip("dist/chromium-unpacked").compress().save("dist/extension-chrome.zip");
|
Zip.zip("dist/browser/chromium-unpacked", (_err, zip) => {
|
||||||
|
zip.compress().save("dist/extension-chrome.zip");
|
||||||
console.info("Packed Chromium Extension written to dist/extension-chrome.zip");
|
console.info("Packed Chromium Extension written to dist/extension-chrome.zip");
|
||||||
|
});
|
||||||
Zip.sync.zip("dist/firefox-unpacked").compress().save("dist/extension-firefox.zip");
|
Zip.zip("dist/browser/firefox-unpacked", (_err, zip) => {
|
||||||
|
zip.compress().save("dist/extension-firefox.zip");
|
||||||
console.info("Packed Firefox Extension written to dist/extension-firefox.zip");
|
console.info("Packed Firefox Extension written to dist/extension-firefox.zip");
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
await appendCssRuntime;
|
await appendCssRuntime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,9 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const VENCORD_FILES = [
|
export const ASAR_FILE = IS_VESKTOP
|
||||||
IS_DISCORD_DESKTOP ? "patcher.js" : "vencordDesktopMain.js",
|
? "vesktop.asar"
|
||||||
IS_DISCORD_DESKTOP ? "preload.js" : "vencordDesktopPreload.js",
|
: "desktop.asar";
|
||||||
IS_DISCORD_DESKTOP ? "renderer.js" : "vencordDesktopRenderer.js",
|
|
||||||
IS_DISCORD_DESKTOP ? "renderer.css" : "vencordDesktopRenderer.css",
|
|
||||||
];
|
|
||||||
|
|
||||||
export function serializeErrors(func: (...args: any[]) => any) {
|
export function serializeErrors(func: (...args: any[]) => any) {
|
||||||
return async function () {
|
return async function () {
|
||||||
|
|
|
@ -26,10 +26,10 @@ import gitHash from "~git-hash";
|
||||||
import gitRemote from "~git-remote";
|
import gitRemote from "~git-remote";
|
||||||
|
|
||||||
import { get } from "../utils/simpleGet";
|
import { get } from "../utils/simpleGet";
|
||||||
import { serializeErrors, VENCORD_FILES } from "./common";
|
import { ASAR_FILE, serializeErrors } from "./common";
|
||||||
|
|
||||||
const API_BASE = `https://api.github.com/repos/${gitRemote}`;
|
const API_BASE = `https://api.github.com/repos/${gitRemote}`;
|
||||||
let PendingUpdates = [] as [string, string][];
|
let PendingUpdate: string | null = null;
|
||||||
|
|
||||||
async function githubGet(endpoint: string) {
|
async function githubGet(endpoint: string) {
|
||||||
return get(API_BASE + endpoint, {
|
return get(API_BASE + endpoint, {
|
||||||
|
@ -65,22 +65,28 @@ async function fetchUpdates() {
|
||||||
if (hash === gitHash)
|
if (hash === gitHash)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
data.assets.forEach(({ name, browser_download_url }) => {
|
|
||||||
if (VENCORD_FILES.some(s => name.startsWith(s))) {
|
const asset = data.assets.find(a => a.name === ASAR_FILE);
|
||||||
PendingUpdates.push([name, browser_download_url]);
|
PendingUpdate = asset.browser_download_url;
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyUpdates() {
|
async function applyUpdates() {
|
||||||
await Promise.all(PendingUpdates.map(
|
if (!PendingUpdate) return true;
|
||||||
async ([name, data]) => writeFile(
|
|
||||||
join(__dirname, name),
|
const data = await get(PendingUpdate);
|
||||||
await get(data)
|
|
||||||
)
|
if (__dirname.endsWith(".asar")) {
|
||||||
));
|
await writeFile(__dirname, data);
|
||||||
PendingUpdates = [];
|
} else { // legacy plain folder install
|
||||||
|
await writeFile(join(__dirname, "../vencord.asar"), data);
|
||||||
|
|
||||||
|
await writeFile(__filename, '// legacy install workaround\n\nrequire("../vencord.asar");');
|
||||||
|
}
|
||||||
|
|
||||||
|
PendingUpdate = null;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue