Live video on the AT Protocol
1#!/usr/bin/env node
2
3const { execSync } = require("child_process");
4const fs = require("fs");
5const path = require("path");
6
7function getGitInfo() {
8 try {
9 const hash = execSync("git rev-parse HEAD", { encoding: "utf-8" }).trim();
10 const shortHash = execSync("git rev-parse --short HEAD", {
11 encoding: "utf-8",
12 }).trim();
13 const branch = execSync("git rev-parse --abbrev-ref HEAD", {
14 encoding: "utf-8",
15 }).trim();
16 const tag = execSync("git describe --tags --always --dirty", {
17 encoding: "utf-8",
18 }).trim();
19 const isDirty = tag.endsWith("-dirty");
20
21 return {
22 hash,
23 shortHash,
24 branch,
25 tag,
26 isDirty,
27 };
28 } catch (error) {
29 console.warn("Could not get git info:", error.message);
30 return {
31 hash: "unknown",
32 shortHash: "unknown",
33 branch: "unknown",
34 tag: "unknown",
35 isDirty: false,
36 };
37 }
38}
39
40const buildInfo = {
41 ...getGitInfo(),
42 buildTime: new Date().toISOString(),
43};
44
45const outputPath = path.join(__dirname, "..", "src", "build-info.json");
46fs.writeFileSync(outputPath, JSON.stringify(buildInfo, null, 2));
47
48console.log("Generated build-info.json:", buildInfo);