Update the browser, editor, settings, and installer
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
export function releaseVersion(value) {
|
||||
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)([a-z]*)$/.exec(value);
|
||||
if (!match) throw Error('Use a release version such as 0.1.23 or 0.1.23a.');
|
||||
const parts = match.slice(1, 4).map(Number);
|
||||
let revision = 0;
|
||||
for (const letter of match[4]) revision = revision * 26 + letter.charCodeAt(0) - 96;
|
||||
if (parts.some(part => part > 65535) || revision > 65535) throw Error('The Windows version exceeds 65535.');
|
||||
const base = parts.join('.');
|
||||
return { version: value, base, suffix: match[4], revision,
|
||||
toolchain: revision ? `${base}+${revision}` : base, windows: `${base}.${revision}` };
|
||||
}
|
||||
|
||||
export function nextHotfix(value) {
|
||||
const parsed = releaseVersion(value);
|
||||
let revision = parsed.revision + 1;
|
||||
let suffix = '';
|
||||
while (revision) {
|
||||
revision--;
|
||||
suffix = String.fromCharCode(97 + revision % 26) + suffix;
|
||||
revision = Math.floor(revision / 26);
|
||||
}
|
||||
return releaseVersion(parsed.base + suffix).version;
|
||||
}
|
||||
|
||||
export function compareReleases(left, right) {
|
||||
const a = releaseVersion(left).windows.split('.').map(Number);
|
||||
const b = releaseVersion(right).windows.split('.').map(Number);
|
||||
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return Math.sign(a[i] - b[i]);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user