chore:turbo config
This commit is contained in:
parent
86cd49fae6
commit
72248864da
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,4 +13,5 @@ resources/ocr/*.js
|
||||
resources/ocr/*.wasm
|
||||
resources/renderer
|
||||
resources/service
|
||||
*.traineddata
|
||||
*.traineddata
|
||||
.turbo
|
||||
|
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@ -10,7 +10,10 @@
|
||||
},
|
||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||
"typescript.tsc.autoDetect": "off",
|
||||
|
||||
|
||||
"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
3
package-lock.json
generated
@ -10,8 +10,7 @@
|
||||
"workspaces": [
|
||||
"service",
|
||||
"renderer",
|
||||
"software",
|
||||
"packages/*"
|
||||
"software"
|
||||
],
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.10.2",
|
||||
|
14
package.json
14
package.json
@ -212,7 +212,16 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"workspaces": [
|
||||
"service",
|
||||
"renderer",
|
||||
"software"
|
||||
],
|
||||
"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",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
@ -223,6 +232,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.10.2",
|
||||
"@openmcp/service": "*",
|
||||
"@seald-io/nedb": "^4.1.1",
|
||||
"axios": "^1.7.7",
|
||||
"bson": "^6.8.0",
|
||||
@ -239,8 +249,10 @@
|
||||
"@types/vscode": "^1.72.0",
|
||||
"copy-webpack-plugin": "^13.0.0",
|
||||
"ts-loader": "^9.5.1",
|
||||
"turbo": "^2.5.3",
|
||||
"typescript": "^5.4.2",
|
||||
"webpack": "^5.99.5",
|
||||
"webpack-cli": "^5.1.4"
|
||||
}
|
||||
},
|
||||
"packageManager": "npm@10.0.0"
|
||||
}
|
||||
|
@ -3,8 +3,9 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"dev": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"postbuild": "node scripts/post-build.mjs",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -2,8 +2,42 @@ import fsPath from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import * as process from "node:process";
|
||||
|
||||
const cwd = process.cwd();
|
||||
const sdkPath = fsPath.join(cwd, 'openmcp-sdk');
|
||||
console.log(cwd);
|
||||
// fs.rmSync(sdkPath, { recursive: true, force: true });
|
||||
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();
|
||||
// 确保上级目录的 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 })
|
||||
|
@ -2,14 +2,12 @@
|
||||
"name": "@openmcp/service",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"type": "commonjs",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"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:watch": "tsc --watch",
|
||||
"start": "node dist/main.js",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as OpenMCPService from '../openmcp-sdk/service';
|
||||
import * as OpenMCPService from '@openmcp/service';
|
||||
import { launch } from './common/entry';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
@ -19,4 +19,4 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
export function deactivate() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,18 @@ import * as vscode from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
import * as fspath from 'path';
|
||||
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 {
|
||||
const viewRoot = fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer');
|
||||
const htmlIndexPath = fspath.join(viewRoot, 'index.html');
|
||||
const html = fs.readFileSync(htmlIndexPath, { encoding: 'utf-8' })?.replace(/(<link.+?href="|<script.+?src="|<img.+?src="|url\()(.+?)(\)|")/g, (m, $1, $2) => {
|
||||
const absLocalPath = fspath.resolve(viewRoot, $2);
|
||||
const absLocalPath = fspath.resolve(viewRoot, $2);
|
||||
const webviewUri = panel.webview.asWebviewUri(vscode.Uri.file(absLocalPath));
|
||||
|
||||
const replaceHref = $1 + webviewUri?.toString() + '"';
|
||||
return replaceHref;
|
||||
});
|
||||
});
|
||||
return html;
|
||||
}
|
||||
|
||||
@ -56,9 +56,9 @@ export function revealOpenMcpWebviewPanel(
|
||||
|
||||
|
||||
// 设置HTML内容
|
||||
const html = getWebviewContent(context, panel);
|
||||
const html = getWebviewContent(context, panel);
|
||||
panel.webview.html = html || '';
|
||||
panel.iconPath = vscode.Uri.file(fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer', 'images', 'openmcp.png'));
|
||||
panel.iconPath = vscode.Uri.file(fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer', 'images', 'openmcp.png'));
|
||||
|
||||
// 处理来自webview的消息
|
||||
panel.webview.onDidReceiveMessage(message => {
|
||||
@ -79,7 +79,7 @@ export function revealOpenMcpWebviewPanel(
|
||||
url: option.url,
|
||||
oauth: option.oauth || ''
|
||||
};
|
||||
|
||||
|
||||
const launchResult = {
|
||||
code: 200,
|
||||
msg: launchResultMessage
|
||||
@ -91,7 +91,7 @@ export function revealOpenMcpWebviewPanel(
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'vscode/update-connection-sigature':
|
||||
if (type === 'installed') {
|
||||
updateInstalledConnectionConfig(panelKey, data);
|
||||
@ -101,7 +101,7 @@ export function revealOpenMcpWebviewPanel(
|
||||
break;
|
||||
|
||||
default:
|
||||
OpenMCPService.routeMessage(command, data, panel.webview);
|
||||
OpenMCPService.routeMessage(command, data, panel.webview);
|
||||
break;
|
||||
}
|
||||
|
||||
|
22
turbo.json
22
turbo.json
@ -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/**"]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user