forked from AuroraTeam/AuroraLauncher
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { valid, SemVer } from "semver"; | ||
|
||
export enum VersionType { | ||
RELEASE = "release", // or STABLE? | ||
DEV = "dev", | ||
TESTING = "testing", | ||
LTS = "lts" | ||
// etc? | ||
} | ||
|
||
export class VersionHelper { | ||
static MAJOR: number = 0 | ||
static MINOR: number = 0 | ||
static PATCH: number = 1 | ||
static TYPE: VersionType = VersionType.DEV | ||
|
||
/** | ||
* Получить обработанную версию лаунчсервера в виде строки | ||
* @returns `string` | ||
*/ | ||
static getVersion(): string { | ||
if (!this.TYPE) { | ||
return `${this.MAJOR}.${this.MINOR}.${this.PATCH}` | ||
} else { | ||
return `${this.MAJOR}.${this.MINOR}.${this.PATCH}-${this.TYPE}` | ||
} | ||
} | ||
|
||
/** | ||
* **Обёртка над `semver.valid`** | ||
* | ||
* Возвращает обработанную версию в виде строки или null, если она недействительна | ||
* @param version - Версия в виде строки или объекта SemVer | ||
* @returns `string` или `null` | ||
*/ | ||
static versionValidate(version: string | SemVer | null | undefined): string | null { | ||
return valid(version) | ||
} | ||
} |