Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions bin/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const COMMANDS = {
migrate: 'Migrate from other frameworks',
serve: 'Start a development server',
build: 'Build optimized production files',
convert: 'Convert a Figma export (.fig) to a Pencil mockup file (.pencil)',
help: 'Show help information'
};

Expand Down Expand Up @@ -381,6 +382,19 @@ async function serve(options = {}) {
}
}

// Command: convert (fig → pencil)
async function convertFigToPencil(inputPath, outputPath) {
const { FigToPencilConverter } = require('../js/fig-to-pencil');
const converter = new FigToPencilConverter();

log('\n🔄 Converting Figma export to Pencil format...', 'bright');
info(`Input: ${inputPath}`);
info(`Output: ${outputPath}`);

const result = await converter.convert(inputPath, outputPath);
success(`Conversion complete! ${result.pages} page(s) written to ${result.outputPath}`);
}

// Command: build
async function build(options = {}) {
log('\n🔨 Building for production...', 'bright');
Expand Down Expand Up @@ -613,6 +627,7 @@ function showHelp() {
log(' renderer validate', 'yellow');
log(' renderer deploy netlify', 'yellow');
log(' renderer serve --port 3000', 'yellow');
log(' renderer convert design.fig design.pencil', 'yellow');
}

// Main CLI handler
Expand Down Expand Up @@ -680,6 +695,18 @@ async function main() {
await build();
break;

case 'convert': {
if (!subArgs[0]) {
error('Please provide the path to a .fig file');
log('Usage: renderer convert <input.fig> [output.pencil]');
process.exit(1);
}
const figInput = subArgs[0];
const pencilOutput = subArgs[1] || figInput.replace(/\.fig$/i, '') + '.pencil';
await convertFigToPencil(figInput, pencilOutput);
break;
}

default:
error(`Unknown command: ${command}`);
log('Run "renderer help" for available commands');
Expand Down
Loading