the build needs a working directory, and its absence was silent
`bun run build:site` resolves the script from the package.json in the current directory. The helper had no cwd parameter, so it ran in the platform's own directory, which has no such script — and the error, "Script not found build:site", reads as the site missing a script rather than as it being asked in the wrong place. Second time today a spawn helper quietly lacked something the caller needed: the first was the environment for pm2. Both had the same shape — assembled correctly and then not passed. Verified by running the real build with the same environment the plugin builds: 29 entries in dist and an index.html with the site in it.
This commit is contained in:
+18
-7
@@ -65,12 +65,24 @@ const readRow = async () => (await db.select().from(fofosAdminSettings).limit(1)
|
||||
|
||||
export const distPath = (root: string): string => join(root, 'website', 'dist');
|
||||
|
||||
const run = async (argv: string[], timeoutMs = 60_000, env?: Record<string, string>) => {
|
||||
const run = async (
|
||||
argv: string[],
|
||||
timeoutMs = 60_000,
|
||||
options: { env?: Record<string, string>; cwd?: string } = {},
|
||||
) => {
|
||||
/*
|
||||
`cwd` matters and its absence was silent.
|
||||
|
||||
`bun run build:site` resolves the script from the package.json in the CURRENT directory. Without a
|
||||
cwd it ran in the platform's own, which has no such script, and the error — "Script not found" —
|
||||
reads like the site is missing one rather than like it was asked in the wrong place.
|
||||
*/
|
||||
const proc = Bun.spawn(argv, {
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
stdin: 'ignore',
|
||||
...(env ? { env: { ...process.env, ...env } } : {}),
|
||||
...(options.cwd ? { cwd: options.cwd } : {}),
|
||||
...(options.env ? { env: { ...process.env, ...options.env } } : {}),
|
||||
});
|
||||
const timer = setTimeout(() => proc.kill(), timeoutMs);
|
||||
try {
|
||||
@@ -137,10 +149,9 @@ export async function buildSite(secrets: {
|
||||
const url = new URL(raw);
|
||||
url.pathname = `/${databases.production.name}`;
|
||||
|
||||
const result = await run(
|
||||
['bun', 'run', 'build:site'],
|
||||
15 * 60 * 1000,
|
||||
{
|
||||
const result = await run(['bun', 'run', 'build:site'], 15 * 60 * 1000, {
|
||||
cwd: websiteDir,
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
FOFOS_ENV: 'production',
|
||||
POSTGRES_URL: url.toString(),
|
||||
@@ -154,7 +165,7 @@ export async function buildSite(secrets: {
|
||||
PUBLIC_URL: process.env.FOFOS_PUBLIC_URL ?? 'http://127.0.0.1',
|
||||
API_URL: process.env.FOFOS_PUBLIC_URL ?? 'http://127.0.0.1',
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
return { ok: result.ok, output: `$ bun run build:site (FOFOS_ENV=production)\n${result.output}` };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user