@skuba-lib/api 0.0.0 → 0.1.0-skuba-lib-api-20250925050503
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/LICENSE +21 -0
- package/README.md +8 -0
- package/buildkite/package.json +5 -0
- package/git/package.json +5 -0
- package/github/package.json +5 -0
- package/lib/buildkite/index.d.mts +2 -0
- package/lib/buildkite/index.d.ts +2 -0
- package/lib/buildkite/index.js +6 -0
- package/lib/buildkite/index.mjs +5 -0
- package/lib/buildkite-BXHjSY0I.js +67 -0
- package/lib/buildkite-DSHpKA4z.mjs +50 -0
- package/lib/chunk-CZCtuq8p.mjs +37 -0
- package/lib/chunk-odGzh3W-.js +58 -0
- package/lib/exec-B2akdw0z.js +17597 -0
- package/lib/exec-p0gJ30UO.mjs +17580 -0
- package/lib/git/index.d.mts +2 -0
- package/lib/git/index.d.ts +2 -0
- package/lib/git/index.js +14 -0
- package/lib/git/index.mjs +3 -0
- package/lib/git-DDfcZdbm.mjs +379 -0
- package/lib/git-DVG_dHiI.js +474 -0
- package/lib/github/index.d.mts +3 -0
- package/lib/github/index.d.ts +3 -0
- package/lib/github/index.js +12 -0
- package/lib/github/index.mjs +5 -0
- package/lib/github-B4auwKt7.js +310 -0
- package/lib/github-vycKoVtK.mjs +269 -0
- package/lib/index-1eEu26nG.d.ts +255 -0
- package/lib/index-9i8gHTGu.d.mts +38 -0
- package/lib/index-B91wXiwr.d.ts +278 -0
- package/lib/index-CfnlMf_4.d.ts +39 -0
- package/lib/index-Cl--YMPq.d.mts +255 -0
- package/lib/index-DNXQKEza.d.mts +278 -0
- package/lib/index-DiqTDK1U.d.mts +39 -0
- package/lib/index-MmnRaakr.d.ts +38 -0
- package/lib/index.d.mts +5 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +31 -0
- package/lib/index.mjs +8 -0
- package/lib/logging-6TTEX4U4.js +2217 -0
- package/lib/logging-Dr8kuQ_p.mjs +2194 -0
- package/lib/net/index.d.mts +2 -0
- package/lib/net/index.d.ts +2 -0
- package/lib/net/index.js +5 -0
- package/lib/net/index.mjs +5 -0
- package/lib/net-BteSPzmU.js +86 -0
- package/lib/net-ByUFe0qv.mjs +75 -0
- package/net/package.json +5 -0
- package/package.json +58 -8
package/lib/net/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-odGzh3W-.js');
|
|
2
|
+
const require_exec = require('./exec-B2akdw0z.js');
|
|
3
|
+
const net = require_chunk.__toESM(require("net"));
|
|
4
|
+
|
|
5
|
+
//#region src/net/compose.ts
|
|
6
|
+
const portStringToNumber = (portString) => {
|
|
7
|
+
const port = Number(portString);
|
|
8
|
+
if (!Number.isSafeInteger(port)) throw Error(`received non-integer port: '${portString}'`);
|
|
9
|
+
return port;
|
|
10
|
+
};
|
|
11
|
+
const resolveComposeAddress = async (privateHost, privatePort) => {
|
|
12
|
+
const exec = require_exec.createExec({ stdio: "pipe" });
|
|
13
|
+
const { stdout } = await exec("docker", "compose", "port", privateHost, String(privatePort));
|
|
14
|
+
const [host, portString] = stdout.trim().split(":");
|
|
15
|
+
if (!host || !portString) throw Error(`Docker Compose returned unrecognised address: '${stdout}'`);
|
|
16
|
+
return {
|
|
17
|
+
host,
|
|
18
|
+
port: portStringToNumber(portString)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/net/socket.ts
|
|
24
|
+
const trySocket = async (host, port) => new Promise((resolve) => {
|
|
25
|
+
const socket = new net.default.Socket();
|
|
26
|
+
const onFailure = () => {
|
|
27
|
+
socket.destroy();
|
|
28
|
+
resolve(false);
|
|
29
|
+
};
|
|
30
|
+
const onSuccess = () => socket.end(() => resolve(true));
|
|
31
|
+
socket.connect(port, host, onSuccess).once("error", onFailure).once("timeout", onFailure).setTimeout(1e3);
|
|
32
|
+
});
|
|
33
|
+
const pollSocket = async (host, port, timeout) => new Promise((resolve, reject) => {
|
|
34
|
+
const callPort = async () => {
|
|
35
|
+
const success = await trySocket(host, port);
|
|
36
|
+
if (!success) return;
|
|
37
|
+
clearTimeout(intervalId);
|
|
38
|
+
clearTimeout(timeoutId);
|
|
39
|
+
resolve();
|
|
40
|
+
};
|
|
41
|
+
const intervalId = setInterval(() => {
|
|
42
|
+
callPort().catch(() => void 0);
|
|
43
|
+
}, 250);
|
|
44
|
+
const timeoutId = setTimeout(() => {
|
|
45
|
+
clearTimeout(intervalId);
|
|
46
|
+
clearTimeout(timeoutId);
|
|
47
|
+
reject(Error(`could not reach ${host}:${port} within ${timeout}ms`));
|
|
48
|
+
}, timeout);
|
|
49
|
+
callPort().catch(() => void 0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/net/waitFor.ts
|
|
54
|
+
/**
|
|
55
|
+
* Wait for a resource to start listening on a socket address.
|
|
56
|
+
*
|
|
57
|
+
* The socket is polled on an interval until it accepts a connection or the
|
|
58
|
+
* `timeout` is reached.
|
|
59
|
+
*/
|
|
60
|
+
const waitFor = async ({ host = "localhost", port, resolveCompose = false, timeout = 15e3 }) => {
|
|
61
|
+
const resolvedAddress = resolveCompose ? await resolveComposeAddress(host, port) : {
|
|
62
|
+
host,
|
|
63
|
+
port
|
|
64
|
+
};
|
|
65
|
+
await pollSocket(resolvedAddress.host, resolvedAddress.port, timeout);
|
|
66
|
+
return resolvedAddress;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/net/index.ts
|
|
71
|
+
var net_exports = {};
|
|
72
|
+
require_chunk.__export(net_exports, { waitFor: () => waitFor });
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
Object.defineProperty(exports, 'net_exports', {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return net_exports;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, 'waitFor', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return waitFor;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __export } from "./chunk-CZCtuq8p.mjs";
|
|
2
|
+
import { createExec } from "./exec-p0gJ30UO.mjs";
|
|
3
|
+
import net from "net";
|
|
4
|
+
|
|
5
|
+
//#region src/net/compose.ts
|
|
6
|
+
const portStringToNumber = (portString) => {
|
|
7
|
+
const port = Number(portString);
|
|
8
|
+
if (!Number.isSafeInteger(port)) throw Error(`received non-integer port: '${portString}'`);
|
|
9
|
+
return port;
|
|
10
|
+
};
|
|
11
|
+
const resolveComposeAddress = async (privateHost, privatePort) => {
|
|
12
|
+
const exec = createExec({ stdio: "pipe" });
|
|
13
|
+
const { stdout } = await exec("docker", "compose", "port", privateHost, String(privatePort));
|
|
14
|
+
const [host, portString] = stdout.trim().split(":");
|
|
15
|
+
if (!host || !portString) throw Error(`Docker Compose returned unrecognised address: '${stdout}'`);
|
|
16
|
+
return {
|
|
17
|
+
host,
|
|
18
|
+
port: portStringToNumber(portString)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/net/socket.ts
|
|
24
|
+
const trySocket = async (host, port) => new Promise((resolve) => {
|
|
25
|
+
const socket = new net.Socket();
|
|
26
|
+
const onFailure = () => {
|
|
27
|
+
socket.destroy();
|
|
28
|
+
resolve(false);
|
|
29
|
+
};
|
|
30
|
+
const onSuccess = () => socket.end(() => resolve(true));
|
|
31
|
+
socket.connect(port, host, onSuccess).once("error", onFailure).once("timeout", onFailure).setTimeout(1e3);
|
|
32
|
+
});
|
|
33
|
+
const pollSocket = async (host, port, timeout) => new Promise((resolve, reject) => {
|
|
34
|
+
const callPort = async () => {
|
|
35
|
+
const success = await trySocket(host, port);
|
|
36
|
+
if (!success) return;
|
|
37
|
+
clearTimeout(intervalId);
|
|
38
|
+
clearTimeout(timeoutId);
|
|
39
|
+
resolve();
|
|
40
|
+
};
|
|
41
|
+
const intervalId = setInterval(() => {
|
|
42
|
+
callPort().catch(() => void 0);
|
|
43
|
+
}, 250);
|
|
44
|
+
const timeoutId = setTimeout(() => {
|
|
45
|
+
clearTimeout(intervalId);
|
|
46
|
+
clearTimeout(timeoutId);
|
|
47
|
+
reject(Error(`could not reach ${host}:${port} within ${timeout}ms`));
|
|
48
|
+
}, timeout);
|
|
49
|
+
callPort().catch(() => void 0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/net/waitFor.ts
|
|
54
|
+
/**
|
|
55
|
+
* Wait for a resource to start listening on a socket address.
|
|
56
|
+
*
|
|
57
|
+
* The socket is polled on an interval until it accepts a connection or the
|
|
58
|
+
* `timeout` is reached.
|
|
59
|
+
*/
|
|
60
|
+
const waitFor = async ({ host = "localhost", port, resolveCompose = false, timeout = 15e3 }) => {
|
|
61
|
+
const resolvedAddress = resolveCompose ? await resolveComposeAddress(host, port) : {
|
|
62
|
+
host,
|
|
63
|
+
port
|
|
64
|
+
};
|
|
65
|
+
await pollSocket(resolvedAddress.host, resolvedAddress.port, timeout);
|
|
66
|
+
return resolvedAddress;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/net/index.ts
|
|
71
|
+
var net_exports = {};
|
|
72
|
+
__export(net_exports, { waitFor: () => waitFor });
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { net_exports, waitFor };
|
package/net/package.json
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skuba-lib/api",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-skuba-lib-api-20250925050503",
|
|
4
|
+
"description": "Shared apis for skuba",
|
|
5
|
+
"homepage": "https://github.com/seek-oss/skuba#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/seek-oss/skuba/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+ssh://git@github.com/seek-oss/skuba.git",
|
|
12
|
+
"directory": "packages/api"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./lib/index.mjs",
|
|
17
|
+
"require": "./lib/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./buildkite": {
|
|
20
|
+
"import": "./lib/buildkite/index.mjs",
|
|
21
|
+
"require": "./lib/buildkite/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./git": {
|
|
24
|
+
"import": "./lib/git/index.mjs",
|
|
25
|
+
"require": "./lib/git/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./github": {
|
|
28
|
+
"import": "./lib/github/index.mjs",
|
|
29
|
+
"require": "./lib/github/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./net": {
|
|
32
|
+
"import": "./lib/net/index.mjs",
|
|
33
|
+
"require": "./lib/net/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
7
36
|
},
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
37
|
+
"main": "./lib/index.js",
|
|
38
|
+
"module": "./lib/index.mjs",
|
|
39
|
+
"types": "./lib/index.d.ts",
|
|
40
|
+
"files": [
|
|
41
|
+
"lib",
|
|
42
|
+
"buildkite",
|
|
43
|
+
"git",
|
|
44
|
+
"github",
|
|
45
|
+
"net"
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@octokit/graphql": "^9.0.0",
|
|
49
|
+
"@octokit/rest": "^22.0.0",
|
|
50
|
+
"@octokit/types": "^15.0.0",
|
|
51
|
+
"fs-extra": "^11.0.0",
|
|
52
|
+
"ignore": "^7.0.0",
|
|
53
|
+
"isomorphic-git": "^1.11.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"tsdown": "^0.15.4"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsdown"
|
|
60
|
+
}
|
|
61
|
+
}
|