fix: 修复无法启动问题
This commit is contained in:
@@ -30,7 +30,7 @@ program
|
||||
process.env.PORT = options.port;
|
||||
|
||||
// 启动服务
|
||||
const serverPath = path.join(__dirname, '..', 'src', 'index.js');
|
||||
const serverPath = path.join(__dirname, '..', 'dist', 'index.js');
|
||||
spawn('node', [serverPath], { stdio: 'inherit' });
|
||||
});
|
||||
|
||||
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hula-spark/hula-mcp",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "HuLa 即时通讯应用的 MCP 服务",
|
||||
"type": "module",
|
||||
"license": "Apache-2.0",
|
||||
@@ -14,16 +14,16 @@
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bin",
|
||||
"src",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "tsc && node scripts/copy-js.js",
|
||||
"start": "node bin/hula-mcp.js start",
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"test": "jest",
|
||||
"prepublishOnly": "npm run build",
|
||||
"prepare": "npm run build"
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [
|
||||
"mcp",
|
||||
|
||||
51
scripts/copy-js.js
Normal file
51
scripts/copy-js.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const srcDir = path.join(__dirname, '..', 'src');
|
||||
const distDir = path.join(__dirname, '..', 'dist');
|
||||
|
||||
async function copyJsFiles(dir) {
|
||||
const entries = await fs.readdir(dir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(dir, entry.name);
|
||||
const relativePath = path.relative(srcDir, srcPath);
|
||||
const destPath = path.join(distDir, relativePath);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await fs.mkdir(destPath, { recursive: true }).catch(() => {});
|
||||
await copyJsFiles(srcPath);
|
||||
} else if (entry.name.endsWith('.js')) {
|
||||
await fs.copyFile(srcPath, destPath).catch(err => {
|
||||
if (err.code !== 'ENOENT') throw err;
|
||||
console.error(`无法复制文件: ${srcPath}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除所有 .map 文件的函数
|
||||
async function removeMapFiles(dir) {
|
||||
const entries = await fs.readdir(dir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await removeMapFiles(fullPath);
|
||||
} else if (entry.name.endsWith('.map')) {
|
||||
await fs.unlink(fullPath);
|
||||
console.log(`已删除: ${fullPath}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 执行复制和清理操作
|
||||
async function main() {
|
||||
await copyJsFiles(srcDir);
|
||||
await removeMapFiles(distDir);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -1,5 +1,5 @@
|
||||
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { Message, Conversation } from '../types.ts';
|
||||
import { Message, Conversation } from '../types.js';
|
||||
|
||||
// 模拟数据
|
||||
const mockMessages: Message[] = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { Group } from '../types.ts';
|
||||
import { Group } from '../types.js';
|
||||
|
||||
// 模拟数据 - 在实际应用中,这些数据应该从数据库中获取
|
||||
const mockGroups: Group[] = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { User } from '../types.ts';
|
||||
import { User } from '../types.js';
|
||||
|
||||
// 模拟数据 - 在实际应用中,这些数据应该从数据库中获取
|
||||
const mockUsers: User[] = [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { z } from 'zod';
|
||||
import { Message } from '../types.ts';
|
||||
import { Message } from '../types.js';
|
||||
|
||||
// 生成唯一ID的辅助函数
|
||||
function generateId(prefix: string): string {
|
||||
|
||||
@@ -6,20 +6,19 @@
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"outDir": "./dist",
|
||||
"sourceMap": true,
|
||||
"sourceMap": false,
|
||||
"declaration": true,
|
||||
"resolveJsonModule": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"allowJs": true
|
||||
},
|
||||
"ts-node": {
|
||||
"esm": true,
|
||||
"experimentalSpecifierResolution": "node"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"include": ["src/**/*.ts", "src/**/*.js"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user