@yemi33/minions 0.1.35 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dashboard.js +32 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dashboard.js
CHANGED
|
@@ -92,11 +92,39 @@ function buildDashboardHtml() {
|
|
|
92
92
|
.replace('/* __JS__ */', () => jsHtml);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
let HTML_RAW = buildDashboardHtml();
|
|
96
|
+
let HTML = HTML_RAW.replace('Minions Mission Control', `Minions Mission Control — ${projectNames}`);
|
|
97
|
+
let HTML_GZ = zlib.gzipSync(HTML);
|
|
98
|
+
let HTML_ETAG = '"' + require('crypto').createHash('md5').update(HTML).digest('hex') + '"';
|
|
99
99
|
|
|
100
|
+
// Hot-reload: watch dashboard/ directory for changes and rebuild
|
|
101
|
+
function rebuildDashboardHtml() {
|
|
102
|
+
try {
|
|
103
|
+
const newRaw = buildDashboardHtml();
|
|
104
|
+
if (newRaw === HTML_RAW) return; // no changes
|
|
105
|
+
HTML_RAW = newRaw;
|
|
106
|
+
HTML = HTML_RAW.replace('Minions Mission Control', `Minions Mission Control — ${projectNames}`);
|
|
107
|
+
HTML_GZ = zlib.gzipSync(HTML);
|
|
108
|
+
HTML_ETAG = '"' + require('crypto').createHash('md5').update(HTML).digest('hex') + '"';
|
|
109
|
+
console.log(' Dashboard hot-reloaded');
|
|
110
|
+
} catch (e) { console.error(' Hot-reload error:', e.message); }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const dashDir = path.join(MINIONS_DIR, 'dashboard');
|
|
114
|
+
if (fs.existsSync(dashDir)) {
|
|
115
|
+
let _reloadTimer = null;
|
|
116
|
+
const scheduleReload = () => {
|
|
117
|
+
if (_reloadTimer) clearTimeout(_reloadTimer);
|
|
118
|
+
_reloadTimer = setTimeout(rebuildDashboardHtml, 300); // debounce 300ms
|
|
119
|
+
};
|
|
120
|
+
// Watch top-level files (styles.css, layout.html)
|
|
121
|
+
try { fs.watch(dashDir, scheduleReload); } catch {}
|
|
122
|
+
// Watch subdirectories (pages/, js/)
|
|
123
|
+
for (const sub of ['pages', 'js']) {
|
|
124
|
+
const subDir = path.join(dashDir, sub);
|
|
125
|
+
if (fs.existsSync(subDir)) try { fs.watch(subDir, scheduleReload); } catch {}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
100
128
|
|
|
101
129
|
// -- Data Collectors (most moved to engine/queries.js) --
|
|
102
130
|
|
package/package.json
CHANGED