Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding version details to the PWA #3606

Merged
merged 5 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ module.exports = {
cordovaChromeapi: true,
appAvailability: true,
// end cordova bindings

// globals for vite
__APP_PRODUCTNAME__: "readonly",
__APP_VERSION__: "readonly",
__APP_REVISION__: "readonly",
},
// ignore src/dist folders
ignorePatterns: ["src/dist/*"],
Expand Down
4 changes: 4 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ function readConfiguratorVersionMetadata() {
CONFIGURATOR.productName = manifest.productName;
CONFIGURATOR.version = manifest.version;
CONFIGURATOR.gitRevision = manifest.gitRevision;
} else {
CONFIGURATOR.productName = __APP_PRODUCTNAME__;
CONFIGURATOR.version = __APP_VERSION__;
CONFIGURATOR.gitRevision = __APP_REVISION__;
}
}

Expand Down
8 changes: 8 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import vue from "@vitejs/plugin-vue2";
import path from "node:path";
import { readFileSync } from "node:fs";
import copy from "rollup-plugin-copy";
import pkg from './package.json';

const childProcess = require('child_process');

function serveFileFromDirectory(directory) {
return (req, res, next) => {
Expand Down Expand Up @@ -46,6 +49,11 @@ function serveLocalesPlugin() {
}

export default defineConfig({
define: {
'__APP_VERSION__': JSON.stringify(pkg.version),
'__APP_PRODUCTNAME__': JSON.stringify(pkg.productName),
'__APP_REVISION__': JSON.stringify(childProcess.execSync("git rev-parse --short HEAD").toString().trim()),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is sonarcloud wants the full path to git. It doesn't like that I've let the system search for it... it can just be reviewed as 'safe'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's asking the path for git 🤕

},
test: {
// NOTE: this is a replacement location for karma tests.
// moving forward we should colocate tests with the
Expand Down