Skip to content

Commit

Permalink
added some basic dev info
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo1212 committed Oct 26, 2023
1 parent dcd82fd commit a05f62e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ REACT_APP_FIREBASE_MESSAGING_SENDER_ID=
REACT_APP_FIREBASE_APP_ID=
REACT_APP_SENTRY_DNS=
REACT_APP_AUTH0_DOMAIN=
REACT_APP_AUTH0_CLIENT_ID=
REACT_APP_AUTH0_CLIENT_ID=
REACT_APP_DEV_ENV=true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

generatedGitInfo.json

# dependencies
/node_modules
/.pnp
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
"typescript": "^4.4.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"git-info": "node src/gitInfo.js",
"start": "npm run git-info && react-scripts start",
"build": "npm run git-info && react-scripts build",
"test": "npm run git-info && react-scripts test",
"eject": "react-scripts eject",
"serve": "serve -s build"
},
Expand Down
8 changes: 5 additions & 3 deletions src/components/navigation/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {createContext, useEffect, useState} from 'react';
import styles from './NavigationMenu.module.scss';
import appStyles from 'styles.module.scss';
import classNames from 'classnames';
import {Layout, Menu, message, Spin, Typography} from 'antd';
import {Layout, Menu, message, Spin, Tag, Typography} from 'antd';
import {AppRoute, AppRoutes, HomeRoute} from 'routes';
import {Route, Routes, useLocation, useNavigate} from 'react-router';
import {auth, firestore} from 'config/firebase/firebase';
Expand All @@ -15,6 +15,7 @@ import {abteilungenCollection} from 'config/firebase/collections';
import {setGroupDates} from 'util/GroupUtil';
import {VerifyEmail} from './VerifyEmail';
import { useParams } from "react-router-dom";
import generatedGitInfo from 'generatedGitInfo.json';

const {Header, Content, Footer, Sider} = Layout;

Expand Down Expand Up @@ -168,11 +169,12 @@ const NavigationMenu: React.FC = () => {
</Routes>
}
</Content>
<Footer style={{textAlign: 'center'}}>
<Footer style={{textAlign: 'center', backgroundColor: process.env.REACT_APP_DEV_ENV === 'true' ? '#FF4B91' : 'unset'}}>
Designed by <a href='https://cevi.tools' target='_blank'>Cevi Tools</a> | &copy; Cevi
Tools {(new Date()).getFullYear()}
{process.env.REACT_APP_DEV_ENV === 'true' && <> |
DEV
Branch: <Tag>{generatedGitInfo.gitBranch}</Tag>
Git Hash: <Tag>{generatedGitInfo.gitCommitHash}</Tag>
</>}
</Footer>
</Layout>
Expand Down
31 changes: 31 additions & 0 deletions src/gitInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const fs = require('fs');
const path = require('path');
const {execSync} = require('child_process');

const execSyncWrapper = (command) => {
let stdout = null;
try {
stdout = execSync(command).toString().trim();
} catch (error) {
console.error(error);
}
return stdout;
};

const main = () => {
let gitBranch = execSyncWrapper('git rev-parse --abbrev-ref HEAD');
let gitCommitHash = execSyncWrapper('git rev-parse --short=7 HEAD');

const obj = {
gitBranch,
gitCommitHash
};

const filePath = path.resolve('src', 'generatedGitInfo.json');
const fileContents = JSON.stringify(obj, null, 2);

fs.writeFileSync(filePath, fileContents);
console.log(`Wrote the following contents to ${filePath}\n${fileContents}`);
};

main();

0 comments on commit a05f62e

Please sign in to comment.