From da5bbdab600d424d20d4d27c6ce5be88af5cafaa Mon Sep 17 00:00:00 2001 From: DanyLE Date: Fri, 22 Jul 2022 20:13:08 +0200 Subject: [PATCH] Allow to set version number and build ID to the current Antos build --- Makefile | 3 +- d.ts/antos.d.ts | 25 ++++++++++++++-- src/core/core.ts | 57 +++++++++++++++++++++++++++++++++---- src/core/gui.ts | 11 +++++-- src/themes/system/antos.css | 20 +++++++++++-- 5 files changed, 101 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 2e570f1..0173300 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ TSC=./node_modules/typescript/bin/tsc UGLIFYJS=./node_modules/terser/bin/terser UGLIFYCSS=./node_modules/uglifycss/uglifycss -VERSION=$(shell grep -e "export const VERSION" src/core/core.ts | cut -d '"' -f 2 | cut -d "-" -f 1) +VERSION=1.2.1-b-$(shell git rev-parse --short HEAD) GSED=sed UNAME_S := $(shell uname -s) @@ -117,6 +117,7 @@ build_javascripts: ts (cat "$${f}"; echo) >> dist/antos.js;\ rm "$${f}";\ done + echo 'OS.VERSION.version_string = "$(VERSION)";' >> dist/antos.js cp dist/antos.js $(BUILDDIR)/scripts/ echo "if(exports){ exports.__esModule = true;exports.OS = OS; }" >> dist/antos.js rm -r dist/core diff --git a/d.ts/antos.d.ts b/d.ts/antos.d.ts index 8daae6b..26ba6e0 100644 --- a/d.ts/antos.d.ts +++ b/d.ts/antos.d.ts @@ -1559,13 +1559,14 @@ declare namespace OS { * AntOS version number is in the following format: * * ``` - * [major_number].[minor_number].[patch]-[branch] + * [major_number].[minor_number].[patch]-[branch]-[build ID]) * - * e.g.: 1.2.3-r means that: + * e.g.: 1.2.3-r-b means that: * - version major number is 1 * - version minor number is 2 * - patch version is 3 * - the current branch is release `r` + * - build ID (optional) * ``` * * @export @@ -1575,10 +1576,11 @@ declare namespace OS { /** * The version string * + * @private * @type {string} * @memberof Version */ - string: string; + private string; /** * The current branch * - 1: `a` - alpha branch @@ -1611,12 +1613,24 @@ declare namespace OS { * @memberof Version */ patch: number; + /** + * Version build ID (optional): usually the current git commit hash + * + * @type {number} + * @memberof Version + */ + build_id: string; /** *Creates an instance of Version. * @param {string} string string represents the version * @memberof Version */ constructor(string: string); + /** + * Setter getter to set the version string to the object + */ + set version_string(v: string); + get version_string(): string; /** * Compare the current version with another version. * @@ -1670,6 +1684,11 @@ declare namespace OS { * is an instance of [[Version]] */ const VERSION: Version; + /** + * Variable represents the current AntOS source code repository + * is an instance of [[string]] + */ + const REPOSITORY: string; /** * Register a model prototype to the system namespace. * There are two types of model to be registered, if the model diff --git a/src/core/core.ts b/src/core/core.ts index e8dbc64..1e6ffce 100644 --- a/src/core/core.ts +++ b/src/core/core.ts @@ -424,13 +424,14 @@ namespace OS { * AntOS version number is in the following format: * * ``` - * [major_number].[minor_number].[patch]-[branch] + * [major_number].[minor_number].[patch]-[branch]-[build ID]) * - * e.g.: 1.2.3-r means that: + * e.g.: 1.2.3-r-b means that: * - version major number is 1 * - version minor number is 2 * - patch version is 3 * - the current branch is release `r` + * - build ID (optional) * ``` * * @export @@ -440,10 +441,11 @@ namespace OS { /** * The version string * + * @private * @type {string} * @memberof Version */ - string: string; + private string: string; /** * The current branch @@ -481,13 +483,40 @@ namespace OS { */ patch: number; + /** + * Version build ID (optional): usually the current git commit hash + * + * @type {number} + * @memberof Version + */ + build_id: string; + /** *Creates an instance of Version. + * * @param {string} string string represents the version * @memberof Version */ constructor(string: string) { - this.string = string; + this.version_string = string; + } + /** + * Setter/getter to set the version string to the object + * + * @memberof Version + */ + set version_string(v: string) + { + if(!v) + { + this.string = undefined; + this.major = undefined; + this.minor = undefined; + this.patch = undefined; + this.build_id = undefined; + return; + } + this.string = v; const arr = this.string.split("-"); const br = { r: 3, @@ -495,9 +524,14 @@ namespace OS { a: 1, }; this.branch = 3; - if (arr.length === 2 && br[arr[1]]) { + if (arr.length >= 2 && br[arr[1]]) { this.branch = br[arr[1]]; + if(arr[2]) + { + this.build_id = arr[2]; + } } + const mt = arr[0].match(/\d+/g); if (!mt) { API.throwe( @@ -517,6 +551,10 @@ namespace OS { this.patch = Number(mt[2]); } } + get version_string(): string + { + return this.string; + } /** * Compare the current version with another version. @@ -761,7 +799,14 @@ namespace OS { * Variable represents the current AntOS version, it * is an instance of [[Version]] */ - export const VERSION: Version = "1.2.1-b".__v(); + export const VERSION: Version = new Version(undefined); + + /** + * Variable represents the current AntOS source code repository + * is an instance of [[string]] + */ + export const REPOSITORY: string = "https://github.com/lxsang/antos"; + /** * Register a model prototype to the system namespace. * There are two types of model to be registered, if the model diff --git a/src/core/gui.ts b/src/core/gui.ts index b8b1cd8..4d9fc45 100644 --- a/src/core/gui.ts +++ b/src/core/gui.ts @@ -926,7 +926,11 @@ namespace OS { * @export */ export function login(): void { - const scheme = $.parseHTML(schemes.login); + const scheme = $.parseHTML( + schemes.login + .replace("[ANTOS_BUILD_ID]", OS.VERSION.build_id) + .replace("[ANTOS_VERSION]", OS.VERSION.version_string) + ); $("#wrapper").append(scheme); $("#btlogin").on("click", async function () { const data: API.UserLoginType = { @@ -1060,12 +1064,13 @@ namespace OS { schemes.login = `\
-

Welcome to AntOS v${OS.VERSION.toString()}, please login

+

Welcome to AntOS, please login

-
\ + +
AntOS v[ANTOS_VERSION]
\ `; } } diff --git a/src/themes/system/antos.css b/src/themes/system/antos.css index b421214..3f747e8 100644 --- a/src/themes/system/antos.css +++ b/src/themes/system/antos.css @@ -62,7 +62,7 @@ body #login_form{ width:300px; - height: 200px; + height: 180px; display: block; border:1px solid #262626; border-radius: 6px; @@ -130,7 +130,23 @@ body height: 1px; box-sizing: border-box; } - +#antos_build_id { + position: absolute; + display: block; + bottom: 0; + right: 0; + padding: 2px; + background-color: #d6d4d4; + font-family: Verdana, Geneva, Tahoma, sans-serif; + font-size: 12px; +} +#antos_build_id a:link, +#antos_build_id a:visited, +#antos_build_id a:hover +{ + color:#df3154; + text-decoration: none; +} afx-desktop > .list-container > ul > afx-list-item afx-label span { flex-direction: column; }