@matterbridge/utils 3.10.9-dev-20260904-cbaddbb → 3.10.9-dev-20260906-2a9dc0e
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 +2 -0
- package/dist/runtimeBun.d.ts +1 -0
- package/dist/runtimeBun.js +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,3 +22,5 @@
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
24
|
[Matterbridge](https://matterbridge.io) internal package (not intended for direct use).
|
|
25
|
+
|
|
26
|
+
`getBunLatestVersion()` from `@matterbridge/utils/bun` fetches the latest stable Bun version from GitHub and returns a string such as `1.4.0`. It works on Node.js and Bun, uses a 10-second request timeout, and returns `undefined` on request failures or invalid release tags. `getBunVersion()` returns the currently running Bun version.
|
package/dist/runtimeBun.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function isBun(): boolean;
|
|
2
2
|
export declare function bunAvailable(): boolean;
|
|
3
3
|
export declare function getBunVersion(): string | undefined;
|
|
4
|
+
export declare function getBunLatestVersion(): Promise<string | undefined>;
|
|
4
5
|
export declare function getBunRevision(): string | undefined;
|
|
5
6
|
export declare function getNodeCompatVersion(): string | undefined;
|
|
6
7
|
export declare function getBun(): typeof Bun | undefined;
|
package/dist/runtimeBun.js
CHANGED
|
@@ -3,6 +3,7 @@ import { existsSync } from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { logModuleLoaded } from './loader.js';
|
|
6
|
+
import { isValidObject, isValidString } from './validate.js';
|
|
6
7
|
logModuleLoaded('RuntimeBun');
|
|
7
8
|
const HAS_BUN_GLOBAL = typeof Bun !== 'undefined';
|
|
8
9
|
export function isBun() {
|
|
@@ -28,6 +29,24 @@ export function getBunVersion() {
|
|
|
28
29
|
return Bun.version;
|
|
29
30
|
return process?.versions?.bun;
|
|
30
31
|
}
|
|
32
|
+
export async function getBunLatestVersion() {
|
|
33
|
+
try {
|
|
34
|
+
const response = await fetch('https://api.github.com/repos/oven-sh/bun/releases/latest', {
|
|
35
|
+
headers: { 'Accept': 'application/vnd.github+json', 'User-Agent': 'matterbridge' },
|
|
36
|
+
signal: AbortSignal.timeout(10_000),
|
|
37
|
+
});
|
|
38
|
+
if (!response.ok)
|
|
39
|
+
return undefined;
|
|
40
|
+
const release = await response.json();
|
|
41
|
+
if (!isValidObject(release) || !('tag_name' in release) || !isValidString(release.tag_name) || !/^bun-v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(release.tag_name)) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return release.tag_name.slice('bun-v'.length);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
31
50
|
export function getBunRevision() {
|
|
32
51
|
return HAS_BUN_GLOBAL ? Bun.revision : undefined;
|
|
33
52
|
}
|
package/package.json
CHANGED