@livestore/utils-dev 0.4.0-dev.22 → 0.4.0-dev.23

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 (55) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/node/DockerComposeService/DockerComposeService.d.ts +8 -3
  3. package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +1 -1
  4. package/dist/node/DockerComposeService/DockerComposeService.js +47 -42
  5. package/dist/node/DockerComposeService/DockerComposeService.js.map +1 -1
  6. package/dist/node/DockerComposeService/DockerComposeService.test.js +2 -2
  7. package/dist/node/DockerComposeService/DockerComposeService.test.js.map +1 -1
  8. package/dist/node/FileLogger.d.ts.map +1 -1
  9. package/dist/node/FileLogger.js +3 -3
  10. package/dist/node/FileLogger.js.map +1 -1
  11. package/dist/node/cmd-log.d.ts +2 -2
  12. package/dist/node/cmd-log.d.ts.map +1 -1
  13. package/dist/node/cmd-log.js +6 -6
  14. package/dist/node/cmd-log.js.map +1 -1
  15. package/dist/node/cmd.d.ts +1 -1
  16. package/dist/node/cmd.d.ts.map +1 -1
  17. package/dist/node/cmd.js +25 -27
  18. package/dist/node/cmd.js.map +1 -1
  19. package/dist/node/cmd.test.js +2 -1
  20. package/dist/node/cmd.test.js.map +1 -1
  21. package/dist/node/mod.d.ts +2 -2
  22. package/dist/node/mod.d.ts.map +1 -1
  23. package/dist/node/mod.js +17 -16
  24. package/dist/node/mod.js.map +1 -1
  25. package/dist/node/workspace.d.ts.map +1 -1
  26. package/dist/node/workspace.js.map +1 -1
  27. package/dist/node-vitest/Vitest.d.ts.map +1 -1
  28. package/dist/node-vitest/Vitest.js +11 -11
  29. package/dist/node-vitest/Vitest.js.map +1 -1
  30. package/dist/node-vitest/Vitest.test.d.ts +8 -0
  31. package/dist/node-vitest/Vitest.test.d.ts.map +1 -1
  32. package/dist/node-vitest/Vitest.test.js +11 -7
  33. package/dist/node-vitest/Vitest.test.js.map +1 -1
  34. package/dist/wrangler/WranglerDevServer.d.ts +2 -2
  35. package/dist/wrangler/WranglerDevServer.d.ts.map +1 -1
  36. package/dist/wrangler/WranglerDevServer.js +7 -7
  37. package/dist/wrangler/WranglerDevServer.js.map +1 -1
  38. package/dist/wrangler/WranglerDevServer.test.js +2 -2
  39. package/dist/wrangler/WranglerDevServer.test.js.map +1 -1
  40. package/package.json +68 -15
  41. package/src/node/DockerComposeService/DockerComposeService.test.ts +5 -2
  42. package/src/node/DockerComposeService/DockerComposeService.ts +105 -90
  43. package/src/node/DockerComposeService/test-fixtures/docker-compose.yml +1 -1
  44. package/src/node/FileLogger.ts +4 -3
  45. package/src/node/cmd-log.ts +52 -55
  46. package/src/node/cmd.test.ts +54 -50
  47. package/src/node/cmd.ts +54 -57
  48. package/src/node/mod.ts +20 -18
  49. package/src/node/workspace.ts +1 -0
  50. package/src/node-vitest/Vitest.test.ts +12 -7
  51. package/src/node-vitest/Vitest.ts +28 -24
  52. package/src/wrangler/WranglerDevServer.test.ts +4 -2
  53. package/src/wrangler/WranglerDevServer.ts +9 -8
  54. package/src/wrangler/fixtures/wrangler.toml +1 -1
  55. package/dist/.tsbuildinfo.json +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"WranglerDevServer.test.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAEL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,WAAW,GAAG,MAAM,CAAA;AAE1B,MAAM,qBAAqB,GAAG,CAAC,OAA4C,EAAE,EAAE,EAAE,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A;YAE9C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;YACtC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAA;QACtD,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC,CACjC,CAAA;QAED,MAAM,CAAC,UAAU,CAAC,0CAA0C,EAAE,CAAC,IAAI,EAAE,EAAE,CACrE,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CACnC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,wBAAwB,CAAA;YAE9C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC9B,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAA;QACrD,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CACxD,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,16 @@
