Skip to content

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.

build: add script to create symlinks for .env files

Brad Barbinf92eb2ee57b6
diff --git a/.gitignore b/.gitignore
index 647f7d71fd..3508b41990 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,5 +21,6 @@ vite.config.ts.timestamp*
.env.production.local
!packages/apps/**/.env
packages/database/.env
+packages/database/supabase/seed.sql
.vercel
\ No newline at end of file
diff --git a/apps/erp/app/routes/onboarding+/_index.tsx b/apps/erp/app/routes/onboarding+/_index.tsx
index 4adbbd61a7..8792fa490e 100644
--- a/apps/erp/app/routes/onboarding+/_index.tsx
+++ b/apps/erp/app/routes/onboarding+/_index.tsx
@@ -14,6 +14,10 @@ export default function GetStarted() {
<Heading size="h1" className="m-0">
Welcome to Carbon
</Heading>
+ <p className="text-muted-foreground text-balance text-sm pb-4">
+ Carbon is a manufacturing platform that combines ERP, MES, and QMS into
+ a single, unified system.
+ </p>
<Button size="lg" asChild>
<Link to={onboardingSequence[0]}>Get Started</Link>
diff --git a/package.json b/package.json
index 5f1618285f..6c12fad853 100755
--- a/package.json
+++ b/package.json
@@ -54,6 +54,7 @@
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "turbo run lint",
"novu:sync": "npx novu@latest sync --bridge-url https://app.carbonos.dev/api/novu --secret-key $NOVU_SECRET_KEY --api-url https://api.novu.co",
+ "predb:build": "tsx scripts/setup-env-files.ts",
"postdb:build": "run-s generate:types generate:swagger",
"prepare": "npx husky install",
"setup": "turbo run setup",
diff --git a/scripts/setup-env-files.ts b/scripts/setup-env-files.ts
new file mode 100644
index 0000000000..eb89dc453d
--- /dev/null
+++ b/scripts/setup-env-files.ts
@@ -0,0 +1,79 @@
+import * as dotenv from "dotenv";
+import {
+ existsSync,
+ readFileSync,
+ symlinkSync,
+ unlinkSync,
+ writeFileSync,
+} from "fs";
+import { join } from "path";
+
+const ROOT_ENV_PATH = join(process.cwd(), ".env");
+
+if (!existsSync(ROOT_ENV_PATH)) {
+ throw new Error("No .env file found in root directory");
+}
+
+// Load and parse .env file
+dotenv.config();
+const DEFAULT_EMAIL = process.env.DEFAULT_EMAIL_ADDRESS;
+
+if (!DEFAULT_EMAIL) {
+ throw new Error("DEFAULT_EMAIL_ADDRESS not found in .env file");
+}
+
+const APPS_DIR = join(process.cwd(), "apps");
+const PACKAGES_DIR = join(process.cwd(), "packages");
+const SEED_SQL_PATH = join(PACKAGES_DIR, "database", "supabase", "seed.sql");
+
+// List of package folders that need .env symlinks
+const PACKAGE_FOLDERS = ["database", "kv"];
+
+function createSymlink(targetPath: string, sourcePath: string) {
+ try {
+ // Remove existing symlink if it exists
+ if (existsSync(targetPath)) {
+ unlinkSync(targetPath);
+ }
+
+ // Create new symlink
+ symlinkSync(sourcePath, targetPath);
+ console.log(`Created symlink at ${targetPath}`);
+ } catch (error) {
+ console.error(`Failed to create symlink at ${targetPath}:`, error);
+ }
+}
+
+// Update seed.sql with new email
+if (existsSync(SEED_SQL_PATH)) {
+ try {
+ const content = readFileSync(SEED_SQL_PATH, "utf8");
+ const updatedContent = content.replace(
+ /brad@carbonos\.dev/g,
+ DEFAULT_EMAIL
+ );
+ writeFileSync(SEED_SQL_PATH, updatedContent);
+ console.log(`Updated email in seed.sql`);
+ } catch (error) {
+ console.error(`Failed to update seed.sql:`, error);
+ }
+}
+
+// Create symlinks in apps directory
+if (existsSync(APPS_DIR)) {
+ const apps = ["erp", "mes", "starter"];
+ apps.forEach((app) => {
+ const appEnvPath = join(APPS_DIR, app, ".env");
+ createSymlink(appEnvPath, ROOT_ENV_PATH);
+ });
+}
+
+// Create symlinks in selected packages
+if (existsSync(PACKAGES_DIR)) {
+ PACKAGE_FOLDERS.forEach((pkg) => {
+ const pkgEnvPath = join(PACKAGES_DIR, pkg, ".env");
+ createSymlink(pkgEnvPath, ROOT_ENV_PATH);
+ });
+}
+
+console.log("Environment file setup complete!");