From 6fc7a564e85fc8e60e2d096e48f624f058f4d396 Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Sat, 2 Nov 2024 17:08:22 -0700 Subject: [PATCH] Remove unused dependencies. (#170) * Local todesktop publish. * Remove unused packages: ws and update-electron. * update yarn lock. * update. * test --- package.json | 4 +-- scripts/preMake.js | 2 +- scripts/todesktop/afterPack.js | 2 +- scripts/todesktop/postInstall.js | 2 +- src/__tests__/unit/main.test.ts | 8 ----- src/main.ts | 2 -- todesktop.json | 15 ++------- yarn.lock | 54 -------------------------------- 8 files changed, 7 insertions(+), 82 deletions(-) diff --git a/package.json b/package.json index 4f41ccff..0c91735c 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "test:update-snapshots": "npx playwright test --update-snapshots", "todesktop:afterPack": "./scripts/todesktop/afterPack.js", "todesktop:beforeInstall": "./scripts/todesktop/beforeInstall.js", + "todesktop:postInstall": "./scripts/todesktop/postInstall.js", "typescript": "yarn run tsc", "vite:compile": "vite build --config vite.renderer.config.ts && vite build --config vite.main.config.ts && vite build --config vite.preload.config.ts" }, @@ -54,7 +55,6 @@ "@types/react": "^18.3.4", "@types/react-dom": "^18.3.0", "@types/tar": "6.1.13", - "@types/ws": "^8.5.12", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", "electron": "31.3.1", @@ -90,8 +90,6 @@ "react-dom": "^18.3.1", "systeminformation": "^5.23.5", "tar": "^7.4.3", - "update-electron-app": "^3.0.0", - "ws": "^8.18.0", "yaml": "^2.6.0" }, "lint-staged": { diff --git a/scripts/preMake.js b/scripts/preMake.js index 3a3fd84f..c82b2f86 100644 --- a/scripts/preMake.js +++ b/scripts/preMake.js @@ -36,4 +36,4 @@ module.exports = async ({ appOutDir, packager, outDir }) => { } console.log(">PREMAKE FINISH<"); -} \ No newline at end of file +} diff --git a/scripts/todesktop/afterPack.js b/scripts/todesktop/afterPack.js index bf265ba1..74b18cbf 100644 --- a/scripts/todesktop/afterPack.js +++ b/scripts/todesktop/afterPack.js @@ -34,4 +34,4 @@ module.exports = async ({ appOutDir, packager, outDir }) => { const resourcePath = path.join(path.dirname(appPath), "resources"); await fs.cp(assetPath, resourcePath, { recursive: true }); } -} \ No newline at end of file +} diff --git a/scripts/todesktop/postInstall.js b/scripts/todesktop/postInstall.js index 38bab8ad..3c2d0810 100644 --- a/scripts/todesktop/postInstall.js +++ b/scripts/todesktop/postInstall.js @@ -41,4 +41,4 @@ async function postInstall() { } }; -postInstall(); \ No newline at end of file +postInstall(); diff --git a/src/__tests__/unit/main.test.ts b/src/__tests__/unit/main.test.ts index 144348e8..a79d2e41 100644 --- a/src/__tests__/unit/main.test.ts +++ b/src/__tests__/unit/main.test.ts @@ -81,14 +81,6 @@ jest.mock('electron-log/main', () => ({ // Add other methods you might use from electron-log })); -// Mock the update-electron-app module -jest.mock('update-electron-app', () => ({ - updateElectronApp: jest.fn(), - UpdateSourceType: { - StaticStorage: 'StaticStorage', - }, -})); - describe('createWindow', () => { // it('should create a new BrowserWindow with correct options', async () => { // const window = await createWindow('/'); diff --git a/src/main.ts b/src/main.ts index 50ea8674..423f03b5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,7 +18,6 @@ import Store from 'electron-store'; import * as net from 'net'; import { graphics } from 'systeminformation'; import { createModelConfigFiles, readBasePathFromConfig } from './config/extra_model_config'; -import { WebSocketServer } from 'ws'; import { StoreType } from './store'; import todesktop from '@todesktop/runtime'; import { PythonEnvironment } from './pythonEnvironment'; @@ -31,7 +30,6 @@ let isRestarting: boolean = false; // Prevents double restarts TODO(robinhuang): const host = '127.0.0.1'; let port = 8188; let mainWindow: BrowserWindow | null = null; -let wss: WebSocketServer | null; let store: Store | null = null; const messageQueue: Array = []; // Stores mesaages before renderer is ready. let downloadManager: DownloadManager; diff --git a/todesktop.json b/todesktop.json index 0e175e81..60f66700 100644 --- a/todesktop.json +++ b/todesktop.json @@ -4,16 +4,7 @@ "schemaVersion": 1, "uploadSizeLimit": 250, "appPath": ".", - "appFiles": ["src/**", "scripts/**", "assets/**", "dist/**", ".vite/**", ".yarnrc.yml", ".yarn/**"], - "extraResources": [{ "from": "./assets" }], - "filesForDistribution": ["!assets/**", "!dist/**", "!src/**", "!scripts/**", "!.yarn/**", "!.yarnrc.yml"], - "mac": { - "additionalBinariesToSign": [ - "./assets/output/lib/libpython3.12.dylib", - "./assets/output/lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so", - "./assets/output/bin/uv", - "./assets/output/bin/uvx", - "./assets/output/bin/python3.12" - ] - } + "appFiles": ["src/**", "scripts/**", "assets/UI/**", ".vite/**", ".yarnrc.yml", ".yarn/**"], + "extraResources": [{ "from": "./assets/UI" }], + "filesForDistribution": ["!assets/**", "!dist/**", "!src/**", "!scripts/**", "!.yarn/**", "!.yarnrc.yml"] } diff --git a/yarn.lock b/yarn.lock index 44442950..a47e26ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3281,15 +3281,6 @@ __metadata: languageName: node linkType: hard -"@types/ws@npm:^8.5.12": - version: 8.5.12 - resolution: "@types/ws@npm:8.5.12" - dependencies: - "@types/node": "npm:*" - checksum: 10c0/3fd77c9e4e05c24ce42bfc7647f7506b08c40a40fe2aea236ef6d4e96fc7cb4006a81ed1b28ec9c457e177a74a72924f4768b7b4652680b42dfd52bc380e15f9 - languageName: node - linkType: hard - "@types/yargs-parser@npm:*": version: 21.0.3 resolution: "@types/yargs-parser@npm:21.0.3" @@ -4864,7 +4855,6 @@ __metadata: "@types/react": "npm:^18.3.4" "@types/react-dom": "npm:^18.3.0" "@types/tar": "npm:6.1.13" - "@types/ws": "npm:^8.5.12" "@typescript-eslint/eslint-plugin": "npm:^5.0.0" "@typescript-eslint/parser": "npm:^5.0.0" adm-zip: "npm:^0.5.15" @@ -4888,9 +4878,7 @@ __metadata: ts-jest: "npm:^29.2.5" ts-node: "npm:^10.0.0" typescript: "npm:~5.5.4" - update-electron-app: "npm:^3.0.0" vite: "npm:^5.0.12" - ws: "npm:^8.18.0" yaml: "npm:^2.6.0" languageName: unknown linkType: soft @@ -6750,15 +6738,6 @@ __metadata: languageName: node linkType: hard -"github-url-to-object@npm:^4.0.4": - version: 4.0.6 - resolution: "github-url-to-object@npm:4.0.6" - dependencies: - is-url: "npm:^1.1.0" - checksum: 10c0/b8ed9b2b93c55657299b7cc5ce9faf4441f143e59f995e126929d18f8fc692fc932d8530da9bde7655f35b29201beacbc17b066b7e26dbcc0dc983f8d3c918cf - languageName: node - linkType: hard - "glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" @@ -7790,13 +7769,6 @@ __metadata: languageName: node linkType: hard -"is-url@npm:^1.1.0, is-url@npm:^1.2.4": - version: 1.2.4 - resolution: "is-url@npm:1.2.4" - checksum: 10c0/0157a79874f8f95fdd63540e3f38c8583c2ef572661cd0693cda80ae3e42dfe8e9a4a972ec1b827f861d9a9acf75b37f7d58a37f94a8a053259642912c252bc3 - languageName: node - linkType: hard - "is-weakref@npm:^1.0.2": version: 1.0.2 resolution: "is-weakref@npm:1.0.2" @@ -12212,17 +12184,6 @@ __metadata: languageName: node linkType: hard -"update-electron-app@npm:^3.0.0": - version: 3.0.0 - resolution: "update-electron-app@npm:3.0.0" - dependencies: - github-url-to-object: "npm:^4.0.4" - is-url: "npm:^1.2.4" - ms: "npm:^2.1.1" - checksum: 10c0/5e0b9ce8fd2cbcf6ea64d8029f90d90394facf05d86c8dceda5dba79af6e21522ef4f37f212982be781f488d497882529d9b11b91174159f6567a24039c76e6a - languageName: node - linkType: hard - "uri-js@npm:^4.2.2": version: 4.4.1 resolution: "uri-js@npm:4.4.1" @@ -12577,21 +12538,6 @@ __metadata: languageName: node linkType: hard -"ws@npm:^8.18.0": - version: 8.18.0 - resolution: "ws@npm:8.18.0" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 10c0/25eb33aff17edcb90721ed6b0eb250976328533ad3cd1a28a274bd263682e7296a6591ff1436d6cbc50fa67463158b062f9d1122013b361cec99a05f84680e06 - languageName: node - linkType: hard - "xcode@npm:3.0.1": version: 3.0.1 resolution: "xcode@npm:3.0.1"