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
JavaScript
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