From 2b0118d518d764c9a5fa2cb4b4436b27b6b25387 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 14 Feb 2026 04:19:58 +0000 Subject: [PATCH] Fix 4everland deployment by adding build script - Added `build.mjs` to bundle `landing`, `dashboard`, and `docs` into a `dist/` directory. - Updated `package.json` with a `build` script (`node build.mjs`). - Updated `.gitignore` to ignore the `dist/` directory. - Patched `landing/index.html` paths in the build output to correctly reference resources when deployed from `dist/` root. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- .gitignore | 3 ++- build.mjs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 build.mjs diff --git a/.gitignore b/.gitignore index b512c09..44d646d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +dist/ diff --git a/build.mjs b/build.mjs new file mode 100644 index 0000000..3f0e84a --- /dev/null +++ b/build.mjs @@ -0,0 +1,47 @@ +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const DIST_DIR = path.join(__dirname, 'dist'); +const LANDING_SRC = path.join(__dirname, 'landing'); +const DASHBOARD_SRC = path.join(__dirname, 'dashboard'); +const DOCS_SRC = path.join(__dirname, 'src', 'docs'); +const CONFIG_SRC = path.join(__dirname, 'torch-config.json'); + +// Ensure clean slate +if (fs.existsSync(DIST_DIR)) { + fs.rmSync(DIST_DIR, { recursive: true, force: true }); +} +fs.mkdirSync(DIST_DIR); + +// 1. Copy landing/index.html -> dist/index.html +const landingHtml = fs.readFileSync(path.join(LANDING_SRC, 'index.html'), 'utf8'); +let distHtml = landingHtml; + +// Patch relative paths for root deployment +// Remove ../ prefix for these specific paths since they are now relative to root (dist/) +distHtml = distHtml.replace(/"\.\.\/dashboard\/styles\.css"/g, '"dashboard/styles.css"'); +distHtml = distHtml.replace(/"\.\.\/dashboard\/"/g, '"dashboard/"'); // Link to dashboard +distHtml = distHtml.replace(/'\.\.\/src\/docs\/TORCH\.md'/g, "'src/docs/TORCH.md'"); + +fs.writeFileSync(path.join(DIST_DIR, 'index.html'), distHtml); + +// 2. Copy dashboard/ -> dist/dashboard/ +const distDashboard = path.join(DIST_DIR, 'dashboard'); +fs.mkdirSync(distDashboard, { recursive: true }); +fs.cpSync(DASHBOARD_SRC, distDashboard, { recursive: true }); + +// 3. Copy src/docs/ -> dist/src/docs/ +const distDocs = path.join(DIST_DIR, 'src', 'docs'); +fs.mkdirSync(distDocs, { recursive: true }); +fs.cpSync(DOCS_SRC, distDocs, { recursive: true }); + +// 4. Copy torch-config.json -> dist/torch-config.json (optional config) +if (fs.existsSync(CONFIG_SRC)) { + fs.copyFileSync(CONFIG_SRC, path.join(DIST_DIR, 'torch-config.json')); +} + +console.log('Build complete! Output directory: dist/'); diff --git a/package.json b/package.json index 2f66468..3a9fe98 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "lock:check:weekly": "node src/nostr-lock.mjs check --cadence weekly", "lock:list": "node src/nostr-lock.mjs list", "lock:lock": "node src/nostr-lock.mjs lock", - "dashboard:serve": "python3 -m http.server 4173" + "dashboard:serve": "python3 -m http.server 4173", + "build": "node build.mjs" }, "dependencies": { "nostr-tools": "2.19.4",