diff --git a/README.md b/README.md index 244ec2b..4d10a1d 100644 --- a/README.md +++ b/README.md @@ -145,10 +145,7 @@ B <--mcp--> m(MCP Server) 启动 dev server ```bash -## linux -./dev.sh -## windows -./dev.ps1 +npm run dev ``` > 端口占用: 8080 (renderer) + 8081 (service) @@ -163,11 +160,7 @@ B <--mcp--> m(MCP Server) 负载部署 ```bash -## linux -./build_service.sh - -## windows -./build_service.ps1 +npm run build ``` and just press f5, いただきます diff --git a/configure.ps1 b/configure.ps1 index 805146f..46ac414 100644 --- a/configure.ps1 +++ b/configure.ps1 @@ -1,17 +1,19 @@ -# 安装 renderer 依赖 -Set-Location renderer -npm i -Set-Location .. - -# 安装 service 依赖并打补丁 -Set-Location service -npm i -node patch-mcp-sdk.js -Set-Location .. +## 安装 renderer 依赖 +#Set-Location renderer +#npm i +#Set-Location .. +# +## 安装 service 依赖并打补丁 +#Set-Location service +#npm i +#node patch-mcp-sdk.js +#Set-Location .. Set-Location servers uv sync Set-Location .. # 安装根目录依赖 -npm i \ No newline at end of file +npm i + +npm run prepare:ocr diff --git a/configure.sh b/configure.sh index ec323d4..fdd35c1 100755 --- a/configure.sh +++ b/configure.sh @@ -1,5 +1,3 @@ -cd renderer && npm i && cd .. -cd service && npm i && cd .. -cd servers && uv sync +cd servers && uv sync && cd .. npm i -npm run prepare:ocr \ No newline at end of file +npm run prepare:ocr diff --git a/service/package.json b/service/package.json index 5d0686a..f189d85 100644 --- a/service/package.json +++ b/service/package.json @@ -10,6 +10,7 @@ "dev": "ts-node-dev --respawn --transpile-only src/main.ts", "build": "tsc", "build:watch": "tsc --watch", + "postbuild": "node ./scripts/post-build.mjs", "start": "node dist/main.js", "start:prod": "NODE_ENV=production node dist/main.js", "debug": "node --inspect -r ts-node/register src/main.ts", diff --git a/service/scripts/post-build.mjs b/service/scripts/post-build.mjs new file mode 100644 index 0000000..9ed7412 --- /dev/null +++ b/service/scripts/post-build.mjs @@ -0,0 +1,33 @@ +import fs from "node:fs"; +import process from "node:process"; +import fsPath from "node:path"; + +function createDirIfExists(filePath) { + if (!fs.existsSync(filePath)) { + fs.mkdirSync(filePath, { recursive: true }) + } +} + +function recreateDir(filePath) { + if (fs.existsSync(filePath)) { + fs.rmSync(filePath, { recursive: true, force: true }); + } + + fs.mkdirSync(filePath, { recursive: true }); +} + +const currentDir = process.cwd(); +const sourceDist = fsPath.join(currentDir, 'dist'); + +// 如果源目录不存在则报错 +if (!fs.existsSync(sourceDist)) { + throw new Error(`Source directory not found: ${sourceDist}`) +} +// electron目录 +const electronOpenMcpSdkPath = fsPath.join(currentDir, '..', 'software', 'openmcp-sdk'); +createDirIfExists(electronOpenMcpSdkPath); + +const electronServicePath = fsPath.join(electronOpenMcpSdkPath, 'service'); +recreateDir(electronServicePath); + +fs.cpSync(sourceDist, electronServicePath, { recursive: true }) diff --git a/software/src/main.ts b/software/src/main.ts index 8225e08..bbbdc87 100644 --- a/software/src/main.ts +++ b/software/src/main.ts @@ -1,5 +1,5 @@ import { app, BrowserWindow, ipcMain } from 'electron'; -import * as OpenMCPService from '@openmcp/service'; +import * as OpenMCPService from '../openmcp-sdk/service'; import * as path from 'path'; import { ElectronIPCLike, getInitConnectionOption, ILaunchSigature, updateConnectionOption } from './util';