systemview 2.1.0 → 2.2.1

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/cli/index.js CHANGED
@@ -25,27 +25,40 @@ const DEFAULT_PORT = 3000;
25
25
  const VERSION = require("../package.json").version;
26
26
  const UI_URL = `http://localhost:${DEFAULT_PORT}`;
27
27
 
28
- const MANIFEST_FILE = flags.manifest || path.join(process.cwd(), "systemview.manifest.json");
28
+ const MANIFEST_FILE =
29
+ flags.manifest || path.join(process.cwd(), "systemview.manifest.json");
29
30
  const connectedUrls = new Set();
30
31
 
31
- function loadManifest() {
32
+ async function loadManifest() {
32
33
  if (!fs.existsSync(MANIFEST_FILE)) return;
33
34
  try {
34
35
  const manifest = JSON.parse(fs.readFileSync(MANIFEST_FILE, "utf8"));
36
+ const { projectCode } = manifest;
35
37
  const services = manifest.services || [manifest];
36
- for (const { system } of services) {
37
- if (system && system.connectionData) {
38
- Client.createService(system.connectionData);
39
- connectedUrls.add(system.connectionData.serviceUrl);
40
- }
41
- }
42
- } catch {}
38
+ log.info(`Reading manifest: ${projectCode} ${services.length} service(s)`);
39
+ const api = `http://localhost:${DEFAULT_PORT}/systemview/api`;
40
+ const { SystemView } = await Client.loadService(api);
41
+ await Promise.all(
42
+ services.map(async ({ system, serviceId, specList }) => {
43
+ if (!system || !system.connectionData) return;
44
+ const alive = await appIsRunning(system.connectionData.serviceUrl);
45
+ if (alive) {
46
+ Client.createService(system.connectionData);
47
+ connectedUrls.add(system.connectionData.serviceUrl);
48
+ try { await SystemView.connect({ system, projectCode, serviceId, specList }); } catch {}
49
+ }
50
+ log.info(` ${serviceId || system.connectionData.serviceUrl} — ${alive ? "live" : "offline"}`);
51
+ }),
52
+ );
53
+ } catch (err) {
54
+ log.warn("Failed to read manifest: " + err.message);
55
+ }
43
56
  }
44
57
 
45
58
  async function startApp() {
46
59
  const port = isNaN(input[1]) ? DEFAULT_PORT : Number(input[1]);
47
60
  try {
48
- await launchApp(port, { interactive: true, connectedUrls, client: Client });
61
+ await launchApp(port, { interactive: true, connectedUrls, onReady: loadManifest });
49
62
  } catch (error) {
50
63
  log.error("Launch failed: " + error.message);
51
64
  }
@@ -56,6 +69,7 @@ async function startTest() {
56
69
  const namespace = input[2];
57
70
  try {
58
71
  await launchApp(DEFAULT_PORT);
72
+ await loadManifest();
59
73
  const exitCode = await runTests(UI_URL, project_code, namespace, {
60
74
  json: flags.json,
61
75
  verbose: flags.verbose,
@@ -137,7 +151,6 @@ async function quitApp() {
137
151
  }
138
152
 
139
153
  init();
140
- loadManifest();
141
154
 
142
155
  const command = input[0];
143
156
 
package/cli/launchApp.js CHANGED
@@ -4,7 +4,7 @@ const launchSystemView = require("../api");
4
4
  const startLineReader = require("./startLineReader");
5
5
  const listTests = require("./listTests");
6
6
 
7
- module.exports = async function launchApp(port, { interactive = false, connectedUrls = new Set() } = {}) {
7
+ module.exports = async function launchApp(port, { interactive = false, connectedUrls = new Set(), onReady } = {}) {
8
8
  const ui = `http://localhost:${port}`;
9
9
  const api = `${ui}/systemview/api`;
10
10
 
@@ -18,6 +18,7 @@ module.exports = async function launchApp(port, { interactive = false, connected
18
18
  if (interactive) {
19
19
  log.warn(`SystemView already running on port ${port} — attaching.`);
20
20
  logConnection();
21
+ if (onReady) await onReady();
21
22
  await listTests(ui, null, null, { connectedUrls });
22
23
  return startLineReader(ui, { connectedUrls });
23
24
  }
@@ -29,6 +30,7 @@ module.exports = async function launchApp(port, { interactive = false, connected
29
30
  logConnection();
30
31
 
31
32
  if (interactive) {
33
+ if (onReady) await onReady();
32
34
  await listTests(ui, null, null, { connectedUrls });
33
35
  return startLineReader(ui, { connectedUrls });
34
36
  }
package/cli/logs.js CHANGED
@@ -31,7 +31,7 @@ const SKIP_KEYS = new Set([
31
31
  "moduleMethod",
32
32
  "traceId",
33
33
  "level",
34
- "message",
34
+ "scope",
35
35
  "duration",
36
36
  ]);
37
37
 
@@ -45,7 +45,7 @@ function formatRow(entry, verbose, extraFields) {
45
45
  const service = entry.serviceId || "—";
46
46
  const method = entry.moduleMethod || "—";
47
47
  const level = colorLevel(entry.level);
48
- const msg = entry.message || "";
48
+ const msg = entry.scope || "";
49
49
  const dur = entry.duration != null ? chalk.dim(` ${entry.duration}ms`) : "";
50
50
  const traceId = chalk.dim(entry.traceId || "—");
51
51
  let row = ` ${chalk.dim(time)} ${chalk.cyan(project)} › ${chalk.cyan(service)} ${method.padEnd(15)} ${level} ${traceId} ${msg}${dur}`;
@@ -116,7 +116,7 @@ const DISPLAY_SKIP = new Set([
116
116
  "moduleMethod",
117
117
  "traceId",
118
118
  "level",
119
- "message",
119
+ "scope",
120
120
  "duration",
121
121
  ]);
122
122
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "systemview",
3
3
  "description": "A documentation and testing suite for SystemLynx",
4
- "version": "2.1.0",
4
+ "version": "2.2.1",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
7
7
  "systemview": "cli/index.js"
@@ -16,7 +16,7 @@
16
16
  "chalk": "^4.1.2",
17
17
  "express": "^4.18.2",
18
18
  "moment": "^2.29.1",
19
- "systemlynx": "^2.0.0",
19
+ "systemlynx": "^2.1.0",
20
20
  "systemlynx-client": "^2.0.0",
21
21
  "web-vitals": "^0.2.4"
22
22
  },