-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add git commit version to organizer dashboard
- Loading branch information
Showing
6 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const { execSync } = require("child_process"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const commitHash = execSync('git log --pretty=format:"%h" -n1').toString().trim(); | ||
|
||
const key = "NEXT_PUBLIC_COMMIT_HASH"; | ||
|
||
const envFile = path.resolve(__dirname, "../.env"); | ||
|
||
let data = ""; | ||
if (fs.existsSync(envFile)) { | ||
data = fs.readFileSync(envFile, "utf8"); | ||
} | ||
|
||
const indexOfCommitHash = data.indexOf(key); | ||
|
||
if (indexOfCommitHash === -1) { | ||
fs.writeFileSync(envFile, `${data}\n${key}=${commitHash}\n`, "utf8"); | ||
} else { | ||
const indexOfNextLine = data.indexOf("\n", indexOfCommitHash); | ||
fs.writeFileSync( | ||
envFile, | ||
data | ||
.slice(0, indexOfCommitHash) | ||
.concat(data.slice(indexOfNextLine + 1)) | ||
.concat(`${key}=${commitHash}\n`), | ||
"utf8", | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import { config } from "~/config"; | ||
import { Layout } from "~/layouts/DefaultLayout"; | ||
|
||
const CoordinatorPage = (): JSX.Element => <Layout requireAuth>This is the coordinator page.</Layout>; | ||
const CoordinatorPage = (): JSX.Element => ( | ||
<Layout requireAuth> | ||
<div> | ||
<p>This is the coordinator page.</p> | ||
|
||
<p>You are using version with commit: {config.commitHash}</p> | ||
</div> | ||
</Layout> | ||
); | ||
|
||
export default CoordinatorPage; |