import { readFile } from "node:fs/promises";
import { dirname, join } from "node:path";
import { commit, commitAt, commitAuthor, commitEmail } from "./package.readonly.js";
import { ok } from "./is.js";
const { pathname } = new URL(import.meta.url);
const directory = dirname(pathname);
export const root = join(directory, "../");
const packageJSON = await readFile(join(root, "./package.json"), "utf-8");
const packageInfo = JSON.parse(packageJSON);
export const name = packageInfo.name;
const splitName = name.split("/");
ok(splitName.length === 2, "Expected namespaced package");
export const namespace = splitName[0].replace(/^@/, "");
export const project = splitName[1];
export const description = packageInfo.description || "";
export const version = packageInfo.version;
export const packageIdentifier = `${name}@${version}`;
export const homepage = packageInfo.homepage;
export const bugsUrl = packageInfo.bugs?.url ?? homepage;
export const importmapRootName = (packageInfo.importmap?.root ?? "esnext/imports").replace(":name", name);
export const importmapPrefix = (packageInfo.importmap?.prefix ?? ":name").replace(":name", name);
export const importmapRoot = join(root, importmapRootName);
export const importmapPath = join(importmapRoot, "importmap.json");
export * from "./package.readonly.js";
export function logPackage() {
    console.log({
        packageIdentifier,
        homepage,
        commit,
        commitAt,
        commitAuthor,
        commitEmail
    });
}
//# sourceMappingURL=package.js.map