Browse Source

refactor: Insert musare version and git info into builds via index.html

Owen Diffey 2 years ago
parent
commit
195415929a
3 changed files with 19 additions and 16 deletions
  1. 10 9
      frontend/src/index.html
  2. 8 0
      frontend/src/types/global.d.ts
  3. 1 7
      frontend/vite.config.js

+ 10 - 9
frontend/src/index.html

@@ -117,15 +117,16 @@
 
 		<script src="https://www.youtube.com/iframe_api"></script>
 
-		<!--Musare version: {{ version }}-->
-		<!--
-			Git info
-			Remote: {{ gitRemote }}
-			Remote URL: {{ gitRemoteUrl }}
-			Branch: {{ gitBranch }}
-			Latest commit: {{ gitLatestCommit }}
-			Latest commit short: {{ gitLatestCommitShort }}
-		-->
+		<script>
+			const MUSARE_VERSION = "{{ version }}";
+			const MUSARE_GIT = {
+				remote: "{{ gitRemote }}",
+				remoteUrl: "{{ gitRemoteUrl }}",
+				branch: "{{ gitBranch }}",
+				latestCommit: "{{ gitLatestCommit }}",
+				latestCommitShort: "{{ gitLatestCommitShort }}"
+			};
+		</script>
 	</head>
 
 	<body>

+ 8 - 0
frontend/src/types/global.d.ts

@@ -24,6 +24,14 @@ declare global {
 				initialItemIndex: number;
 				initialItemListUuid: string;
 		  };
+	var MUSARE_VERSION: string;
+	var MUSARE_GIT: {
+		remote: string;
+		remoteUrl: string;
+		branch: string;
+		latestCommit: string;
+		latestCommitShort: string;
+	};
 }
 
 export {};

+ 1 - 7
frontend/vite.config.js

@@ -156,13 +156,7 @@ export default {
 	define: {
 		__VUE_PROD_DEVTOOLS__: config.get("mode") === "development",
 		MUSARE_VERSION: JSON.stringify(debug.version),
-		MUSARE_GIT_REMOTE: JSON.stringify(debug.git.remote),
-		MUSARE_GIT_REMOTE_URL: JSON.stringify(debug.git.remoteUrl),
-		MUSARE_GIT_BRANCH: JSON.stringify(debug.git.branch),
-		MUSARE_GIT_LATEST_COMMIT: JSON.stringify(debug.git.latestCommit),
-		MUSARE_GIT_LATEST_COMMIT_SHORT: JSON.stringify(
-			debug.git.latestCommitShort
-		),
+		MUSARE_GIT: debug.git,
 		__VUE_I18N_LEGACY_API__: false
 	},
 	plugins: [