Skip to content

Commit c7882eb

Browse files
SimplyLizclaude
andcommitted
fix(site): fall back to GitHub raw when Cargo.toml is out of build tree
Vercel only uploads the website/ directory, so the relative read of ../Cargo.toml fails with ENOENT during the build. Try the local file first (monorepo / local dev), then fall back to fetching Cargo.toml from main on raw.githubusercontent.com so Vercel still gets the canonical version. Single source of truth stays Cargo.toml. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4e359f5 commit c7882eb

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

website/astro.config.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ import { readFileSync } from 'node:fs';
44
import { fileURLToPath } from 'node:url';
55
import { dirname, resolve } from 'node:path';
66

7-
const here = dirname(fileURLToPath(import.meta.url));
8-
const cargoToml = readFileSync(resolve(here, '../Cargo.toml'), 'utf8');
7+
async function loadCargoToml() {
8+
// Local / monorepo build: read from sibling Cargo.toml.
9+
try {
10+
const here = dirname(fileURLToPath(import.meta.url));
11+
return readFileSync(resolve(here, '../Cargo.toml'), 'utf8');
12+
} catch {
13+
// Vercel / out-of-tree build: fetch the canonical version from main.
14+
const url = 'https://raw.githubusercontent.com/nyxCore-Systems/LIP/main/Cargo.toml';
15+
const res = await fetch(url);
16+
if (!res.ok) throw new Error(`astro.config: fetch ${url}${res.status}`);
17+
return await res.text();
18+
}
19+
}
20+
21+
const cargoToml = await loadCargoToml();
922
const match = cargoToml.match(/^\s*\[workspace\.package\][^\[]*?^\s*version\s*=\s*"([^"]+)"/ms);
1023
if (!match) {
1124
throw new Error('astro.config: could not parse [workspace.package].version from Cargo.toml');

0 commit comments

Comments
 (0)