29 lines
960 B
JavaScript
29 lines
960 B
JavaScript
const { execSync } = require('child_process');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
try {
|
|
// Run semantic-release to get the next version number
|
|
const dryRunOutput = execSync('npx semantic-release --dry-run').toString();
|
|
|
|
// Extract the version number from the semantic-release output
|
|
const versionMatch = dryRunOutput.match(
|
|
/The next release version is ([\S]+)/
|
|
);
|
|
if (!versionMatch) {
|
|
throw new Error('Version number not found in semantic-release output');
|
|
}
|
|
const version = versionMatch[1];
|
|
|
|
// Create version content
|
|
const versionContent = `export const APP_VERSION = '${version}';\n`;
|
|
const versionFilePath = path.resolve(__dirname, 'src/version.js');
|
|
|
|
// Write version to 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);
|
|
}
|