const fs = require('fs');
const path = require('path');

// Read package.json
const packageJsonPath = path.resolve(__dirname, '../package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

// Extract version
const version = packageJson.version;

// Write version to version.js
const versionJsPath = path.resolve(__dirname, '../src/lib/version.js');
const versionJsContent = `export const version = '${version}';\n`;

fs.writeFileSync(versionJsPath, versionJsContent, 'utf-8');
console.log(`Version ${version} written to version.js`);