// Test script to connect to figmamind on Smithery using the CLI
const { spawn } = require('child_process');
const readline = require('readline');
// Function to run a command and capture its output
function runCommand(command, args) {
return new Promise((resolve, reject) => {
const process = spawn(command, args);
let output = '';
let errorOutput = '';
process.stdout.on('data', (data) => {
output += data.toString();
console.log(`[stdout]: ${data.toString().trim()}`);
});
process.stderr.on('data', (data) => {
errorOutput += data.toString();
console.error(`[stderr]: ${data.toString().trim()}`);
});
process.on('close', (code) => {
if (code === 0) {
resolve(output);
} else {
reject(new Error(`Command failed with code ${code}. ${errorOutput}`));
}
});
process.on('error', (error) => {
reject(error);
});
});
}
// Function to run a tool using Smithery CLI
async function runSmitheryTool(toolName, args = {}) {
const command = 'npx';
const commandArgs = [
'-y',
'@smithery/cli@latest',
'run',
'@joao-loker/figmamind',
'--key',
'd1cf009d-9fbe-4cf6-bfe2-d7cd270f295d',
'--tool',
toolName,
'--args',
JSON.stringify(args)
];
console.log(`Running tool: ${toolName}`);
try {
const output = await runCommand(command, commandArgs);
return output;
} catch (error) {
console.error(`Error running tool ${toolName}:`, error);
throw error;
}
}
// Run the tests
async function runTests() {
try {
// Test the info tool first
console.log('Testing figmamind.info...');
await runSmitheryTool('figmamind.info');
// Test the transform tool with a Figma URL
console.log('\nTesting figmamind.transform...');
await runSmitheryTool('figmamind.transform', {
figmaUrl: 'https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File'
});
console.log('\nAll tests completed successfully!');
} catch (error) {
console.error('Test failed:', error);
}
}
// Run the tests
runTests();