UNPKG

figma-restoration-tools

Version:

Professional Figma Component Restoration Kit - MCP tools with snapDOM-powered high-quality screenshots, intelligent shadow detection, and smart debugging for Vue component restoration. Includes figma_compare and snapdom_screenshot tools.

136 lines (109 loc) • 3.69 kB
#!/usr/bin/env node import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; import { spawn } from 'child_process'; import fs from 'fs/promises'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const packageRoot = join(__dirname, '..'); const commands = { 'install-puppeteer': async () => { console.log('šŸ”§ Installing Puppeteer...'); const scriptPath = join(packageRoot, 'scripts', 'install-puppeteer.js'); const child = spawn('node', [scriptPath], { stdio: 'inherit', cwd: process.cwd() }); child.on('close', (code) => { process.exit(code); }); }, init: async () => { console.log('šŸš€ Initializing Figma Restoration Tools...'); // Copy configuration files to current directory const configFiles = [ 'config/mcp-config.template.json', 'config/cursor-rules.template.md', 'config/vscode-settings.template.json' ]; for (const file of configFiles) { const sourcePath = join(packageRoot, file); const targetPath = file.replace('.template', '').replace('config/', ''); try { const content = await fs.readFile(sourcePath, 'utf8'); await fs.writeFile(targetPath, content); console.log(`āœ… Created ${targetPath}`); } catch (error) { console.log(`āš ļø Could not copy ${file}: ${error.message}`); } } console.log('\nšŸ“š Next steps:'); console.log('1. Configure your MCP settings in mcp-config.json'); console.log('2. Start the MCP server: npx figma-restoration-tools start'); console.log('3. Check documentation: https://github.com/tianmuji/figma-restoration-tools'); }, start: () => { console.log('šŸš€ Starting Figma Restoration MCP Server...'); const serverPath = join(packageRoot, 'src/server.js'); const child = spawn('node', [serverPath], { stdio: 'inherit', cwd: process.cwd() }); child.on('error', (error) => { console.error('āŒ Failed to start server:', error.message); process.exit(1); }); child.on('exit', (code) => { if (code !== 0) { console.error(`āŒ Server exited with code ${code}`); process.exit(code); } }); }, 'install-puppeteer': () => { console.log('šŸ”§ Installing Puppeteer safely...'); const installScript = join(packageRoot, 'scripts/install-puppeteer.js'); const child = spawn('node', [installScript], { stdio: 'inherit', cwd: process.cwd() }); child.on('error', (error) => { console.error('āŒ Failed to install Puppeteer:', error.message); process.exit(1); }); child.on('exit', (code) => { if (code !== 0) { console.error(`āŒ Puppeteer installation failed with code ${code}`); process.exit(code); } }); }, help: () => { console.log(` šŸ› ļø Figma Restoration Tools Usage: npx figma-restoration-tools <command> Commands: init Initialize configuration files in current directory start Start the MCP server install-puppeteer Install Puppeteer safely (optional) help Show this help message Examples: npx figma-restoration-tools init npx figma-restoration-tools install-puppeteer npx figma-restoration-tools start Documentation: https://github.com/tianmuji/figma-restoration-tools Issues: https://github.com/tianmuji/figma-restoration-tools/issues `); } }; const command = process.argv[2] || 'help'; if (commands[command]) { commands[command](); } else { console.error(`āŒ Unknown command: ${command}`); commands.help(); process.exit(1); }