storyboard-bridge 0.3.3 → 0.3.4
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/index.mjs +17 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -32,7 +32,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
32
32
|
import { tmpdir } from 'node:os';
|
|
33
33
|
import { WebSocket } from 'ws';
|
|
34
34
|
|
|
35
|
-
const VERSION = '0.3.
|
|
35
|
+
const VERSION = '0.3.4';
|
|
36
36
|
|
|
37
37
|
// ---- config ----
|
|
38
38
|
const arg = (name, fallback) => {
|
|
@@ -62,6 +62,18 @@ const JOB_TIMEOUT_MS = 300_000;
|
|
|
62
62
|
|
|
63
63
|
const log = (m) => console.log(`[bridge ${new Date().toISOString().slice(11, 19)}] ${m}`);
|
|
64
64
|
|
|
65
|
+
// Is version `a` strictly older than `b`? (numeric x.y.z compare; missing parts = 0.) Used so the
|
|
66
|
+
// update nag fires ONLY when this bridge is behind the backend's advertised latest, never when ahead.
|
|
67
|
+
function isOlderVersion(a, b) {
|
|
68
|
+
const pa = String(a).split('.').map((n) => parseInt(n, 10) || 0);
|
|
69
|
+
const pb = String(b).split('.').map((n) => parseInt(n, 10) || 0);
|
|
70
|
+
for (let i = 0; i < 3; i++) {
|
|
71
|
+
if ((pa[i] || 0) < (pb[i] || 0)) return true;
|
|
72
|
+
if ((pa[i] || 0) > (pb[i] || 0)) return false;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
function wsUrl(httpUrl) {
|
|
66
78
|
const u = new URL(httpUrl);
|
|
67
79
|
u.protocol = u.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
@@ -243,7 +255,10 @@ function connect() {
|
|
|
243
255
|
return;
|
|
244
256
|
}
|
|
245
257
|
if (msg.type === 'welcome') {
|
|
246
|
-
|
|
258
|
+
// Only nag when we're genuinely OLDER than what the backend advertises — a plain `!==` also fired
|
|
259
|
+
// when this bridge was NEWER than the backend's advertised version (e.g. mid-rollout, before the
|
|
260
|
+
// backend redeploys), wrongly telling the user to "update" to an older build.
|
|
261
|
+
if (msg.latest && isOlderVersion(VERSION, msg.latest)) {
|
|
247
262
|
log(`UPDATE AVAILABLE: bridge v${msg.latest} (you have v${VERSION}). Update with: npm i -g storyboard-bridge (or just re-run via npx).`);
|
|
248
263
|
}
|
|
249
264
|
} else if (msg.type === 'job' && msg.id) {
|
package/package.json
CHANGED