@velaro/cli 0.5.0 → 0.7.0

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.
@@ -1,64 +1,64 @@
1
- /**
2
- * Non-blocking update checker.
3
- * Fetches the latest version from npm once per day (cached in ~/.velaro/config.json).
4
- * Prints a one-line notice AFTER the command completes if a newer version is available.
5
- */
6
-
7
- import { readConfig, writeConfig } from './config.js';
8
- import { createRequire } from 'module';
9
-
10
- const require = createRequire(import.meta.url);
11
- const { version: currentVersion } = require('../package.json');
12
-
13
- const NPM_REGISTRY = 'https://registry.npmjs.org/@velaro/cli/latest';
14
- const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // once per day
15
-
16
- /**
17
- * Starts the update check in the background.
18
- * Returns a function you await AFTER your command finishes to print any notice.
19
- */
20
- export function startUpdateCheck() {
21
- const cfg = readConfig();
22
- const lastCheck = cfg._lastUpdateCheck ?? 0;
23
- const now = Date.now();
24
-
25
- if (now - lastCheck < CHECK_INTERVAL_MS) {
26
- // Use cached result — no network call
27
- return async () => printNoticeIfStale(cfg._latestVersion);
28
- }
29
-
30
- // Fire off the network request without awaiting it here
31
- const fetchPromise = fetch(NPM_REGISTRY, { signal: AbortSignal.timeout(4000) })
32
- .then((r) => r.json())
33
- .then((data) => {
34
- const latest = data?.version ?? null;
35
- writeConfig({ ...readConfig(), _lastUpdateCheck: now, _latestVersion: latest });
36
- return latest;
37
- })
38
- .catch(() => null); // never block the CLI on a network failure
39
-
40
- return async () => {
41
- const latest = await fetchPromise;
42
- printNoticeIfStale(latest);
43
- };
44
- }
45
-
46
- function printNoticeIfStale(latest) {
47
- if (!latest || latest === currentVersion) return;
48
- if (!isNewer(latest, currentVersion)) return;
49
-
50
- process.stderr.write(
51
- `\n Update available: ${currentVersion} → ${latest}\n` +
52
- ` Run: npm install -g @velaro/cli@latest\n\n`
53
- );
54
- }
55
-
56
- function isNewer(a, b) {
57
- const pa = a.split('.').map(Number);
58
- const pb = b.split('.').map(Number);
59
- for (let i = 0; i < 3; i++) {
60
- if ((pa[i] ?? 0) > (pb[i] ?? 0)) return true;
61
- if ((pa[i] ?? 0) < (pb[i] ?? 0)) return false;
62
- }
63
- return false;
64
- }
1
+ /**
2
+ * Non-blocking update checker.
3
+ * Fetches the latest version from npm once per day (cached in ~/.velaro/config.json).
4
+ * Prints a one-line notice AFTER the command completes if a newer version is available.
5
+ */
6
+
7
+ import { readConfig, writeConfig } from './config.js';
8
+ import { createRequire } from 'module';
9
+
10
+ const require = createRequire(import.meta.url);
11
+ const { version: currentVersion } = require('../package.json');
12
+
13
+ const NPM_REGISTRY = 'https://registry.npmjs.org/@velaro/cli/latest';
14
+ const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // once per day
15
+
16
+ /**
17
+ * Starts the update check in the background.
18
+ * Returns a function you await AFTER your command finishes to print any notice.
19
+ */
20
+ export function startUpdateCheck() {
21
+ const cfg = readConfig();
22
+ const lastCheck = cfg._lastUpdateCheck ?? 0;
23
+ const now = Date.now();
24
+
25
+ if (now - lastCheck < CHECK_INTERVAL_MS) {
26
+ // Use cached result — no network call
27
+ return async () => printNoticeIfStale(cfg._latestVersion);
28
+ }
29
+
30
+ // Fire off the network request without awaiting it here
31
+ const fetchPromise = fetch(NPM_REGISTRY, { signal: AbortSignal.timeout(4000) })
32
+ .then((r) => r.json())
33
+ .then((data) => {
34
+ const latest = data?.version ?? null;
35
+ writeConfig({ ...readConfig(), _lastUpdateCheck: now, _latestVersion: latest });
36
+ return latest;
37
+ })
38
+ .catch(() => null); // never block the CLI on a network failure
39
+
40
+ return async () => {
41
+ const latest = await fetchPromise;
42
+ printNoticeIfStale(latest);
43
+ };
44
+ }
45
+
46
+ function printNoticeIfStale(latest) {
47
+ if (!latest || latest === currentVersion) return;
48
+ if (!isNewer(latest, currentVersion)) return;
49
+
50
+ process.stderr.write(
51
+ `\n Update available: ${currentVersion} → ${latest}\n` +
52
+ ` Run: npm install -g @velaro/cli@latest\n\n`
53
+ );
54
+ }
55
+
56
+ function isNewer(a, b) {
57
+ const pa = a.split('.').map(Number);
58
+ const pb = b.split('.').map(Number);
59
+ for (let i = 0; i < 3; i++) {
60
+ if ((pa[i] ?? 0) > (pb[i] ?? 0)) return true;
61
+ if ((pa[i] ?? 0) < (pb[i] ?? 0)) return false;
62
+ }
63
+ return false;
64
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@velaro/cli",
3
- "version": "0.5.0",
4
- "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, and MCP API keys.",
3
+ "version": "0.7.0",
4
+ "description": "Velaro Workspace v20 — command-line interface for managing bots, knowledge base ingestion, MCP API keys, search indexes, and ops health.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "velaro": "bin/velaro.js"