From 6ac1111a50d53fec65505f6219edc925ace5ccb8 Mon Sep 17 00:00:00 2001 From: TautCony Date: Mon, 8 Jan 2024 20:19:14 +0800 Subject: [PATCH] feat: add bun support --- .gitattributes | 3 +++ setup/dashboard/ws/package-lock.json | 21 ++++++++++++++++++++ setup/dashboard/ws/package.json | 1 + setup/dashboard/ws/src/widgets/disk_data.tsx | 2 +- setup/dashboard/ws/tests/test-server.js | 2 +- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 5d015665..d00363e7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,3 +19,6 @@ setup/templates/**/* text eol=lf *.ttf binary *.woff binary *.woff2 binary + +# config for bun lock file +*.lockb binary diff=lockb diff --git a/setup/dashboard/ws/package-lock.json b/setup/dashboard/ws/package-lock.json index 9985a5fd..33861f1b 100644 --- a/setup/dashboard/ws/package-lock.json +++ b/setup/dashboard/ws/package-lock.json @@ -29,6 +29,7 @@ "@types/node": "^20.10.7", "@types/react": "^18.2.47", "@types/react-dom": "^18.2.18", + "@types/webpack-node-externals": "^3.0.4", "@types/which": "^3.0.3", "@types/ws": "^8.5.10", "@typescript-eslint/eslint-plugin": "^6.18.0", @@ -969,6 +970,16 @@ "@types/node": "*" } }, + "node_modules/@types/webpack-node-externals": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/webpack-node-externals/-/webpack-node-externals-3.0.4.tgz", + "integrity": "sha512-8Z3/edqxE3RRlOJwKSgOFxLZRt/i1qFlv/Bi308ZUKo9jh8oGngd9r8GR0ZNKW5AEJq8QNQE3b17CwghTjQ0Uw==", + "dev": true, + "dependencies": { + "@types/node": "*", + "webpack": "^5" + } + }, "node_modules/@types/which": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.3.tgz", @@ -6423,6 +6434,16 @@ "@types/node": "*" } }, + "@types/webpack-node-externals": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/webpack-node-externals/-/webpack-node-externals-3.0.4.tgz", + "integrity": "sha512-8Z3/edqxE3RRlOJwKSgOFxLZRt/i1qFlv/Bi308ZUKo9jh8oGngd9r8GR0ZNKW5AEJq8QNQE3b17CwghTjQ0Uw==", + "dev": true, + "requires": { + "@types/node": "*", + "webpack": "^5" + } + }, "@types/which": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.3.tgz", diff --git a/setup/dashboard/ws/package.json b/setup/dashboard/ws/package.json index 9b57d510..477d972f 100644 --- a/setup/dashboard/ws/package.json +++ b/setup/dashboard/ws/package.json @@ -37,6 +37,7 @@ "@types/node": "^20.10.7", "@types/react": "^18.2.47", "@types/react-dom": "^18.2.18", + "@types/webpack-node-externals": "^3.0.4", "@types/which": "^3.0.3", "@types/ws": "^8.5.10", "@typescript-eslint/eslint-plugin": "^6.18.0", diff --git a/setup/dashboard/ws/src/widgets/disk_data.tsx b/setup/dashboard/ws/src/widgets/disk_data.tsx index 57e079d7..773adf60 100644 --- a/setup/dashboard/ws/src/widgets/disk_data.tsx +++ b/setup/dashboard/ws/src/widgets/disk_data.tsx @@ -85,7 +85,7 @@ async function renderTorrentInfo() { ); - const ret = []; + const ret: React.JSX.Element[] = []; if (await processExists("rtorrent", username) && await exists("/install/.rtorrent.lock")) { const rtorrents = await countTorrent(`/home/.${username}/.sessions/`); diff --git a/setup/dashboard/ws/tests/test-server.js b/setup/dashboard/ws/tests/test-server.js index 300a0c1e..64607aaa 100644 --- a/setup/dashboard/ws/tests/test-server.js +++ b/setup/dashboard/ws/tests/test-server.js @@ -10,7 +10,7 @@ php.stdout.on('data', (data) => process.stdout.write(`[PHP::OUT::STD] ${data}`)) php.stderr.on('data', (data) => process.stderr.write(`[PHP::OUT::ERR] ${data}`)); php.on('exit', (code) => console.log(`php exited with code ${code}`)); -const ws = spawn('node', [path.join(__dirname, '..', 'dist', 'server.js')]); +const ws = spawn('bun', [path.join(__dirname, '..', 'src', 'server.tsx')]); ws.stdout.on('data', (data) => process.stdout.write(`[NODE::OUT::STD] ${data}`)); ws.stderr.on('data', (data) => process.stderr.write(`[NODE::OUT::ERR] ${data}`)); ws.on('exit', (code) => console.log(`node exited with code ${code}`));