UNPKG

figma-to-react-mcp

Version:

Convert Figma designs to React components automatically. MCP server with GitHub, Figma, and Playwright integrations for seamless design-to-code workflow.

137 lines • 5.79 kB
import { execSync } from "child_process"; import { readFileSync, writeFileSync } from "fs"; import { createInterface } from "readline"; export class ReleaseManager { rl = createInterface({ input: process.stdin, output: process.stdout, }); async run() { try { console.log("šŸš€ Figma to React MCP Release Manager\n"); const versionInfo = this.getVersionInfo(); console.log(`Current version: ${versionInfo.current}\n`); await this.showRecentChanges(); const versionType = await this.promptVersionType(versionInfo); const confirmed = await this.confirmRelease(versionType, versionInfo); if (!confirmed) { console.log("āŒ Release cancelled"); return; } await this.executeRelease(versionType); console.log("āœ… Release completed successfully!"); } catch (error) { console.error("āŒ Release failed:", error); process.exit(1); } finally { this.rl.close(); } } getVersionInfo() { const packageJson = JSON.parse(readFileSync("package.json", "utf8")); const current = packageJson.version; const [major, minor, patch] = current.split(".").map(Number); return { current, patch: `${major}.${minor}.${patch + 1}`, minor: `${major}.${minor + 1}.0`, major: `${major + 1}.0.0`, }; } async showRecentChanges() { try { const changes = execSync("git log --oneline -10", { encoding: "utf8" }); console.log("šŸ“‹ Recent changes:"); console.log(changes); } catch (error) { console.log("šŸ“‹ Could not fetch recent changes"); } } async promptVersionType(versionInfo) { console.log("šŸŽÆ Select version bump type:\n"); console.log(`1. šŸ› Patch (${versionInfo.current} → ${versionInfo.patch})`); console.log(" - Bug fixes, documentation updates"); console.log(" - No new features or breaking changes\n"); console.log(`2. ✨ Minor (${versionInfo.current} → ${versionInfo.minor})`); console.log(" - New features, enhancements"); console.log(" - Backwards compatible changes\n"); console.log(`3. šŸ’„ Major (${versionInfo.current} → ${versionInfo.major})`); console.log(" - Breaking changes"); console.log(" - API changes, major refactors\n"); return new Promise((resolve) => { this.rl.question("Enter your choice (1/2/3): ", (answer) => { const choice = answer.trim(); switch (choice) { case "1": resolve("patch"); break; case "2": resolve("minor"); break; case "3": resolve("major"); break; default: console.log("āŒ Invalid choice. Please select 1, 2, or 3."); this.promptVersionType(versionInfo).then(resolve); } }); }); } async confirmRelease(versionType, versionInfo) { const newVersion = versionInfo[versionType]; console.log(`\nšŸ”„ About to release version ${newVersion}`); console.log("This will:"); console.log("- Run tests and linting"); console.log("- Build the project"); console.log("- Update package.json"); console.log("- Create git tag"); console.log("- Publish to npm"); console.log("- Push to GitHub\n"); return new Promise((resolve) => { this.rl.question("Continue with release? (y/N): ", (answer) => { resolve(answer.toLowerCase().startsWith("y")); }); }); } async executeRelease(versionType) { console.log("\nšŸ”Ø Starting release process...\n"); console.log("1ļøāƒ£ Running tests..."); execSync("npm test", { stdio: "inherit" }); console.log("2ļøāƒ£ Running linter..."); execSync("npm run lint", { stdio: "inherit" }); console.log("3ļøāƒ£ Building project..."); execSync("npm run build", { stdio: "inherit" }); console.log(`4ļøāƒ£ Updating version (${versionType})...`); const output = execSync(`npm version ${versionType} --no-git-tag-version`, { encoding: "utf8", }); const newVersion = output.trim().replace("v", ""); this.updateCLIVersion(newVersion); console.log("5ļøāƒ£ Creating git commit..."); execSync("git add .", { stdio: "inherit" }); execSync(`git commit -m "chore: release v${newVersion}"`, { stdio: "inherit", }); console.log("6ļøāƒ£ Creating git tag..."); execSync(`git tag v${newVersion}`, { stdio: "inherit" }); console.log("7ļøāƒ£ Publishing to npm..."); execSync("npm publish", { stdio: "inherit" }); console.log("8ļøāƒ£ Pushing to GitHub..."); execSync("git push && git push --tags", { stdio: "inherit" }); } updateCLIVersion(version) { const indexPath = "src/index.ts"; let content = readFileSync(indexPath, "utf8"); content = content.replace(/figma-to-react-mcp v[\d.]+/g, `figma-to-react-mcp v${version}`); writeFileSync(indexPath, content); } } if (import.meta.url === new URL(process.argv[1] || "", "file:").href) { const releaseManager = new ReleaseManager(); releaseManager.run().catch(console.error); } //# sourceMappingURL=cli-release.js.map