From ceedab457f4738b7b5973a0afb1178137ed7a998 Mon Sep 17 00:00:00 2001 From: Raboneko <119771935+raboneko@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:10:24 -0700 Subject: [PATCH] fix: arrpc (#1115) (#1129) Add suppport for esbuild / node20 Close #1114 (cherry picked from commit e6d6774339fac28542615ef8079b5517aa05c9ca) Co-authored-by: madomado --- .../misc/arrpc/0001-fix-support-esbuild.patch | 31 +++++++++++++++++++ anda/misc/arrpc/arrpc.spec | 11 ++++--- 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 anda/misc/arrpc/0001-fix-support-esbuild.patch diff --git a/anda/misc/arrpc/0001-fix-support-esbuild.patch b/anda/misc/arrpc/0001-fix-support-esbuild.patch new file mode 100644 index 0000000000..28e7183fae --- /dev/null +++ b/anda/misc/arrpc/0001-fix-support-esbuild.patch @@ -0,0 +1,31 @@ +From db29e1ce9f1a2b6b2ac3ef9df8b8b8524ab895f9 Mon Sep 17 00:00:00 2001 +From: madomado +Date: Mon, 29 Apr 2024 21:29:01 +0800 +Subject: [PATCH] fix: support esbuild + +--- + src/process/index.js | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +diff --git a/src/process/index.js b/src/process/index.js +index 97ea651..f5486ca 100644 +--- a/src/process/index.js ++++ b/src/process/index.js +@@ -1,13 +1,7 @@ + const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`; + const log = (...args) => console.log(`[${rgb(88, 101, 242, 'arRPC')} > ${rgb(237, 66, 69, 'process')}]`, ...args); + +-import fs from 'node:fs'; +-import { dirname, join } from 'path'; +-import { fileURLToPath } from 'url'; +- +-const __dirname = dirname(fileURLToPath(import.meta.url)); +-const DetectableDB = JSON.parse(fs.readFileSync(join(__dirname, 'detectable.json'), 'utf8')); +- ++import DetectableDB from './detectable.json' with { type: "json" }; + import * as Natives from './native/index.js'; + const Native = Natives[process.platform]; + +-- +2.44.0 + diff --git a/anda/misc/arrpc/arrpc.spec b/anda/misc/arrpc/arrpc.spec index a9802da434..f08773510a 100644 --- a/anda/misc/arrpc/arrpc.spec +++ b/anda/misc/arrpc/arrpc.spec @@ -4,12 +4,13 @@ Name: arrpc Version: 3.4.0 -Release: 1%?dist +Release: 2%?dist Summary: Open Discord RPC server for atypical setups License: MIT URL: https://arrpc.openasar.dev Source0: https://github.com/OpenAsar/arrpc/archive/%commit.tar.gz Source1: arrpc.service +Patch0: 0001-fix-support-esbuild.patch Requires: glibc BuildRequires: nodejs-npm systemd-rpm-macros @@ -21,15 +22,15 @@ server which messages the JSON of exactly what to dispatch with in the client wi allowing small and simple mods or plugins. arRPC is experimental and a work in progress, so expect bugs, etc. %prep -%autosetup -n arrpc-%commit +%autosetup -n arrpc-%commit -p1 # patch for using esbuild sed -i -E 's@const server[^\n]+;@async function main() {\0@' src/index.js sed -i -E 's@server\.on[^\n]+;@\0}\nmain();@' src/index.js %build -npm i esbuild pkg -npx esbuild --bundle --platform=node --target=node18 --outdir=dist ./src/index.js -npx pkg -t node18-linux-x64 -o arrpc ./dist/index.js +npm i esbuild @yao-pkg/pkg +npx esbuild --bundle --platform=node --target=node20 --outdir=dist ./src/index.js +npx pkg -t node20-linux-x64 -o arrpc ./dist/index.js %install install -D -m755 arrpc %buildroot%_bindir/arrpc