From 1acf1f7bea5ecc2b56902c10fd20037481f23857 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Fri, 8 May 2026 06:03:15 +0200 Subject: [PATCH 1/2] feat: automatically write version hash in deployment Update shared/version.ts with current git commit hash prior to building the site for deployment. Test-bot: skip --- package-lock.json | 24 +++++++++++++++++++++++- package.json | 15 +++++++++++---- shared/version.ts | 1 + tools/_prebuild.bat | 4 ++++ tools/_prebuild.sh | 4 ++++ 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 tools/_prebuild.bat create mode 100755 tools/_prebuild.sh diff --git a/package-lock.json b/package-lock.json index edf39e4..598ba69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,29 @@ "": { "name": "keyman-status", "version": "1.0.0", - "license": "MIT" + "license": "MIT", + "devDependencies": { + "run-script-os": "^1.1.6" + } + }, + "node_modules/run-script-os": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/run-script-os/-/run-script-os-1.1.6.tgz", + "integrity": "sha512-ql6P2LzhBTTDfzKts+Qo4H94VUKpxKDFz6QxxwaUZN0mwvi7L3lpOI7BqPCq7lgDh3XLl0dpeXwfcVIitlrYrw==", + "dev": true, + "license": "MIT", + "bin": { + "run-os": "index.js", + "run-script-os": "index.js" + } + } + }, + "dependencies": { + "run-script-os": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/run-script-os/-/run-script-os-1.1.6.tgz", + "integrity": "sha512-ql6P2LzhBTTDfzKts+Qo4H94VUKpxKDFz6QxxwaUZN0mwvi7L3lpOI7BqPCq7lgDh3XLl0dpeXwfcVIitlrYrw==", + "dev": true } } } diff --git a/package.json b/package.json index fe94296..5355449 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,21 @@ "main": "server/dist/server/code.js", "type": "module", "scripts": { - "build": "npm run-script build-server && npm run-script build-client", - "build-client": "cd public && npm install && npm run-script build", - "build-server": "cd server && npm install && npm run-script build", + "prebuild": "run-script-os", + "prebuild:windows": "tools\\_prebuild.bat", + "prebuild:default": "./tools/_prebuild.sh", + "postbuild": "git checkout shared/version.ts", + "build": "npm ci && npm run-script prebuild && npm run-script build-server && npm run-script build-client && npm run-script postbuild", + "build-client": "cd public && npm ci && npm run-script build", + "build-server": "cd server && npm ci && npm run-script build", "start-client": "cd public && npm run-script start", "start-server": "cd server && npm run-script start", "test": "cd server && npx mocha --import=./_mocha_register.js", "log": "az webapp log tail --resource-group keyman --name com-keyman-status" }, "author": "Marc Durdin", - "license": "MIT" + "license": "MIT", + "devDependencies": { + "run-script-os": "^1.1.6" + } } diff --git a/shared/version.ts b/shared/version.ts index fff0b3f..0fb8bd5 100644 --- a/shared/version.ts +++ b/shared/version.ts @@ -1 +1,2 @@ +// WARNING: this file is overwritten during builds (see _prebuild.bat/.sh) export const buildVersion = '1.0'; \ No newline at end of file diff --git a/tools/_prebuild.bat b/tools/_prebuild.bat new file mode 100644 index 0000000..6ba9271 --- /dev/null +++ b/tools/_prebuild.bat @@ -0,0 +1,4 @@ +@echo off +for /f %%i in ('git rev-parse HEAD') do set NEWVERSION=%%i +echo "Setting build version to %NEWVERSION%" +echo export const buildVersion = '%NEWVERSION%'; > shared\version.ts diff --git a/tools/_prebuild.sh b/tools/_prebuild.sh new file mode 100755 index 0000000..b88ae6c --- /dev/null +++ b/tools/_prebuild.sh @@ -0,0 +1,4 @@ +#!/bin/bash +NEWVERSION="$(git rev-parse HEAD)" +echo "Writing version '$NEWVERSION' to version.ts" +echo "export const buildVersion = '$NEWVERSION';" > shared/version.ts From 5e659bad127810bbc818eda8269c0435aa6c572f Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Fri, 8 May 2026 06:22:19 +0200 Subject: [PATCH 2/2] feat: reload page button for new version Rather than auto-refresh, show a 'refresh page' link when the version changes, which both informs the user that there are changes to the status site, and avoids potential refresh loops. Test-bot: skip --- public/src/app/data/data.model.ts | 2 ++ public/src/app/home/home.component.css | 4 ++++ public/src/app/home/home.component.html | 4 ++++ public/src/app/home/home.component.ts | 11 +++++++---- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/public/src/app/data/data.model.ts b/public/src/app/data/data.model.ts index bd5cc00..b3fe27c 100644 --- a/public/src/app/data/data.model.ts +++ b/public/src/app/data/data.model.ts @@ -15,6 +15,8 @@ interface OtherSites { export class DataModel { status: Status = EMPTY_STATUS; + serverBuildVersion: string = ''; + serviceState: {service: ServiceIdentifier, state: ServiceState, message?: string}[]; platforms: PlatformSpec[] = JSON.parse(JSON.stringify(platforms)); // makes a copy of the constant platform data for this component diff --git a/public/src/app/home/home.component.css b/public/src/app/home/home.component.css index 5208a27..537e260 100644 --- a/public/src/app/home/home.component.css +++ b/public/src/app/home/home.component.css @@ -14,6 +14,10 @@ overflow-y: scroll; } +#navbar-reload-page-link { + margin-left: 16px; +} + .navbar-phase { background: rgb(240,240,240); border-radius: 3px; diff --git a/public/src/app/home/home.component.html b/public/src/app/home/home.component.html index e127379..20f2b30 100644 --- a/public/src/app/home/home.component.html +++ b/public/src/app/home/home.component.html @@ -4,6 +4,10 @@