UNPKG

@storm-software/config-tools

Version:

⚡The Storm-Ops monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.

95 lines (92 loc) 2.43 kB
import { findWorkspaceRoot } from "./chunk-K6PUXRK3.js"; import { joinPaths } from "./chunk-D6E6GZD2.js"; import { __name } from "./chunk-SHUYVCID.js"; // src/utilities/get-default-config.ts import { STORM_DEFAULT_HOMEPAGE, STORM_DEFAULT_LICENSE } from "@storm-software/config"; import { existsSync } from "node:fs"; import { readFile } from "node:fs/promises"; import { join } from "node:path"; var DEFAULT_COLOR_CONFIG = { light: { background: "#fafafa", foreground: "#1d1e22", brand: "#1fb2a6", alternate: "#db2777", help: "#5C4EE5", success: "#087f5b", info: "#0550ae", warning: "#e3b341", danger: "#D8314A", positive: "#22c55e", negative: "#dc2626" }, dark: { background: "#1d1e22", foreground: "#cbd5e1", brand: "#2dd4bf", alternate: "#db2777", help: "#818cf8", success: "#10b981", info: "#58a6ff", warning: "#f3d371", danger: "#D8314A", positive: "#22c55e", negative: "#dc2626" } }; var getDefaultConfig = /* @__PURE__ */ __name(async (root) => { let license = STORM_DEFAULT_LICENSE; let homepage = STORM_DEFAULT_HOMEPAGE; let name = void 0; let namespace = void 0; let repository = void 0; const workspaceRoot = findWorkspaceRoot(root); if (existsSync(join(workspaceRoot, "package.json"))) { const file = await readFile(joinPaths(workspaceRoot, "package.json"), "utf8"); if (file) { const packageJson = JSON.parse(file); if (packageJson.name) { name = packageJson.name; } if (packageJson.namespace) { namespace = packageJson.namespace; } if (packageJson.repository) { if (typeof packageJson.repository === "string") { repository = packageJson.repository; } else if (packageJson.repository.url) { repository = packageJson.repository.url; } } if (packageJson.license) { license = packageJson.license; } if (packageJson.homepage) { homepage = packageJson.homepage; } } } return { workspaceRoot, name, namespace, repository, license, homepage, docs: `${homepage || STORM_DEFAULT_HOMEPAGE}/docs`, licensing: `${homepage || STORM_DEFAULT_HOMEPAGE}/license`, error: { url: `${homepage || STORM_DEFAULT_HOMEPAGE}/errors` } }; }, "getDefaultConfig"); export { DEFAULT_COLOR_CONFIG, getDefaultConfig };