diff --git a/packages/interface/package.json b/packages/interface/package.json index 37250d78..3b76e22b 100644 --- a/packages/interface/package.json +++ b/packages/interface/package.json @@ -3,15 +3,16 @@ "version": "0.1.0", "private": true, "scripts": { - "build": "next build", - "dev": "next dev", + "build": "pnpm run git-hash && next build", + "dev": "pnpm run git-hash && next dev", "lint": "next lint", "lint:fix": "next lint --fix", - "start": "next start", + "start": "pnpm run git-hash && next start", "prettier": "prettier -c .", "prettier:fix": "prettier -w .", "types": "tsc -p tsconfig.json --noEmit", - "eas:registerSchemas": "npx tsx src/lib/eas/registerSchemas" + "eas:registerSchemas": "npx tsx src/lib/eas/registerSchemas", + "git-hash": "node ./scripts/genGitHash.js" }, "dependencies": { "@ethereum-attestation-service/eas-sdk": "^2.7.0", diff --git a/packages/interface/scripts/genGitHash.js b/packages/interface/scripts/genGitHash.js new file mode 100644 index 00000000..94c6f65a --- /dev/null +++ b/packages/interface/scripts/genGitHash.js @@ -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", + ); +} diff --git a/packages/interface/src/components/Footer.tsx b/packages/interface/src/components/Footer.tsx index 574d6708..340475c5 100644 --- a/packages/interface/src/components/Footer.tsx +++ b/packages/interface/src/components/Footer.tsx @@ -2,6 +2,8 @@ import Image from "next/image"; import { FaGithub, FaDiscord } from "react-icons/fa"; import { FaXTwitter } from "react-icons/fa6"; +import { config } from "~/config"; + import { Logo } from "./ui/Logo"; export const Footer = (): JSX.Element => ( @@ -26,6 +28,8 @@ export const Footer = (): JSX.Element => (