| 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}`); |
|
|