-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-web.js
More file actions
49 lines (42 loc) · 1.93 KB
/
Copy pathbuild-web.js
File metadata and controls
49 lines (42 loc) · 1.93 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
// ============================================================
// build-web.js — assemble the GitHub Pages site for lab.usersfirst.games
// ============================================================
//
// Layout produced in _site/:
// _site/index.html ← web/index.html (landing page)
// _site/overlay/ ← apps/overlay/src (the overlay app, served at /overlay)
// _site/CNAME ← custom domain
// _site/.nojekyll ← serve files verbatim (no Jekyll _underscore munging)
//
// Run AFTER `node apps/overlay/scripts/copy-workspace.js`, which populates
// apps/overlay/src/lib/{controller-core,controller-visualizer} + the GLB
// assets. `three` is loaded from a CDN in web mode (the overlay's importmap),
// so it is NOT vendored here.
const fs = require('fs');
const path = require('path');
const root = path.join(__dirname, '..');
const site = path.join(root, '_site');
const overlaySrc = path.join(root, 'apps', 'overlay', 'src');
const DOMAIN = 'lab.usersfirst.games';
function copyDir(src, dest) {
fs.mkdirSync(dest, { recursive: true });
for (const e of fs.readdirSync(src, { withFileTypes: true })) {
const s = path.join(src, e.name);
const d = path.join(dest, e.name);
if (e.isDirectory()) copyDir(s, d);
else fs.copyFileSync(s, d);
}
}
if (!fs.existsSync(path.join(overlaySrc, 'lib', 'controller-core'))) {
console.error('ERROR: apps/overlay/src/lib not populated.');
console.error('Run `node apps/overlay/scripts/copy-workspace.js` first.');
process.exit(1);
}
fs.rmSync(site, { recursive: true, force: true });
fs.mkdirSync(site, { recursive: true });
fs.copyFileSync(path.join(root, 'web', 'index.html'), path.join(site, 'index.html'));
copyDir(overlaySrc, path.join(site, 'overlay'));
fs.writeFileSync(path.join(site, 'CNAME'), DOMAIN + '\n');
fs.writeFileSync(path.join(site, '.nojekyll'), '');
console.log(`Built _site/ for ${DOMAIN} (landing at /, overlay at /overlay/).`);