@worca/ui 0.1.0-rc.2 → 0.1.0-rc.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worca/ui",
3
- "version": "0.1.0-rc.2",
3
+ "version": "0.1.0-rc.3",
4
4
  "description": "Pipeline monitoring UI for worca-cc",
5
5
  "license": "MIT",
6
6
  "author": "Sinisha Djukic",
package/server/index.js CHANGED
@@ -31,6 +31,7 @@ function findProjectRoot(startDir) {
31
31
  return startDir; // fallback
32
32
  }
33
33
 
34
+ import { checkWorcaVersion } from './version-check.js';
34
35
  import { createInbox } from './webhook-inbox.js';
35
36
 
36
37
  let projectRoot, worcaDir, settingsPath;
@@ -102,6 +103,18 @@ app.locals.broadcast = broadcast;
102
103
  app.locals.scheduleRefresh = scheduleRefresh;
103
104
  app.locals.resolveRunProject = resolveRunProject;
104
105
 
106
+ // ─── worca-cc version check (non-blocking) ─────────────────────────────
107
+ checkWorcaVersion().then((result) => {
108
+ app.locals.worcaVersion = result;
109
+ if (result.ok) {
110
+ console.log(`[version] ${result.message}`);
111
+ } else if (result.installed) {
112
+ console.warn(`[version] ${result.message}`);
113
+ } else {
114
+ console.log(`[version] ${result.message}`);
115
+ }
116
+ });
117
+
105
118
  // ─── inotify budget check (Linux only) ─────────────────────────────────
106
119
  if (platform() === 'linux') {
107
120
  try {
@@ -0,0 +1,82 @@
1
+ // server/version-check.js — worca-cc version compatibility check
2
+ import { execFile } from 'node:child_process';
3
+
4
+ /** Minimum worca-cc version required by this @worca/ui release. */
5
+ export const MIN_WORCA_CC = '0.6.0';
6
+
7
+ /**
8
+ * Parse the version string from `worca --version` output.
9
+ * Expected format: "worca-cc X.Y.Z" or "worca-cc X.Y.Zrc3"
10
+ * @param {string} output - stdout from `worca --version`
11
+ * @returns {string|null} version string or null if unparseable
12
+ */
13
+ export function parseWorcaVersion(output) {
14
+ const match = output.trim().match(/^worca-cc\s+(\S+)/);
15
+ return match ? match[1] : null;
16
+ }
17
+
18
+ /**
19
+ * Compare two semver-ish versions, ignoring pre-release suffixes.
20
+ * "0.6.0rc3" satisfies ">= 0.6.0".
21
+ * @param {string} installed - installed version (e.g. "0.6.0rc3")
22
+ * @param {string} minimum - minimum required version (e.g. "0.6.0")
23
+ * @returns {boolean} true if installed >= minimum
24
+ */
25
+ export function meetsMinimum(installed, minimum) {
26
+ const parse = (v) =>
27
+ v.split('.').map((s) => {
28
+ const n = parseInt(s, 10);
29
+ return Number.isNaN(n) ? 0 : n;
30
+ });
31
+ const inst = parse(installed);
32
+ const min = parse(minimum);
33
+ const len = Math.max(inst.length, min.length);
34
+ for (let i = 0; i < len; i++) {
35
+ const a = inst[i] || 0;
36
+ const b = min[i] || 0;
37
+ if (a > b) return true;
38
+ if (a < b) return false;
39
+ }
40
+ return true; // equal
41
+ }
42
+
43
+ /**
44
+ * Run `worca --version` and check compatibility.
45
+ * @returns {Promise<{ok: boolean, installed: string|null, minimum: string, message: string}>}
46
+ */
47
+ export async function checkWorcaVersion() {
48
+ const minimum = MIN_WORCA_CC;
49
+ try {
50
+ const output = await new Promise((resolve, reject) => {
51
+ execFile('worca', ['--version'], { timeout: 5000 }, (err, stdout) => {
52
+ if (err) return reject(err);
53
+ resolve(stdout);
54
+ });
55
+ });
56
+ const installed = parseWorcaVersion(output);
57
+ if (!installed) {
58
+ return {
59
+ ok: false,
60
+ installed: null,
61
+ minimum,
62
+ message: `worca CLI not found — install with 'pip install worca-cc'`,
63
+ };
64
+ }
65
+ const ok = meetsMinimum(installed, minimum);
66
+ return {
67
+ ok,
68
+ installed,
69
+ minimum,
70
+ message: ok
71
+ ? `worca-cc ${installed} — compatible`
72
+ : `WARNING: worca-cc ${installed} found, minimum ${minimum} required — run 'pip install --upgrade worca-cc'`,
73
+ };
74
+ } catch {
75
+ return {
76
+ ok: false,
77
+ installed: null,
78
+ minimum,
79
+ message: `worca CLI not found — install with 'pip install worca-cc'`,
80
+ };
81
+ }
82
+ }