@hasna/logs 0.3.19 → 0.3.20

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/dist/mcp/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  scoreLabel,
25
25
  summarizeLogs,
26
26
  updateIssueStatus
27
- } from "../index-9n6bpjxf.js";
27
+ } from "../index-5cj74qka.js";
28
28
  import {
29
29
  createJob,
30
30
  listJobs
@@ -6,7 +6,7 @@ import {
6
6
  setPageAuth,
7
7
  setRetentionPolicy,
8
8
  startScheduler
9
- } from "../index-sgg59p1t.js";
9
+ } from "../index-2tg9psrh.js";
10
10
  import {
11
11
  getHealth
12
12
  } from "../index-cpvq9np9.js";
@@ -33,7 +33,7 @@ import {
33
33
  updateAlertRule,
34
34
  updateIssueStatus,
35
35
  updateProject
36
- } from "../index-9n6bpjxf.js";
36
+ } from "../index-5cj74qka.js";
37
37
  import {
38
38
  createJob,
39
39
  deleteJob,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/logs",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "description": "Log aggregation + browser script + headless page scanner + performance monitoring for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,43 @@
1
+ import { afterEach, expect, test } from "bun:test"
2
+ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
3
+ import { tmpdir } from "node:os"
4
+ import { join } from "node:path"
5
+ import { pathToFileURL } from "node:url"
6
+ import { readPackageVersion } from "./package-meta.ts"
7
+
8
+ const tempRoots: string[] = []
9
+
10
+ function createFixture() {
11
+ const root = mkdtempSync(join(tmpdir(), "logs-package-meta-"))
12
+ tempRoots.push(root)
13
+
14
+ mkdirSync(join(root, "src/lib"), { recursive: true })
15
+ mkdirSync(join(root, "dist"), { recursive: true })
16
+ writeFileSync(join(root, "package.json"), JSON.stringify({ version: "9.9.9" }), "utf8")
17
+
18
+ return root
19
+ }
20
+
21
+ afterEach(() => {
22
+ while (tempRoots.length > 0) {
23
+ const root = tempRoots.pop()
24
+ if (!root) continue
25
+ rmSync(root, { recursive: true, force: true })
26
+ }
27
+ })
28
+
29
+ test("readPackageVersion resolves package.json from source module paths", () => {
30
+ const root = createFixture()
31
+
32
+ const version = readPackageVersion(pathToFileURL(join(root, "src/lib/fake.js")))
33
+
34
+ expect(version).toBe("9.9.9")
35
+ })
36
+
37
+ test("readPackageVersion resolves package.json from bundled dist chunk paths", () => {
38
+ const root = createFixture()
39
+
40
+ const version = readPackageVersion(pathToFileURL(join(root, "dist/index-abc123.js")))
41
+
42
+ expect(version).toBe("9.9.9")
43
+ })
@@ -1,4 +1,4 @@
1
- import { readFileSync } from "node:fs"
1
+ import { existsSync, readFileSync } from "node:fs"
2
2
 
3
3
  type StandaloneCliSpec = {
4
4
  name: string
@@ -10,11 +10,29 @@ type PackageJson = {
10
10
  version?: string
11
11
  }
12
12
 
13
- const packageJson = JSON.parse(
14
- readFileSync(new URL("../../package.json", import.meta.url), "utf8"),
15
- ) as PackageJson
13
+ const PACKAGE_JSON_CANDIDATES = [
14
+ "../../package.json",
15
+ "../package.json",
16
+ "./package.json",
17
+ ]
16
18
 
17
- export const PACKAGE_VERSION = packageJson.version ?? "0.0.0"
19
+ function readPackageJson(baseUrl: string | URL = import.meta.url): PackageJson {
20
+ // Bundled shared chunks live under dist/, while source modules live under src/lib/.
21
+ for (const relativePath of PACKAGE_JSON_CANDIDATES) {
22
+ const candidate = new URL(relativePath, baseUrl)
23
+ if (!existsSync(candidate)) continue
24
+
25
+ return JSON.parse(readFileSync(candidate, "utf8")) as PackageJson
26
+ }
27
+
28
+ throw new Error(`Unable to locate package.json from ${String(baseUrl)}`)
29
+ }
30
+
31
+ export function readPackageVersion(baseUrl: string | URL = import.meta.url): string {
32
+ return readPackageJson(baseUrl).version ?? "0.0.0"
33
+ }
34
+
35
+ export const PACKAGE_VERSION = readPackageVersion()
18
36
 
19
37
  export function exitIfMetadataRequest(spec: StandaloneCliSpec, argv = process.argv.slice(2)): void {
20
38
  if (argv.includes("--version") || argv.includes("-V")) {