@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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -0
  3. package/buildkite/package.json +5 -0
  4. package/git/package.json +5 -0
  5. package/github/package.json +5 -0
  6. package/lib/buildkite/index.d.mts +2 -0
  7. package/lib/buildkite/index.d.ts +2 -0
  8. package/lib/buildkite/index.js +6 -0
  9. package/lib/buildkite/index.mjs +5 -0
  10. package/lib/buildkite-BXHjSY0I.js +67 -0
  11. package/lib/buildkite-DSHpKA4z.mjs +50 -0
  12. package/lib/chunk-CZCtuq8p.mjs +37 -0
  13. package/lib/chunk-odGzh3W-.js +58 -0
  14. package/lib/exec-B2akdw0z.js +17597 -0
  15. package/lib/exec-p0gJ30UO.mjs +17580 -0
  16. package/lib/git/index.d.mts +2 -0
  17. package/lib/git/index.d.ts +2 -0
  18. package/lib/git/index.js +14 -0
  19. package/lib/git/index.mjs +3 -0
  20. package/lib/git-DDfcZdbm.mjs +379 -0
  21. package/lib/git-DVG_dHiI.js +474 -0
  22. package/lib/github/index.d.mts +3 -0
  23. package/lib/github/index.d.ts +3 -0
  24. package/lib/github/index.js +12 -0
  25. package/lib/github/index.mjs +5 -0
  26. package/lib/github-B4auwKt7.js +310 -0
  27. package/lib/github-vycKoVtK.mjs +269 -0
  28. package/lib/index-1eEu26nG.d.ts +255 -0
  29. package/lib/index-9i8gHTGu.d.mts +38 -0
  30. package/lib/index-B91wXiwr.d.ts +278 -0
  31. package/lib/index-CfnlMf_4.d.ts +39 -0
  32. package/lib/index-Cl--YMPq.d.mts +255 -0
  33. package/lib/index-DNXQKEza.d.mts +278 -0
  34. package/lib/index-DiqTDK1U.d.mts +39 -0
  35. package/lib/index-MmnRaakr.d.ts +38 -0
  36. package/lib/index.d.mts +5 -0
  37. package/lib/index.d.ts +5 -0
  38. package/lib/index.js +31 -0
  39. package/lib/index.mjs +8 -0
  40. package/lib/logging-6TTEX4U4.js +2217 -0
  41. package/lib/logging-Dr8kuQ_p.mjs +2194 -0
  42. package/lib/net/index.d.mts +2 -0
  43. package/lib/net/index.d.ts +2 -0
  44. package/lib/net/index.js +5 -0
  45. package/lib/net/index.mjs +5 -0
  46. package/lib/net-BteSPzmU.js +86 -0
  47. package/lib/net-ByUFe0qv.mjs +75 -0
  48. package/net/package.json +5 -0
  49. package/package.json +58 -8
@@ -0,0 +1,2 @@
1
+ import { waitFor$1 as waitFor } from "../index-9i8gHTGu.mjs";
2
+ export { waitFor };
@@ -0,0 +1,2 @@
1
+ import { waitFor } from "../index-MmnRaakr.js";
2
+ export { waitFor };
@@ -0,0 +1,5 @@
1
+ require('../exec-B2akdw0z.js');
2
+ require('../logging-6TTEX4U4.js');
3
+ const require_net = require('../net-BteSPzmU.js');
4
+
5
+ exports.waitFor = require_net.waitFor;
@@ -0,0 +1,5 @@
1
+ import "../exec-p0gJ30UO.mjs";
2
+ import "../logging-Dr8kuQ_p.mjs";
3
+ import { waitFor } from "../net-ByUFe0qv.mjs";
4
+
5
+ export { waitFor };
@@ -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 };
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../lib/net/index.js",
3
+ "module": "../lib/net/index.mjs",
4
+ "types": "../lib/net/index.d.ts"
5
+ }
package/package.json CHANGED
@@ -1,11 +1,61 @@
1
1
  {
2
2
  "name": "@skuba-lib/api",
3
- "version": "0.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
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
- "author": "",
9
- "license": "ISC",
10
- "description": ""
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
+ }