1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-15 04:15:32 +03:00

Adding version details to the PWA (#3606)

* Adding version details to the PWA

* Created a coded version.js that can be loaded as a module.

* Reverting, and simply identifying the permissible global vars for Vite

* Update .eslintrc.js

Removing whitespace

* Update vite.config.js
This commit is contained in:
J Blackman 2023-10-17 11:55:42 +11:00 committed by GitHub
parent 16df95118a
commit d6575e175f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -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/*"],

View file

@ -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__;
}
}

View file

@ -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) => {
@ -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()),
},
test: {
// NOTE: this is a replacement location for karma tests.
// moving forward we should colocate tests with the