everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
35 lines (33 loc) • 1.17 kB
JavaScript
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
let node_fs = require("node:fs");
let node_path = require("node:path");
//#region src/cli/snapshot.ts
const SNAPSHOT_DIR = ".bos";
const SNAPSHOT_FILE = "sync-snapshot.json";
function snapshotPath(projectDir) {
return (0, node_path.join)(projectDir, SNAPSHOT_DIR, SNAPSHOT_FILE);
}
async function readSnapshot(projectDir) {
const path = snapshotPath(projectDir);
if (!(0, node_fs.existsSync)(path)) return null;
try {
const content = (0, node_fs.readFileSync)(path, "utf-8");
return JSON.parse(content);
} catch {
return null;
}
}
async function writeSnapshot(projectDir, data) {
const dir = (0, node_path.join)(projectDir, SNAPSHOT_DIR);
if (!(0, node_fs.existsSync)(dir)) (0, node_fs.mkdirSync)(dir, { recursive: true });
const snapshot = {
parentRef: data.parentRef,
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
files: data.files
};
(0, node_fs.writeFileSync)(snapshotPath(projectDir), `${JSON.stringify(snapshot, null, 2)}\n`);
}
//#endregion
exports.readSnapshot = readSnapshot;
exports.writeSnapshot = writeSnapshot;
//# sourceMappingURL=snapshot.cjs.map