File size: 883 Bytes
5710dd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node
// Copy web/dist/** into server/dist/public/ so the bundled server can serve
// the SPA out of a single deploy artifact.

import { cp, mkdir, rm, stat } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

const here = dirname(fileURLToPath(import.meta.url));
const root = join(here, '..');
const src = join(root, 'web', 'dist');
const dst = join(root, 'server', 'dist', 'public');

try {
  await stat(src);
} catch {
  process.stderr.write(`[copy-web-dist] source missing: ${src}\n`);
  process.stderr.write('Did you run `pnpm --filter @moonshot-ai/vis-web build` first?\n');
  process.exit(1);
}

await rm(dst, { recursive: true, force: true });
await mkdir(dirname(dst), { recursive: true });
await cp(src, dst, { recursive: true });

process.stdout.write(`[copy-web-dist] copied ${src} -> ${dst}\n`);