mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-07-01 10:02:57 +08:00
feat: use cross-spawn
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import express from 'express';
|
|||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
import sqlite3 from 'sqlite3';
|
import sqlite3 from 'sqlite3';
|
||||||
import { open } from 'sqlite';
|
import { open } from 'sqlite';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { extractProjectDirectory } from '../../../projects.js';
|
import { extractProjectDirectory } from '../../../projects.js';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import path from 'path';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
@@ -17,10 +17,6 @@ router.get('/cli/list', async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
console.log('📋 Listing MCP servers using Claude CLI');
|
console.log('📋 Listing MCP servers using Claude CLI');
|
||||||
|
|
||||||
const { spawn } = await import('child_process');
|
|
||||||
const { promisify } = await import('util');
|
|
||||||
const exec = promisify(spawn);
|
|
||||||
|
|
||||||
const process = spawn('claude', ['mcp', 'list'], {
|
const process = spawn('claude', ['mcp', 'list'], {
|
||||||
stdio: ['pipe', 'pipe', 'pipe']
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
});
|
});
|
||||||
@@ -62,8 +58,6 @@ router.post('/cli/add', async (req, res) => {
|
|||||||
|
|
||||||
console.log(`➕ Adding MCP server using Claude CLI (${scope} scope):`, name);
|
console.log(`➕ Adding MCP server using Claude CLI (${scope} scope):`, name);
|
||||||
|
|
||||||
const { spawn } = await import('child_process');
|
|
||||||
|
|
||||||
let cliArgs = ['mcp', 'add'];
|
let cliArgs = ['mcp', 'add'];
|
||||||
|
|
||||||
// Add scope flag
|
// Add scope flag
|
||||||
@@ -178,8 +172,6 @@ router.post('/cli/add-json', async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { spawn } = await import('child_process');
|
|
||||||
|
|
||||||
// Build the command: claude mcp add-json --scope <scope> <name> '<json>'
|
// Build the command: claude mcp add-json --scope <scope> <name> '<json>'
|
||||||
const cliArgs = ['mcp', 'add-json', '--scope', scope, name];
|
const cliArgs = ['mcp', 'add-json', '--scope', scope, name];
|
||||||
|
|
||||||
@@ -250,8 +242,6 @@ router.delete('/cli/remove/:name', async (req, res) => {
|
|||||||
|
|
||||||
console.log('🗑️ Removing MCP server using Claude CLI:', actualName, 'scope:', actualScope);
|
console.log('🗑️ Removing MCP server using Claude CLI:', actualName, 'scope:', actualScope);
|
||||||
|
|
||||||
const { spawn } = await import('child_process');
|
|
||||||
|
|
||||||
// Build command args based on scope
|
// Build command args based on scope
|
||||||
let cliArgs = ['mcp', 'remove'];
|
let cliArgs = ['mcp', 'remove'];
|
||||||
|
|
||||||
@@ -308,8 +298,6 @@ router.get('/cli/get/:name', async (req, res) => {
|
|||||||
|
|
||||||
console.log('📄 Getting MCP server details using Claude CLI:', name);
|
console.log('📄 Getting MCP server details using Claude CLI:', name);
|
||||||
|
|
||||||
const { spawn } = await import('child_process');
|
|
||||||
|
|
||||||
const process = spawn('claude', ['mcp', 'get', name], {
|
const process = spawn('claude', ['mcp', 'get', name], {
|
||||||
stdio: ['pipe', 'pipe', 'pipe']
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import express from 'express';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
import { authenticateToken } from '../auth/auth.middleware.js';
|
import { authenticateToken } from '../auth/auth.middleware.js';
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import express from 'express';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { promises as fsPromises } from 'fs';
|
import { promises as fsPromises } from 'fs';
|
||||||
import { spawn } from 'child_process';
|
import spawn from 'cross-spawn';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
@@ -474,7 +474,6 @@ router.get('/next/:projectName', async (req, res) => {
|
|||||||
|
|
||||||
// Try to execute task-master next command
|
// Try to execute task-master next command
|
||||||
try {
|
try {
|
||||||
const { spawn } = await import('child_process');
|
|
||||||
|
|
||||||
const nextTaskCommand = spawn('task-master', ['next'], {
|
const nextTaskCommand = spawn('task-master', ['next'], {
|
||||||
cwd: projectPath,
|
cwd: projectPath,
|
||||||
|
|||||||
Reference in New Issue
Block a user