chore:turbo config

This commit is contained in:
lirz 2025-05-08 21:24:01 +08:00 committed by lirun
parent 86cd49fae6
commit 72248864da
10 changed files with 97 additions and 27 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ resources/ocr/*.wasm
resources/renderer resources/renderer
resources/service resources/service
*.traineddata *.traineddata
.turbo

View File

@ -12,5 +12,8 @@
"typescript.tsc.autoDetect": "off", "typescript.tsc.autoDetect": "off",
"i18n-haru.root": "renderer/src/i18n", "i18n-haru.root": "renderer/src/i18n",
"i18n-haru.main": "zh" "i18n-haru.main": "zh",
"i18n-ally.localesPaths": [
"renderer/src/i18n"
]
} }

3
package-lock.json generated
View File

@ -10,8 +10,7 @@
"workspaces": [ "workspaces": [
"service", "service",
"renderer", "renderer",
"software", "software"
"packages/*"
], ],
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.10.2", "@modelcontextprotocol/sdk": "^1.10.2",

View File

@ -212,7 +212,16 @@
] ]
} }
}, },
"workspaces": [
"service",
"renderer",
"software"
],
"scripts": { "scripts": {
"dev": "turbo dev --filter=!@openmcp/electron",
"dev:electron": "turbo dev --filter=@openmcp/electron",
"dev:all": "turbo dev",
"build": "turbo build",
"vscode:prepublish": "webpack --mode production", "vscode:prepublish": "webpack --mode production",
"compile": "tsc -p ./", "compile": "tsc -p ./",
"watch": "tsc -watch -p ./", "watch": "tsc -watch -p ./",
@ -223,6 +232,7 @@
}, },
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.10.2", "@modelcontextprotocol/sdk": "^1.10.2",
"@openmcp/service": "*",
"@seald-io/nedb": "^4.1.1", "@seald-io/nedb": "^4.1.1",
"axios": "^1.7.7", "axios": "^1.7.7",
"bson": "^6.8.0", "bson": "^6.8.0",
@ -239,8 +249,10 @@
"@types/vscode": "^1.72.0", "@types/vscode": "^1.72.0",
"copy-webpack-plugin": "^13.0.0", "copy-webpack-plugin": "^13.0.0",
"ts-loader": "^9.5.1", "ts-loader": "^9.5.1",
"turbo": "^2.5.3",
"typescript": "^5.4.2", "typescript": "^5.4.2",
"webpack": "^5.99.5", "webpack": "^5.99.5",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
} },
"packageManager": "npm@10.0.0"
} }

View File

@ -3,8 +3,9 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "dev": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"postbuild": "node scripts/post-build.mjs",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {

View File

@ -2,8 +2,42 @@ import fsPath from 'node:path';
import fs from 'node:fs'; import fs from 'node:fs';
import * as process from "node:process"; import * as process from "node:process";
const cwd = process.cwd(); function createDirIfExists(filePath) {
const sdkPath = fsPath.join(cwd, 'openmcp-sdk'); if (!fs.existsSync(filePath)) {
console.log(cwd); fs.mkdirSync(filePath, { recursive: true })
// fs.rmSync(sdkPath, { recursive: true, force: true }); }
}
function recreateDir(filePath) {
if (fs.existsSync(filePath)) {
fs.rmSync(filePath, { recursive: true, force: true });
}
fs.mkdirSync(filePath, { recursive: true });
}
const currentDir = process.cwd();
// 确保上级目录的 openmcp-sdk 存在
const openMCPSdkPath = fsPath.join(currentDir, '..', 'openmcp-sdk')
createDirIfExists(openMCPSdkPath);
const sdkRenderPath = fsPath.join(openMCPSdkPath, 'renderer');
recreateDir(sdkRenderPath);
const sourceDist = fsPath.join(currentDir, 'dist');
// 如果源目录不存在则报错
if (!fs.existsSync(sourceDist)) {
throw new Error(`Source directory not found: ${sourceDist}`)
}
fs.cpSync(sourceDist, sdkRenderPath, { recursive: true })
// electron目录
const electronOpenMcpSdkPath = fsPath.join(currentDir, '..', 'software', 'openmcp-sdk');
createDirIfExists(electronOpenMcpSdkPath);
const electronRendererPath = fsPath.join(electronOpenMcpSdkPath, 'renderer');
recreateDir(electronRendererPath);
fs.cpSync(sourceDist, electronRendererPath, { recursive: true })

View File

@ -2,14 +2,12 @@
"name": "@openmcp/service", "name": "@openmcp/service",
"version": "0.0.1", "version": "0.0.1",
"description": "", "description": "",
"main": "./dist/index.js", "main": "dist/index.js",
"types": "./dist/index.d.ts", "types": "dist/index.d.ts",
"type": "commonjs", "type": "commonjs",
"exports": {
".": "./src/index.ts"
},
"scripts": { "scripts": {
"serve": "ts-node-dev --respawn --transpile-only src/main.ts", "postinstall": "npm run build",
"dev": "ts-node-dev --respawn --transpile-only src/main.ts",
"build": "tsc", "build": "tsc",
"build:watch": "tsc --watch", "build:watch": "tsc --watch",
"start": "node dist/main.js", "start": "node dist/main.js",

View File

@ -1,5 +1,5 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as OpenMCPService from '../openmcp-sdk/service'; import * as OpenMCPService from '@openmcp/service';
import { launch } from './common/entry'; import { launch } from './common/entry';
export function activate(context: vscode.ExtensionContext) { export function activate(context: vscode.ExtensionContext) {

View File

@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import * as fs from 'fs'; import * as fs from 'fs';
import * as fspath from 'path'; import * as fspath from 'path';
import { IConnectionItem, ILaunchSigature, panels, updateInstalledConnectionConfig, updateWorkspaceConnectionConfig } from '../global'; import { IConnectionItem, ILaunchSigature, panels, updateInstalledConnectionConfig, updateWorkspaceConnectionConfig } from '../global';
import * as OpenMCPService from '../../openmcp-sdk/service'; import * as OpenMCPService from '@openmcp/service';
export function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined { export function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined {
const viewRoot = fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer'); const viewRoot = fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer');

View File

@ -0,0 +1,22 @@
{
"$schema": "https://turborepo.com/schema.json",
"tasks": {
"dev": {
"persistent": true,
"cache": false
},
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"@openmcp/electron#dev": {
"dependsOn": ["@openmcp/renderer#build", "@openmcp/service#build"],
"persistent": true,
"cache": false
},
"@openmcp/electron#build": {
"dependsOn": ["@openmcp/renderer#build", "@openmcp/service#build"],
"outputs": ["dist/**"]
}
}
}