2019-06-19 21:31:55 +00:00
|
|
|
const semver = require('semver');
|
|
|
|
|
2024-10-03 03:52:01 +00:00
|
|
|
const fs = require('node:fs');
|
|
|
|
|
2019-06-19 21:31:55 +00:00
|
|
|
const outputPath = process.argv[2];
|
2022-10-25 06:44:43 +00:00
|
|
|
const currentVersion = process.argv[3];
|
2019-06-19 21:31:55 +00:00
|
|
|
|
|
|
|
const parsed = semver.parse(currentVersion);
|
|
|
|
|
|
|
|
let prerelease = '';
|
|
|
|
if (parsed.prerelease && parsed.prerelease.length > 0) {
|
|
|
|
prerelease = parsed.prerelease.join('.');
|
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
|
|
|
major,
|
|
|
|
minor,
|
|
|
|
patch
|
|
|
|
} = parsed;
|
|
|
|
|
|
|
|
fs.writeFileSync(outputPath, JSON.stringify({
|
2022-10-25 06:44:43 +00:00
|
|
|
full_version: currentVersion,
|
2019-06-19 21:31:55 +00:00
|
|
|
major,
|
|
|
|
minor,
|
|
|
|
patch,
|
|
|
|
prerelease,
|
2022-10-25 06:44:43 +00:00
|
|
|
prerelease_number: prerelease ? parsed.prerelease[parsed.prerelease.length - 1] : '0',
|
2019-06-19 21:31:55 +00:00
|
|
|
has_prerelease: prerelease === '' ? 0 : 1
|
|
|
|
}, null, 2));
|