diff --git a/build-config/dependencies-patch.js b/build-config/dependencies-patch.js new file mode 100644 index 00000000..f4f1e1f4 --- /dev/null +++ b/build-config/dependencies-patch.js @@ -0,0 +1,38 @@ +// 修补依赖源码以使vite构建的依赖恢复正常工作 + +const fs = require('node:fs') +const path = require('node:path') + +const rootPath = path.join(__dirname, '../') + +const patchs = [ + [ + path.join(rootPath, './node_modules/ws/package.json'), + '\n "browser": "./browser.js",', + '', + ], + [ + path.join(rootPath, './node_modules/music-metadata/package.json'), + '"default": "./lib/core.js"', + '"default": "./lib/index.js"', + ], + [ + path.join(rootPath, './node_modules/strtok3/package.json'), + '"default": "./lib/core.js"', + '"default": "./lib/index.js"', + ], +] + +;(async() => { + for (const [filePath, fromStr, toStr] of patchs) { + console.log(`Patching ${filePath.replace(rootPath, '')}`) + try { + const file = (await fs.promises.readFile(filePath)).toString() + await fs.promises.writeFile(filePath, file.replace(fromStr, toStr)) + } catch (err) { + console.error(`Patch ${filePath.replace(rootPath, '')} failed: ${err.message}`) + } + } + console.log('\nDependencies patch finished.\n') +})() + diff --git a/package-lock.json b/package-lock.json index 15fbb75b..d69965da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lx-music-desktop", - "version": "2.4.0-beta.4", + "version": "2.4.0-beta.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lx-music-desktop", - "version": "2.4.0-beta.4", + "version": "2.4.0-beta.5", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -31,7 +31,7 @@ "utf-8-validate": "^6.0.3", "vue": "~3.2.47", "vue-router": "^4.2.4", - "ws": "github:lyswhut/ws#76966d23e9b610422d8395cdd3a6b1ca0e1f25c4" + "ws": "^8.13.0" }, "devDependencies": { "@babel/core": "^7.22.9", @@ -6960,9 +6960,9 @@ } }, "node_modules/file-type": { - "version": "18.2.1", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.2.1.tgz", - "integrity": "sha512-Yw5MtnMv7vgD2/6Bjmmuegc8bQEVA9GmAyaR18bMYWKqsWDG9wgYZ1j4I6gNMF5Y5JBDcUcjRQqNQx7Y8uotcg==", + "version": "18.5.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.5.0.tgz", + "integrity": "sha512-yvpl5U868+V6PqXHMmsESpg6unQ5GfnPssl4dxdJudBrr9qy7Fddt7EVX1VLlddFfe8Gj9N7goCZH22FXuSQXQ==", "dependencies": { "readable-web-to-node-stream": "^3.0.2", "strtok3": "^7.0.0", @@ -12791,9 +12791,8 @@ }, "node_modules/ws": { "version": "8.13.0", - "resolved": "git+ssh://git@github.com/lyswhut/ws.git#76966d23e9b610422d8395cdd3a6b1ca0e1f25c4", - "integrity": "sha512-cdckvFUwVOy8HY+OpaFNB6ydNNzNdWJV89fyUSn6WvzVvfo93tvU/IxLCpu8TVjMj9HJ+Wd3s6duGuH46u6slw==", - "license": "MIT", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", "engines": { "node": ">=10.0.0" }, @@ -17890,9 +17889,9 @@ } }, "file-type": { - "version": "18.2.1", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.2.1.tgz", - "integrity": "sha512-Yw5MtnMv7vgD2/6Bjmmuegc8bQEVA9GmAyaR18bMYWKqsWDG9wgYZ1j4I6gNMF5Y5JBDcUcjRQqNQx7Y8uotcg==", + "version": "18.5.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.5.0.tgz", + "integrity": "sha512-yvpl5U868+V6PqXHMmsESpg6unQ5GfnPssl4dxdJudBrr9qy7Fddt7EVX1VLlddFfe8Gj9N7goCZH22FXuSQXQ==", "requires": { "readable-web-to-node-stream": "^3.0.2", "strtok3": "^7.0.0", @@ -22318,9 +22317,9 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "ws": { - "version": "git+ssh://git@github.com/lyswhut/ws.git#76966d23e9b610422d8395cdd3a6b1ca0e1f25c4", - "integrity": "sha512-cdckvFUwVOy8HY+OpaFNB6ydNNzNdWJV89fyUSn6WvzVvfo93tvU/IxLCpu8TVjMj9HJ+Wd3s6duGuH46u6slw==", - "from": "ws@github:lyswhut/ws#76966d23e9b610422d8395cdd3a6b1ca0e1f25c4", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", "requires": {} }, "xml-name-validator": { diff --git a/package.json b/package.json index c8c19ffa..df9f9327 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lx-music-desktop", - "version": "2.4.0-beta.4", + "version": "2.4.0-beta.5", "description": "一个免费的音乐查找助手", "main": "./dist/main/main.js", "productName": "lx-music-desktop", @@ -59,7 +59,7 @@ "build": "ts-node build-config/pack.js", "lint": "eslint --ext .ts,.js,.vue src", "lint:fix": "eslint --ext .ts,.js,.vue --fix src", - "postinstall": "electron-builder install-app-deps", + "postinstall": "node ./build-config/dependencies-patch.js && electron-builder install-app-deps", "dp": "cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://127.0.0.1:2081 npm run pack", "up": "cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://127.0.0.1:2081 npm i" }, @@ -270,7 +270,7 @@ "utf-8-validate": "^6.0.3", "vue": "~3.2.47", "vue-router": "^4.2.4", - "ws": "github:lyswhut/ws#76966d23e9b610422d8395cdd3a6b1ca0e1f25c4" + "ws": "^8.13.0" }, "overrides": { "got": "^11",