Skip to content

Commit c49b044

Browse files
committed
test version control
1 parent 8b64020 commit c49b044

File tree

8 files changed

+99
-40
lines changed

8 files changed

+99
-40
lines changed

dist/build/static/js/bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/*! For license information please see main.4f3316df.js.LICENSE.txt */
1+
/*! For license information please see main.9e9a9a1a.js.LICENSE.txt */
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
require('dotenv').config();
1+
22
const path = require("path");
33
const TerserPlugin = require("terser-webpack-plugin");
44
const glob = require("glob");
5-
const { execSync } = require("child_process");
65
const webpack = require("webpack");
7-
const commitHash = process.env.LOCAL_COMMIT_HASH || (() => {
8-
try {
9-
return execSync("git rev-parse HEAD").toString().trim();
10-
} catch (error) {
11-
return "unknown";
12-
}
13-
})();
6+
7+
const child_process = require("child_process");
8+
9+
function git(command) {
10+
return child_process.execSync(`git ${command}`, { encoding: "utf8" }).trim();
11+
}
12+
1413
module.exports = {
1514
mode: "production",
1615
entry: {
@@ -23,7 +22,6 @@ module.exports = {
2322
rules: [
2423
{
2524
test: /\.css$/,
26-
exclude: /dist|design/,
2725
use: ["style-loader", "css-loader"],
2826
},
2927
],
@@ -34,7 +32,11 @@ module.exports = {
3432
},
3533
plugins: [
3634
new webpack.DefinePlugin({
37-
"process.env.LOCAL_COMMIT_HASH": JSON.stringify(commitHash)
35+
"process.env.GIT_VERSION": JSON.stringify(git("describe --always")),
36+
"process.env.GIT_AUTHOR_DATE": JSON.stringify(git("log -1 --format=%aI")),
37+
"process.env.LOCAL_COMMIT_HASH": JSON.stringify(git("rev-parse HEAD")),
3838
}),
3939
],
40+
41+
4042
};

package-lock.json

Lines changed: 60 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@material-ui/lab": "^4.0.0-alpha.61",
1313
"axios": "^1.7.7",
1414
"better-react-mathjax": "^2.0.4-beta1",
15+
"cross-env": "^7.0.3",
1516
"css-loader": "^7.1.2",
1617
"d3": "^6.3.1",
1718
"d3-delaunay": "^6.0.2",
@@ -21,6 +22,7 @@
2122
"electron-is-dev": "^2.0.0",
2223
"electron-squirrel-startup": "^1.0.0",
2324
"gh-pages": "^3.2.3",
25+
"git-revision-webpack-plugin": "^5.0.0",
2426
"material-ui-image": "^3.3.2",
2527
"material-ui-popup-state": "^3.1.1",
2628
"moment": "^2.29.4",
@@ -38,13 +40,15 @@
3840
"xlsx-populate": "^1.21.0",
3941
"xlsx-style": "^0.8.13"
4042
},
41-
"browser":{
42-
"child_process": false
43+
"browser": {
44+
"child_process": false
4345
},
4446
"scripts": {
4547
"start": "electron-forge start",
4648
"dev2": "react-scripts start",
47-
"build": "npm run build:react && npm run build:bundle",
49+
"old.build": "npm run build:react && npm run build:bundle",
50+
"build-linux": "REACT_APP_COMMIT_HASH=$(git rev-parse HEAD) react-scripts build",
51+
"build-win": "git rev-parse HEAD && cross-env REACT_APP_COMMIT_HASH=$(\"git rev-parse HEAD\") react-scripts build",
4852
"build:react": "react-scripts build",
4953
"build:bundle": "webpack --config webpack.config.js",
5054
"test": "react-scripts test",
@@ -157,4 +161,4 @@
157161
"wait-on": "^6.0.0",
158162
"webpack-cli": "^4.10.0"
159163
}
160-
}
164+
}

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
manifest.json provides metadata used when your web app is installed on a
1717
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1818
-->
19-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
19+
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> -->
2020
<!--
2121
Notice the use of %PUBLIC_URL% in the tags above.
2222
It will be replaced with the URL of the `public` folder during the build.

