-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
102 lines (85 loc) · 3.23 KB
/
Copy pathbuild.js
File metadata and controls
102 lines (85 loc) · 3.23 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env node
/**
* build.js — AI Architecture Advisor
*
* Bundles all modular source files into a single self-contained dist/index.html
* that works when opened from the desktop, GitHub Pages, or any static host.
*
* Usage:
* node build.js
*
* Output:
* dist/index.html ← upload this file to GitHub as index.html
*
* Workflow:
* 1. Edit source files in assets/ as normal
* 2. Run: node build.js
* 3. Deploy dist/index.html to GitHub
*/
const fs = require('fs');
const path = require('path');
// ─── CONFIG ──────────────────────────────────────────────────────────────────
const ROOT = __dirname;
const DIST = path.join(ROOT, 'dist');
const OUT = path.join(DIST, 'index.html');
const CSS_FILE = 'assets/css/styles.css';
// JS files in exact load order (mirrors the <script> tags in index.html)
const JS_FILES = [
'assets/data/scoring.js',
'assets/data/financial.js',
'assets/data/scenarios.js',
'assets/data/demo-blueprint.js',
'assets/agents/agent-01-discovery.js',
'assets/agents/agent-02-outcome.js',
'assets/agents/agent-03-capability.js',
'assets/agents/agent-04-architecture.js',
'assets/agents/agent-05-data-platform.js',
'assets/agents/agent-06-governance.js',
'assets/agents/agent-07-roadmap.js',
'assets/agents/agent-08-value.js',
'assets/data/agents.js',
'assets/js/api-client.js',
'assets/js/wizard.js',
'assets/js/pipeline.js',
'assets/js/results.js',
'assets/js/app.js',
];
// ─── BUILD ───────────────────────────────────────────────────────────────────
function read(relPath) {
return fs.readFileSync(path.join(ROOT, relPath), 'utf8');
}
function build() {
// Create dist/ if needed
if (!fs.existsSync(DIST)) fs.mkdirSync(DIST);
let html = read('index.html');
// 1. Inline CSS — replace <link> with <style>
const css = read(CSS_FILE);
html = html.replace(
`<link rel="stylesheet" href="${CSS_FILE}">`,
`<style>\n${css}\n</style>`
);
// 2. Inline JS — replace all <script src="..."> blocks with one <script>
// Find the DATA comment block through to </body>
const scriptBlockStart = html.indexOf('<!-- ─── DATA');
const bodyClose = html.indexOf('</body>');
if (scriptBlockStart === -1 || bodyClose === -1) {
console.error('✗ Could not find script block markers in index.html');
process.exit(1);
}
// Build combined JS
let combinedJs = JS_FILES.map(f => {
const name = path.basename(f);
const content = read(f);
return `\n/* ── ${name} ── */\n${content}`;
}).join('\n');
// Replace the external script block with inline
html = html.slice(0, scriptBlockStart)
+ `<script>${combinedJs}\n</script>\n`
+ html.slice(bodyClose); // includes </body></html>
// 3. Write output
fs.writeFileSync(OUT, html, 'utf8');
const kb = Math.round(fs.statSync(OUT).size / 1024);
console.log(`✓ Built: dist/index.html (${kb} KB)`);
console.log(` → Upload dist/index.html to GitHub as index.html`);
}
build();