const fs = require('fs'); const path = require('path'); try { const version = process.argv[2]; if (!version) throw Error('Must pass version on command line'); // Create version content const versionContent = `export const APP_VERSION = '${version}';\n`; const versionTxtFilePath = path.resolve(__dirname, './VERSION'); const versionFilePath = path.resolve(__dirname, 'src/version.js'); // Write version to TXT file fs.writeFileSync(versionTxtFilePath, version, 'utf8'); // Write version to js file fs.writeFileSync(versionFilePath, versionContent, 'utf8'); console.log(`Version file generated with version: ${version}`); } catch (error) { console.error('Error generating version file:', error); process.exit(1); }