From f6ddce9290edbbae18e37909baa2db7e72985352 Mon Sep 17 00:00:00 2001
From: Derek Slenk
Date: Wed, 16 Jul 2025 17:42:21 -0400
Subject: [PATCH] Add commit hash to footer for deployment verification
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Display git commit hash in footer to track deployed version
- Create cross-platform build script to inject commit hash
- Update build process to include version information
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude
---
.claude/settings.local.json | 7 ++++++-
package-lock.json | 20 ++++++++++++++++++++
package.json | 5 +++--
scripts/set-git-commit.js | 33 +++++++++++++++++++++++++++++++++
src/components/Footer.tsx | 3 +++
5 files changed, 65 insertions(+), 3 deletions(-)
create mode 100644 scripts/set-git-commit.js
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 8183bd6..db61623 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -12,7 +12,12 @@
"Bash(git push:*)",
"Bash(git commit:*)",
"Bash(git pull:*)",
- "Bash(git add:*)"
+ "Bash(git add:*)",
+ "Bash(git push:*)",
+ "Bash(git reset:*)",
+ "Bash(git checkout:*)",
+ "WebFetch(domain:cheatingchelsea.com)",
+ "Bash(npm install:*)"
],
"deny": []
}
diff --git a/package-lock.json b/package-lock.json
index 2313aca..08d33db 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -58,6 +58,7 @@
"@types/react-dom": "^18",
"aws-cdk-lib": "^2.189.1",
"constructs": "^10.4.2",
+ "cross-env": "^7.0.3",
"esbuild": "^0.25.5",
"eslint": "^9.30.0",
"eslint-config-next": "15.3.4",
@@ -5633,6 +5634,25 @@
"node": ">= 0.10"
}
},
+ "node_modules/cross-env": {
+ "version": "7.0.3",
+ "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
+ "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "cross-spawn": "^7.0.1"
+ },
+ "bin": {
+ "cross-env": "src/bin/cross-env.js",
+ "cross-env-shell": "src/bin/cross-env-shell.js"
+ },
+ "engines": {
+ "node": ">=10.14",
+ "npm": ">=6",
+ "yarn": ">=1"
+ }
+ },
"node_modules/cross-spawn": {
"version": "7.0.6",
"license": "MIT",
diff --git a/package.json b/package.json
index fb9fbd8..0f57edf 100644
--- a/package.json
+++ b/package.json
@@ -6,12 +6,12 @@
"dev": "next dev --turbopack -p 9002",
"genkit:dev": "genkit start -- tsx src/ai/dev.ts",
"genkit:watch": "genkit start -- tsx --watch src/ai/dev.ts",
- "build": "next build",
+ "build": "node scripts/set-git-commit.js && next build",
"build:static": "next build",
"start": "next start",
"lint": "next lint",
"typecheck": "tsc --noEmit",
- "deploy:s3": "npm run build:static && aws s3 sync out/ s3://$S3_BUCKET_NAME --delete",
+ "deploy:s3": "npm run build && aws s3 sync out/ s3://$S3_BUCKET_NAME --delete",
"create-s3-bucket": "node scripts/create-s3-bucket.js",
"prepare": "husky install"
},
@@ -66,6 +66,7 @@
"@types/react-dom": "^18",
"aws-cdk-lib": "^2.189.1",
"constructs": "^10.4.2",
+ "cross-env": "^7.0.3",
"esbuild": "^0.25.5",
"eslint": "^9.30.0",
"eslint-config-next": "15.3.4",
diff --git a/scripts/set-git-commit.js b/scripts/set-git-commit.js
new file mode 100644
index 0000000..6ccec14
--- /dev/null
+++ b/scripts/set-git-commit.js
@@ -0,0 +1,33 @@
+const { execSync } = require('child_process');
+const fs = require('fs');
+const path = require('path');
+
+try {
+ // Get the short commit hash
+ const gitCommit = execSync('git rev-parse --short HEAD').toString().trim();
+
+ // Create .env.local file with the commit hash
+ const envContent = `NEXT_PUBLIC_GIT_COMMIT=${gitCommit}\n`;
+ const envPath = path.join(process.cwd(), '.env.local');
+
+ // Read existing .env.local if it exists
+ let existingContent = '';
+ if (fs.existsSync(envPath)) {
+ existingContent = fs.readFileSync(envPath, 'utf8');
+ // Remove any existing NEXT_PUBLIC_GIT_COMMIT line
+ existingContent = existingContent.split('\n')
+ .filter(line => !line.startsWith('NEXT_PUBLIC_GIT_COMMIT='))
+ .join('\n');
+ if (existingContent && !existingContent.endsWith('\n')) {
+ existingContent += '\n';
+ }
+ }
+
+ // Write the updated content
+ fs.writeFileSync(envPath, existingContent + envContent);
+
+ console.log(`Git commit hash set: ${gitCommit}`);
+} catch (error) {
+ console.error('Error setting git commit:', error.message);
+ process.exit(1);
+}
\ No newline at end of file
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx
index ba59303..0b3d080 100644
--- a/src/components/Footer.tsx
+++ b/src/components/Footer.tsx
@@ -29,6 +29,9 @@ export function Footer() {
and is not affiliated with or endorsed by Kristen Jacobs.
© {new Date().getFullYear()} Cheating Chelsea Exposed. All Rights Reserved.
+
+ Build: {process.env.NEXT_PUBLIC_GIT_COMMIT || 'development'}
+
);