src/App.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { createMuiTheme } from "@material-ui/core/styles";
1212
import headerPic from './image/Header_EXBD_prnt_fromMac.png';
1313
import packagejson from '../package.json';
1414

15+
1516
let theme = createMuiTheme({
1617
palette: {
1718
primary: { main: '#14375A' },
@@ -72,7 +73,6 @@ function App() {
7273
async function checkForUpdates() {
7374
const repo = "iDataVisualizationLab/TxDOT";
7475
const branch = "main";
75-
7676
try {
7777
// Use the GitHub API to get the latest commit
7878
const response = await fetch(`https://api.github.com/repos/${repo}/commits/${branch}`);
@@ -83,9 +83,8 @@ function App() {
8383

8484
const data = await response.json();
8585
const latestCommitHash = data.sha;
86-
console.log(process.env.LOCAL_COMMIT_HASH, latestCommitHash)
87-
// Compare with the local commit hash
88-
if (process.env.LOCAL_COMMIT_HASH !== latestCommitHash) {
86+
console.log(process.env.REACT_APP_COMMIT_HASH, latestCommitHash)
87+
if (process.env.REACT_APP_COMMIT_HASH !== latestCommitHash) {
8988
if (!isShown) {
9089
setOpenUpdateDialog(true);
9190
} else {

yarn.lock

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4969,6 +4969,13 @@ cross-dirname@^0.1.0:
49694969
resolved "https://registry.npmjs.org/cross-dirname/-/cross-dirname-0.1.0.tgz"
49704970
integrity sha512-+R08/oI0nl3vfPcqftZRpytksBXDzOUveBq/NBVx0sUp1axwzPQrKinNx5yd5sxPu8j1wIy8AfnVQ+5eFdha6Q==
49714971

4972+
cross-env@^7.0.3:
4973+
version "7.0.3"
4974+
resolved "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz"
4975+
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
4976+
dependencies:
4977+
cross-spawn "^7.0.1"
4978+
49724979
cross-spawn-windows-exe@^1.1.0, cross-spawn-windows-exe@^1.2.0:
49734980
version "1.2.0"
49744981
resolved "https://registry.npmjs.org/cross-spawn-windows-exe/-/cross-spawn-windows-exe-1.2.0.tgz"
@@ -6118,11 +6125,6 @@ dotenv@^10.0.0:
61186125
resolved "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz"
61196126
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
61206127

6121-
dotenv@^16.4.5:
6122-
version "16.4.5"
6123-
resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz"
6124-
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==
6125-
61266128
dotenv@^9.0.2:
61276129
version "9.0.2"
61286130
resolved "https://registry.npmjs.org/dotenv/-/dotenv-9.0.2.tgz"
@@ -7598,6 +7600,11 @@ gh-pages@^3.2.3:
75987600
fs-extra "^8.1.0"
75997601
globby "^6.1.0"
76007602

7603+
git-revision-webpack-plugin@^5.0.0:
7604+
version "5.0.0"
7605+
resolved "https://registry.npmjs.org/git-revision-webpack-plugin/-/git-revision-webpack-plugin-5.0.0.tgz"
7606+
integrity sha512-RptQN/4UKcEPkCBmRy8kLPo5i8MnF8+XfAgFYN9gbwmKLTLx4YHsQw726H+C5+sIGDixDkmGL3IxPA2gKo+u4w==
7607+
76017608
gl-mat4@^1.2.0:
76027609
version "1.2.0"
76037610
resolved "https://registry.npmjs.org/gl-mat4/-/gl-mat4-1.2.0.tgz"

0 commit comments

Comments
 (0)