Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import type { SourceFile } from "../check";
const MIGRATIONS_REL = "packages/database/supabase/migrations";
/**
* Repo root, resolved from this source file (not cwd) so checks run correctly
* from any working directory. This file is packages/checks/src/sources/ → 4 up.
*/
export function repoRoot(): string {
const root = resolve(dirname(fileURLToPath(import.meta.url)), "../../../..");
if (!existsSync(join(root, MIGRATIONS_REL))) {
throw new Error(
`Could not locate repo root from ${import.meta.url} (resolved ${root}); ${MIGRATIONS_REL} not found.`
);
}
return root;
}
export function migrationsDir(root: string): string {
return join(root, MIGRATIONS_REL);
}
export function loadSqlFiles(dir: string): SourceFile[] {
return readdirSync(dir)
.filter((f) => f.endsWith(".sql"))
.sort()
.map((f) => ({ file: f, contents: readFileSync(join(dir, f), "utf8") }));
}