@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/cli/index.js +2 -2
- package/dist/index-2tg9psrh.js +1241 -0
- package/dist/index-5cj74qka.js +10803 -0
- package/dist/mcp/index.js +1 -1
- package/dist/server/index.js +2 -2
- package/package.json +1 -1
- package/src/lib/package-meta.test.ts +43 -0
- package/src/lib/package-meta.ts +23 -5
package/dist/mcp/index.js
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
setPageAuth,
|
|
7
7
|
setRetentionPolicy,
|
|
8
8
|
startScheduler
|
|
9
|
-
} from "../index-
|
|
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-
|
|
36
|
+
} from "../index-5cj74qka.js";
|
|
37
37
|
import {
|
|
38
38
|
createJob,
|
|
39
39
|
deleteJob,
|
package/package.json
CHANGED
|
@@ -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
|
+
})
|
package/src/lib/package-meta.ts
CHANGED
|
@@ -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
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const PACKAGE_JSON_CANDIDATES = [
|
|
14
|
+
"../../package.json",
|
|
15
|
+
"../package.json",
|
|
16
|
+
"./package.json",
|
|
17
|
+
]
|
|
16
18
|
|
|
17
|
-
|
|
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")) {
|