@tolinax/ayoune-cli 2026.4.0 → 2026.5.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.
@@ -54,7 +54,13 @@ import { getLogo, getDescription, BRAND_BLUE } from "../helpers/logo.js";
54
54
  import { checkForUpdates } from "../helpers/updateNotifier.js";
55
55
  import { createRequire } from "module";
56
56
  const require = createRequire(import.meta.url);
57
- const pkg = require("../../../package.json");
57
+ let pkg;
58
+ try {
59
+ pkg = require("../../package.json"); // dist/ and npm install
60
+ }
61
+ catch (_a) {
62
+ pkg = require("../../../package.json"); // source tree (tests)
63
+ }
58
64
  export function createProgram(program) {
59
65
  program
60
66
  .version(pkg.version || "0.0.0")
@@ -6,50 +6,63 @@ import { EXIT_GENERAL_ERROR } from "../exitCodes.js";
6
6
  import { cliError } from "../helpers/cliError.js";
7
7
  import { handleResponseFormatOptions } from "../helpers/handleResponseFormatOptions.js";
8
8
  const CORE_SERVICES = [
9
- { name: "config-api", module: "config", path: "healthz" },
10
- { name: "auth", module: "auth", path: "healthz", customUrl: "auth" },
9
+ { name: "config-api", module: "config" },
10
+ { name: "auth", module: "auth" },
11
11
  ];
12
12
  const MODULE_SERVICES = {
13
- crm: [{ name: "crm-api", module: "crm", path: "healthz" }],
14
- marketing: [{ name: "marketing-api", module: "marketing", path: "healthz" }],
15
- hr: [{ name: "hr-api", module: "hr", path: "healthz" }],
16
- ecommerce: [{ name: "ecommerce-api", module: "ecommerce", path: "healthz" }],
17
- pm: [{ name: "pm-api", module: "pm", path: "healthz" }],
18
- devops: [{ name: "devops-api", module: "devops", path: "healthz" }],
19
- accounting: [{ name: "accounting-api", module: "accounting", path: "healthz" }],
20
- automation: [{ name: "automation-api", module: "automation", path: "healthz" }],
21
- support: [{ name: "support-api", module: "support", path: "healthz" }],
22
- reporting: [{ name: "reporting-api", module: "reporting", path: "healthz" }],
23
- monitoring: [{ name: "monitoring-api", module: "monitoring", path: "healthz" }],
13
+ crm: [{ name: "crm-api", module: "crm" }],
14
+ marketing: [{ name: "marketing-api", module: "marketing" }],
15
+ hr: [{ name: "hr-api", module: "hr" }],
16
+ ecommerce: [{ name: "ecommerce-api", module: "ecommerce" }],
17
+ pm: [{ name: "pm-api", module: "pm" }],
18
+ devops: [{ name: "devops-api", module: "devops" }],
19
+ accounting: [{ name: "accounting-api", module: "accounting" }],
20
+ automation: [{ name: "automation-api", module: "automation" }],
21
+ support: [{ name: "support-api", module: "support" }],
22
+ reporting: [{ name: "reporting-api", module: "reporting" }],
23
+ monitoring: [{ name: "monitoring-api", module: "monitoring" }],
24
24
  };
25
- async function checkService(name, module, healthPath) {
26
- var _a;
25
+ function extractVersion(data) {
26
+ var _a, _b, _c, _d, _e;
27
+ return ((_b = (_a = data === null || data === void 0 ? void 0 : data.meta) === null || _a === void 0 ? void 0 : _a.version) === null || _b === void 0 ? void 0 : _b.core) || ((_d = (_c = data === null || data === void 0 ? void 0 : data.meta) === null || _c === void 0 ? void 0 : _c.version) === null || _d === void 0 ? void 0 : _d.host) || (data === null || data === void 0 ? void 0 : data.version) || ((_e = data === null || data === void 0 ? void 0 : data.payload) === null || _e === void 0 ? void 0 : _e.version) || undefined;
28
+ }
29
+ async function checkService(name, module) {
27
30
  const baseUrl = getModuleBaseUrl(module);
28
31
  const start = Date.now();
29
32
  try {
30
- // Use api client directly to avoid handleAPIError calling process.exit()
31
33
  const response = await api({
32
34
  baseURL: baseUrl,
33
35
  method: "get",
34
- url: healthPath,
36
+ url: "/",
35
37
  timeout: 10000,
36
38
  headers: {
37
39
  Authorization: `Bearer ${secureStorage.getItem("token") || ""}`,
38
40
  },
39
41
  });
40
42
  const responseTime = Date.now() - start;
41
- const res = response.data;
42
43
  return {
43
44
  service: name,
44
45
  url: baseUrl,
45
46
  status: "healthy",
46
47
  responseTime,
47
- version: (res === null || res === void 0 ? void 0 : res.version) || ((_a = res === null || res === void 0 ? void 0 : res.payload) === null || _a === void 0 ? void 0 : _a.version) || undefined,
48
+ version: extractVersion(response.data),
48
49
  };
49
50
  }
50
51
  catch (e) {
51
52
  const responseTime = Date.now() - start;
52
53
  if (e.response) {
54
+ const data = e.response.data;
55
+ const version = extractVersion(data);
56
+ // A structured JSON response (even 404) with version info means the service is running
57
+ if (e.response.status < 500 && version) {
58
+ return {
59
+ service: name,
60
+ url: baseUrl,
61
+ status: "healthy",
62
+ responseTime,
63
+ version,
64
+ };
65
+ }
53
66
  return {
54
67
  service: name,
55
68
  url: baseUrl,
@@ -101,7 +114,7 @@ Examples:
101
114
  }
102
115
  }
103
116
  // Check services concurrently
104
- const results = await Promise.all(servicesToCheck.map((svc) => checkService(svc.name, svc.module, svc.path)));
117
+ const results = await Promise.all(servicesToCheck.map((svc) => checkService(svc.name, svc.module)));
105
118
  spinner.stop();
106
119
  const healthy = results.filter((r) => r.status === "healthy").length;
107
120
  const unhealthy = results.filter((r) => r.status === "unhealthy").length;
@@ -24,9 +24,10 @@ export function checkForUpdates(currentVersion) {
24
24
  return;
25
25
  }
26
26
  // Run npm view in background-ish (sync but with short timeout)
27
- const latest = execSync(`npm view ${PKG_NAME} version 2>/dev/null`, {
27
+ const latest = execSync(`npm view ${PKG_NAME} version`, {
28
28
  encoding: "utf-8",
29
29
  timeout: 5000,
30
+ stdio: ["pipe", "pipe", "ignore"],
30
31
  }).trim();
31
32
  localStorage.setItem("updateCheckTimestamp", String(Date.now()));
32
33
  localStorage.setItem("updateCheckLatest", latest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolinax/ayoune-cli",
3
- "version": "2026.4.0",
3
+ "version": "2026.5.0",
4
4
  "description": "CLI for the aYOUne Business-as-a-Service platform",
5
5
  "type": "module",
6
6
  "main": "./index.js",