1
1
  {
2
2
  "name": "@livestore/utils-dev",
3
- "version": "0.4.0-dev.22",
3
+ "version": "0.4.0-dev.23",
4
+ "license": "Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/livestorejs/livestore.git"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "package.json",
12
+ "src"
13
+ ],
4
14
  "type": "module",
5
15
  "sideEffects": [
6
16
  "./src/node-vitest/global.ts",
@@ -11,10 +21,13 @@
11
21
  "./node-vitest": "./dist/node-vitest/mod.js",
12
22
  "./wrangler": "./dist/wrangler/mod.js"
13
23
  },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
14
27
  "dependencies": {
15
- "@effect/opentelemetry": "0.59.3",
16
- "@effect/vitest": "0.27.0",
17
- "@iarna/toml": "2.2.5",
28
+ "@effect/opentelemetry": "0.63.0",
29
+ "@effect/vitest": "0.29.0",
30
+ "@iarna/toml": "3.0.0",
18
31
  "@opentelemetry/api": "1.9.0",
19
32
  "@opentelemetry/exporter-metrics-otlp-http": "0.208.0",
20
33
  "@opentelemetry/exporter-trace-otlp-http": "0.208.0",
@@ -22,18 +35,58 @@
22
35
  "@opentelemetry/sdk-trace-base": "2.2.0",
23
36
  "@opentelemetry/sdk-trace-node": "2.2.0",
24
37
  "wrangler": "4.42.2",
25
- "@livestore/utils": "0.4.0-dev.22"
38
+ "@livestore/utils": "^0.4.0-dev.23"
26
39
  },
