@livestore/utils-dev 0.4.0-dev.22 → 0.4.0-dev.24
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 -0
- package/dist/node/DockerComposeService/DockerComposeService.d.ts +8 -3
- package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +1 -1
- package/dist/node/DockerComposeService/DockerComposeService.js +47 -42
- package/dist/node/DockerComposeService/DockerComposeService.js.map +1 -1
- package/dist/node/DockerComposeService/DockerComposeService.test.js +2 -2
- package/dist/node/DockerComposeService/DockerComposeService.test.js.map +1 -1
- package/dist/node/FileLogger.d.ts.map +1 -1
- package/dist/node/FileLogger.js +3 -3
- package/dist/node/FileLogger.js.map +1 -1
- package/dist/node/cmd-log.d.ts +2 -2
- package/dist/node/cmd-log.d.ts.map +1 -1
- package/dist/node/cmd-log.js +6 -6
- package/dist/node/cmd-log.js.map +1 -1
- package/dist/node/cmd.d.ts +1 -1
- package/dist/node/cmd.d.ts.map +1 -1
- package/dist/node/cmd.js +25 -27
- package/dist/node/cmd.js.map +1 -1
- package/dist/node/cmd.test.js +2 -1
- package/dist/node/cmd.test.js.map +1 -1
- package/dist/node/mod.d.ts +2 -2
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +17 -16
- package/dist/node/mod.js.map +1 -1
- package/dist/node/workspace.d.ts.map +1 -1
- package/dist/node/workspace.js.map +1 -1
- package/dist/node-vitest/Vitest.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.js +11 -11
- package/dist/node-vitest/Vitest.js.map +1 -1
- package/dist/node-vitest/Vitest.test.d.ts +8 -0
- package/dist/node-vitest/Vitest.test.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.test.js +11 -7
- package/dist/node-vitest/Vitest.test.js.map +1 -1
- package/dist/wrangler/WranglerDevServer.d.ts +2 -2
- package/dist/wrangler/WranglerDevServer.d.ts.map +1 -1
- package/dist/wrangler/WranglerDevServer.js +7 -7
- package/dist/wrangler/WranglerDevServer.js.map +1 -1
- package/dist/wrangler/WranglerDevServer.test.js +2 -2
- package/dist/wrangler/WranglerDevServer.test.js.map +1 -1
- package/package.json +68 -15
- package/src/node/DockerComposeService/DockerComposeService.test.ts +5 -2
- package/src/node/DockerComposeService/DockerComposeService.ts +105 -90
- package/src/node/DockerComposeService/test-fixtures/docker-compose.yml +1 -1
- package/src/node/FileLogger.ts +4 -3
- package/src/node/cmd-log.ts +52 -55
- package/src/node/cmd.test.ts +54 -50
- package/src/node/cmd.ts +54 -57
- package/src/node/mod.ts +20 -18
- package/src/node/workspace.ts +1 -0
- package/src/node-vitest/Vitest.test.ts +12 -7
- package/src/node-vitest/Vitest.ts +28 -24
- package/src/wrangler/WranglerDevServer.test.ts +4 -2
- package/src/wrangler/WranglerDevServer.ts +9 -8
- package/src/wrangler/fixtures/wrangler.toml +1 -1
- package/dist/.tsbuildinfo.json +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as inspector from 'node:inspector'
|
|
2
|
+
|
|
2
3
|
import type * as Vitest from '@effect/vitest'
|
|
4
|
+
|
|
3
5
|
import { IS_CI } from '@livestore/utils'
|
|
4
6
|
import {
|
|
5
7
|
type Cause,
|
|
@@ -14,6 +16,7 @@ import {
|
|
|
14
16
|
type Scope,
|
|
15
17
|
} from '@livestore/utils/effect'
|
|
16
18
|
import { OtelLiveDummy } from '@livestore/utils/node'
|
|
19
|
+
|
|
17
20
|
import { OtelLiveHttp } from '../node/mod.ts'
|
|
18
21
|
|
|
19
22
|
export * from '@effect/vitest'
|
|
@@ -47,7 +50,7 @@ export const withTestCtx =
|
|
|
47
50
|
{
|
|
48
51
|
suffix,
|
|
49
52
|
makeLayer,
|
|
50
|
-
timeout = IS_CI ? 60_000 : 10_000,
|
|
53
|
+
timeout = IS_CI === true ? 60_000 : 10_000,
|
|
51
54
|
forceOtel = false,
|
|
52
55
|
}: {
|
|
53
56
|
suffix?: string
|
|
@@ -67,24 +70,24 @@ export const withTestCtx =
|
|
|
67
70
|
// provided layer from the effect dependencies
|
|
68
71
|
| Exclude<R, ROut | OtelTracer.OtelTracer | Scope.Scope>
|
|
69
72
|
> => {
|
|
70
|
-
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`
|
|
73
|
+
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix !== undefined ? `:${suffix}` : ''}`
|
|
71
74
|
const layer = makeLayer?.(testContext) ?? Layer.empty
|
|
72
75
|
|
|
73
76
|
const otelLayer =
|
|
74
|
-
DEBUGGER_ACTIVE || forceOtel
|
|
77
|
+
DEBUGGER_ACTIVE === true || forceOtel === true
|
|
75
78
|
? OtelLiveHttp({ rootSpanName: spanName, serviceName: 'vitest-runner', skipLogUrl: false })
|
|
76
79
|
: OtelLiveDummy
|
|
77
80
|
|
|
78
81
|
const combinedLayer = layer.pipe(Layer.provideMerge(otelLayer))
|
|
79
82
|
|
|
80
83
|
return self.pipe(
|
|
81
|
-
DEBUGGER_ACTIVE
|
|
84
|
+
DEBUGGER_ACTIVE === true
|
|
82
85
|
? identity
|
|
83
86
|
: Effect.logWarnIfTakesLongerThan({
|
|
84
87
|
duration: Duration.toMillis(timeout) * 0.8,
|
|
85
88
|
label: `${spanName} approaching timeout (timeout: ${Duration.format(timeout)})`,
|
|
86
89
|
}),
|
|
87
|
-
DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout),
|
|
90
|
+
DEBUGGER_ACTIVE === true ? identity : Effect.timeout(timeout),
|
|
88
91
|
Effect.provide(combinedLayer),
|
|
89
92
|
Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
|
|
90
93
|
Effect.annotateLogs({ suffix }),
|
|
@@ -132,7 +135,7 @@ const normalizePropOptions = <Arbs extends Vitest.Vitest.Arbitraries>(
|
|
|
132
135
|
}>
|
|
133
136
|
} => {
|
|
134
137
|
// If it's a number, treat as timeout and add our default fastCheck
|
|
135
|
-
if (
|
|
138
|
+
if (Predicate.isObject(propOptions) === false) {
|
|
136
139
|
return {
|
|
137
140
|
timeout: propOptions,
|
|
138
141
|
fastCheck: { numRuns: 100 },
|
|
@@ -140,7 +143,7 @@ const normalizePropOptions = <Arbs extends Vitest.Vitest.Arbitraries>(
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
// If no fastCheck property, add it with our default numRuns
|
|
143
|
-
if (
|
|
146
|
+
if (propOptions.fastCheck == null) {
|
|
144
147
|
return {
|
|
145
148
|
...propOptions,
|
|
146
149
|
fastCheck: { numRuns: 100 },
|
|
@@ -148,7 +151,7 @@ const normalizePropOptions = <Arbs extends Vitest.Vitest.Arbitraries>(
|
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
// If fastCheck exists but no numRuns, add our default
|
|
151
|
-
if (propOptions.fastCheck &&
|
|
154
|
+
if (propOptions.fastCheck !== undefined && propOptions.fastCheck.numRuns == null) {
|
|
152
155
|
return {
|
|
153
156
|
...propOptions,
|
|
154
157
|
fastCheck: {
|
|
@@ -205,31 +208,32 @@ export const asProp = <Arbs extends Vitest.Vitest.Arbitraries, A, E, R>(
|
|
|
205
208
|
name,
|
|
206
209
|
arbitraries,
|
|
207
210
|
(properties, ctx) => {
|
|
208
|
-
if (ctx.signal.aborted) {
|
|
211
|
+
if (ctx.signal.aborted === true) {
|
|
209
212
|
return ctx.skip('Test aborted')
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
totalExecutions++
|
|
213
216
|
const isInShrinkingPhase = runIndex >= numRuns
|
|
214
217
|
|
|
215
|
-
if (isInShrinkingPhase) {
|
|
218
|
+
if (isInShrinkingPhase === true) {
|
|
216
219
|
shrinkAttempts++
|
|
217
220
|
}
|
|
218
221
|
|
|
219
|
-
const enhancedContext: EnhancedTestContext =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
222
|
+
const enhancedContext: EnhancedTestContext =
|
|
223
|
+
isInShrinkingPhase === true
|
|
224
|
+
? {
|
|
225
|
+
_tag: 'shrinking',
|
|
226
|
+
numRuns,
|
|
227
|
+
runIndex: runIndex++,
|
|
228
|
+
shrinkAttempt: shrinkAttempts,
|
|
229
|
+
totalExecutions,
|
|
230
|
+
}
|
|
231
|
+
: {
|
|
232
|
+
_tag: 'initial',
|
|
233
|
+
numRuns,
|
|
234
|
+
runIndex: runIndex++,
|
|
235
|
+
totalExecutions,
|
|
236
|
+
}
|
|
233
237
|
|
|
234
238
|
return test(properties, ctx, enhancedContext)
|
|
235
239
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { expect } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
1
4
|
import { Effect, FetchHttpClient, Layer } from '@livestore/utils/effect'
|
|
2
5
|
import { getFreePort, PlatformNode } from '@livestore/utils/node'
|
|
3
|
-
|
|
4
|
-
import { expect } from 'vitest'
|
|
6
|
+
|
|
5
7
|
import {
|
|
6
8
|
type StartWranglerDevServerArgs,
|
|
7
9
|
WranglerDevServerError,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as path from 'node:path'
|
|
2
|
+
|
|
2
3
|
import * as Toml from '@iarna/toml'
|
|
3
4
|
import { IS_CI } from '@livestore/utils'
|
|
4
5
|
import { Cause, Duration, Effect, FileSystem, HttpClient, Schedule, Schema } from '@livestore/utils/effect'
|
|
@@ -8,7 +9,7 @@ import * as wrangler from 'wrangler'
|
|
|
8
9
|
/**
|
|
9
10
|
* Error type for WranglerDevServer operations
|
|
10
11
|
*/
|
|
11
|
-
export class WranglerDevServerError extends Schema.TaggedError<WranglerDevServerError>()('WranglerDevServerError', {
|
|
12
|
+
export class WranglerDevServerError extends Schema.TaggedError<WranglerDevServerError>('~@livestore/utils-dev/WranglerDevServerError')('WranglerDevServerError', {
|
|
12
13
|
cause: Schema.Unknown,
|
|
13
14
|
message: Schema.String,
|
|
14
15
|
port: Schema.Number,
|
|
@@ -37,7 +38,7 @@ export interface WranglerReadinessOptions {
|
|
|
37
38
|
/** Max time for the HTTP connectivity check after wrangler reports ready. */
|
|
38
39
|
connectTimeout?: Duration.DurationInput
|
|
39
40
|
/** Retry policy for startup attempts (applies when startupTimeout elapses or wrangler throws). */
|
|
40
|
-
retrySchedule?: Schedule.Schedule<unknown
|
|
41
|
+
retrySchedule?: Schedule.Schedule<unknown>
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export interface StartWranglerDevServerArgs {
|
|
@@ -93,14 +94,14 @@ export class WranglerDevServerService extends Effect.Service<WranglerDevServerSe
|
|
|
93
94
|
const resolvedMainPath = yield* Effect.try(() => path.resolve(args.cwd, parsedConfig.main))
|
|
94
95
|
|
|
95
96
|
const readiness = args.readiness ?? {}
|
|
96
|
-
const startupTimeout = readiness.startupTimeout ?? Duration.seconds(IS_CI ? 30 : 10)
|
|
97
|
+
const startupTimeout = readiness.startupTimeout ?? Duration.seconds(IS_CI === true ? 30 : 10)
|
|
97
98
|
const devServer = yield* Effect.promise(() =>
|
|
98
99
|
wrangler.unstable_dev(resolvedMainPath, {
|
|
99
100
|
config: configPath,
|
|
100
101
|
port: preferredPort,
|
|
101
102
|
inspectorPort: args.inspectorPort ?? 0,
|
|
102
103
|
persistTo: path.join(args.cwd, '.wrangler/state'),
|
|
103
|
-
logLevel: showLogs ? 'debug' : 'none',
|
|
104
|
+
logLevel: showLogs === true ? 'debug' : 'none',
|
|
104
105
|
experimental: {
|
|
105
106
|
disableExperimentalWarning: true,
|
|
106
107
|
},
|
|
@@ -150,12 +151,12 @@ export class WranglerDevServerService extends Effect.Service<WranglerDevServerSe
|
|
|
150
151
|
const url = `http://${actualHost}:${actualPort}`
|
|
151
152
|
|
|
152
153
|
// Use longer timeout in CI environments to account for slower HTTP readiness
|
|
153
|
-
const defaultConnectivityTimeout = Duration.seconds(IS_CI ? 30 : 5)
|
|
154
|
+
const defaultConnectivityTimeout = Duration.seconds(IS_CI === true ? 30 : 5)
|
|
154
155
|
const connectivityTimeout = readiness.connectTimeout ?? defaultConnectivityTimeout
|
|
155
156
|
|
|
156
157
|
yield* verifyHttpConnectivity({ url, showLogs, connectTimeout: connectivityTimeout })
|
|
157
158
|
|
|
158
|
-
if (showLogs) {
|
|
159
|
+
if (showLogs === true) {
|
|
159
160
|
yield* Effect.logDebug(
|
|
160
161
|
`Wrangler dev server ready and accepting connections on port ${actualPort} (preferred: ${preferredPort})`,
|
|
161
162
|
)
|
|
@@ -192,7 +193,7 @@ const verifyHttpConnectivity = ({
|
|
|
192
193
|
Effect.gen(function* () {
|
|
193
194
|
const client = yield* HttpClient.HttpClient
|
|
194
195
|
|
|
195
|
-
if (showLogs) {
|
|
196
|
+
if (showLogs === true) {
|
|
196
197
|
yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}`)
|
|
197
198
|
}
|
|
198
199
|
|
|
@@ -213,7 +214,7 @@ const verifyHttpConnectivity = ({
|
|
|
213
214
|
}),
|
|
214
215
|
),
|
|
215
216
|
),
|
|
216
|
-
Effect.tap(() => (showLogs ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)),
|
|
217
|
+
Effect.tap(() => (showLogs === true ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)),
|
|
217
218
|
Effect.asVoid,
|
|
218
219
|
Effect.withSpan('verifyHttpConnectivity'),
|
|
219
220
|
)
|