Add build info JSON file after builds

This commit is contained in:
2026-09-23 05:18:53 +01:00
parent 2335c60cc3
commit 39a5e91eeb
9 changed files with 52 additions and 4 deletions
+15 -1
View File
@@ -4,6 +4,8 @@ import grabDirNames from "../../utils/grab-dir-names";
import { rmSync, writeFileSync } from "fs";
import bunextInit from "../../functions/bunext-init";
import pagesSSRBundler from "../../functions/bundler/pages-ssr-bundler";
import type { BuildDataType } from "../../types";
import { v4 } from "uuid";
const {
HYDRATION_DST_DIR,
@@ -11,7 +13,7 @@ const {
BUNDLER_CTX_MAP_JSON,
SSR_BUNDLER_CTX_MAP_JSON,
BUNX_CWD_MODULE_CACHE_DIR,
ROOT_DIR,
BUILD_INFO_JSON,
} = grabDirNames();
export default function () {
@@ -56,6 +58,18 @@ export default function () {
);
}
const build_data: BuildDataType = {
build_id: v4(),
build_date_unix: Date.now(),
build_date: Date(),
};
writeFileSync(
BUILD_INFO_JSON,
JSON.stringify(build_data, null, 4),
"utf-8",
);
log.success("Modules Built Successfully!");
process.exit();
+6
View File
@@ -424,3 +424,9 @@ export type BunSpawnOptions = Bun.SpawnOptions.SpawnOptions<
> & {
cmd: string[];
};
export type BuildDataType = {
build_id: string;
build_date_unix: number;
build_date: string;
};
+5
View File
@@ -30,6 +30,7 @@ export type DirNames = {
BUNX_LOGS_DIR: string;
BUNDLER_CTX_MAP_JSON: string;
SSR_BUNDLER_CTX_MAP_JSON: string;
BUILD_INFO_JSON: string;
};
export default function grabDirNames(): DirNames {
@@ -90,11 +91,14 @@ export default function grabDirNames(): DirNames {
BUNX_CWD_DIR,
"bundler-ctx-map.json",
);
const SSR_BUNDLER_CTX_MAP_JSON = path.join(
BUNX_CWD_DIR,
"ssr-bundler-ctx-map.json",
);
const BUILD_INFO_JSON = path.join(BUNX_CWD_DIR, "build-info.json");
return {
ROOT_DIR,
SRC_DIR,
@@ -125,6 +129,7 @@ export default function grabDirNames(): DirNames {
BUNX_LOGS_DIR,
BUNDLER_CTX_MAP_JSON,
SSR_BUNDLER_CTX_MAP_JSON,
BUILD_INFO_JSON,
};
}