Prechádzať zdrojové kódy

feat: pull version from package.json and make it available as a log/comment/variable on the frontend and backend

Kristian Vos 3 rokov pred
rodič
commit
174ea12ceb

+ 13 - 0
backend/index.js

@@ -3,6 +3,8 @@ import "./loadEnvVariables.js";
 import util from "util";
 import config from "config";
 
+import package_json from "./package.json";
+
 const REQUIRED_CONFIG_VERSION = 8;
 
 // eslint-disable-next-line
@@ -29,6 +31,14 @@ console.log = (...args) => {
 	if (!blacklisted) oldConsole.log.apply(null, args);
 };
 
+const MUSARE_VERSION = package_json.version;
+
+const printVersion = () => {
+	console.log(`Musare version: ${MUSARE_VERSION}.`);
+}
+
+printVersion();
+
 if (
 	(!config.has("configVersion") || config.get("configVersion") !== REQUIRED_CONFIG_VERSION) &&
 	!(config.has("skipConfigVersionCheck") && config.get("skipConfigVersionCheck"))
@@ -274,6 +284,9 @@ function printTask(task, layer) {
 
 process.stdin.on("data", data => {
 	const command = data.toString().replace(/\r?\n|\r/g, "");
+	if (command === "version") {
+		printVersion();
+	}
 	if (command === "lockdown") {
 		console.log("Locking down.");
 		moduleManager._lockdown();

+ 5 - 0
frontend/dist/index.tpl.html

@@ -38,6 +38,11 @@
 	<script src='https://www.youtube.com/iframe_api'></script>
 	<script type='text/javascript' src='/vendor/can-autoplay.min.js'></script>
 	<script type='text/javascript' src='/vendor/lofig.1.3.4.min.js'></script>
+
+	<!--Musare version: <%= htmlWebpackPlugin.options.musareVersion %>-->
+	<script>
+		const MUSARE_VERSION = "<%= htmlWebpackPlugin.options.musareVersion %>";
+	</script>
 </head>
 
 <body>

+ 4 - 2
frontend/webpack.common.js

@@ -1,7 +1,8 @@
 const path = require("path");
 const { VueLoaderPlugin } = require("vue-loader");
 const HtmlWebpackPlugin = require("html-webpack-plugin");
-const ESLintPlugin = require('eslint-webpack-plugin');
+const ESLintPlugin = require("eslint-webpack-plugin");
+const package_json = require("./package.json");
 
 module.exports = {
 	entry: "./src/main.js",
@@ -21,7 +22,8 @@ module.exports = {
 			hash: true,
 			template: "dist/index.tpl.html",
 			inject: "body",
-			filename: "index.html"
+			filename: "index.html",
+			musareVersion: package_json.version
 		}),
 		new ESLintPlugin()
 	],