@glassmkr/crucible 0.6.6 → 0.7.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/README.md +25 -0
- package/config/collector.example.yaml +2 -2
- package/dist/__tests__/reboot-marker.test.d.ts +1 -0
- package/dist/__tests__/reboot-marker.test.js +110 -0
- package/dist/__tests__/reboot-marker.test.js.map +1 -0
- package/dist/cli.d.ts +4 -1
- package/dist/cli.js +56 -0
- package/dist/cli.js.map +1 -1
- package/dist/collect/__tests__/system.test.d.ts +1 -0
- package/dist/collect/__tests__/system.test.js +25 -0
- package/dist/collect/__tests__/system.test.js.map +1 -0
- package/dist/collect/system.d.ts +1 -0
- package/dist/collect/system.js +10 -0
- package/dist/collect/system.js.map +1 -1
- package/dist/index.js +54 -16
- package/dist/index.js.map +1 -1
- package/dist/lib/reboot-marker.d.ts +35 -0
- package/dist/lib/reboot-marker.js +95 -0
- package/dist/lib/reboot-marker.js.map +1 -0
- package/dist/lib/types.d.ts +8 -0
- package/dist/lib/version-check.js +1 -1
- package/dist/lib/version-check.js.map +1 -1
- package/dist/lib/version.d.ts +1 -0
- package/dist/lib/version.js +32 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/notify/email.js +2 -1
- package/dist/notify/email.js.map +1 -1
- package/dist/notify/slack.js +2 -1
- package/dist/notify/slack.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/reboot-marker.test.ts +122 -0
- package/src/cli.ts +51 -1
- package/src/collect/__tests__/system.test.ts +29 -0
- package/src/collect/system.ts +11 -0
- package/src/index.ts +54 -17
- package/src/lib/reboot-marker.ts +88 -0
- package/src/lib/types.ts +12 -0
- package/src/lib/version-check.ts +2 -1
- package/src/lib/version.ts +33 -0
- package/src/notify/email.ts +2 -1
- package/src/notify/slack.ts +2 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Single source of truth for the Crucible version string at runtime.
|
|
2
|
+
// Read from package.json so a release bump propagates everywhere
|
|
3
|
+
// (notification footers, version-check log lines, --version flag, the
|
|
4
|
+
// `collector_version` field on every snapshot) without anyone having to
|
|
5
|
+
// remember to update a hardcoded constant.
|
|
6
|
+
//
|
|
7
|
+
// Returns "0.0.0" on read failure rather than throwing; the agent has to
|
|
8
|
+
// keep running even if its package.json is somehow missing.
|
|
9
|
+
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
|
|
14
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
|
|
16
|
+
function readPkgVersion(): string {
|
|
17
|
+
// src/lib/version.ts -> ../../package.json under src layout, but at
|
|
18
|
+
// runtime (compiled to dist/lib/version.js) it's still ../../package.json.
|
|
19
|
+
// Both paths resolve correctly because package.json sits one level above
|
|
20
|
+
// dist/ AND one level above src/.
|
|
21
|
+
for (const candidate of [
|
|
22
|
+
join(__dirname, "..", "..", "package.json"),
|
|
23
|
+
join(__dirname, "..", "package.json"),
|
|
24
|
+
]) {
|
|
25
|
+
try {
|
|
26
|
+
const pkg = JSON.parse(readFileSync(candidate, "utf8"));
|
|
27
|
+
if (pkg && typeof pkg.version === "string") return pkg.version;
|
|
28
|
+
} catch { /* try next */ }
|
|
29
|
+
}
|
|
30
|
+
return "0.0.0";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const CRUCIBLE_VERSION = readPkgVersion();
|
package/src/notify/email.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFile } from "child_process";
|
|
2
2
|
import { promisify } from "util";
|
|
3
3
|
import type { AlertResult } from "../lib/types.js";
|
|
4
|
+
import { CRUCIBLE_VERSION } from "../lib/version.js";
|
|
4
5
|
|
|
5
6
|
const execFileAsync = promisify(execFile);
|
|
6
7
|
|
|
@@ -63,6 +64,6 @@ function buildBody(newAlerts: AlertResult[], resolvedAlerts: AlertResult[], serv
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
lines.push("---");
|
|
66
|
-
lines.push(
|
|
67
|
+
lines.push(`Glassmkr Crucible v${CRUCIBLE_VERSION}`);
|
|
67
68
|
return lines.join("\n");
|
|
68
69
|
}
|
package/src/notify/slack.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AlertResult } from "../lib/types.js";
|
|
2
|
+
import { CRUCIBLE_VERSION } from "../lib/version.js";
|
|
2
3
|
|
|
3
4
|
export async function sendSlack(
|
|
4
5
|
webhookUrl: string,
|
|
@@ -29,7 +30,7 @@ export async function sendSlack(
|
|
|
29
30
|
if (blocks.length === 0) return true;
|
|
30
31
|
|
|
31
32
|
blocks.push({ type: "divider" });
|
|
32
|
-
blocks.push({ type: "context", elements: [{ type: "mrkdwn", text:
|
|
33
|
+
blocks.push({ type: "context", elements: [{ type: "mrkdwn", text: `Glassmkr Crucible v${CRUCIBLE_VERSION}` }] });
|
|
33
34
|
|
|
34
35
|
try {
|
|
35
36
|
const res = await fetch(webhookUrl, {
|