27
- "devDependencies": {},
28
- "files": [
29
- "package.json",
30
- "src",
31
- "dist"
32
- ],
33
- "license": "Apache-2.0",
34
- "peerDependencies": {},
35
- "publishConfig": {
36
- "access": "public"
40
+ "devDependencies": {
41
+ "@effect/ai": "0.35.0",
42
+ "@effect/cli": "0.75.1",
43
+ "@effect/cluster": "0.58.2",
44
+ "@effect/experimental": "0.60.0",
45
+ "@effect/opentelemetry": "0.63.0",
46
+ "@effect/platform": "0.96.1",
47
+ "@effect/platform-browser": "0.76.0",
48
+ "@effect/platform-bun": "0.89.0",
49
+ "@effect/platform-node": "0.106.0",
50
+ "@effect/printer": "0.49.0",
51
+ "@effect/printer-ansi": "0.49.0",
52
+ "@effect/rpc": "0.75.1",
53
+ "@effect/sql": "0.51.1",
54
+ "@effect/typeclass": "0.40.0",
55
+ "@effect/vitest": "0.29.0",
56
+ "@opentelemetry/api": "1.9.0",
57
+ "@opentelemetry/resources": "2.2.0",
58
+ "@standard-schema/spec": "1.1.0",
59
+ "effect": "3.21.2",
60
+ "vitest": "3.2.4"
61
+ },
62
+ "peerDependencies": {
63
+ "@effect/ai": "^0.35.0",
64
+ "@effect/cli": "^0.75.1",
65
+ "@effect/cluster": "^0.58.2",
66
+ "@effect/experimental": "^0.60.0",
67
+ "@effect/opentelemetry": "^0.63.0",
68
+ "@effect/platform": "^0.96.1",
69
+ "@effect/platform-browser": "^0.76.0",
70
+ "@effect/platform-bun": "^0.89.0",
71
+ "@effect/platform-node": "^0.106.0",
72
+ "@effect/printer": "^0.49.0",
73
+ "@effect/printer-ansi": "^0.49.0",
74
+ "@effect/rpc": "^0.75.1",
75
+ "@effect/sql": "^0.51.1",
76
+ "@effect/typeclass": "^0.40.0",
77
+ "@effect/vitest": "^0.29.0",
78
+ "@opentelemetry/api": "^1.9.0",
79
+ "@opentelemetry/resources": "^2.2.0",
80
+ "@standard-schema/spec": "^1.1.0",
81
+ "effect": "^3.21.2"
82
+ },
83
+ "$genie": {
84
+ "source": "package.json.genie.ts",
85
+ "warning": "DO NOT EDIT - changes will be overwritten",
86
+ "workspaceClosureDirs": [
87
+ "packages/@livestore/utils",
88
+ "packages/@livestore/utils-dev"
89
+ ]
37
90
  },
38
91
  "scripts": {
39
92
  "test": "echo 'No tests for utils-dev'"
@@ -1,8 +1,11 @@
1
1
  import path from 'node:path'
2
+
3
+ import { expect } from 'vitest'
4
+
5
+ import { Vitest } from '@livestore/utils-dev/node-vitest'
2
6
  import { Duration, Effect, Layer, Stream } from '@livestore/utils/effect'
3
7
  import { PlatformNode } from '@livestore/utils/node'
4
- import { Vitest } from '@livestore/utils-dev/node-vitest'
5
- import { expect } from 'vitest'
8
+
6
9
  import { type DockerComposeArgs, DockerComposeService } from './DockerComposeService.ts'
7
10
 
8
11
  const testTimeout = 30_000
@@ -1,4 +1,4 @@
1
- import { omitUndefineds } from '@livestore/utils'
1
+ import { objectToString, omitUndefineds } from '@livestore/utils'
2
2
  import {
3
3
  Command,
4
4
  type CommandExecutor,
@@ -12,7 +12,7 @@ import {
12
12
  Stream,
13
13
  } from '@livestore/utils/effect'
14
14
 
15
- export class DockerComposeError extends Schema.TaggedError<DockerComposeError>()('DockerComposeError', {
15
+ export class DockerComposeError extends Schema.TaggedError<DockerComposeError>('~@livestore/utils-dev/DockerComposeError')('DockerComposeError', {
16
16
  cause: Schema.Defect,
17
17
  note: Schema.String,
18
18
  }) {}
@@ -20,6 +20,8 @@ export class DockerComposeError extends Schema.TaggedError<DockerComposeError>()
20
20
  export interface DockerComposeArgs {
21
21
  readonly cwd: string
22
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
23
25
  }
24
26
 
25
27
  export interface StartOptions {
@@ -52,20 +54,27 @@ export interface DockerComposeOperations {
52
54
  readonly logs: (
53
55
  options?: LogsOptions,
54
56
  ) => Stream.Stream<string, DockerComposeError | PlatformError.PlatformError, Scope.Scope>
57
+ /** The unique project name used to isolate this compose instance */
58
+ readonly projectName: string
55
59
  }
56
60
 
61
+ const generateProjectName = (): string => `ls-test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
62
+
57
63
  export class DockerComposeService extends Effect.Service<DockerComposeService>()('DockerComposeService', {
58
64
  scoped: (args: DockerComposeArgs) =>
59
65
  Effect.gen(function* () {
60
66
  const { cwd, serviceName } = args
67
+ const projectName = args.projectName ?? generateProjectName()
61
68
 
62
69
  const commandExecutorContext = yield* Effect.context<CommandExecutor.CommandExecutor>()
63
70
 
71
+ const baseComposeArgs = ['-p', projectName]
72
+
64
73
  const pull = Effect.gen(function* () {
65
74
  yield* Effect.log(`Pulling Docker Compose images in ${cwd}`)
66
75
 
67
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.
68
- const pullCommand = Command.make('docker', 'compose', 'pull').pipe(
77
+ const pullCommand = Command.make('docker', 'compose', ...baseComposeArgs, 'pull').pipe(
69
78
  Command.workingDirectory(cwd),
70
79
  Command.stdout('pipe'),
71
80
  Command.stderr('pipe'),
@@ -118,61 +127,60 @@ export class DockerComposeService extends Effect.Service<DockerComposeService>()
118
127
  Effect.scoped,
119
128
  )
120
129
 
121
- const start = (options: StartOptions = {}) =>
122
- Effect.gen(function* () {
123
- const { detached = true, healthCheck } = options
130
+ const start = Effect.fn('startDockerCompose')(function* (options: StartOptions = {}) {
131
+ const { detached = true, healthCheck } = options
124
132
 
125
- // Build start command
126
- const baseArgs = ['docker', 'compose', 'up']
127
- if (detached) baseArgs.push('-d')
128
- if (serviceName) baseArgs.push(serviceName)
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)
129
137
 
130
- const command = yield* Command.make(baseArgs[0]!, ...baseArgs.slice(1)).pipe(
131
- Command.workingDirectory(cwd),
132
- Command.env(options.env ?? {}),
133
- Command.stderr('inherit'),
134
- Command.stdout('inherit'),
135
- Command.start,
136
- Effect.catchAll((cause) =>
137
- Effect.fail(
138
- new DockerComposeError({
139
- cause,
140
- note: `Failed to start Docker Compose services in ${cwd}`,
141
- }),
142
- ),
143
- ),
144
- Effect.provide(commandExecutorContext),
145
- )
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
+ )
146
153
 
147
- // Wait for command completion
148
- yield* command.exitCode.pipe(
149
- Effect.flatMap((exitCode) =>
150
- exitCode === 0
151
- ? Effect.void
152
- : Effect.fail(
153
- new DockerComposeError({
154
- cause: new Error(`Docker compose exited with code ${exitCode}`),
155
- note: `Docker Compose failed to start with exit code ${exitCode}. Env: ${JSON.stringify(options.env)}`,
156
- }),
157
- ),
158
- ),
159
- Effect.provide(commandExecutorContext),
160
- )
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
+ )
161
168
 
162
- // Perform health check if requested
163
- if (healthCheck) {
164
- yield* performHealthCheck(healthCheck).pipe(Effect.provide(commandExecutorContext))
165
- }
169
+ // Perform health check if requested
170
+ if (healthCheck !== undefined) {
171
+ yield* performHealthCheck(healthCheck).pipe(Effect.provide(commandExecutorContext))
172
+ }
166
173
 
167
- yield* Effect.log(`Docker Compose services started successfully in ${cwd}`)
168
- }).pipe(Effect.withSpan('startDockerCompose'))
174
+ yield* Effect.log(`Docker Compose services started successfully in ${cwd}`)
175
+ })
169
176
 
170
177
  const stop = Effect.gen(function* () {
171
178
  yield* Effect.log(`Stopping Docker Compose services in ${cwd}`)
172
179
 
173
- const stopCommand = serviceName
174
- ? Command.make('docker', 'compose', 'stop', serviceName)
175
- : Command.make('docker', 'compose', 'stop')
180
+ const stopCommand =
181
+ serviceName !== undefined
182
+ ? Command.make('docker', 'compose', ...baseComposeArgs, 'stop', serviceName)
183
+ : Command.make('docker', 'compose', ...baseComposeArgs, 'stop')
176
184
 
177
185
  yield* stopCommand.pipe(
178
186
  Command.workingDirectory(cwd),
@@ -197,22 +205,21 @@ export class DockerComposeService extends Effect.Service<DockerComposeService>()
197
205
  Effect.gen(function* () {
198
206
  const { follow = false, tail, since } = options
199
207
 
200
- const baseArgs = ['docker', 'compose', 'logs']
201
- if (follow) baseArgs.push('-f')
202
- if (tail) baseArgs.push('--tail', tail.toString())
203
- if (since) baseArgs.push('--since', since)
204
- if (serviceName) baseArgs.push(serviceName)
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)
205
213
 
206
- const command = yield* Command.make(baseArgs[0]!, ...baseArgs.slice(1)).pipe(
214
+ const command = yield* Command.make(logsArgs[0]!, ...logsArgs.slice(1)).pipe(
207
215
  Command.workingDirectory(cwd),
208
216
  Command.start,
209
- Effect.catchAll((cause) =>
210
- Effect.fail(
217
+ Effect.mapError(
218
+ (cause) =>
211
219
  new DockerComposeError({
212
220
  cause,
213
221
  note: `Failed to read Docker Compose logs in ${cwd}`,
214
222
  }),
215
- ),
216
223
  ),
217
224
  Effect.provide(commandExecutorContext),
218
225
  )
@@ -230,40 +237,49 @@ export class DockerComposeService extends Effect.Service<DockerComposeService>()
230
237
  )
231
238
  }).pipe(Stream.unwrapScoped)
232
239
 
233
- const down = (options?: {
240
+ const down = Effect.fn('downDockerCompose')(function* (options?: {
234
241
  readonly env?: Record<string, string>
235
242
  readonly volumes?: boolean
236
243
  readonly removeOrphans?: boolean
237
- }) =>
238
- Effect.gen(function* () {
239
- yield* Effect.log(`Tearing down Docker Compose services in ${cwd}`)
244
+ }) {
245
+ yield* Effect.log(`Tearing down Docker Compose services in ${cwd}`)
240
246
 
241
- const baseArgs = ['docker', 'compose', 'down']
242
- if (options?.volumes) baseArgs.push('-v')
243
- if (options?.removeOrphans) baseArgs.push('--remove-orphans')
244
- if (serviceName) baseArgs.push(serviceName)
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)
245
251
 
246
- yield* Command.make(baseArgs[0]!, ...baseArgs.slice(1)).pipe(
247
- Command.workingDirectory(cwd),
248
- Command.env(options?.env ?? {}),
249
- Command.exitCode,
250
- Effect.flatMap((exitCode: number) =>
251
- exitCode === 0
252
- ? Effect.void
253
- : Effect.fail(
254
- new DockerComposeError({
255
- cause: new Error(`Docker compose down exited with code ${exitCode}`),
256
- note: `Failed to tear down Docker Compose services`,
257
- }),
258
- ),
259
- ),
260
- Effect.provide(commandExecutorContext),
261
- )
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
+ })
262
271
 
263
- yield* Effect.log(`Docker Compose services torn down successfully`)
264
- }).pipe(Effect.withSpan('downDockerCompose'))
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
+ )
265
281
 
266
- return { pull, start, stop, down, logs }
282
+ return { pull, start, stop, down, logs, projectName }
267
283
  }),
268
284
  }) {}
269
285
 
@@ -287,17 +303,16 @@ const performHealthCheck = ({
287
303
 
288
304
  const healthCheck = checkHealth.pipe(
289
305
  Effect.repeat({
290
- while: (healthy: boolean) => !healthy,
306
+ while: (healthy: boolean) => healthy === false,
291
307
  schedule: Schedule.fixed(interval),
292
308
  }),
293
309
  Effect.timeout(timeout),
294
- Effect.catchAll(() =>
295
- Effect.fail(
310
+ Effect.mapError(
311
+ () =>
296
312
  new DockerComposeError({
297
313
  cause: new Error('Health check timeout'),
298
314
  note: `Health check failed for ${url} after ${Duration.toMillis(timeout)}ms`,
299
315
  }),
300
- ),
301
316
  ),
302
317
  )
303
318
 
@@ -320,7 +335,7 @@ export const startDockerComposeServicesScoped = (
320
335
 
321
336
  // Start the services
322
337
  yield* dockerCompose.start({
323
- ...omitUndefineds({ healthCheck: args.healthCheck ? args.healthCheck : undefined }),
338
+ ...omitUndefineds({ healthCheck: args.healthCheck !== undefined ? args.healthCheck : undefined }),
324
339
  })
325
340
 
326
341
  // Add cleanup finalizer to the current scope
@@ -1,4 +1,4 @@
1
1
  services:
2
2
  hello-world:
3
3
  image: hello-world
4
- profiles: [manual] # Don't auto-start this service
4
+ profiles: [manual] # Don't auto-start this service
@@ -1,6 +1,7 @@
1
1
  import * as fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
  import util from 'node:util'
4
+
4
5
  import {
5
6
  Cause,
6
7
  Effect,
@@ -120,7 +121,7 @@ export const prettyLoggerTty = (options: {
120
121
  readonly formatDate: (date: Date) => string
121
122
  readonly onLog?: (str: string) => void
122
123
  }) => {
123
- const color = options.colors ? withColor : withColorNoop
124
+ const color = options.colors === true ? withColor : withColorNoop
124
125
  return Logger.make<unknown, string>(({ annotations, cause, date, fiberId, logLevel, message: message_, spans }) => {
125
126
  let str = ''
126
127
 
@@ -141,7 +142,7 @@ export const prettyLoggerTty = (options: {
141
142
  ` ${color(logLevel.label, ...logLevelColors[logLevel._tag])}` +
142
143
  ` (${FiberId.threadName(fiberId)})`
143
144
 
144
- if (List.isCons(spans)) {
145
+ if (List.isCons(spans) === true) {
145
146
  const now = date.getTime()
146
147
  const render = LogSpan.render(now)
147
148
  for (const span of spans) {
@@ -162,7 +163,7 @@ export const prettyLoggerTty = (options: {
162
163
  log(firstLine)
163
164
  // if (!processIsBun) console.group()
164
165
 
165
- if (!Cause.isEmpty(cause)) {
166
+ if (Cause.isEmpty(cause) === false) {
166
167
  logIndented(Cause.pretty(cause, { renderErrorCause: true }))
167
168
  }
168
169
 
@@ -14,55 +14,52 @@ export type TCmdLoggingOptions = {
14
14
  * Prepares logging directories, archives previous canonical log and prunes archives.
15
15
  * Returns the canonical current log path if logging is enabled, otherwise undefined.
16
16
  */
17
- export const prepareCmdLogging: (options: TCmdLoggingOptions) => Effect.Effect<string | undefined, never, never> =
18
- Effect.fn('cmd.logging.prepare')(function* ({
19
- logDir,
20
- logFileName = 'dev.log',
21
- logRetention = 50,
22
- }: TCmdLoggingOptions) {
23
- if (!logDir || logDir === '') return undefined as string | undefined
17
+ export const prepareCmdLogging: (options: TCmdLoggingOptions) => Effect.Effect<string | undefined> = Effect.fn(
18
+ 'cmd.logging.prepare',
19
+ )(function* ({ logDir, logFileName = 'dev.log', logRetention = 50 }: TCmdLoggingOptions) {
20
+ if (logDir == null || logDir === '') return undefined as string | undefined
24
21
 
25
- const logsDir = logDir
26
- const archiveDir = path.join(logsDir, 'archive')
27
- const currentLogPath = path.join(logsDir, logFileName)
22
+ const logsDir = logDir
23
+ const archiveDir = path.join(logsDir, 'archive')
24
+ const currentLogPath = path.join(logsDir, logFileName)
28
25
 
29
- // Ensure directories exist
30
- yield* Effect.sync(() => fs.mkdirSync(archiveDir, { recursive: true }))
26
+ // Ensure directories exist
27
+ yield* Effect.sync(() => fs.mkdirSync(archiveDir, { recursive: true }))
31
28
 
32
- // Archive previous log if present
33
- if (fs.existsSync(currentLogPath)) {
34
- const safeIso = new Date().toISOString().replaceAll(':', '-')
35
- const archivedBase = `${path.parse(logFileName).name}-${safeIso}.log`
36
- const archivedLog = path.join(archiveDir, archivedBase)
37
- yield* Effect.try(() => fs.renameSync(currentLogPath, archivedLog)).pipe(
38
- Effect.catchAll(() =>
39
- Effect.try(() => {
40
- fs.copyFileSync(currentLogPath, archivedLog)
41
- fs.truncateSync(currentLogPath, 0)
42
- }),
43
- ),
44
- Effect.ignore,
45
- )
29
+ // Archive previous log if present
30
+ if (fs.existsSync(currentLogPath) === true) {
31
+ const safeIso = new Date().toISOString().replaceAll(':', '-')
32
+ const archivedBase = `${path.parse(logFileName).name}-${safeIso}.log`
33
+ const archivedLog = path.join(archiveDir, archivedBase)
34
+ yield* Effect.try(() => fs.renameSync(currentLogPath, archivedLog)).pipe(
35
+ Effect.catchAll(() =>
36
+ Effect.try(() => {
37
+ fs.copyFileSync(currentLogPath, archivedLog)
38
+ fs.truncateSync(currentLogPath, 0)
39
+ }),
40
+ ),
41
+ Effect.ignore,
42
+ )
46
43
 
47
- // Prune archives to retain only the newest N
48
- yield* Effect.try(() => fs.readdirSync(archiveDir)).pipe(
49
- Effect.map((names) => names.filter((n) => n.endsWith('.log'))),
50
- Effect.map((names) =>
51
- names
52
- .map((name) => ({ name, mtimeMs: fs.statSync(path.join(archiveDir, name)).mtimeMs }))
53
- .sort((a, b) => b.mtimeMs - a.mtimeMs),
54
- ),
55
- Effect.flatMap((entries) =>
56
- Effect.forEach(entries.slice(logRetention), (e) =>
57
- Effect.try(() => fs.unlinkSync(path.join(archiveDir, e.name))).pipe(Effect.ignore),
58
- ),
44
+ // Prune archives to retain only the newest N
45
+ yield* Effect.try(() => fs.readdirSync(archiveDir)).pipe(
46
+ Effect.map((names) => names.filter((n) => n.endsWith('.log'))),
47
+ Effect.map((names) =>
48
+ names
49
+ .map((name) => ({ name, mtimeMs: fs.statSync(path.join(archiveDir, name)).mtimeMs }))
50
+ .sort((a, b) => b.mtimeMs - a.mtimeMs),
51
+ ),
52
+ Effect.flatMap((entries) =>
53
+ Effect.forEach(entries.slice(logRetention), (e) =>
54
+ Effect.try(() => fs.unlinkSync(path.join(archiveDir, e.name))).pipe(Effect.ignore),
59
55
  ),
60
- Effect.ignore,
61
- )
62
- }
56
+ ),
57
+ Effect.ignore,
58
+ )
59
+ }
63
60
 
64
- return currentLogPath
65
- })
61
+ return currentLogPath
62
+ })
66
63
 
67
64
  /**
68
65
  * Given a command input, applies logging by piping output through `tee` to the
@@ -71,17 +68,17 @@ export const prepareCmdLogging: (options: TCmdLoggingOptions) => Effect.Effect<s
71
68
  export const applyLoggingToCommand: (
72
69
  commandInput: string | (string | undefined)[],
73
70
  options: TCmdLoggingOptions,
74
- ) => Effect.Effect<{ input: string | string[]; subshell: boolean; logPath?: string }, never, never> = Effect.fn(
75
- 'cmd.logging.apply',
76
- )(function* (commandInput, options) {
77
- const asArray = Array.isArray(commandInput)
78
- const parts = asArray ? (commandInput as (string | undefined)[]).filter(isNotUndefined) : undefined
71
+ ) => Effect.Effect<{ input: string | string[]; subshell: boolean; logPath?: string }> = Effect.fn('cmd.logging.apply')(
72
+ function* (commandInput, options) {
73
+ const asArray = Array.isArray(commandInput)
74
+ const parts = asArray === true ? commandInput.filter(isNotUndefined) : undefined
79
75
 
80
- const logPath = yield* prepareCmdLogging(options)
76
+ const logPath = yield* prepareCmdLogging(options)
81
77
 
82
- return {
83
- input: asArray ? ((parts as string[]) ?? []) : (commandInput as string),
84
- subshell: false,
85
- ...(logPath ? { logPath } : {}),
86
- }
87
- })
78
+ return {
79
+ input: asArray === true ? ((parts as string[]) ?? []) : commandInput,
80
+ subshell: false,
81
+ ...(logPath !== undefined ? { logPath } : {}),
82
+ }
83
+ },
84
+ )