UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

56 lines (55 loc) • 2.84 kB
import { a as asOptionalRecord } from "./record-coerce-CVPuDqcc.mjs"; import { n as readInstallOwner, t as formatInstallOwnerMessage } from "./install-owner-DDPQXcjQ.mjs"; import { t as note } from "./note-CnLgHvug.mjs"; import fs from "node:fs"; import path from "node:path"; import { parseDocument } from "yaml"; //#region src/commands/doctor-install.ts async function noteSourceInstallIssues(e) { if (!e) return; const t = await readInstallOwner(e); if (t) { note(formatInstallOwnerMessage(t), "Install"); return; } const n = path.join(e, "src", "entry.ts"); const r = path.join(e, "pnpm-workspace.yaml"); if (!fs.existsSync(r) || !fs.existsSync(n)) return; const i = []; const a = path.join(e, "node_modules"); const o = path.join(a, ".pnpm"); const s = path.join(a, ".bin", "tsx"); if (fs.existsSync(a) && !fs.existsSync(o)) i.push("- node_modules was not installed by pnpm (missing node_modules/.pnpm). Run: pnpm install so bundled plugins can load package-local dependencies."); if (fs.existsSync(path.join(e, "package-lock.json"))) i.push("- package-lock.json present in a pnpm workspace. If you ran npm install, remove it and reinstall with pnpm."); if (!fs.existsSync(s)) i.push("- tsx binary is missing for source runs. Run: pnpm install."); i.push(...detectSelfLinkWarnings(e)); if (i.length > 0) note(i.join("\n"), "Install"); } const SELF_LINK_RECOVERY = "Inspect the diff: git diff -- package.json pnpm-workspace.yaml pnpm-lock.yaml. Selectively restore the damaged dependency and override entries (including any missing override pins) and matching lockfile changes from a known-good revision, preserving unrelated edits in all three files. Then verify recovery: pnpm install --frozen-lockfile. Never run pnpm link/npm link inside a deployment checkout."; function isSelfLink(e, t) { if (typeof t !== "string" || !t.startsWith("link:")) return false; const n = path.resolve(e, t.slice(5)); try { return fs.realpathSync(n) === fs.realpathSync(e); } catch { return n === path.resolve(e); } } function detectSelfLinkWarnings(e) { const t = []; for (const [n, r] of [["package.json", "has a self-referential \"openclaw\": \"link:\" dependency"], ["pnpm-workspace.yaml", "contains a self-referential \"openclaw: link:\" entry"]]) try { const i = fs.readFileSync(path.join(e, n), "utf8"); let a; if (n === "package.json") { const e = asOptionalRecord(JSON.parse(i)); a = [e?.dependencies, e?.devDependencies].map((e) => asOptionalRecord(e)?.openclaw); } else { const e = parseDocument(i); a = e.errors.length === 0 ? [e.toJS()?.overrides?.openclaw] : []; } if (a.some((t) => isSelfLink(e, t))) t.push(`- ${n} ${r}, which can break frozen pnpm installs. If the link is unintended: ${SELF_LINK_RECOVERY}`); } catch {} return t; } //#endregion export { noteSourceInstallIssues };