Compare commits
24 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b42e06d12d | ||
|
|
480110a285 | ||
|
|
86528e30f7 | ||
|
|
66991c826f | ||
|
|
f5e5b12876 | ||
|
|
cca3a14fd3 | ||
|
|
0ec0d1e4fb | ||
|
|
59a440c964 | ||
|
|
3f5be2f949 | ||
|
|
aad290c9a3 | ||
|
|
faf400acf3 | ||
|
|
022e2a7a37 | ||
|
|
8e0315ac2a | ||
|
|
bd92fb79d5 | ||
|
|
585dd82dc1 | ||
|
|
58e886a884 | ||
|
|
f656dc2612 | ||
|
|
d0212642d2 | ||
|
|
c7a0b23ad2 | ||
|
|
4348c4b4e6 | ||
|
|
f300928aa8 | ||
|
|
3a6f4713e3 | ||
|
|
b415877b2f | ||
|
|
fbd1d1b551 |
30 changed files with 1683 additions and 6203 deletions
34
.github/workflows/build.yml
vendored
34
.github/workflows/build.yml
vendored
|
|
@ -17,56 +17,43 @@ jobs:
|
|||
Build:
|
||||
name: Build Equicord
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: pnpm/action-setup@v6
|
||||
|
||||
- name: Use Node.js 24
|
||||
uses: actions/setup-node@v6
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
node-version: 24
|
||||
cache: "pnpm"
|
||||
|
||||
bun-version: latest
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
run: bun install
|
||||
- name: Build web
|
||||
run: pnpm buildWebStandalone
|
||||
|
||||
run: bun run buildWebStandalone
|
||||
- name: Build
|
||||
run: pnpm buildStandalone
|
||||
run: bun run buildStandalone
|
||||
|
||||
- name: Generate plugin lists
|
||||
run: |
|
||||
pnpm generatePluginJson dist/plugins.json
|
||||
pnpm generateEquicordPluginJson dist/equicordplugins.json
|
||||
pnpm generateVencordPluginJson dist/vencordplugins.json
|
||||
pnpm generateDevsList dist/devs.json
|
||||
bun run generatePluginJson dist/plugins.json
|
||||
bun run generateEquicordPluginJson dist/equicordplugins.json
|
||||
bun run generateVencordPluginJson dist/vencordplugins.json
|
||||
bun run generateDevsList dist/devs.json
|
||||
|
||||
- name: Collect files to be released
|
||||
run: |
|
||||
cd dist
|
||||
mkdir release
|
||||
|
||||
cp browser/browser.* release
|
||||
cp Equicord.user.{js,js.LEGAL.txt} release
|
||||
|
||||
# copy the plugin data jsons, the extension zips and the desktop/equibop asars
|
||||
cp *.{json,zip,asar} release
|
||||
|
||||
# legacy un-asared files
|
||||
cp desktop/* release
|
||||
for file in equibop/*; do
|
||||
filename=$(basename "$file")
|
||||
cp "$file" "release/equibop${filename^}"
|
||||
done
|
||||
|
||||
find release -size 0 -delete
|
||||
rm release/package.json
|
||||
rm release/*.map
|
||||
|
||||
- name: Upload Equicord Stable
|
||||
if: ${{ vars.ACT == 'false' }}
|
||||
run: |
|
||||
|
|
@ -83,6 +70,5 @@ jobs:
|
|||
cp ../dist/release/*plugins.json .
|
||||
cp ../dist/release/devs.json .
|
||||
git add -A
|
||||
|
||||
git commit -m "Plugins for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
||||
git push --force https://$USERNAME:$GITHUB_TOKEN@github.com/$REPO.git
|
||||
|
|
|
|||
35
.github/workflows/nixosBuild.yml
vendored
35
.github/workflows/nixosBuild.yml
vendored
|
|
@ -16,58 +16,45 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: pnpm/action-setup@v6
|
||||
|
||||
- name: Use Node.js 24
|
||||
uses: actions/setup-node@v6
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
node-version: 24
|
||||
cache: "pnpm"
|
||||
|
||||
bun-version: latest
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
run: bun install
|
||||
- name: Build web
|
||||
run: pnpm buildWebStandalone
|
||||
|
||||
run: bun run buildWebStandalone
|
||||
- name: Build
|
||||
run: pnpm buildStandalone
|
||||
run: bun run buildStandalone
|
||||
|
||||
- name: Generate plugin lists
|
||||
run: |
|
||||
pnpm generatePluginJson dist/plugins.json
|
||||
pnpm generateEquicordPluginJson dist/equicordplugins.json
|
||||
pnpm generateVencordPluginJson dist/vencordplugins.json
|
||||
pnpm generateDevsList dist/devs.json
|
||||
bun run generatePluginJson dist/plugins.json
|
||||
bun run generateEquicordPluginJson dist/equicordplugins.json
|
||||
bun run generateVencordPluginJson dist/vencordplugins.json
|
||||
bun run generateDevsList dist/devs.json
|
||||
|
||||
- name: Collect files to be released
|
||||
run: |
|
||||
cd dist
|
||||
mkdir release
|
||||
|
||||
cp browser/browser.* release
|
||||
cp Equicord.user.{js,js.LEGAL.txt} release
|
||||
|
||||
# copy the plugin data jsons, the extension zips and the desktop/equibop asars
|
||||
cp *.{json,zip,asar} release
|
||||
|
||||
# legacy un-asared files
|
||||
cp desktop/* release
|
||||
for file in equibop/*; do
|
||||
filename=$(basename "$file")
|
||||
cp "$file" "release/equibop${filename^}"
|
||||
done
|
||||
|
||||
find release -size 0 -delete
|
||||
rm release/package.json
|
||||
rm release/*.map
|
||||
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
|
||||
|
||||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
|
||||
- name: Upload Equicord Stable
|
||||
if: ${{ vars.ACT == 'false' }}
|
||||
run: |
|
||||
|
|
|
|||
17
.github/workflows/publish.yml
vendored
17
.github/workflows/publish.yml
vendored
|
|
@ -58,24 +58,19 @@ jobs:
|
|||
with:
|
||||
tag_prefix: "v"
|
||||
|
||||
- name: Setup PNPM
|
||||
- name: Setup Bun
|
||||
if: steps.check.outputs.release == 'true'
|
||||
uses: pnpm/action-setup@v6
|
||||
|
||||
- name: Use Node.js 24
|
||||
if: steps.check.outputs.release == 'true'
|
||||
uses: actions/setup-node@v6
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
node-version: 24
|
||||
cache: "pnpm"
|
||||
bun-version: latest
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.check.outputs.release == 'true'
|
||||
run: pnpm install --frozen-lockfile
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Build web
|
||||
if: steps.check.outputs.release == 'true'
|
||||
run: pnpm buildWebStandalone
|
||||
run: bun run buildWebStandalone
|
||||
|
||||
- name: Create sources zip
|
||||
if: steps.check.outputs.release == 'true'
|
||||
|
|
@ -84,7 +79,7 @@ jobs:
|
|||
|
||||
- name: Publish extension
|
||||
if: steps.check.outputs.release == 'true' && !vars.ACT == 'false'
|
||||
run: pnpx @equicord/publish-browser-extension@latest --chrome-zip
|
||||
run: bunx @equicord/publish-browser-extension@latest --chrome-zip
|
||||
dist/extension-chrome.zip --firefox-zip
|
||||
dist/extension-firefox.zip --firefox-sources-zip
|
||||
dist/extension-sources.zip --edge-zip
|
||||
|
|
|
|||
18
.github/workflows/reportBrokenPlugins.yml
vendored
18
.github/workflows/reportBrokenPlugins.yml
vendored
|
|
@ -33,28 +33,24 @@ jobs:
|
|||
with:
|
||||
ref: ${{ github.event_name == 'schedule' && 'dev' || github.ref }}
|
||||
|
||||
- uses: pnpm/action-setup@v6 # Install pnpm using packageManager key in package.json
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
|
||||
- name: Use Node.js 24
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
cache: "pnpm"
|
||||
bun-version: latest
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pnpm install --frozen-lockfile --prefer-offline
|
||||
bun install
|
||||
|
||||
- name: Build Equicord Reporter Version
|
||||
run: pnpm buildReporter
|
||||
run: bun run buildReporter
|
||||
|
||||
- name: Run Reporter
|
||||
timeout-minutes: 10
|
||||
run: |
|
||||
export PATH="$PWD/node_modules/.bin:$PATH"
|
||||
export CHROMIUM_BIN=/usr/bin/google-chrome
|
||||
|
||||
esbuild scripts/generateReport.ts > dist/report.mjs
|
||||
bun build scripts/generateReport.ts --outfile dist/report.mjs --target bun
|
||||
|
||||
stable_output_file=$(mktemp)
|
||||
canary_output_file=$(mktemp)
|
||||
|
|
@ -67,12 +63,12 @@ jobs:
|
|||
fi
|
||||
|
||||
if [[ "$branch" = "both" || "$branch" = "stable" ]]; then
|
||||
node dist/report.mjs > "$stable_output_file" &
|
||||
bun run dist/report.mjs > "$stable_output_file" &
|
||||
pids+=" $!"
|
||||
fi
|
||||
|
||||
if [[ "$branch" = "both" || "$branch" = "canary" ]]; then
|
||||
USE_CANARY=true node dist/report.mjs > "$canary_output_file" &
|
||||
USE_CANARY=true bun run dist/report.mjs > "$canary_output_file" &
|
||||
pids+=" $!"
|
||||
fi
|
||||
|
||||
|
|
|
|||
24
.github/workflows/test.yml
vendored
24
.github/workflows/test.yml
vendored
|
|
@ -8,30 +8,20 @@ on:
|
|||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
Test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: pnpm/action-setup@v6 # Install pnpm using packageManager key in package.json
|
||||
|
||||
- name: Use Node.js 24
|
||||
uses: actions/setup-node@v6
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
node-version: 24
|
||||
cache: "pnpm"
|
||||
|
||||
bun-version: latest
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
run: bun install
|
||||
- name: Lint & Test if desktop version compiles
|
||||
run: pnpm test
|
||||
|
||||
run: bun run test
|
||||
- name: Test if web version compiles
|
||||
run: pnpm buildWeb
|
||||
|
||||
run: bun run buildWeb
|
||||
- name: Test if plugin structure is valid
|
||||
run: pnpm generatePluginJson
|
||||
run: bun run generatePluginJson
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -13,15 +13,14 @@ equicord_installer
|
|||
.DS_Store
|
||||
|
||||
yarn.lock
|
||||
bun.lock
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
*.tsbuildinfo
|
||||
|
||||
.modules/
|
||||
|
|
|
|||
2
.npmrc
2
.npmrc
|
|
@ -1,2 +0,0 @@
|
|||
strict-peer-dependencies=false
|
||||
package-manager-strict=false
|
||||
27
.vscode/tasks.json
vendored
27
.vscode/tasks.json
vendored
|
|
@ -6,7 +6,7 @@
|
|||
{
|
||||
"label": "Build",
|
||||
"type": "shell",
|
||||
"command": "pnpm build",
|
||||
"command": "bun run build",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
// for use with the vencord companion extension
|
||||
"label": "Build Companion Reporter",
|
||||
"type": "shell",
|
||||
"command": "pnpm build --dev --reporter --companion-test",
|
||||
"command": "bun run build --dev --reporter --companion-test",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
|
|
@ -28,32 +28,13 @@
|
|||
{
|
||||
"label": "Build Dev",
|
||||
"type": "shell",
|
||||
"command": "pnpm build --dev",
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
// for use with the vencord companion extension
|
||||
"label": "Build Companion Reporter",
|
||||
"type": "shell",
|
||||
"command": "pnpm build --dev --reporter --companion-test",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build Dev",
|
||||
"type": "shell",
|
||||
"command": "pnpm build --dev",
|
||||
"command": "bun run build --dev",
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "Watch",
|
||||
"type": "shell",
|
||||
"command": "pnpm watch",
|
||||
"command": "bun run watch",
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build"
|
||||
|
|
|
|||
26
README.md
26
README.md
|
|
@ -37,15 +37,10 @@ sh -c "$(curl -sS https://raw.githubusercontent.com/Equicord/Equicord/refs/heads
|
|||
|
||||
### Dependencies
|
||||
|
||||
[Git](https://git-scm.com/download) and [Node.JS LTS](https://nodejs.dev/en/) are required.
|
||||
[Git](https://git-scm.com/download) and [Bun](https://bun.sh/docs/installation) are required.
|
||||
|
||||
Install `pnpm`:
|
||||
|
||||
> :exclamation: This next command may need to be run as admin/root depending on your system, and you may need to close and reopen your terminal for pnpm to be in your PATH.
|
||||
|
||||
```shell
|
||||
npm i -g pnpm
|
||||
```
|
||||
Install Bun:
|
||||
> :exclamation: This next command may need to be run as admin/root depending on your system, and you may need to close and reopen your terminal for Bun to be in your PATH.
|
||||
|
||||
> :exclamation: **IMPORTANT** Make sure you aren't using an admin/root terminal from here onwards. It **will** mess up your Discord/Equicord instance and you **will** most likely have to reinstall.
|
||||
|
||||
|
|
@ -59,25 +54,32 @@ cd Equicord
|
|||
Install dependencies:
|
||||
|
||||
```shell
|
||||
pnpm install --frozen-lockfile
|
||||
cd packages/vencord-types
|
||||
bun link @vencord/types
|
||||
|
||||
cd ../discord-types
|
||||
bun link @vencord/discord-types
|
||||
cd ../..
|
||||
|
||||
bun install
|
||||
```
|
||||
|
||||
Build Equicord:
|
||||
|
||||
```shell
|
||||
pnpm build
|
||||
bun run build
|
||||
```
|
||||
|
||||
Inject Equicord into your desktop client:
|
||||
|
||||
```shell
|
||||
pnpm inject
|
||||
bun run inject
|
||||
```
|
||||
|
||||
Build Equicord for web:
|
||||
|
||||
```shell
|
||||
pnpm buildWeb
|
||||
bun run buildWeb
|
||||
```
|
||||
|
||||
After building Equicord's web extension, locate the appropriate ZIP file in the `dist` directory and follow your browser’s guide for installing custom extensions, if supported.
|
||||
|
|
|
|||
76
package.json
76
package.json
|
|
@ -13,31 +13,36 @@
|
|||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"author": "Equicord",
|
||||
"workspaces": [
|
||||
"packages/discord-types",
|
||||
"packages/vencord-types"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "pnpm depCheck && node --require=./scripts/suppressExperimentalWarnings.js scripts/build/build.mjs",
|
||||
"buildStandalone": "pnpm build --standalone",
|
||||
"buildWeb": "pnpm depCheck && node --require=./scripts/suppressExperimentalWarnings.js scripts/build/buildWeb.mjs",
|
||||
"buildWebStandalone": "pnpm buildWeb --standalone",
|
||||
"buildReporter": "pnpm buildWebStandalone --reporter --skip-extension",
|
||||
"buildReporterDesktop": "pnpm build --reporter",
|
||||
"watch": "pnpm build --watch",
|
||||
"dev": "pnpm watch",
|
||||
"watchWeb": "pnpm buildWeb --watch",
|
||||
"generateDevsList": "tsx scripts/generateDevsList.ts",
|
||||
"generatePluginJson": "tsx scripts/generatePluginList.ts",
|
||||
"generateEquicordPluginJson": "tsx scripts/generatePluginList.ts --equicord",
|
||||
"generateVencordPluginJson": "tsx scripts/generatePluginList.ts --vencord",
|
||||
"build": "bun run depCheck && bun run scripts/build/build.mjs",
|
||||
"buildStandalone": "bun run build --standalone",
|
||||
"buildWeb": "bun run depCheck && bun run scripts/build/buildWeb.mjs",
|
||||
"buildWebStandalone": "bun run buildWeb --standalone",
|
||||
"buildReporter": "bun run buildWebStandalone --reporter --skip-extension",
|
||||
"buildReporterDesktop": "bun run build --reporter",
|
||||
"watch": "bun run build --watch",
|
||||
"dev": "bun run watch",
|
||||
"watchWeb": "bun run buildWeb --watch",
|
||||
"generateDevsList": "bun run scripts/generateDevsList.ts",
|
||||
"generatePluginJson": "bun run scripts/generatePluginList.ts",
|
||||
"generateEquicordPluginJson": "bun run scripts/generatePluginList.ts --equicord",
|
||||
"generateVencordPluginJson": "bun run scripts/generatePluginList.ts --vencord",
|
||||
"generateTypes": "tspc --emitDeclarationOnly --declaration --outDir packages/vencord-types --allowJs false",
|
||||
"inject": "node scripts/runInstaller.mjs -- --install",
|
||||
"uninject": "node scripts/runInstaller.mjs -- --uninstall",
|
||||
"repair": "node scripts/runInstaller.mjs -- --repair",
|
||||
"inject": "bun run scripts/runInstaller.mjs --install",
|
||||
"uninject": "bun run scripts/runInstaller.mjs --uninstall",
|
||||
"repair": "bun run scripts/runInstaller.mjs --repair",
|
||||
"lint": "eslint",
|
||||
"lint-styles": "stylelint \"src/**/*.css\" --ignore-pattern src/userplugins",
|
||||
"lint:fix": "pnpm lint --fix",
|
||||
"test": "pnpm buildStandalone && pnpm testTsc && pnpm lint:fix && pnpm lint-styles && pnpm generatePluginJson",
|
||||
"testWeb": "pnpm lint:fix && pnpm buildWeb && pnpm testTsc",
|
||||
"lint:fix": "bun run lint --fix",
|
||||
"test": "bun run buildStandalone && bun run testTsc && bun run lint:fix && bun run lint-styles && bun run generatePluginJson",
|
||||
"testWeb": "bun run lint:fix && bun run buildWeb && bun run testTsc",
|
||||
"testTsc": "tsc --noEmit",
|
||||
"depCheck": "node scripts/depCheck.mjs"
|
||||
"postinstall": "bun run scripts/applyPatches.mjs",
|
||||
"depCheck": "bun run scripts/depCheck.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ffmpeg/ffmpeg": "^0.12.10",
|
||||
|
|
@ -64,13 +69,14 @@
|
|||
"devDependencies": {
|
||||
"@electron/asar": "^4.2.0",
|
||||
"@stylistic/eslint-plugin": "^5.10.0",
|
||||
"@types/bun": "^1.3.9",
|
||||
"@types/chrome": "^0.1.40",
|
||||
"@types/lodash": "^4.17.24",
|
||||
"@types/node": "^25.6.0",
|
||||
"@types/react": "^19.0.10",
|
||||
"@types/react-dom": "^19.0.4",
|
||||
"@types/yazl": "^3.3.1",
|
||||
"@vencord/discord-types": "link:packages/discord-types",
|
||||
"@vencord/discord-types": "workspace:*",
|
||||
"diff": "^9.0.0",
|
||||
"esbuild": "^0.28.0",
|
||||
"eslint": "10.2.0",
|
||||
|
|
@ -90,39 +96,21 @@
|
|||
"svgo": "^4.0.1",
|
||||
"ts-patch": "^3.3.0",
|
||||
"ts-pattern": "^5.9.0",
|
||||
"tsx": "^4.21.0",
|
||||
"type-fest": "^5.5.0",
|
||||
"typescript": "^6.0.2",
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"typescript-transform-paths": "^3.5.6",
|
||||
"zip-local": "^0.3.5"
|
||||
},
|
||||
"packageManager": "pnpm@10.33.0",
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@types/less@3.0.8": "patches/@types__less@3.0.8.patch"
|
||||
},
|
||||
"peerDependencyRules": {
|
||||
"ignoreMissing": [
|
||||
"eslint-plugin-import",
|
||||
"eslint"
|
||||
]
|
||||
},
|
||||
"allowedDeprecatedVersions": {
|
||||
"source-map-resolve": "*",
|
||||
"resolve-url": "*",
|
||||
"source-map-url": "*",
|
||||
"urix": "*",
|
||||
"q": "*"
|
||||
},
|
||||
"onlyBuiltDependencies": [
|
||||
"packageManager": "bun@1.3.9",
|
||||
"trustedDependencies": [
|
||||
"esbuild"
|
||||
],
|
||||
"overrides": {
|
||||
"@eslint/plugin-kit@<0.3.4": ">=0.3.4"
|
||||
}
|
||||
"@eslint/plugin-kit": ">=0.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=18",
|
||||
"bun": ">=1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@equicord/discord-types",
|
||||
"name": "@vencord/discord-types",
|
||||
"author": "Equicord & Vencord Contributors",
|
||||
"private": false,
|
||||
"description": "Typescript definitions for the webpack modules of the Discord Web app",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# How to publish
|
||||
|
||||
1. run `pnpm generateTypes` in the project root
|
||||
1. run `bun generateTypes` in the project root
|
||||
2. bump package.json version
|
||||
3. npm publish
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ npm i @equicord/types
|
|||
|
||||
yarn add @equicord/types
|
||||
|
||||
pnpm add @equicord/types
|
||||
bun add @vencord/types
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@equicord/types",
|
||||
"name": "@vencord/types",
|
||||
"private": false,
|
||||
"version": "1.14.2",
|
||||
"description": "",
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
"dependencies": {
|
||||
"@types/lodash": "4.17.15",
|
||||
"@types/node": "^22.13.4",
|
||||
"@vencord/discord-types": "^1.0.0",
|
||||
"@vencord/discord-types": "workspace:*",
|
||||
"highlight.js": "11.11.1",
|
||||
"moment": "^2.22.2",
|
||||
"ts-pattern": "^5.6.0",
|
||||
|
|
|
|||
5815
pnpm-lock.yaml
generated
5815
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,2 +0,0 @@
|
|||
packages:
|
||||
- packages/*
|
||||
31
scripts/applyPatches.mjs
Normal file
31
scripts/applyPatches.mjs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env bun
|
||||
|
||||
import { join } from "path";
|
||||
|
||||
const ROOT = join(import.meta.dir, "..");
|
||||
|
||||
const patches = {
|
||||
"@types/less": {
|
||||
file: join(ROOT, "node_modules/@types/less/index.d.ts"),
|
||||
original: "export = less;",
|
||||
patched: "export = LessStatic;",
|
||||
removeLines: ["declare var less: LessStatic;"]
|
||||
}
|
||||
};
|
||||
|
||||
for (const [pkg, patch] of Object.entries(patches)) {
|
||||
const file = Bun.file(patch.file);
|
||||
if (!await file.exists()) continue;
|
||||
|
||||
let content = await file.text();
|
||||
|
||||
if (content.includes(patch.patched)) continue;
|
||||
|
||||
content = content.replace(patch.original, patch.patched);
|
||||
for (const line of patch.removeLines) {
|
||||
content = content.replace(line, "").replace(/\n{3,}/g, "\n\n");
|
||||
}
|
||||
|
||||
await Bun.write(patch.file, content.trimEnd() + "\n");
|
||||
console.log(`Patched ${pkg}`);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/node
|
||||
#!/usr/bin/env bun
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 Vendicated and contributors
|
||||
|
|
@ -20,12 +20,13 @@
|
|||
// @ts-check
|
||||
|
||||
import { createPackage } from "@electron/asar";
|
||||
import { readdir, writeFile } from "fs/promises";
|
||||
import { dirname, join, resolve } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { readdir } from "fs/promises";
|
||||
import { join, resolve } from "path";
|
||||
|
||||
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, commonRendererPlugins, watch, buildOrWatchAll, stringifyValues, IS_ANTI_CRASH_TEST } from "./common.mjs";
|
||||
|
||||
const __dirname = import.meta.dir;
|
||||
|
||||
const defines = stringifyValues({
|
||||
IS_STANDALONE,
|
||||
IS_DEV,
|
||||
|
|
@ -123,7 +124,7 @@ const buildConfigs = ([
|
|||
// Discord Desktop main & renderer & preload
|
||||
{
|
||||
...nodeCommonOpts,
|
||||
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/main/index.ts")],
|
||||
entryPoints: [join(__dirname, "../../src/main/index.ts")],
|
||||
outfile: "dist/desktop/patcher.js",
|
||||
footer: { js: "//# sourceURL=file:///VencordPatcher\n" + sourceMapFooter("patcher") },
|
||||
sourcemap,
|
||||
|
|
@ -141,7 +142,7 @@ const buildConfigs = ([
|
|||
},
|
||||
{
|
||||
...commonOpts,
|
||||
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/Vencord.ts")],
|
||||
entryPoints: [join(__dirname, "../../src/Vencord.ts")],
|
||||
outfile: "dist/desktop/renderer.js",
|
||||
format: "iife",
|
||||
target: ["esnext"],
|
||||
|
|
@ -161,7 +162,7 @@ const buildConfigs = ([
|
|||
},
|
||||
{
|
||||
...nodeCommonOpts,
|
||||
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/preload.ts")],
|
||||
entryPoints: [join(__dirname, "../../src/preload.ts")],
|
||||
outfile: "dist/desktop/preload.js",
|
||||
footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") },
|
||||
sourcemap,
|
||||
|
|
@ -176,7 +177,7 @@ const buildConfigs = ([
|
|||
// Vencord Desktop main & renderer & preload
|
||||
{
|
||||
...nodeCommonOpts,
|
||||
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/main/index.ts")],
|
||||
entryPoints: [join(__dirname, "../../src/main/index.ts")],
|
||||
outfile: "dist/equibop/main.js",
|
||||
footer: { js: "//# sourceURL=file:///VencordDesktopMain\n" + sourceMapFooter("main") },
|
||||
sourcemap,
|
||||
|
|
@ -193,7 +194,7 @@ const buildConfigs = ([
|
|||
},
|
||||
{
|
||||
...commonOpts,
|
||||
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/Vencord.ts")],
|
||||
entryPoints: [join(__dirname, "../../src/Vencord.ts")],
|
||||
outfile: "dist/equibop/renderer.js",
|
||||
format: "iife",
|
||||
target: ["esnext"],
|
||||
|
|
@ -213,7 +214,7 @@ const buildConfigs = ([
|
|||
},
|
||||
{
|
||||
...nodeCommonOpts,
|
||||
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/preload.ts")],
|
||||
entryPoints: [join(__dirname, "../../src/preload.ts")],
|
||||
outfile: "dist/equibop/preload.js",
|
||||
footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") },
|
||||
sourcemap,
|
||||
|
|
@ -229,11 +230,11 @@ const buildConfigs = ([
|
|||
await buildOrWatchAll(buildConfigs);
|
||||
|
||||
await Promise.all([
|
||||
writeFile("dist/desktop/package.json", JSON.stringify({
|
||||
Bun.write("dist/desktop/package.json", JSON.stringify({
|
||||
name: "equicord",
|
||||
main: "patcher.js"
|
||||
})),
|
||||
writeFile("dist/equibop/package.json", JSON.stringify({
|
||||
Bun.write("dist/equibop/package.json", JSON.stringify({
|
||||
name: "equicord",
|
||||
main: "main.js"
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/node
|
||||
#!/usr/bin/env bun
|
||||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 Vendicated and contributors
|
||||
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
// @ts-check
|
||||
|
||||
import { readFileSync } from "fs";
|
||||
import { appendFile, mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
|
||||
import path, { join } from "path";
|
||||
import { appendFile, mkdir, readdir, rm } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import Zip from "zip-local";
|
||||
|
||||
import { BUILD_TIMESTAMP, commonOpts, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, VERSION, commonRendererPlugins, buildOrWatchAll, stringifyValues, IS_ANTI_CRASH_TEST } from "./common.mjs";
|
||||
|
|
@ -107,7 +106,7 @@ const buildConfigs = [
|
|||
},
|
||||
outfile: "dist/Equicord.user.js",
|
||||
banner: {
|
||||
js: readFileSync("browser/userscript.meta.js", "utf-8").replace("%version%", `${VERSION}.${new Date().getTime()}`)
|
||||
js: (await Bun.file("browser/userscript.meta.js").text()).replace("%version%", `${VERSION}.${Date.now()}`)
|
||||
},
|
||||
footer: {
|
||||
// UserScripts get wrapped in an iife, so define Vencord prop on window that returns our local
|
||||
|
|
@ -144,7 +143,7 @@ async function loadDir(dir, basePath = "") {
|
|||
await Promise.all(
|
||||
files.map(
|
||||
async f =>
|
||||
[f.slice(basePath.length), await readFile(f)]
|
||||
[f.slice(basePath.length), Buffer.from(await Bun.file(f).arrayBuffer())]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
@ -155,15 +154,15 @@ async function loadDir(dir, basePath = "") {
|
|||
*/
|
||||
async function buildExtension(target, files) {
|
||||
const entries = {
|
||||
"dist/Equicord.js": await readFile("dist/browser/extension.js"),
|
||||
"dist/Equicord.css": await readFile("dist/browser/extension.css"),
|
||||
"dist/Equicord.js": Buffer.from(await Bun.file("dist/browser/extension.js").arrayBuffer()),
|
||||
"dist/Equicord.css": Buffer.from(await Bun.file("dist/browser/extension.css").arrayBuffer()),
|
||||
...await loadDir("dist/browser/vendor/monaco", "dist/browser/"),
|
||||
...Object.fromEntries(await Promise.all(files.map(async f => {
|
||||
let content = await readFile(join("browser", f));
|
||||
let content = Buffer.from(await Bun.file(join("browser", f)).arrayBuffer());
|
||||
if (f.startsWith("manifest")) {
|
||||
const json = JSON.parse(content.toString("utf-8"));
|
||||
json.version = VERSION;
|
||||
content = Buffer.from(new TextEncoder().encode(JSON.stringify(json)));
|
||||
content = Buffer.from(JSON.stringify(json));
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
@ -178,13 +177,13 @@ async function buildExtension(target, files) {
|
|||
const dest = join("dist/browser", target, file);
|
||||
const parentDirectory = join(dest, "..");
|
||||
await mkdir(parentDirectory, { recursive: true });
|
||||
await writeFile(dest, content);
|
||||
await Bun.write(dest, content);
|
||||
}));
|
||||
|
||||
console.info("Unpacked Extension written to dist/browser/" + target);
|
||||
}
|
||||
|
||||
const appendCssRuntime = readFile("dist/Equicord.user.css", "utf-8").then(content => {
|
||||
const appendCssRuntime = Bun.file("dist/Equicord.user.css").text().then(content => {
|
||||
const cssRuntime = `unsafeWindow._vcUserScriptRendererCss=\`${content.replaceAll("`", "\\`")}\``;
|
||||
|
||||
return appendFile("dist/Equicord.user.js", cssRuntime);
|
||||
|
|
|
|||
|
|
@ -18,21 +18,17 @@
|
|||
|
||||
// @ts-check
|
||||
|
||||
import "../suppressExperimentalWarnings.js";
|
||||
import "../checkNodeVersion.js";
|
||||
|
||||
import { exec, execSync } from "child_process";
|
||||
import esbuild, { build, context } from "esbuild";
|
||||
import { constants as FsConstants, readFileSync } from "fs";
|
||||
import { access, readdir, readFile } from "fs/promises";
|
||||
import { existsSync } from "fs";
|
||||
import { readdir } from "fs/promises";
|
||||
import { minify as minifyHtml } from "html-minifier-terser";
|
||||
import { dirname, join, relative, resolve } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { promisify } from "util";
|
||||
import { join, relative, resolve } from "path";
|
||||
|
||||
import { getPluginTarget } from "../utils.mjs";
|
||||
|
||||
const PackageJSON = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "../../package.json"), "utf-8"));
|
||||
const __dirname = import.meta.dir;
|
||||
|
||||
const PackageJSON = await Bun.file(join(__dirname, "../../package.json")).json();
|
||||
|
||||
export const VERSION = PackageJSON.version;
|
||||
// https://reproducible-builds.org/docs/source-date-epoch/
|
||||
|
|
@ -48,7 +44,7 @@ if (!IS_COMPANION_TEST && process.argv.includes("--companion-test"))
|
|||
console.error("--companion-test must be run with --reporter for any effect");
|
||||
|
||||
export const IS_UPDATER_DISABLED = process.argv.includes("--disable-updater");
|
||||
export const gitHash = process.env.EQUICORD_HASH || execSync("git rev-parse HEAD", { encoding: "utf-8" }).trim();
|
||||
export const gitHash = process.env.EQUICORD_HASH || new TextDecoder().decode(Bun.spawnSync(["git", "rev-parse", "HEAD"]).stdout).trim();
|
||||
|
||||
export const banner = {
|
||||
js: `
|
||||
|
|
@ -96,14 +92,11 @@ const PluginDefinitionNameMatcher = /definePlugin\(\{\s*(["'])?name\1:\s*(["'`])
|
|||
export async function resolvePluginName(base, dirent) {
|
||||
const fullPath = join(base, dirent.name);
|
||||
const content = dirent.isFile()
|
||||
? await readFile(fullPath, "utf-8")
|
||||
? await Bun.file(fullPath).text()
|
||||
: await (async () => {
|
||||
for (const file of ["index.ts", "index.tsx"]) {
|
||||
try {
|
||||
return await readFile(join(fullPath, file), "utf-8");
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
const f = Bun.file(join(fullPath, file));
|
||||
if (await f.exists()) return await f.text();
|
||||
}
|
||||
throw new Error(`Invalid plugin ${fullPath}: could not resolve entry point`);
|
||||
})();
|
||||
|
|
@ -114,10 +107,8 @@ export async function resolvePluginName(base, dirent) {
|
|||
})();
|
||||
}
|
||||
|
||||
export async function exists(path) {
|
||||
return await access(path, FsConstants.F_OK)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
export function exists(path) {
|
||||
return Bun.file(path).exists().then(e => e || existsSync(path));
|
||||
}
|
||||
|
||||
// https://github.com/evanw/esbuild/issues/619#issuecomment-751995294
|
||||
|
|
@ -231,8 +222,8 @@ export const gitRemotePlugin = {
|
|||
build.onLoad({ filter, namespace: "git-remote" }, async () => {
|
||||
let remote = process.env.EQUICORD_REMOTE;
|
||||
if (!remote) {
|
||||
const res = await promisify(exec)("git remote get-url origin", { encoding: "utf-8" });
|
||||
remote = res.stdout.trim()
|
||||
const proc = Bun.spawn(["git", "remote", "get-url", "origin"], { stdout: "pipe" });
|
||||
remote = (await new Response(proc.stdout).text()).trim()
|
||||
.replace("https://github.com/", "")
|
||||
.replace("git@github.com:", "")
|
||||
.replace(/.git$/, "");
|
||||
|
|
@ -264,15 +255,18 @@ export const fileUrlPlugin = {
|
|||
const minify = searchParams.has("minify");
|
||||
const noTrim = searchParams.get("trim") === "false";
|
||||
|
||||
const encoding = base64 ? "base64" : "utf-8";
|
||||
|
||||
let content;
|
||||
if (!minify) {
|
||||
content = await readFile(path, encoding);
|
||||
if (base64) {
|
||||
const buf = Buffer.from(await Bun.file(path).arrayBuffer());
|
||||
content = buf.toString("base64");
|
||||
} else {
|
||||
content = await Bun.file(path).text();
|
||||
if (!noTrim) content = content.trimEnd();
|
||||
}
|
||||
} else {
|
||||
if (path.endsWith(".html")) {
|
||||
content = await minifyHtml(await readFile(path, "utf-8"), {
|
||||
content = await minifyHtml(await Bun.file(path).text(), {
|
||||
collapseWhitespace: true,
|
||||
removeComments: true,
|
||||
minifyCSS: true,
|
||||
|
|
@ -317,7 +311,7 @@ export const banImportPlugin = (filter, message) => ({
|
|||
}
|
||||
});
|
||||
|
||||
const styleModule = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "module/style.js"), "utf-8");
|
||||
const styleModule = await Bun.file(join(__dirname, "module/style.js")).text();
|
||||
|
||||
/**
|
||||
* @type {import("esbuild").Plugin}
|
||||
|
|
@ -330,7 +324,7 @@ export const stylePlugin = {
|
|||
namespace: "managed-style",
|
||||
}));
|
||||
onLoad({ filter: /\.css$/, namespace: "managed-style" }, async ({ path }) => {
|
||||
const css = await readFile(path, "utf-8");
|
||||
const css = await Bun.file(path).text();
|
||||
const name = relative(process.cwd(), path).replaceAll("\\", "/");
|
||||
|
||||
return {
|
||||
|
|
@ -355,7 +349,7 @@ export const commonOpts = {
|
|||
banner,
|
||||
plugins: [fileUrlPlugin, gitHashPlugin, gitRemotePlugin, stylePlugin],
|
||||
external: ["~plugins", "~git-hash", "~git-remote", "/assets/*"],
|
||||
inject: [join(dirname(fileURLToPath(import.meta.url)), "inject/react.mjs")],
|
||||
inject: [join(__dirname, "inject/react.mjs")],
|
||||
jsx: "transform",
|
||||
jsxFactory: "VencordCreateElement",
|
||||
jsxFragment: "VencordFragment"
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (Number(process.versions.node.split(".")[0]) < 18)
|
||||
throw `Your node version (${process.version}) is too old, please update to v18 or higher https://nodejs.org/en/download/`;
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { BigIntLiteral, createSourceFile, Identifier, isCallExpression, isIdentifier, isObjectLiteralExpression, isPropertyAssignment, isSatisfiesExpression, isVariableStatement, NamedDeclaration, ObjectLiteralExpression, ScriptTarget, StringLiteral } from "typescript";
|
||||
|
||||
interface Dev {
|
||||
|
|
@ -41,8 +40,8 @@ function getObjectProp(node: ObjectLiteralExpression, name: string) {
|
|||
return prop;
|
||||
}
|
||||
|
||||
function parseDevs() {
|
||||
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest);
|
||||
async function parseDevs() {
|
||||
const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
|
||||
|
||||
for (const child of file.getChildAt(0).getChildren()) {
|
||||
if (!isVariableStatement(child)) continue;
|
||||
|
|
@ -72,8 +71,8 @@ function parseDevs() {
|
|||
throw new Error("Could not find Devs constant");
|
||||
}
|
||||
|
||||
function parseEquicordDevs() {
|
||||
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest);
|
||||
async function parseEquicordDevs() {
|
||||
const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
|
||||
|
||||
for (const child of file.getChildAt(0).getChildren()) {
|
||||
if (!isVariableStatement(child)) continue;
|
||||
|
|
@ -104,8 +103,8 @@ function parseEquicordDevs() {
|
|||
}
|
||||
|
||||
(async () => {
|
||||
parseDevs();
|
||||
parseEquicordDevs();
|
||||
await parseDevs();
|
||||
await parseEquicordDevs();
|
||||
|
||||
const allDevs = {
|
||||
vencord: devs,
|
||||
|
|
@ -114,7 +113,7 @@ function parseEquicordDevs() {
|
|||
|
||||
const data = JSON.stringify(allDevs, null, 2);
|
||||
if (process.argv.length > 2) {
|
||||
writeFileSync(process.argv[2], data);
|
||||
await Bun.write(process.argv[2], data);
|
||||
} else {
|
||||
console.log(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { readdirSync, writeFileSync } from "fs";
|
||||
import { readdirSync } from "fs";
|
||||
import { getEntryPoint, isPluginFile, parseDevs, parseEquicordDevs, parseFile, PluginData } from "./utils";
|
||||
|
||||
(async () => {
|
||||
parseDevs();
|
||||
parseEquicordDevs();
|
||||
await parseDevs();
|
||||
await parseEquicordDevs();
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ import { getEntryPoint, isPluginFile, parseDevs, parseEquicordDevs, parseFile, P
|
|||
const data = JSON.stringify(plugins);
|
||||
|
||||
if (outputPath) {
|
||||
writeFileSync(outputPath, data);
|
||||
await Bun.write(outputPath, data);
|
||||
} else {
|
||||
console.log(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
/// <reference types="../src/modules" />
|
||||
|
||||
import { createHmac } from "crypto";
|
||||
import { readFileSync, writeFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
import pup, { JSHandle } from "puppeteer-core";
|
||||
|
||||
|
|
@ -361,7 +360,7 @@ page.on("pageerror", (e: any) => {
|
|||
|
||||
await page.evaluateOnNewDocument(`
|
||||
if (location.host.endsWith("discord.com")) {
|
||||
${readFileSync("./dist/browser/browser.js", "utf-8")};
|
||||
${await Bun.file("./dist/browser/browser.js").text()};
|
||||
}
|
||||
`);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,20 +16,14 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "./checkNodeVersion.js";
|
||||
|
||||
import { execFileSync, execSync } from "child_process";
|
||||
import { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
||||
import { dirname, join } from "path";
|
||||
import { Readable } from "stream";
|
||||
import { finished } from "stream/promises";
|
||||
import { fileURLToPath } from "url";
|
||||
import { mkdirSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
const BASE_URL = "https://github.com/Equicord/Equilotl/releases/latest/download/";
|
||||
const INSTALLER_PATH_DARWIN = "Equilotl.app/Contents/MacOS/Equilotl";
|
||||
const INSTALLER_APP_DARWIN = "Equilotl.app";
|
||||
|
||||
const BASE_DIR = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const BASE_DIR = join(import.meta.dir, "..");
|
||||
const FILE_DIR = join(BASE_DIR, "dist", "Installer");
|
||||
const ETAG_FILE = join(FILE_DIR, "etag.txt");
|
||||
|
||||
|
|
@ -60,8 +54,9 @@ async function ensureBinary() {
|
|||
? join(FILE_DIR, INSTALLER_APP_DARWIN)
|
||||
: null;
|
||||
|
||||
const etag = existsSync(outputFile) && existsSync(ETAG_FILE)
|
||||
? readFileSync(ETAG_FILE, "utf-8")
|
||||
const etagFile = Bun.file(ETAG_FILE);
|
||||
const etag = await Bun.file(outputFile).exists() && await etagFile.exists()
|
||||
? await etagFile.text()
|
||||
: null;
|
||||
|
||||
const res = await fetch(BASE_URL + filename, {
|
||||
|
|
@ -78,33 +73,31 @@ async function ensureBinary() {
|
|||
if (!res.ok)
|
||||
throw new Error(`Failed to download installer: ${res.status} ${res.statusText}`);
|
||||
|
||||
writeFileSync(ETAG_FILE, res.headers.get("etag"));
|
||||
await Bun.write(ETAG_FILE, res.headers.get("etag"));
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
console.log("Saving zip...");
|
||||
const zip = new Uint8Array(await res.arrayBuffer());
|
||||
writeFileSync(downloadName, zip);
|
||||
await Bun.write(downloadName, new Uint8Array(await res.arrayBuffer()));
|
||||
|
||||
console.log("Unzipping app bundle...");
|
||||
execSync(`ditto -x -k '${downloadName}' '${FILE_DIR}'`);
|
||||
Bun.spawnSync(["ditto", "-x", "-k", downloadName, FILE_DIR], { stdio: ["inherit", "inherit", "inherit"] });
|
||||
|
||||
console.log("Clearing quarantine from installer app (this is required to run it)");
|
||||
console.log("xattr might error, that's okay");
|
||||
|
||||
const logAndRun = cmd => {
|
||||
console.log("Running", cmd);
|
||||
const logAndRun = args => {
|
||||
console.log("Running", args.join(" "));
|
||||
try {
|
||||
execSync(cmd);
|
||||
Bun.spawnSync(args, { stdio: ["inherit", "inherit", "inherit"] });
|
||||
} catch { }
|
||||
};
|
||||
logAndRun(`sudo xattr -dr com.apple.quarantine '${outputApp}'`);
|
||||
logAndRun(["sudo", "xattr", "-dr", "com.apple.quarantine", outputApp]);
|
||||
} else {
|
||||
// WHY DOES NODE FETCH RETURN A WEB STREAM OH MY GOD
|
||||
const body = Readable.fromWeb(res.body);
|
||||
await finished(body.pipe(createWriteStream(outputFile, {
|
||||
mode: 0o755,
|
||||
autoClose: true
|
||||
})));
|
||||
await Bun.write(outputFile, new Uint8Array(await res.arrayBuffer()));
|
||||
if (process.platform !== "win32") {
|
||||
const { chmodSync } = await import("fs");
|
||||
chmodSync(outputFile, 0o755);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Finished downloading!");
|
||||
|
|
@ -118,19 +111,18 @@ const installerBin = await ensureBinary();
|
|||
|
||||
console.log("Now running Installer...");
|
||||
|
||||
const argStart = process.argv.indexOf("--");
|
||||
const args = argStart === -1 ? [] : process.argv.slice(argStart + 1);
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
try {
|
||||
execFileSync(installerBin, args, {
|
||||
stdio: "inherit",
|
||||
const result = Bun.spawnSync([installerBin, ...args], {
|
||||
stdio: ["inherit", "inherit", "inherit"],
|
||||
env: {
|
||||
...process.env,
|
||||
EQUICORD_USER_DATA_DIR: BASE_DIR,
|
||||
EQUICORD_DIRECTORY: join(BASE_DIR, "dist/desktop"),
|
||||
EQUICORD_DEV_INSTALL: "1"
|
||||
}
|
||||
});
|
||||
} catch {
|
||||
});
|
||||
|
||||
if (!result.success) {
|
||||
console.error("Something went wrong. Please check the logs above.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Vencord, a modification for Discord's desktop app
|
||||
* Copyright (c) 2022 Vendicated and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
process.emit = (originalEmit => function (name, data) {
|
||||
if (name === "warning" && data?.name === "ExperimentalWarning")
|
||||
return false;
|
||||
|
||||
return originalEmit.apply(process, arguments);
|
||||
})(process.emit);
|
||||
|
|
@ -16,8 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Dirent, readdirSync, readFileSync, writeFileSync } from "fs";
|
||||
import { access, readFile } from "fs/promises";
|
||||
import { Dirent, readdirSync } from "fs";
|
||||
import { join, sep } from "path";
|
||||
import { normalize as posixNormalize, sep as posixSep } from "path/posix";
|
||||
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, PropertyAssignment, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
||||
|
|
@ -69,8 +68,8 @@ export function getObjectProp(node: ObjectLiteralExpression, name: string) {
|
|||
return prop;
|
||||
}
|
||||
|
||||
export function parseDevs() {
|
||||
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest);
|
||||
export async function parseDevs() {
|
||||
const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
|
||||
|
||||
for (const child of file.getChildAt(0).getChildren()) {
|
||||
if (!isVariableStatement(child)) continue;
|
||||
|
|
@ -100,8 +99,8 @@ export function parseDevs() {
|
|||
throw new Error("Could not find Devs constant");
|
||||
}
|
||||
|
||||
export function parseEquicordDevs() {
|
||||
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest);
|
||||
export async function parseEquicordDevs() {
|
||||
const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
|
||||
|
||||
for (const child of file.getChildAt(0).getChildren()) {
|
||||
if (!isVariableStatement(child)) continue;
|
||||
|
|
@ -132,7 +131,7 @@ export function parseEquicordDevs() {
|
|||
}
|
||||
|
||||
export async function parseFile(fileName: string) {
|
||||
const file = createSourceFile(fileName, await readFile(fileName, "utf8"), ScriptTarget.Latest);
|
||||
const file = createSourceFile(fileName, await Bun.file(fileName).text(), ScriptTarget.Latest);
|
||||
|
||||
const fail = (reason: string) => {
|
||||
return new Error(`Invalid plugin ${fileName}, because ${reason}`);
|
||||
|
|
@ -263,10 +262,7 @@ export async function getEntryPoint(dir: string, dirent: Dirent) {
|
|||
|
||||
for (const name of ["index.ts", "index.tsx"]) {
|
||||
const full = join(base, name);
|
||||
try {
|
||||
await access(full);
|
||||
return full;
|
||||
} catch { }
|
||||
if (await Bun.file(full).exists()) return full;
|
||||
}
|
||||
|
||||
throw new Error(`${dirent.name}: Couldn't find entry point`);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export default definePlugin({
|
|||
|
||||
start() {
|
||||
// if we're running the reporter, we need to initws in the reporter file to avoid a race condition
|
||||
if (!IS_DEV) throw new Error("This plugin requires dev mode to run, please build with pnpm build --dev");
|
||||
if (!IS_DEV) throw new Error("This plugin requires dev mode to run, please build with bun run build --dev");
|
||||
initWs();
|
||||
window.reconnectDevtools = () => {
|
||||
socket?.close(1000, "Reconnecting");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue