File size: 712 Bytes
cb5d9d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { readFileSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

const root = dirname(fileURLToPath(import.meta.url));
const frontendRoot = join(root, "..");
const pkg = JSON.parse(
  readFileSync(join(frontendRoot, "package.json"), "utf8"),
);
const version = pkg.version || "0.0.0";
const timestamp = new Date()
  .toISOString()
  .replace(/[-:]/g, "")
  .replace(/\.\d+Z$/, "");
const fullVersion = `${version}-dev.${timestamp}`;
const content = `export const appVersion = ${JSON.stringify(fullVersion)};\n`;

writeFileSync(join(frontendRoot, "src", "version.ts"), content, "utf8");
console.log(`Generated version: ${fullVersion}`);