import fs from "node:fs/promises"; import path from "node:path"; export async function readPackageVersion(root: string): Promise { try { const raw = await fs.readFile(path.join(root, "package.json"), "utf-8"); const parsed = JSON.parse(raw) as { version?: string }; return typeof parsed?.version === "string" ? parsed.version : null; } catch { return null; } } export async function readPackageName(root: string): Promise { try { const raw = await fs.readFile(path.join(root, "package.json"), "utf-8"); const parsed = JSON.parse(raw) as { name?: string }; const name = parsed?.name?.trim(); return name ? name : null; } catch { return null; } }