From 0411b9c7e92b243ed4f24337432c2f0412817920 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Mon, 8 May 2023 17:54:52 +0330 Subject: [PATCH] feat(pwa-helper): add build short sha to alwatr version --- ui/pwa-helper/esbuild.mjs | 6 ++++-- ui/pwa-helper/package.json | 1 - ui/pwa-helper/src/signal/sw-user-notify.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/pwa-helper/esbuild.mjs b/ui/pwa-helper/esbuild.mjs index c24dae428..f9cb9dc29 100755 --- a/ui/pwa-helper/esbuild.mjs +++ b/ui/pwa-helper/esbuild.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node /* eslint-disable no-undef */ /* eslint-disable @typescript-eslint/explicit-function-return-type */ - +import {execSync} from 'child_process'; import {promises as fs, existsSync} from 'node:fs'; import {createLogger} from '@alwatr/logger'; @@ -23,6 +23,8 @@ const watchMode = process.argv.includes('--watch'); const debugMode = process.argv.includes('--debug'); const prettyMode = process.argv.includes('--pretty'); +const gitShortSha = execSync('git rev-parse --short HEAD').toString().trim(); + logger.logOther?.(banner); logger.logProperty?.('cleanMode', cleanMode); @@ -57,7 +59,7 @@ const esbuildContext = await esbuild.context({ metafile: true, define: { - _ALWATR_VERSION_: `'${packageJson.pwaVersion}'`, + _ALWATR_VERSION_: `'${packageJson.version}+${gitShortSha}'`, }, // drop: ['debugger'], diff --git a/ui/pwa-helper/package.json b/ui/pwa-helper/package.json index 6e3a52a79..2749ff4a1 100644 --- a/ui/pwa-helper/package.json +++ b/ui/pwa-helper/package.json @@ -1,7 +1,6 @@ { "name": "@alwatr/pwa-helper", "version": "0.30.0", - "pwaVersion": "0.31.0-beta.6", "description": "Alwatr PWA Helper", "keywords": [ "element", diff --git a/ui/pwa-helper/src/signal/sw-user-notify.ts b/ui/pwa-helper/src/signal/sw-user-notify.ts index 23de94563..da32723fc 100644 --- a/ui/pwa-helper/src/signal/sw-user-notify.ts +++ b/ui/pwa-helper/src/signal/sw-user-notify.ts @@ -12,7 +12,7 @@ eventListener.subscribe('service_worker_registered', async () => { } localStorage.removeItem('notify_new_version'); snackbarSignalTrigger.request({ - message: `به نسخه ${replaceNumber(_ALWATR_VERSION_.replace('-beta.', ' بتا '))} خوش‌آمدید.`, + message: `به نسخه ${replaceNumber(_ALWATR_VERSION_.split('+')[0].replace('-beta.', ' بتا '))} خوش‌آمدید.`, }); } });