@bensandee/tooling 0.18.0 → 0.21.0
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.
|
@@ -6,7 +6,7 @@ function isExecSyncError(err) {
|
|
|
6
6
|
return err instanceof Error && "stdout" in err && typeof err.stdout === "string" && "stderr" in err && typeof err.stderr === "string" && "status" in err && typeof err.status === "number";
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
|
-
//#region src/docker-
|
|
9
|
+
//#region src/docker-check/executor.ts
|
|
10
10
|
/** Create an executor that runs real commands, fetches, and manages process signals. */
|
|
11
11
|
function createRealExecutor() {
|
|
12
12
|
return {
|
|
@@ -66,7 +66,7 @@ function createRealExecutor() {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
|
-
//#region src/docker-
|
|
69
|
+
//#region src/docker-check/compose.ts
|
|
70
70
|
/** Zod schema for a single container entry from `docker compose ps --format json`. */
|
|
71
71
|
const ContainerInfoSchema = z.object({
|
|
72
72
|
Service: z.string(),
|
|
@@ -121,7 +121,7 @@ function composePs(executor, config) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
//#endregion
|
|
124
|
-
//#region src/docker-
|
|
124
|
+
//#region src/docker-check/health.ts
|
|
125
125
|
/** Look up the health status of a specific service from container info. */
|
|
126
126
|
function getContainerHealth(containers, serviceName) {
|
|
127
127
|
return containers.find((c) => c.Service === serviceName)?.Health ?? "unknown";
|
|
@@ -136,11 +136,11 @@ async function checkHttpHealth(executor, check) {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
//#endregion
|
|
139
|
-
//#region src/docker-
|
|
139
|
+
//#region src/docker-check/check.ts
|
|
140
140
|
const DEFAULT_TIMEOUT_MS = 12e4;
|
|
141
141
|
const DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
142
|
-
/** Run the full Docker
|
|
143
|
-
async function
|
|
142
|
+
/** Run the full Docker check lifecycle. */
|
|
143
|
+
async function runDockerCheck(executor, config) {
|
|
144
144
|
const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
145
145
|
const pollIntervalMs = config.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
146
146
|
const { compose } = config;
|
|
@@ -183,7 +183,7 @@ async function runVerification(executor, config) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
if ([...healthStatus.values()].every(Boolean)) {
|
|
186
|
-
executor.log("
|
|
186
|
+
executor.log("Check successful! All systems operational.");
|
|
187
187
|
cleanup();
|
|
188
188
|
return {
|
|
189
189
|
success: true,
|
|
@@ -220,4 +220,4 @@ async function runVerification(executor, config) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
//#endregion
|
|
223
|
-
export { composeDown as a, composeUp as c, composeCommand as i, createRealExecutor as l, checkHttpHealth as n, composeLogs as o, getContainerHealth as r, composePs as s,
|
|
223
|
+
export { composeDown as a, composeUp as c, composeCommand as i, createRealExecutor as l, checkHttpHealth as n, composeLogs as o, getContainerHealth as r, composePs as s, runDockerCheck as t, isExecSyncError as u };
|
|
@@ -13,9 +13,9 @@ interface ExecOptions {
|
|
|
13
13
|
env?: Record<string, string>;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region src/docker-
|
|
16
|
+
//#region src/docker-check/types.d.ts
|
|
17
17
|
/** Abstraction over side effects for testability. */
|
|
18
|
-
interface
|
|
18
|
+
interface DockerCheckExecutor {
|
|
19
19
|
/** Run a shell command and return the result (stdout/stderr captured). */
|
|
20
20
|
exec(command: string, options?: ExecOptions): ExecResult;
|
|
21
21
|
/** Run a shell command, streaming stdout/stderr to the console. */
|
|
@@ -46,15 +46,15 @@ interface HttpHealthCheck {
|
|
|
46
46
|
interface ComposeConfig {
|
|
47
47
|
/** Working directory for docker compose commands. */
|
|
48
48
|
cwd: string;
|
|
49
|
-
/** Compose files to use (e.g. ["docker-compose.yaml", "docker-compose.
|
|
49
|
+
/** Compose files to use (e.g. ["docker-compose.yaml", "docker-compose.check.yaml"]). */
|
|
50
50
|
composeFiles: string[];
|
|
51
51
|
/** Optional env file for compose. */
|
|
52
52
|
envFile?: string;
|
|
53
53
|
/** Service names to monitor for container-level health. */
|
|
54
54
|
services: string[];
|
|
55
55
|
}
|
|
56
|
-
/** Full
|
|
57
|
-
interface
|
|
56
|
+
/** Full docker check configuration. */
|
|
57
|
+
interface CheckConfig {
|
|
58
58
|
/** Docker compose settings. */
|
|
59
59
|
compose: ComposeConfig;
|
|
60
60
|
/** Optional build command to run before starting compose (e.g. "pnpm image:build"). */
|
|
@@ -68,8 +68,8 @@ interface VerifyConfig {
|
|
|
68
68
|
/** Interval between polling attempts, in ms. Default: 5000. */
|
|
69
69
|
pollIntervalMs?: number;
|
|
70
70
|
}
|
|
71
|
-
/** Result of the
|
|
72
|
-
type
|
|
71
|
+
/** Result of the docker check run. */
|
|
72
|
+
type CheckResult = {
|
|
73
73
|
success: true;
|
|
74
74
|
elapsedMs: number;
|
|
75
75
|
} | {
|
|
@@ -79,15 +79,15 @@ type VerifyResult = {
|
|
|
79
79
|
elapsedMs: number;
|
|
80
80
|
};
|
|
81
81
|
//#endregion
|
|
82
|
-
//#region src/docker-
|
|
82
|
+
//#region src/docker-check/executor.d.ts
|
|
83
83
|
/** Create an executor that runs real commands, fetches, and manages process signals. */
|
|
84
|
-
declare function createRealExecutor():
|
|
84
|
+
declare function createRealExecutor(): DockerCheckExecutor;
|
|
85
85
|
//#endregion
|
|
86
|
-
//#region src/docker-
|
|
87
|
-
/** Run the full Docker
|
|
88
|
-
declare function
|
|
86
|
+
//#region src/docker-check/check.d.ts
|
|
87
|
+
/** Run the full Docker check lifecycle. */
|
|
88
|
+
declare function runDockerCheck(executor: DockerCheckExecutor, config: CheckConfig): Promise<CheckResult>;
|
|
89
89
|
//#endregion
|
|
90
|
-
//#region src/docker-
|
|
90
|
+
//#region src/docker-check/compose.d.ts
|
|
91
91
|
/** Zod schema for a single container entry from `docker compose ps --format json`. */
|
|
92
92
|
declare const ContainerInfoSchema: z.ZodObject<{
|
|
93
93
|
Service: z.ZodString;
|
|
@@ -97,21 +97,21 @@ type ContainerInfo = z.infer<typeof ContainerInfoSchema>;
|
|
|
97
97
|
/** Build the `docker compose` base command string from config. */
|
|
98
98
|
declare function composeCommand(config: ComposeConfig): string;
|
|
99
99
|
/** Start the compose stack in detached mode. */
|
|
100
|
-
declare function composeUp(executor:
|
|
100
|
+
declare function composeUp(executor: DockerCheckExecutor, config: ComposeConfig): void;
|
|
101
101
|
/** Tear down the compose stack, removing volumes and orphans. Swallows errors. */
|
|
102
|
-
declare function composeDown(executor:
|
|
102
|
+
declare function composeDown(executor: DockerCheckExecutor, config: ComposeConfig): void;
|
|
103
103
|
/** Show logs for a specific service (or all services if not specified). Swallows errors. */
|
|
104
|
-
declare function composeLogs(executor:
|
|
104
|
+
declare function composeLogs(executor: DockerCheckExecutor, config: ComposeConfig, service?: string): void;
|
|
105
105
|
/**
|
|
106
106
|
* Query container status via `docker compose ps --format json`.
|
|
107
107
|
* Handles both JSON array and newline-delimited JSON (varies by docker compose version).
|
|
108
108
|
*/
|
|
109
|
-
declare function composePs(executor:
|
|
109
|
+
declare function composePs(executor: DockerCheckExecutor, config: ComposeConfig): ContainerInfo[];
|
|
110
110
|
//#endregion
|
|
111
|
-
//#region src/docker-
|
|
111
|
+
//#region src/docker-check/health.d.ts
|
|
112
112
|
/** Look up the health status of a specific service from container info. */
|
|
113
113
|
declare function getContainerHealth(containers: ContainerInfo[], serviceName: string): string;
|
|
114
114
|
/** Run a single HTTP health check, returning true if the validator passes. */
|
|
115
|
-
declare function checkHttpHealth(executor:
|
|
115
|
+
declare function checkHttpHealth(executor: DockerCheckExecutor, check: HttpHealthCheck): Promise<boolean>;
|
|
116
116
|
//#endregion
|
|
117
|
-
export { type
|
|
117
|
+
export { type CheckConfig, type CheckResult, type ComposeConfig, type ContainerInfo, type DockerCheckExecutor, type HttpHealthCheck, checkHttpHealth, composeCommand, composeDown, composeLogs, composePs, composeUp, createRealExecutor, getContainerHealth, runDockerCheck };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as composeDown, c as composeUp, i as composeCommand, l as createRealExecutor, n as checkHttpHealth, o as composeLogs, r as getContainerHealth, s as composePs, t as
|
|
2
|
-
export { checkHttpHealth, composeCommand, composeDown, composeLogs, composePs, composeUp, createRealExecutor, getContainerHealth,
|
|
1
|
+
import { a as composeDown, c as composeUp, i as composeCommand, l as createRealExecutor, n as checkHttpHealth, o as composeLogs, r as getContainerHealth, s as composePs, t as runDockerCheck } from "../check-VAgrEX2D.mjs";
|
|
2
|
+
export { checkHttpHealth, composeCommand, composeDown, composeLogs, composePs, composeUp, createRealExecutor, getContainerHealth, runDockerCheck };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bensandee/tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tooling": "./dist/bin.mjs"
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"default": "./dist/index.mjs"
|
|
19
19
|
},
|
|
20
20
|
"./bin": "./dist/bin.mjs",
|
|
21
|
-
"./docker-
|
|
22
|
-
"types": "./dist/docker-
|
|
23
|
-
"default": "./dist/docker-
|
|
21
|
+
"./docker-check": {
|
|
22
|
+
"types": "./dist/docker-check/index.d.mts",
|
|
23
|
+
"default": "./dist/docker-check/index.mjs"
|
|
24
24
|
},
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|