mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-08-10 00:52:16 +00:00
Some checks are pending
CI / GitHub Env Debug (push) Waiting to run
CI / Setup Release (push) Waiting to run
CI / Setup Flatpak Matrix (push) Waiting to run
CI / Linux Flatpak (push) Blocked by required conditions
CI / Linux ${{ matrix.type }} (--appimage-build, 22.04, AppImage) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (macos, 13) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (macos, 14) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (ubuntu, latest) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (ubuntu, latest, true) (push) Blocked by required conditions
CI / Windows (push) Blocked by required conditions
CI Docker / Check Dockerfiles (push) Waiting to run
CI Docker / Setup Release (push) Blocked by required conditions
CI Docker / Docker${{ matrix.tag }} (push) Blocked by required conditions
CodeQL / Get language matrix (push) Waiting to run
CodeQL / Analyze (${{ matrix.name }}) (push) Blocked by required conditions
Build GH-Pages / prep (push) Waiting to run
Build GH-Pages / call-jekyll-build (push) Blocked by required conditions
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
class SunshineVersion {
|
|
constructor(release = null, version = null) {
|
|
if (release) {
|
|
this.release = release;
|
|
this.version = release.tag_name;
|
|
this.versionName = release.name;
|
|
this.versionTag = release.tag_tag;
|
|
} else if (version) {
|
|
this.release = null;
|
|
this.version = version;
|
|
this.versionName = null;
|
|
this.versionTag = null;
|
|
} else {
|
|
throw new Error('Either release or version must be provided');
|
|
}
|
|
this.versionParts = this.parseVersion(this.version);
|
|
this.versionMajor = this.versionParts ? this.versionParts[0] : null;
|
|
this.versionMinor = this.versionParts ? this.versionParts[1] : null;
|
|
this.versionPatch = this.versionParts ? this.versionParts[2] : null;
|
|
}
|
|
|
|
parseVersion(version) {
|
|
if (!version) {
|
|
return null;
|
|
}
|
|
let v = version;
|
|
if (v.indexOf("v") === 0) {
|
|
v = v.substring(1);
|
|
}
|
|
return v.split('.').map(Number);
|
|
}
|
|
|
|
isGreater(otherVersion) {
|
|
let otherVersionParts;
|
|
if (otherVersion instanceof SunshineVersion) {
|
|
otherVersionParts = otherVersion.versionParts;
|
|
} else if (typeof otherVersion === 'string') {
|
|
otherVersionParts = this.parseVersion(otherVersion);
|
|
} else {
|
|
throw new Error('Invalid argument: otherVersion must be a SunshineVersion object or a version string');
|
|
}
|
|
|
|
if (!this.versionParts || !otherVersionParts) {
|
|
return false;
|
|
}
|
|
for (let i = 0; i < Math.min(3, this.versionParts.length, otherVersionParts.length); i++) {
|
|
if (this.versionParts[i] !== otherVersionParts[i]) {
|
|
return this.versionParts[i] > otherVersionParts[i];
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export default SunshineVersion;
|