@livestore/utils-dev 0.4.0 → 0.5.0-dev.1
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/.tsbuildinfo +1 -1
- package/dist/node/DockerCompose/DockerCompose.d.ts +52 -0
- package/dist/node/DockerCompose/DockerCompose.d.ts.map +1 -0
- package/dist/node/DockerCompose/DockerCompose.js +158 -0
- package/dist/node/DockerCompose/DockerCompose.js.map +1 -0
- package/dist/node/DockerCompose/DockerCompose.test.d.ts +2 -0
- package/dist/node/DockerCompose/DockerCompose.test.d.ts.map +1 -0
- package/dist/node/{DockerComposeService/DockerComposeService.test.js → DockerCompose/DockerCompose.test.js} +16 -16
- package/dist/node/DockerCompose/DockerCompose.test.js.map +1 -0
- package/dist/node/DockerCompose/mod.d.ts +2 -0
- package/dist/node/DockerCompose/mod.d.ts.map +1 -0
- package/dist/node/DockerCompose/mod.js +2 -0
- package/dist/node/DockerCompose/mod.js.map +1 -0
- package/dist/node/FileLogger.d.ts +15 -8
- package/dist/node/FileLogger.d.ts.map +1 -1
- package/dist/node/FileLogger.js +63 -79
- package/dist/node/FileLogger.js.map +1 -1
- package/dist/node/cmd-log.d.ts.map +1 -1
- package/dist/node/cmd-log.js +19 -8
- package/dist/node/cmd-log.js.map +1 -1
- package/dist/node/cmd.d.ts +10 -12
- package/dist/node/cmd.d.ts.map +1 -1
- package/dist/node/cmd.js +76 -39
- package/dist/node/cmd.js.map +1 -1
- package/dist/node/cmd.test.js +19 -19
- package/dist/node/cmd.test.js.map +1 -1
- package/dist/node/mod.d.ts +4 -5
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +63 -60
- package/dist/node/mod.js.map +1 -1
- package/dist/node/workspace.d.ts +2 -2
- package/dist/node/workspace.d.ts.map +1 -1
- package/dist/node/workspace.js +7 -7
- package/dist/node/workspace.js.map +1 -1
- package/dist/node-vitest/Vitest.d.ts +8 -40
- package/dist/node-vitest/Vitest.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.js +7 -78
- package/dist/node-vitest/Vitest.js.map +1 -1
- package/dist/node-vitest/mod.js +2 -2
- package/dist/wrangler/WranglerDevServer.d.ts +15 -20
- package/dist/wrangler/WranglerDevServer.d.ts.map +1 -1
- package/dist/wrangler/WranglerDevServer.js +77 -71
- package/dist/wrangler/WranglerDevServer.js.map +1 -1
- package/dist/wrangler/WranglerDevServer.test.js +28 -28
- package/dist/wrangler/WranglerDevServer.test.js.map +1 -1
- package/dist/wrangler/fixtures/cf-worker.d.ts.map +1 -1
- package/dist/wrangler/mod.d.ts +1 -1
- package/dist/wrangler/mod.d.ts.map +1 -1
- package/dist/wrangler/mod.js +1 -1
- package/dist/wrangler/mod.js.map +1 -1
- package/package.json +40 -58
- package/src/node/{DockerComposeService/DockerComposeService.test.ts → DockerCompose/DockerCompose.test.ts} +18 -18
- package/src/node/DockerCompose/DockerCompose.ts +328 -0
- package/src/node/DockerCompose/mod.ts +1 -0
- package/src/node/FileLogger.ts +89 -114
- package/src/node/cmd-log.ts +21 -10
- package/src/node/cmd.test.ts +19 -17
- package/src/node/cmd.ts +117 -88
- package/src/node/mod.ts +112 -104
- package/src/node/workspace.ts +9 -10
- package/src/node-vitest/Vitest.ts +21 -172
- package/src/wrangler/WranglerDevServer.test.ts +33 -37
- package/src/wrangler/WranglerDevServer.ts +145 -129
- package/src/wrangler/mod.ts +1 -6
- package/dist/node/DockerComposeService/DockerComposeService.d.ts +0 -63
- package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +0 -1
- package/dist/node/DockerComposeService/DockerComposeService.js +0 -149
- package/dist/node/DockerComposeService/DockerComposeService.js.map +0 -1
- package/dist/node/DockerComposeService/DockerComposeService.test.d.ts +0 -2
- package/dist/node/DockerComposeService/DockerComposeService.test.d.ts.map +0 -1
- package/dist/node/DockerComposeService/DockerComposeService.test.js.map +0 -1
- package/dist/node-vitest/Vitest.test.d.ts +0 -10
- package/dist/node-vitest/Vitest.test.d.ts.map +0 -1
- package/dist/node-vitest/Vitest.test.js +0 -74
- package/dist/node-vitest/Vitest.test.js.map +0 -1
- package/src/node/DockerComposeService/DockerComposeService.ts +0 -343
- package/src/node-vitest/Vitest.test.ts +0 -117
- /package/src/node/{DockerComposeService → DockerCompose}/test-fixtures/docker-compose.yml +0 -0
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { objectToString, omitUndefineds } from '@livestore/utils';
|
|
2
|
-
import { Command, Duration, Effect, Fiber, Schedule, Schema, Stream, } from '@livestore/utils/effect';
|
|
3
|
-
export class DockerComposeError extends Schema.TaggedError('~@livestore/utils-dev/DockerComposeError')('DockerComposeError', {
|
|
4
|
-
cause: Schema.Defect,
|
|
5
|
-
note: Schema.String,
|
|
6
|
-
}) {
|
|
7
|
-
}
|
|
8
|
-
const generateProjectName = () => `ls-test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
9
|
-
export class DockerComposeService extends Effect.Service()('DockerComposeService', {
|
|
10
|
-
scoped: (args) => Effect.gen(function* () {
|
|
11
|
-
const { cwd, serviceName } = args;
|
|
12
|
-
const projectName = args.projectName ?? generateProjectName();
|
|
13
|
-
const commandExecutorContext = yield* Effect.context();
|
|
14
|
-
const baseComposeArgs = ['-p', projectName];
|
|
15
|
-
const pull = Effect.gen(function* () {
|
|
16
|
-
yield* Effect.log(`Pulling Docker Compose images in ${cwd}`);
|
|
17
|
-
// TODO (@IMax153) Refactor the effect command related code below as there is probably a much more elegant way to accomplish what we want here in a more effect idiomatic way.
|
|
18
|
-
const pullCommand = Command.make('docker', 'compose', ...baseComposeArgs, 'pull').pipe(Command.workingDirectory(cwd), Command.stdout('pipe'), Command.stderr('pipe'));
|
|
19
|
-
const process = yield* pullCommand.pipe(Command.start, Effect.provide(commandExecutorContext));
|
|
20
|
-
const stdoutFiber = yield* process.stdout.pipe(Stream.decodeText('utf8'), Stream.runFold('', (acc, chunk) => acc + chunk), Effect.fork);
|
|
21
|
-
const stderrFiber = yield* process.stderr.pipe(Stream.decodeText('utf8'), Stream.runFold('', (acc, chunk) => acc + chunk), Effect.fork);
|
|
22
|
-
const exitCode = yield* process.exitCode;
|
|
23
|
-
const stdout = yield* Fiber.join(stdoutFiber);
|
|
24
|
-
const stderr = yield* Fiber.join(stderrFiber);
|
|
25
|
-
const exitCodeNumber = Number(exitCode);
|
|
26
|
-
if (exitCodeNumber !== 0) {
|
|
27
|
-
const stdoutLog = stdout.length > 0 ? stdout : '<empty stdout>';
|
|
28
|
-
const stderrLog = stderr.length > 0 ? stderr : '<empty stderr>';
|
|
29
|
-
const failureMessage = [
|
|
30
|
-
`Docker compose pull failed with exit code ${exitCodeNumber} in ${cwd}`,
|
|
31
|
-
`stdout:\n${stdoutLog}`,
|
|
32
|
-
`stderr:\n${stderrLog}`,
|
|
33
|
-
].join('\n');
|
|
34
|
-
yield* Effect.logError(failureMessage);
|
|
35
|
-
return yield* new DockerComposeError({
|
|
36
|
-
cause: new Error(`Docker compose pull failed with exit code ${exitCodeNumber}`),
|
|
37
|
-
note: failureMessage,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
yield* Effect.log(`Successfully pulled Docker Compose images`);
|
|
41
|
-
}).pipe(Effect.retry({
|
|
42
|
-
schedule: Schedule.exponentialBackoff10Sec,
|
|
43
|
-
while: Schema.is(DockerComposeError),
|
|
44
|
-
}), Effect.withSpan('pullDockerComposeImages'), Effect.scoped);
|
|
45
|
-
const start = Effect.fn('startDockerCompose')(function* (options = {}) {
|
|
46
|
-
const { detached = true, healthCheck } = options;
|
|
47
|
-
// Build start command
|
|
48
|
-
const startArgs = ['docker', 'compose', ...baseComposeArgs, 'up'];
|
|
49
|
-
if (detached === true)
|
|
50
|
-
startArgs.push('-d');
|
|
51
|
-
if (serviceName !== undefined)
|
|
52
|
-
startArgs.push(serviceName);
|
|
53
|
-
const command = yield* Command.make(startArgs[0], ...startArgs.slice(1)).pipe(Command.workingDirectory(cwd), Command.env(options.env ?? {}), Command.stderr('inherit'), Command.stdout('inherit'), Command.start, Effect.mapError((cause) => new DockerComposeError({
|
|
54
|
-
cause,
|
|
55
|
-
note: `Failed to start Docker Compose services in ${cwd}`,
|
|
56
|
-
})), Effect.provide(commandExecutorContext));
|
|
57
|
-
// Wait for command completion
|
|
58
|
-
yield* command.exitCode.pipe(Effect.flatMap((exitCode) => exitCode === 0
|
|
59
|
-
? Effect.void
|
|
60
|
-
: Effect.fail(new DockerComposeError({
|
|
61
|
-
cause: new Error(`Docker compose exited with code ${exitCode}`),
|
|
62
|
-
note: `Docker Compose failed to start with exit code ${exitCode}. Env: ${JSON.stringify(options.env)}`,
|
|
63
|
-
}))), Effect.provide(commandExecutorContext));
|
|
64
|
-
// Perform health check if requested
|
|
65
|
-
if (healthCheck !== undefined) {
|
|
66
|
-
yield* performHealthCheck(healthCheck).pipe(Effect.provide(commandExecutorContext));
|
|
67
|
-
}
|
|
68
|
-
yield* Effect.log(`Docker Compose services started successfully in ${cwd}`);
|
|
69
|
-
});
|
|
70
|
-
const stop = Effect.gen(function* () {
|
|
71
|
-
yield* Effect.log(`Stopping Docker Compose services in ${cwd}`);
|
|
72
|
-
const stopCommand = serviceName !== undefined
|
|
73
|
-
? Command.make('docker', 'compose', ...baseComposeArgs, 'stop', serviceName)
|
|
74
|
-
: Command.make('docker', 'compose', ...baseComposeArgs, 'stop');
|
|
75
|
-
yield* stopCommand.pipe(Command.workingDirectory(cwd), Command.exitCode, Effect.flatMap((exitCode) => exitCode === 0
|
|
76
|
-
? Effect.void
|
|
77
|
-
: Effect.fail(new DockerComposeError({
|
|
78
|
-
cause: new Error(`Docker compose stop exited with code ${exitCode}`),
|
|
79
|
-
note: `Failed to stop Docker Compose services`,
|
|
80
|
-
}))), Effect.provide(commandExecutorContext));
|
|
81
|
-
yield* Effect.log(`Docker Compose services stopped successfully`);
|
|
82
|
-
}).pipe(Effect.withSpan('stopDockerCompose'));
|
|
83
|
-
const logs = (options = {}) => Effect.gen(function* () {
|
|
84
|
-
const { follow = false, tail, since } = options;
|
|
85
|
-
const logsArgs = ['docker', 'compose', ...baseComposeArgs, 'logs'];
|
|
86
|
-
if (follow === true)
|
|
87
|
-
logsArgs.push('-f');
|
|
88
|
-
if (tail !== undefined)
|
|
89
|
-
logsArgs.push('--tail', tail.toString());
|
|
90
|
-
if (since !== undefined)
|
|
91
|
-
logsArgs.push('--since', since);
|
|
92
|
-
if (serviceName !== undefined)
|
|
93
|
-
logsArgs.push(serviceName);
|
|
94
|
-
const command = yield* Command.make(logsArgs[0], ...logsArgs.slice(1)).pipe(Command.workingDirectory(cwd), Command.start, Effect.mapError((cause) => new DockerComposeError({
|
|
95
|
-
cause,
|
|
96
|
-
note: `Failed to read Docker Compose logs in ${cwd}`,
|
|
97
|
-
})), Effect.provide(commandExecutorContext));
|
|
98
|
-
return command.stdout.pipe(Stream.decodeText('utf8'), Stream.splitLines, Stream.mapError((cause) => new DockerComposeError({
|
|
99
|
-
cause,
|
|
100
|
-
note: `Error reading Docker Compose logs in ${cwd}`,
|
|
101
|
-
})));
|
|
102
|
-
}).pipe(Stream.unwrapScoped);
|
|
103
|
-
const down = Effect.fn('downDockerCompose')(function* (options) {
|
|
104
|
-
yield* Effect.log(`Tearing down Docker Compose services in ${cwd}`);
|
|
105
|
-
const downArgs = ['docker', 'compose', ...baseComposeArgs, 'down'];
|
|
106
|
-
if (options?.volumes === true)
|
|
107
|
-
downArgs.push('-v');
|
|
108
|
-
if (options?.removeOrphans === true)
|
|
109
|
-
downArgs.push('--remove-orphans');
|
|
110
|
-
if (serviceName !== undefined)
|
|
111
|
-
downArgs.push(serviceName);
|
|
112
|
-
yield* Command.make(downArgs[0], ...downArgs.slice(1)).pipe(Command.workingDirectory(cwd), Command.env(options?.env ?? {}), Command.exitCode, Effect.flatMap((exitCode) => exitCode === 0
|
|
113
|
-
? Effect.void
|
|
114
|
-
: Effect.fail(new DockerComposeError({
|
|
115
|
-
cause: new Error(`Docker compose down exited with code ${exitCode}`),
|
|
116
|
-
note: `Failed to tear down Docker Compose services`,
|
|
117
|
-
}))), Effect.provide(commandExecutorContext));
|
|
118
|
-
yield* Effect.log(`Docker Compose services torn down successfully`);
|
|
119
|
-
});
|
|
120
|
-
// Register cleanup finalizer to ensure containers are removed when scope closes
|
|
121
|
-
yield* Effect.addFinalizer(() => down({ volumes: true, removeOrphans: true }).pipe(Effect.tap(() => Effect.log(`Docker Compose cleanup completed for project ${projectName}`)), Effect.catchAll((error) => Effect.log('Docker Compose cleanup failed for project', projectName, objectToString(error)))));
|
|
122
|
-
return { pull, start, stop, down, logs, projectName };
|
|
123
|
-
}),
|
|
124
|
-
}) {
|
|
125
|
-
}
|
|
126
|
-
const performHealthCheck = ({ url, timeout = Duration.minutes(2), interval = Duration.seconds(2), }) => Effect.gen(function* () {
|
|
127
|
-
yield* Effect.log(`Performing health check on ${url}`);
|
|
128
|
-
const checkHealth = Command.make('curl', '-f', '-s', url).pipe(Command.exitCode, Effect.map((code) => code === 0), Effect.catchAll(() => Effect.succeed(false)));
|
|
129
|
-
const healthCheck = checkHealth.pipe(Effect.repeat({
|
|
130
|
-
while: (healthy) => healthy === false,
|
|
131
|
-
schedule: Schedule.fixed(interval),
|
|
132
|
-
}), Effect.timeout(timeout), Effect.mapError(() => new DockerComposeError({
|
|
133
|
-
cause: new Error('Health check timeout'),
|
|
134
|
-
note: `Health check failed for ${url} after ${Duration.toMillis(timeout)}ms`,
|
|
135
|
-
})));
|
|
136
|
-
yield* healthCheck;
|
|
137
|
-
yield* Effect.log(`Health check passed for ${url}`);
|
|
138
|
-
});
|
|
139
|
-
// Convenience function for scoped Docker Compose operations with automatic cleanup
|
|
140
|
-
export const startDockerComposeServicesScoped = (args) => Effect.gen(function* () {
|
|
141
|
-
const dockerCompose = yield* DockerComposeService;
|
|
142
|
-
// Start the services
|
|
143
|
-
yield* dockerCompose.start({
|
|
144
|
-
...omitUndefineds({ healthCheck: args.healthCheck !== undefined ? args.healthCheck : undefined }),
|
|
145
|
-
});
|
|
146
|
-
// Add cleanup finalizer to the current scope
|
|
147
|
-
yield* Effect.addFinalizer(() => dockerCompose.stop.pipe(Effect.orDie));
|
|
148
|
-
});
|
|
149
|
-
//# sourceMappingURL=DockerComposeService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DockerComposeService.js","sourceRoot":"","sources":["../../../src/node/DockerComposeService/DockerComposeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EACL,OAAO,EAEP,QAAQ,EACR,MAAM,EACN,KAAK,EAEL,QAAQ,EACR,MAAM,EAEN,MAAM,GACP,MAAM,yBAAyB,CAAA;AAEhC,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,WAAW,CAAqB,0CAA0C,CAAC,CAAC,oBAAoB,EAAE;IAC/I,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC;CAAG;AA2CL,MAAM,mBAAmB,GAAG,GAAW,EAAE,CAAC,WAAW,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AAE3G,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,OAAO,EAAwB,CAAC,sBAAsB,EAAE;IACvG,MAAM,EAAE,CAAC,IAAuB,EAAE,EAAE,CAClC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;QACjC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,mBAAmB,EAAE,CAAA;QAE7D,MAAM,sBAAsB,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAmC,CAAA;QAEvF,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAE3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jD,qBAAqB;IACrB,KAAK,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;QACzB,GAAG,cAAc,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;KAClG,CAAC,CAAA;IAEF,6CAA6C;IAC7C,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AACzE,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DockerComposeService.test.d.ts","sourceRoot":"","sources":["../../../src/node/DockerComposeService/DockerComposeService.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DockerComposeService.test.js","sourceRoot":"","sources":["../../../src/node/DockerComposeService/DockerComposeService.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAA0B,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAExF,MAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AAEvE,MAAM,iBAAiB,GAAG,CAAC,OAAmC,EAAE,EAAE,EAAE,CAClE,oBAAoB,CAAC,OAAO,CAAC;IAC3B,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AEjD,oEAAoE;YACpE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,aAAa;iBAChC,KAAK,CAAC;gBACL,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE;oBACX,GAAG,EAAE,oCAAoC;oBACzC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;iBAC7B;aACF,CAAC;iBACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAEtB,0CAA0C;YAC1C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAClC,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CACnE,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@livestore/utils/effect';
|
|
2
|
-
declare const TestError_base: Schema.TaggedErrorClass<TestError, "TestError", {
|
|
3
|
-
readonly _tag: Schema.tag<"TestError">;
|
|
4
|
-
} & {
|
|
5
|
-
message: typeof Schema.String;
|
|
6
|
-
}>;
|
|
7
|
-
export declare class TestError extends TestError_base {
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=Vitest.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Vitest.test.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;;;AAInE,qBAAa,SAAU,SAAQ,cAE7B;CAAG"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Effect, FastCheck, Schema } from '@livestore/utils/effect';
|
|
2
|
-
import * as Vitest from "./Vitest.js";
|
|
3
|
-
export class TestError extends Schema.TaggedError()('TestError', {
|
|
4
|
-
message: Schema.String,
|
|
5
|
-
}) {
|
|
6
|
-
}
|
|
7
|
-
// Demonstrate enhanced asProp functionality with clear shrinking progress
|
|
8
|
-
// This showcases the fix for the "Run 26/6" bug and accurate shrinking detection
|
|
9
|
-
Vitest.describe('Vitest.asProp', () => {
|
|
10
|
-
const IntArbitrary = FastCheck.integer({ min: 1, max: 100 });
|
|
11
|
-
// Always-passing test - should only show initial phase
|
|
12
|
-
Vitest.asProp(Vitest.scopedLive, 'always-pass test (shows only initial runs)', [IntArbitrary], (properties, _ctx, enhanced) => Effect.gen(function* () {
|
|
13
|
-
const [value] = properties;
|
|
14
|
-
if (value === undefined) {
|
|
15
|
-
return yield* new TestError({ message: 'Value is undefined' });
|
|
16
|
-
}
|
|
17
|
-
console.log(`✅ ALWAYS-PASS [${enhanced._tag.toUpperCase()}]: ` +
|
|
18
|
-
(enhanced._tag === 'initial'
|
|
19
|
-
? `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}`
|
|
20
|
-
: `Shrink #${enhanced.shrinkAttempt} (finding minimal counterexample)`) +
|
|
21
|
-
`, value=${value}, total=${enhanced.totalExecutions}`);
|
|
22
|
-
// This test always passes, so no shrinking will occur
|
|
23
|
-
return;
|
|
24
|
-
}), { fastCheck: { numRuns: 4 } });
|
|
25
|
-
// Failing test - should show initial + shrinking phases
|
|
26
|
-
let alreadyFailed = false;
|
|
27
|
-
Vitest.asProp(Vitest.scopedLive, 'failing test (shows initial runs + shrinking)', [IntArbitrary], (properties, ctx, enhanced) => Effect.gen(function* () {
|
|
28
|
-
const [value] = properties;
|
|
29
|
-
if (value === undefined) {
|
|
30
|
-
return yield* new TestError({ message: 'Value is undefined' });
|
|
31
|
-
}
|
|
32
|
-
const displayInfo = enhanced._tag === 'initial'
|
|
33
|
-
? `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}`
|
|
34
|
-
: `Shrink #${enhanced.shrinkAttempt} (finding minimal counterexample)`;
|
|
35
|
-
const status = value > 80 ? '💥' : '✅';
|
|
36
|
-
console.log(`${status} FAILING-TEST [${enhanced._tag.toUpperCase()}]: ${displayInfo}, value=${value}, total=${enhanced.totalExecutions}`);
|
|
37
|
-
// Fail when value is greater than 80 to trigger shrinking
|
|
38
|
-
if (value > 80) {
|
|
39
|
-
alreadyFailed = true;
|
|
40
|
-
return yield* new TestError({ message: `Value ${value} is too large (> 80)` });
|
|
41
|
-
}
|
|
42
|
-
if (alreadyFailed === true && enhanced._tag === 'shrinking') {
|
|
43
|
-
ctx.skip("For the sake of this test, we don't want to fail but want to skip");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
return;
|
|
47
|
-
}), { fastCheck: { numRuns: 3 } });
|
|
48
|
-
// Test with endOnFailure: true - should not show shrinking
|
|
49
|
-
Vitest.asProp(Vitest.scopedLive, 'failing test with endOnFailure (no shrinking)', [IntArbitrary], (properties, _ctx, enhanced) => Effect.gen(function* () {
|
|
50
|
-
const [value] = properties;
|
|
51
|
-
if (value === undefined) {
|
|
52
|
-
return yield* new TestError({ message: 'Value is undefined' });
|
|
53
|
-
}
|
|
54
|
-
console.log(`🚫 END-ON-FAILURE [${enhanced._tag.toUpperCase()}]: ` +
|
|
55
|
-
`Run ${enhanced.runIndex + 1}/${enhanced.numRuns}, value=${value}, total=${enhanced.totalExecutions}`);
|
|
56
|
-
// This will fail but shrinking is disabled
|
|
57
|
-
if (value > 50) {
|
|
58
|
-
return yield* new TestError({ message: `Value ${value} is too large (> 50) - but no shrinking!` });
|
|
59
|
-
}
|
|
60
|
-
return;
|
|
61
|
-
}), {
|
|
62
|
-
fastCheck: {
|
|
63
|
-
numRuns: 5,
|
|
64
|
-
endOnFailure: true,
|
|
65
|
-
// Provide explicit samples so the second run crosses >50. Randomly drawing five
|
|
66
|
-
// integers has ~3% chance to stay ≤ 50, which would break the `fails: true`
|
|
67
|
-
// expectation even though shrinking remains disabled. The examples keep the
|
|
68
|
-
// demo readable while leaving the remaining runs to FastCheck.
|
|
69
|
-
examples: [[5], [66]],
|
|
70
|
-
},
|
|
71
|
-
fails: true,
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
//# sourceMappingURL=Vitest.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Vitest.test.js","sourceRoot":"","sources":["../../src/node-vitest/Vitest.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,WAAW,EAAa,CAAC,WAAW,EAAE;IAC1E,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL,0EAA0E;AAC1E,iFAAiF;AAEjF,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IACpC,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;IAE5D,uDAAuD;IACvD,MAAM,CAAC,MAAM,CACX,MAAM,CAAC,UAAU,EACjB,4CAA4C,EAC5C,CAAC,YAAY,CAAC,EACd,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAC7B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAA;QAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;QAChE,CAAC;QAED,OAAO,CAAC,GAAG,CACT,kBAAkB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK;YAChD,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;gBAC1B,CAAC,CAAC,OAAO,QAAQ,CAAC,QAAQ,GA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V,YAAY,EAAE,IAAI;YAClB,gFAAgF;YAChF,4EAA4E;YAC5E,4EAA4E;YAC5E,+DAA+D;YAC/D,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACtB;QACD,KAAK,EAAE,IAAI;KACZ,CACF,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import { objectToString, omitUndefineds } from '@livestore/utils'
|
|
2
|
-
import {
|
|
3
|
-
Command,
|
|
4
|
-
type CommandExecutor,
|
|
5
|
-
Duration,
|
|
6
|
-
Effect,
|
|
7
|
-
Fiber,
|
|
8
|
-
type PlatformError,
|
|
9
|
-
Schedule,
|
|
10
|
-
Schema,
|
|
11
|
-
type Scope,
|
|
12
|
-
Stream,
|
|
13
|
-
} from '@livestore/utils/effect'
|
|
14
|
-
|
|
15
|
-
export class DockerComposeError extends Schema.TaggedError<DockerComposeError>('~@livestore/utils-dev/DockerComposeError')('DockerComposeError', {
|
|
16
|
-
cause: Schema.Defect,
|
|
17
|
-
note: Schema.String,
|
|
18
|
-
}) {}
|
|
19
|
-
|
|
20
|
-
export interface DockerComposeArgs {
|
|
21
|
-
readonly cwd: string
|
|
22
|
-
readonly serviceName?: string
|
|
23
|
-
/** Unique project name to isolate this compose instance. If not provided, a random one is generated. */
|
|
24
|
-
readonly projectName?: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface StartOptions {
|
|
28
|
-
readonly detached?: boolean
|
|
29
|
-
readonly env?: Record<string, string>
|
|
30
|
-
readonly healthCheck?: {
|
|
31
|
-
readonly url: string
|
|
32
|
-
readonly timeout?: Duration.Duration
|
|
33
|
-
readonly interval?: Duration.Duration
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface LogsOptions {
|
|
38
|
-
readonly follow?: boolean
|
|
39
|
-
readonly tail?: number
|
|
40
|
-
readonly since?: string
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface DockerComposeOperations {
|
|
44
|
-
readonly pull: Effect.Effect<void, DockerComposeError | PlatformError.PlatformError>
|
|
45
|
-
readonly start: (
|
|
46
|
-
options?: StartOptions,
|
|
47
|
-
) => Effect.Effect<void, DockerComposeError | PlatformError.PlatformError, Scope.Scope>
|
|
48
|
-
readonly stop: Effect.Effect<void, DockerComposeError | PlatformError.PlatformError>
|
|
49
|
-
readonly down: (options?: {
|
|
50
|
-
readonly env?: Record<string, string>
|
|
51
|
-
readonly volumes?: boolean
|
|
52
|
-
readonly removeOrphans?: boolean
|
|
53
|
-
}) => Effect.Effect<void, DockerComposeError | PlatformError.PlatformError>
|
|
54
|
-
readonly logs: (
|
|
55
|
-
options?: LogsOptions,
|
|
56
|
-
) => Stream.Stream<string, DockerComposeError | PlatformError.PlatformError, Scope.Scope>
|
|
57
|
-
/** The unique project name used to isolate this compose instance */
|
|
58
|
-
readonly projectName: string
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const generateProjectName = (): string => `ls-test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
|
62
|
-
|
|
63
|
-
export class DockerComposeService extends Effect.Service<DockerComposeService>()('DockerComposeService', {
|
|
64
|
-
scoped: (args: DockerComposeArgs) =>
|
|
65
|
-
Effect.gen(function* () {
|
|
66
|
-
const { cwd, serviceName } = args
|
|
67
|
-
const projectName = args.projectName ?? generateProjectName()
|
|
68
|
-
|
|
69
|
-
const commandExecutorContext = yield* Effect.context<CommandExecutor.CommandExecutor>()
|
|
70
|
-
|
|
71
|
-
const baseComposeArgs = ['-p', projectName]
|
|
72
|
-
|
|
73
|
-
const pull = Effect.gen(function* () {
|
|
74
|
-
yield* Effect.log(`Pulling Docker Compose images in ${cwd}`)
|
|
75
|
-
|
|
76
|
-
// TODO (@IMax153) Refactor the effect command related code below as there is probably a much more elegant way to accomplish what we want here in a more effect idiomatic way.
|
|
77
|
-
const pullCommand = Command.make('docker', 'compose', ...baseComposeArgs, 'pull').pipe(
|
|
78
|
-
Command.workingDirectory(cwd),
|
|
79
|
-
Command.stdout('pipe'),
|
|
80
|
-
Command.stderr('pipe'),
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
const process = yield* pullCommand.pipe(Command.start, Effect.provide(commandExecutorContext))
|
|
84
|
-
|
|
85
|
-
const stdoutFiber = yield* process.stdout.pipe(
|
|
86
|
-
Stream.decodeText('utf8'),
|
|
87
|
-
Stream.runFold('', (acc, chunk) => acc + chunk),
|
|
88
|
-
Effect.fork,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
const stderrFiber = yield* process.stderr.pipe(
|
|
92
|
-
Stream.decodeText('utf8'),
|
|
93
|
-
Stream.runFold('', (acc, chunk) => acc + chunk),
|
|
94
|
-
Effect.fork,
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
const exitCode = yield* process.exitCode
|
|
98
|
-
const stdout = yield* Fiber.join(stdoutFiber)
|
|
99
|
-
const stderr = yield* Fiber.join(stderrFiber)
|
|
100
|
-
|
|
101
|
-
const exitCodeNumber = Number(exitCode)
|
|
102
|
-
|
|
103
|
-
if (exitCodeNumber !== 0) {
|
|
104
|
-
const stdoutLog = stdout.length > 0 ? stdout : '<empty stdout>'
|
|
105
|
-
const stderrLog = stderr.length > 0 ? stderr : '<empty stderr>'
|
|
106
|
-
const failureMessage = [
|
|
107
|
-
`Docker compose pull failed with exit code ${exitCodeNumber} in ${cwd}`,
|
|
108
|
-
`stdout:\n${stdoutLog}`,
|
|
109
|
-
`stderr:\n${stderrLog}`,
|
|
110
|
-
].join('\n')
|
|
111
|
-
|
|
112
|
-
yield* Effect.logError(failureMessage)
|
|
113
|
-
|
|
114
|
-
return yield* new DockerComposeError({
|
|
115
|
-
cause: new Error(`Docker compose pull failed with exit code ${exitCodeNumber}`),
|
|
116
|
-
note: failureMessage,
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
yield* Effect.log(`Successfully pulled Docker Compose images`)
|
|
121
|
-
}).pipe(
|
|
122
|
-
Effect.retry({
|
|
123
|
-
schedule: Schedule.exponentialBackoff10Sec,
|
|
124
|
-
while: Schema.is(DockerComposeError),
|
|
125
|
-
}),
|
|
126
|
-
Effect.withSpan('pullDockerComposeImages'),
|
|
127
|
-
Effect.scoped,
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
const start = Effect.fn('startDockerCompose')(function* (options: StartOptions = {}) {
|
|
131
|
-
const { detached = true, healthCheck } = options
|
|
132
|
-
|
|
133
|
-
// Build start command
|
|
134
|
-
const startArgs = ['docker', 'compose', ...baseComposeArgs, 'up']
|
|
135
|
-
if (detached === true) startArgs.push('-d')
|
|
136
|
-
if (serviceName !== undefined) startArgs.push(serviceName)
|
|
137
|
-
|
|
138
|
-
const command = yield* Command.make(startArgs[0]!, ...startArgs.slice(1)).pipe(
|
|
139
|
-
Command.workingDirectory(cwd),
|
|
140
|
-
Command.env(options.env ?? {}),
|
|
141
|
-
Command.stderr('inherit'),
|
|
142
|
-
Command.stdout('inherit'),
|
|
143
|
-
Command.start,
|
|
144
|
-
Effect.mapError(
|
|
145
|
-
(cause) =>
|
|
146
|
-
new DockerComposeError({
|
|
147
|
-
cause,
|
|
148
|
-
note: `Failed to start Docker Compose services in ${cwd}`,
|
|
149
|
-
}),
|
|
150
|
-
),
|
|
151
|
-
Effect.provide(commandExecutorContext),
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
// Wait for command completion
|
|
155
|
-
yield* command.exitCode.pipe(
|
|
156
|
-
Effect.flatMap((exitCode) =>
|
|
157
|
-
exitCode === 0
|
|
158
|
-
? Effect.void
|
|
159
|
-
: Effect.fail(
|
|
160
|
-
new DockerComposeError({
|
|
161
|
-
cause: new Error(`Docker compose exited with code ${exitCode}`),
|
|
162
|
-
note: `Docker Compose failed to start with exit code ${exitCode}. Env: ${JSON.stringify(options.env)}`,
|
|
163
|
-
}),
|
|
164
|
-
),
|
|
165
|
-
),
|
|
166
|
-
Effect.provide(commandExecutorContext),
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
// Perform health check if requested
|
|
170
|
-
if (healthCheck !== undefined) {
|
|
171
|
-
yield* performHealthCheck(healthCheck).pipe(Effect.provide(commandExecutorContext))
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
yield* Effect.log(`Docker Compose services started successfully in ${cwd}`)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
const stop = Effect.gen(function* () {
|
|
178
|
-
yield* Effect.log(`Stopping Docker Compose services in ${cwd}`)
|
|
179
|
-
|
|
180
|
-
const stopCommand =
|
|
181
|
-
serviceName !== undefined
|
|
182
|
-
? Command.make('docker', 'compose', ...baseComposeArgs, 'stop', serviceName)
|
|
183
|
-
: Command.make('docker', 'compose', ...baseComposeArgs, 'stop')
|
|
184
|
-
|
|
185
|
-
yield* stopCommand.pipe(
|
|
186
|
-
Command.workingDirectory(cwd),
|
|
187
|
-
Command.exitCode,
|
|
188
|
-
Effect.flatMap((exitCode: number) =>
|
|
189
|
-
exitCode === 0
|
|
190
|
-
? Effect.void
|
|
191
|
-
: Effect.fail(
|
|
192
|
-
new DockerComposeError({
|
|
193
|
-
cause: new Error(`Docker compose stop exited with code ${exitCode}`),
|
|
194
|
-
note: `Failed to stop Docker Compose services`,
|
|
195
|
-
}),
|
|
196
|
-
),
|
|
197
|
-
),
|
|
198
|
-
Effect.provide(commandExecutorContext),
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
yield* Effect.log(`Docker Compose services stopped successfully`)
|
|
202
|
-
}).pipe(Effect.withSpan('stopDockerCompose'))
|
|
203
|
-
|
|
204
|
-
const logs = (options: LogsOptions = {}) =>
|
|
205
|
-
Effect.gen(function* () {
|
|
206
|
-
const { follow = false, tail, since } = options
|
|
207
|
-
|
|
208
|
-
const logsArgs = ['docker', 'compose', ...baseComposeArgs, 'logs']
|
|
209
|
-
if (follow === true) logsArgs.push('-f')
|
|
210
|
-
if (tail !== undefined) logsArgs.push('--tail', tail.toString())
|
|
211
|
-
if (since !== undefined) logsArgs.push('--since', since)
|
|
212
|
-
if (serviceName !== undefined) logsArgs.push(serviceName)
|
|
213
|
-
|
|
214
|
-
const command = yield* Command.make(logsArgs[0]!, ...logsArgs.slice(1)).pipe(
|
|
215
|
-
Command.workingDirectory(cwd),
|
|
216
|
-
Command.start,
|
|
217
|
-
Effect.mapError(
|
|
218
|
-
(cause) =>
|
|
219
|
-
new DockerComposeError({
|
|
220
|
-
cause,
|
|
221
|
-
note: `Failed to read Docker Compose logs in ${cwd}`,
|
|
222
|
-
}),
|
|
223
|
-
),
|
|
224
|
-
Effect.provide(commandExecutorContext),
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
return command.stdout.pipe(
|
|
228
|
-
Stream.decodeText('utf8'),
|
|
229
|
-
Stream.splitLines,
|
|
230
|
-
Stream.mapError(
|
|
231
|
-
(cause) =>
|
|
232
|
-
new DockerComposeError({
|
|
233
|
-
cause,
|
|
234
|
-
note: `Error reading Docker Compose logs in ${cwd}`,
|
|
235
|
-
}),
|
|
236
|
-
),
|
|
237
|
-
)
|
|
238
|
-
}).pipe(Stream.unwrapScoped)
|
|
239
|
-
|
|
240
|
-
const down = Effect.fn('downDockerCompose')(function* (options?: {
|
|
241
|
-
readonly env?: Record<string, string>
|
|
242
|
-
readonly volumes?: boolean
|
|
243
|
-
readonly removeOrphans?: boolean
|
|
244
|
-
}) {
|
|
245
|
-
yield* Effect.log(`Tearing down Docker Compose services in ${cwd}`)
|
|
246
|
-
|
|
247
|
-
const downArgs = ['docker', 'compose', ...baseComposeArgs, 'down']
|
|
248
|
-
if (options?.volumes === true) downArgs.push('-v')
|
|
249
|
-
if (options?.removeOrphans === true) downArgs.push('--remove-orphans')
|
|
250
|
-
if (serviceName !== undefined) downArgs.push(serviceName)
|
|
251
|
-
|
|
252
|
-
yield* Command.make(downArgs[0]!, ...downArgs.slice(1)).pipe(
|
|
253
|
-
Command.workingDirectory(cwd),
|
|
254
|
-
Command.env(options?.env ?? {}),
|
|
255
|
-
Command.exitCode,
|
|
256
|
-
Effect.flatMap((exitCode: number) =>
|
|
257
|
-
exitCode === 0
|
|
258
|
-
? Effect.void
|
|
259
|
-
: Effect.fail(
|
|
260
|
-
new DockerComposeError({
|
|
261
|
-
cause: new Error(`Docker compose down exited with code ${exitCode}`),
|
|
262
|
-
note: `Failed to tear down Docker Compose services`,
|
|
263
|
-
}),
|
|
264
|
-
),
|
|
265
|
-
),
|
|
266
|
-
Effect.provide(commandExecutorContext),
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
yield* Effect.log(`Docker Compose services torn down successfully`)
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
// Register cleanup finalizer to ensure containers are removed when scope closes
|
|
273
|
-
yield* Effect.addFinalizer(() =>
|
|
274
|
-
down({ volumes: true, removeOrphans: true }).pipe(
|
|
275
|
-
Effect.tap(() => Effect.log(`Docker Compose cleanup completed for project ${projectName}`)),
|
|
276
|
-
Effect.catchAll((error) =>
|
|
277
|
-
Effect.log('Docker Compose cleanup failed for project', projectName, objectToString(error)),
|
|
278
|
-
),
|
|
279
|
-
),
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
return { pull, start, stop, down, logs, projectName }
|
|
283
|
-
}),
|
|
284
|
-
}) {}
|
|
285
|
-
|
|
286
|
-
const performHealthCheck = ({
|
|
287
|
-
url,
|
|
288
|
-
timeout = Duration.minutes(2),
|
|
289
|
-
interval = Duration.seconds(2),
|
|
290
|
-
}: {
|
|
291
|
-
url: string
|
|
292
|
-
timeout?: Duration.Duration
|
|
293
|
-
interval?: Duration.Duration
|
|
294
|
-
}): Effect.Effect<void, DockerComposeError, CommandExecutor.CommandExecutor | Scope.Scope> =>
|
|
295
|
-
Effect.gen(function* () {
|
|
296
|
-
yield* Effect.log(`Performing health check on ${url}`)
|
|
297
|
-
|
|
298
|
-
const checkHealth = Command.make('curl', '-f', '-s', url).pipe(
|
|
299
|
-
Command.exitCode,
|
|
300
|
-
Effect.map((code: number) => code === 0),
|
|
301
|
-
Effect.catchAll(() => Effect.succeed(false)),
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
const healthCheck = checkHealth.pipe(
|
|
305
|
-
Effect.repeat({
|
|
306
|
-
while: (healthy: boolean) => healthy === false,
|
|
307
|
-
schedule: Schedule.fixed(interval),
|
|
308
|
-
}),
|
|
309
|
-
Effect.timeout(timeout),
|
|
310
|
-
Effect.mapError(
|
|
311
|
-
() =>
|
|
312
|
-
new DockerComposeError({
|
|
313
|
-
cause: new Error('Health check timeout'),
|
|
314
|
-
note: `Health check failed for ${url} after ${Duration.toMillis(timeout)}ms`,
|
|
315
|
-
}),
|
|
316
|
-
),
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
yield* healthCheck
|
|
320
|
-
yield* Effect.log(`Health check passed for ${url}`)
|
|
321
|
-
})
|
|
322
|
-
|
|
323
|
-
// Convenience function for scoped Docker Compose operations with automatic cleanup
|
|
324
|
-
export const startDockerComposeServicesScoped = (
|
|
325
|
-
args: DockerComposeArgs & {
|
|
326
|
-
healthCheck?: StartOptions['healthCheck']
|
|
327
|
-
},
|
|
328
|
-
): Effect.Effect<
|
|
329
|
-
void,
|
|
330
|
-
DockerComposeError | PlatformError.PlatformError,
|
|
331
|
-
DockerComposeService | CommandExecutor.CommandExecutor | Scope.Scope
|
|
332
|
-
> =>
|
|
333
|
-
Effect.gen(function* () {
|
|
334
|
-
const dockerCompose = yield* DockerComposeService
|
|
335
|
-
|
|
336
|
-
// Start the services
|
|
337
|
-
yield* dockerCompose.start({
|
|
338
|
-
...omitUndefineds({ healthCheck: args.healthCheck !== undefined ? args.healthCheck : undefined }),
|
|
339
|
-
})
|
|
340
|
-
|
|
341
|
-
// Add cleanup finalizer to the current scope
|
|
342
|
-
yield* Effect.addFinalizer(() => dockerCompose.stop.pipe(Effect.orDie))
|
|
343
|
-
})
|