@livestore/utils-dev 0.4.0-dev.1 → 0.4.0-dev.10

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 (68) hide show
  1. package/dist/.tsbuildinfo.json +1 -1
  2. package/dist/node/DockerComposeService/DockerComposeService.d.ts +58 -0
  3. package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +1 -0
  4. package/dist/node/DockerComposeService/DockerComposeService.js +144 -0
  5. package/dist/node/DockerComposeService/DockerComposeService.js.map +1 -0
  6. package/dist/node/DockerComposeService/DockerComposeService.test.d.ts +2 -0
  7. package/dist/node/DockerComposeService/DockerComposeService.test.d.ts.map +1 -0
  8. package/dist/node/DockerComposeService/DockerComposeService.test.js +64 -0
  9. package/dist/node/DockerComposeService/DockerComposeService.test.js.map +1 -0
  10. package/dist/node/cmd-log.d.ts +21 -0
  11. package/dist/node/cmd-log.d.ts.map +1 -0
  12. package/dist/node/cmd-log.js +50 -0
  13. package/dist/node/cmd-log.js.map +1 -0
  14. package/dist/node/cmd.d.ts +36 -0
  15. package/dist/node/cmd.d.ts.map +1 -0
  16. package/dist/node/cmd.js +234 -0
  17. package/dist/node/cmd.js.map +1 -0
  18. package/dist/node/cmd.test.d.ts +2 -0
  19. package/dist/node/cmd.test.d.ts.map +1 -0
  20. package/dist/node/cmd.test.js +101 -0
  21. package/dist/node/cmd.test.js.map +1 -0
  22. package/dist/node/mod.d.ts +4 -26
  23. package/dist/node/mod.d.ts.map +1 -1
  24. package/dist/node/mod.js +51 -59
  25. package/dist/node/mod.js.map +1 -1
  26. package/dist/node-vitest/Vitest.d.ts +41 -7
  27. package/dist/node-vitest/Vitest.d.ts.map +1 -1
  28. package/dist/node-vitest/Vitest.js +82 -5
  29. package/dist/node-vitest/Vitest.js.map +1 -1
  30. package/dist/node-vitest/Vitest.test.d.ts +2 -0
  31. package/dist/node-vitest/Vitest.test.d.ts.map +1 -0
  32. package/dist/node-vitest/Vitest.test.js +70 -0
  33. package/dist/node-vitest/Vitest.test.js.map +1 -0
  34. package/dist/wrangler/WranglerDevServer.d.ts +52 -0
  35. package/dist/wrangler/WranglerDevServer.d.ts.map +1 -0
  36. package/dist/wrangler/WranglerDevServer.js +90 -0
  37. package/dist/wrangler/WranglerDevServer.js.map +1 -0
  38. package/dist/wrangler/WranglerDevServer.test.d.ts +2 -0
  39. package/dist/wrangler/WranglerDevServer.test.d.ts.map +1 -0
  40. package/dist/wrangler/WranglerDevServer.test.js +77 -0
  41. package/dist/wrangler/WranglerDevServer.test.js.map +1 -0
  42. package/dist/wrangler/fixtures/cf-worker.d.ts +8 -0
  43. package/dist/wrangler/fixtures/cf-worker.d.ts.map +1 -0
  44. package/dist/wrangler/fixtures/cf-worker.js +11 -0
  45. package/dist/wrangler/fixtures/cf-worker.js.map +1 -0
  46. package/dist/wrangler/mod.d.ts +2 -0
  47. package/dist/wrangler/mod.d.ts.map +1 -0
  48. package/dist/wrangler/mod.js +2 -0
  49. package/dist/wrangler/mod.js.map +1 -0
  50. package/package.json +11 -10
  51. package/src/node/DockerComposeService/DockerComposeService.test.ts +91 -0
  52. package/src/node/DockerComposeService/DockerComposeService.ts +328 -0
  53. package/src/node/DockerComposeService/test-fixtures/docker-compose.yml +4 -0
  54. package/src/node/cmd-log.ts +92 -0
  55. package/src/node/cmd.test.ts +129 -0
  56. package/src/node/cmd.ts +419 -0
  57. package/src/node/mod.ts +62 -116
  58. package/src/node-vitest/Vitest.test.ts +112 -0
  59. package/src/node-vitest/Vitest.ts +193 -17
  60. package/src/wrangler/WranglerDevServer.test.ts +133 -0
  61. package/src/wrangler/WranglerDevServer.ts +180 -0
  62. package/src/wrangler/fixtures/cf-worker.ts +11 -0
  63. package/src/wrangler/fixtures/wrangler.toml +11 -0
  64. package/src/wrangler/mod.ts +6 -0
  65. package/dist/node-vitest/polyfill.d.ts +0 -2
  66. package/dist/node-vitest/polyfill.d.ts.map +0 -1
  67. package/dist/node-vitest/polyfill.js +0 -3
  68. package/dist/node-vitest/polyfill.js.map +0 -1
@@ -1,18 +1,52 @@
1
1
  import type * as Vitest from '@effect/vitest';
2
- import { type Cause, Duration, Effect, Layer, type OtelTracer, type Scope } from '@livestore/utils/effect';
2
+ import { type Cause, Duration, Effect, type FastCheck as FC, Layer, type OtelTracer, type Schema, type Scope } from '@livestore/utils/effect';
3
3
  export * from '@effect/vitest';
4
4
  export declare const DEBUGGER_ACTIVE: boolean;
5
- export declare const makeWithTestCtx: <R1 = never, E1 = never>(ctxParams: WithTestCtxParams<R1, E1>) => (testContext: Vitest.TestContext) => <A, E>(self: Effect.Effect<A, E, OtelTracer.OtelTracer | Scope.Scope | R1>) => Effect.Effect<A, Cause.TimeoutException | E1 | E, Scope.Scope>;
6
- export type WithTestCtxParams<R1 = never, E1 = never> = {
5
+ export declare const makeWithTestCtx: <ROut = never, E1 = never, RIn = never>(ctxParams: WithTestCtxParams<ROut, E1, RIn>) => (testContext: Vitest.TestContext) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E1 | Cause.TimeoutException, Exclude<RIn, OtelTracer.OtelTracer | Scope.Scope> | Exclude<R, ROut | OtelTracer.OtelTracer | Scope.Scope>>;
6
+ export type WithTestCtxParams<ROut, E1, RIn> = {
7
7
  suffix?: string;
8
- makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>;
8
+ makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn | Scope.Scope>;
9
9
  timeout?: Duration.DurationInput;
10
10
  forceOtel?: boolean;
11
11
  };
12
- export declare const withTestCtx: <R1 = never, E1 = never>(testContext: Vitest.TestContext, { suffix, makeLayer, timeout, forceOtel, }?: {
12
+ export declare const withTestCtx: <ROut = never, E1 = never, RIn = never>(testContext: Vitest.TestContext, { suffix, makeLayer, timeout, forceOtel, }?: {
13
13
  suffix?: string;
14
- makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>;
14
+ makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn>;
15
15
  timeout?: Duration.DurationInput;
16
16
  forceOtel?: boolean;
17
- }) => <A, E>(self: Effect.Effect<A, E, Scope.Scope | OtelTracer.OtelTracer | R1>) => Effect.Effect<A, E | Cause.TimeoutException | E1, Scope.Scope>;
17
+ }) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E1 | Cause.TimeoutException, Exclude<RIn, OtelTracer.OtelTracer | Scope.Scope> | Exclude<R, ROut | OtelTracer.OtelTracer | Scope.Scope>>;
18
+ /**
19
+ * Shared properties for all enhanced test context phases
20
+ */
21
+ export interface EnhancedTestContextBase {
22
+ numRuns: number;
23
+ /** 0-based index */
24
+ runIndex: number;
25
+ /** Total number of executions including initial runs and shrinking attempts */
26
+ totalExecutions: number;
27
+ }
28
+ /**
29
+ * Enhanced context for property-based tests that includes shrinking phase information
30
+ */
31
+ export type EnhancedTestContext = (EnhancedTestContextBase & {
32
+ _tag: 'initial';
33
+ }) | (EnhancedTestContextBase & {
34
+ _tag: 'shrinking';
35
+ /** Number of shrinking attempts */
36
+ shrinkAttempt: number;
37
+ });
38
+ /**
39
+ * Equivalent to Vitest.prop but provides enhanced context including shrinking progress visibility
40
+ *
41
+ * This function enhances the standard property-based testing by providing clear information about
42
+ * whether FastCheck is in the initial testing phase or the shrinking phase, solving the confusion
43
+ * where tests show "Run 26/6" when FastCheck's shrinking algorithm is active.
44
+ *
45
+ * TODO: allow for upper timelimit instead of / additional to `numRuns`
46
+ *
47
+ * TODO: Upstream to Effect
48
+ */
49
+ export declare const asProp: <Arbs extends Vitest.Vitest.Arbitraries, A, E, R>(api: Vitest.Vitest.Tester<R>, name: string, arbitraries: Arbs, test: Vitest.Vitest.TestFunction<A, E, R, [{ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>; }, Vitest.TestContext, EnhancedTestContext]>, propOptions: number | (Vitest.TestOptions & {
50
+ fastCheck?: FC.Parameters<{ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>; }>;
51
+ })) => void;
18
52
  //# sourceMappingURL=Vitest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Vitest.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAY,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAIpH,cAAc,gBAAgB,CAAA;AAE9B,eAAO,MAAM,eAAe,SAAwE,CAAA;AAEpG,eAAO,MAAM,eAAe,GACzB,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,WAAW,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,MAC5D,aAAa,MAAM,CAAC,WAAW,MAyB/B,CAAC,EAAE,CAAC,wIAxBgC,CAAA;AAEvC,MAAM,MAAM,iBAAiB,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,IAAI;IACtD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACjF,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;IAChC,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,WAAW,GACrB,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,EACrB,aAAa,MAAM,CAAC,WAAW,EAC/B,6CAKG;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAA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SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAC3F,CAAC,CAAA;CACH,CAAC,SA0CP,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import * as inspector from 'node:inspector';
2
2
  import { IS_CI } from '@livestore/utils';
3
- import { Duration, Effect, identity, Layer } from '@livestore/utils/effect';
3
+ import { Duration, Effect, identity, Layer, Predicate, } from '@livestore/utils/effect';
4
4
  import { OtelLiveDummy } from '@livestore/utils/node';
5
5
  import { OtelLiveHttp } from "../node/mod.js";
6
6
  export * from '@effect/vitest';
@@ -8,14 +8,91 @@ export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.
8
8
  export const makeWithTestCtx = (ctxParams) => (testContext) => withTestCtx(testContext, ctxParams);
9
9
  export const withTestCtx = (testContext, { suffix, makeLayer, timeout = IS_CI ? 60_000 : 10_000, forceOtel = false, } = {}) => (self) => {
10
10
  const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`;
11
- const layer = makeLayer?.(testContext);
12
- const otelLayer = DEBUGGER_ACTIVE || forceOtel ? OtelLiveHttp({ serviceName: 'vitest-runner', skipLogUrl: false }) : OtelLiveDummy;
11
+ const layer = makeLayer?.(testContext) ?? Layer.empty;
12
+ const otelLayer = DEBUGGER_ACTIVE || forceOtel
13
+ ? OtelLiveHttp({ rootSpanName: spanName, serviceName: 'vitest-runner', skipLogUrl: false })
14
+ : OtelLiveDummy;
15
+ const combinedLayer = layer.pipe(Layer.provideMerge(otelLayer));
13
16
  return self.pipe(DEBUGGER_ACTIVE
14
17
  ? identity
15
18
  : Effect.logWarnIfTakesLongerThan({
16
19
  duration: Duration.toMillis(timeout) * 0.8,
17
20
  label: `${spanName} approaching timeout (timeout: ${Duration.format(timeout)})`,
18
- }), DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout), Effect.provide(otelLayer), Effect.provide(layer ?? Layer.empty), Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
19
- Effect.withSpan(spanName), Effect.annotateLogs({ suffix }));
21
+ }), DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout), Effect.provide(combinedLayer), Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
22
+ Effect.annotateLogs({ suffix }));
23
+ };
24
+ /**
25
+ * Normalizes propOptions to ensure @effect/vitest receives correct fastCheck structure
26
+ */
27
+ const normalizePropOptions = (propOptions) => {
28
+ // If it's a number, treat as timeout and add our default fastCheck
29
+ if (!Predicate.isObject(propOptions)) {
30
+ return {
31
+ timeout: propOptions,
32
+ fastCheck: { numRuns: 100 },
33
+ };
34
+ }
35
+ // If no fastCheck property, add it with our default numRuns
36
+ if (!propOptions.fastCheck) {
37
+ return {
38
+ ...propOptions,
39
+ fastCheck: { numRuns: 100 },
40
+ };
41
+ }
42
+ // If fastCheck exists but no numRuns, add our default
43
+ if (propOptions.fastCheck && !propOptions.fastCheck.numRuns) {
44
+ return {
45
+ ...propOptions,
46
+ fastCheck: {
47
+ ...propOptions.fastCheck,
48
+ numRuns: 100,
49
+ },
50
+ };
51
+ }
52
+ // If everything is properly structured, pass through
53
+ return propOptions;
54
+ };
55
+ /**
56
+ * Equivalent to Vitest.prop but provides enhanced context including shrinking progress visibility
57
+ *
58
+ * This function enhances the standard property-based testing by providing clear information about
59
+ * whether FastCheck is in the initial testing phase or the shrinking phase, solving the confusion
60
+ * where tests show "Run 26/6" when FastCheck's shrinking algorithm is active.
61
+ *
62
+ * TODO: allow for upper timelimit instead of / additional to `numRuns`
63
+ *
64
+ * TODO: Upstream to Effect
65
+ */
66
+ export const asProp = (api, name, arbitraries, test, propOptions) => {
67
+ const normalizedPropOptions = normalizePropOptions(propOptions);
68
+ const numRuns = normalizedPropOptions.fastCheck?.numRuns ?? 100;
69
+ let runIndex = 0;
70
+ let shrinkAttempts = 0;
71
+ let totalExecutions = 0;
72
+ return api.prop(name, arbitraries, (properties, ctx) => {
73
+ if (ctx.signal.aborted) {
74
+ return ctx.skip('Test aborted');
75
+ }
76
+ totalExecutions++;
77
+ const isInShrinkingPhase = runIndex >= numRuns;
78
+ if (isInShrinkingPhase) {
79
+ shrinkAttempts++;
80
+ }
81
+ const enhancedContext = isInShrinkingPhase
82
+ ? {
83
+ _tag: 'shrinking',
84
+ numRuns,
85
+ runIndex: runIndex++,
86
+ shrinkAttempt: shrinkAttempts,
87
+ totalExecutions,
88
+ }
89
+ : {
90
+ _tag: 'initial',
91
+ numRuns,
92
+ runIndex: runIndex++,
93
+ totalExecutions,
94
+ };
95
+ return test(properties, ctx, enhancedContext);
96
+ }, normalizedPropOptions);
20
97
  };
21
98
  //# sourceMappingURL=Vitest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Vitest.js","sourceRoot":"","sources":["../../src/node-vitest/Vitest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAc,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAA+B,MAAM,yBAAyB,CAAA;AACpH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,cAAc,gBAAgB,CAAA;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,SAAS,CAAC,GAAG,EAAE,KAAK,SAAS,CAAC,CAAA;AAEpG,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAyB,SAAoC,EAAE,EAAE,CACjE,CAAC,WAA+B,EAAE,EAAE,CAClC,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;AASvC,MAAM,CAAC,MAAM,WAAW,GACtB,CACE,WAA+B,EAC/B,EACE,MAAM,EACN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AO,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,eAAe,CAAC,CAAA;IAC/C,CAAC,EACD,qBAAqB,CACtB,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Vitest.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Vitest.test.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ import { Effect, FastCheck } from '@livestore/utils/effect';
2
+ import * as Vitest from "./Vitest.js";
3
+ // Demonstrate enhanced asProp functionality with clear shrinking progress
4
+ // This showcases the fix for the "Run 26/6" bug and accurate shrinking detection
5
+ Vitest.describe('Vitest.asProp', () => {
6
+ const IntArbitrary = FastCheck.integer({ min: 1, max: 100 });
7
+ // Always-passing test - should only show initial phase
8
+ Vitest.asProp(Vitest.scopedLive, 'always-pass test (shows only initial runs)', [IntArbitrary], (properties, _ctx, enhanced) => Effect.gen(function* () {
9
+ const [value] = properties;
10
+ if (value === undefined) {
11
+ return yield* Effect.fail(new Error('Value is undefined'));
12
+ }
13
+ console.log(`✅ ALWAYS-PASS [${enhanced._tag.toUpperCase()}]: ` +
14
+ (enhanced._tag === 'initial'
15
+ ? `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}`
16
+ : `Shrink #${enhanced.shrinkAttempt} (finding minimal counterexample)`) +
17
+ `, value=${value}, total=${enhanced.totalExecutions}`);
18
+ // This test always passes, so no shrinking will occur
19
+ return;
20
+ }), { fastCheck: { numRuns: 4 } });
21
+ // Failing test - should show initial + shrinking phases
22
+ let alreadyFailed = false;
23
+ Vitest.asProp(Vitest.scopedLive, 'failing test (shows initial runs + shrinking)', [IntArbitrary], (properties, ctx, enhanced) => Effect.gen(function* () {
24
+ const [value] = properties;
25
+ if (value === undefined) {
26
+ return yield* Effect.fail(new Error('Value is undefined'));
27
+ }
28
+ const displayInfo = enhanced._tag === 'initial'
29
+ ? `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}`
30
+ : `Shrink #${enhanced.shrinkAttempt} (finding minimal counterexample)`;
31
+ const status = value > 80 ? '💥' : '✅';
32
+ console.log(`${status} FAILING-TEST [${enhanced._tag.toUpperCase()}]: ${displayInfo}, value=${value}, total=${enhanced.totalExecutions}`);
33
+ // Fail when value is greater than 80 to trigger shrinking
34
+ if (value > 80) {
35
+ alreadyFailed = true;
36
+ return yield* Effect.fail(new Error(`Value ${value} is too large (> 80)`));
37
+ }
38
+ if (alreadyFailed && enhanced._tag === 'shrinking') {
39
+ ctx.skip("For the sake of this test, we don't want to fail but want to skip");
40
+ return;
41
+ }
42
+ return;
43
+ }), { fastCheck: { numRuns: 3 } });
44
+ // Test with endOnFailure: true - should not show shrinking
45
+ Vitest.asProp(Vitest.scopedLive, 'failing test with endOnFailure (no shrinking)', [IntArbitrary], (properties, _ctx, enhanced) => Effect.gen(function* () {
46
+ const [value] = properties;
47
+ if (value === undefined) {
48
+ return yield* Effect.fail(new Error('Value is undefined'));
49
+ }
50
+ console.log(`🚫 END-ON-FAILURE [${enhanced._tag.toUpperCase()}]: ` +
51
+ `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}, value=${value}, total=${enhanced.totalExecutions}`);
52
+ // This will fail but shrinking is disabled
53
+ if (value > 50) {
54
+ yield* Effect.fail(new Error(`Value ${value} is too large (> 50) - but no shrinking!`));
55
+ }
56
+ return;
57
+ }), {
58
+ fastCheck: {
59
+ numRuns: 5,
60
+ endOnFailure: true,
61
+ // Provide explicit samples so the second run crosses >50. Randomly drawing five
62
+ // integers has ~3% chance to stay ≤ 50, which would break the `fails: true`
63
+ // expectation even though shrinking remains disabled. The examples keep the
64
+ // demo readable while leaving the remaining runs to FastCheck.
65
+ examples: [[5], [66]],
66
+ },
67
+ fails: true,
68
+ });
69
+ });
70
+ //# sourceMappingURL=Vitest.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Vitest.test.js","sourceRoot":"","sources":["../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declare const WranglerDevServerError_base: Schema.TaggedErrorClass<WranglerDevServerError, "WranglerDevServerError", {
3
+ readonly _tag: Schema.tag<"WranglerDevServerError">;
4
+ } & {
5
+ cause: typeof Schema.Unknown;
6
+ message: typeof Schema.String;
7
+ port: typeof Schema.Number;
8
+ }>;
9
+ /**
10
+ * Error type for WranglerDevServer operations
11
+ */
12
+ export declare class WranglerDevServerError extends WranglerDevServerError_base {
13
+ }
14
+ /**
15
+ * WranglerDevServer instance interface
16
+ */
17
+ export interface WranglerDevServer {
18
+ readonly port: number;
19
+ readonly url: string;
20
+ }
21
+ /**
22
+ * Configuration for starting WranglerDevServer
23
+ */
24
+ export interface StartWranglerDevServerArgs {
25
+ wranglerConfigPath?: string;
26
+ cwd: string;
27
+ /** The port to try first. The dev server may bind a different port if unavailable. */
28
+ preferredPort?: number;
29
+ /** @default false */
30
+ showLogs?: boolean;
31
+ inspectorPort?: number;
32
+ connectTimeout?: Duration.DurationInput;
33
+ }
34
+ declare const WranglerDevServerService_base: Effect.Service.Class<WranglerDevServerService, "WranglerDevServerService", {
35
+ readonly scoped: (args: StartWranglerDevServerArgs) => Effect.Effect<{
36
+ port: number;
37
+ url: string;
38
+ }, WranglerDevServerError, import("effect/Scope").Scope | HttpClient.HttpClient | FileSystem.FileSystem>;
39
+ }>;
40
+ /**
41
+ * WranglerDevServer as an Effect.Service.
42
+ *
43
+ * This service provides the WranglerDevServer properties and can be accessed
44
+ * directly to get port and url.
45
+ *
46
+ * TODO: Allow for config to be passed in via code instead of `wrangler.toml` file
47
+ * (would need to be placed in temporary file as wrangler only accepts files as config)
48
+ */
49
+ export declare class WranglerDevServerService extends WranglerDevServerService_base {
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=WranglerDevServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WranglerDevServer.d.ts","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAY,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;;;;;AAI3G;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,2BAI1C;CAAG;AAEL;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAErB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;CACxC;;4BAYgB,0BAA0B;;;;;AAV3C;;;;;;;;GAQG;AACH,qBAAa,wBAAyB,SAAQ,6BAyF5C;CAAG"}
@@ -0,0 +1,90 @@
1
+ import * as path from 'node:path';
2
+ import * as Toml from '@iarna/toml';
3
+ import { IS_CI } from '@livestore/utils';
4
+ import { Cause, Duration, Effect, FileSystem, HttpClient, Schedule, Schema } from '@livestore/utils/effect';
5
+ import { getFreePort } from '@livestore/utils/node';
6
+ import * as wrangler from 'wrangler';
7
+ /**
8
+ * Error type for WranglerDevServer operations
9
+ */
10
+ export class WranglerDevServerError extends Schema.TaggedError()('WranglerDevServerError', {
11
+ cause: Schema.Unknown,
12
+ message: Schema.String,
13
+ port: Schema.Number,
14
+ }) {
15
+ }
16
+ /**
17
+ * WranglerDevServer as an Effect.Service.
18
+ *
19
+ * This service provides the WranglerDevServer properties and can be accessed
20
+ * directly to get port and url.
21
+ *
22
+ * TODO: Allow for config to be passed in via code instead of `wrangler.toml` file
23
+ * (would need to be placed in temporary file as wrangler only accepts files as config)
24
+ */
25
+ export class WranglerDevServerService extends Effect.Service()('WranglerDevServerService', {
26
+ scoped: (args) => Effect.gen(function* () {
27
+ const showLogs = args.showLogs ?? false;
28
+ // Allocate preferred port (Wrangler may bind a different one if unavailable)
29
+ const preferredPort = args.preferredPort ??
30
+ (yield* getFreePort.pipe(Effect.mapError((cause) => new WranglerDevServerError({ cause, message: 'Failed to get free port', port: -1 }))));
31
+ yield* Effect.annotateCurrentSpan({ preferredPort });
32
+ const configPath = path.resolve(args.wranglerConfigPath ?? path.join(args.cwd, 'wrangler.toml'));
33
+ const fs = yield* FileSystem.FileSystem;
34
+ const configContent = yield* fs.readFileString(configPath);
35
+ const parsedConfig = yield* Effect.try(() => Toml.parse(configContent)).pipe(Effect.andThen(Schema.decodeUnknown(Schema.Struct({ main: Schema.String }))), Effect.mapError((error) => new WranglerDevServerError({ cause: error, message: 'Failed to parse wrangler config', port: -1 })));
36
+ const resolvedMainPath = yield* Effect.try(() => path.resolve(args.cwd, parsedConfig.main));
37
+ const devServer = yield* Effect.promise(() => wrangler.unstable_dev(resolvedMainPath, {
38
+ config: configPath,
39
+ port: preferredPort,
40
+ inspectorPort: args.inspectorPort ?? 0,
41
+ persistTo: path.join(args.cwd, '.wrangler/state'),
42
+ logLevel: showLogs ? 'debug' : 'none',
43
+ experimental: {
44
+ disableExperimentalWarning: true,
45
+ },
46
+ }));
47
+ yield* Effect.addFinalizer(Effect.fn(function* (exit) {
48
+ if (exit._tag === 'Failure' && Cause.isInterruptedOnly(exit.cause) === false) {
49
+ yield* Effect.logError('Closing wrangler dev server on failure', exit.cause);
50
+ }
51
+ yield* Effect.tryPromise(async () => {
52
+ await devServer.stop();
53
+ // TODO investigate whether we need to wait until exit (see workers-sdk repo/talk to Cloudflare team)
54
+ // await devServer.waitUntilExit()
55
+ });
56
+ }, Effect.timeout('5 seconds'), Effect.orDie, Effect.tapCauseLogPretty, Effect.withSpan('WranglerDevServerService:stopDevServer')));
57
+ const actualPort = devServer.port;
58
+ const actualHost = devServer.address;
59
+ const url = `http://${actualHost}:${actualPort}`;
60
+ // Use longer timeout in CI environments to account for slower startup times
61
+ const defaultTimeout = Duration.seconds(IS_CI ? 30 : 5);
62
+ yield* verifyHttpConnectivity({ url, showLogs, connectTimeout: args.connectTimeout ?? defaultTimeout });
63
+ if (showLogs) {
64
+ yield* Effect.logDebug(`Wrangler dev server ready and accepting connections on port ${actualPort} (preferred: ${preferredPort})`);
65
+ }
66
+ return {
67
+ port: actualPort,
68
+ url,
69
+ };
70
+ }).pipe(Effect.mapError((error) => new WranglerDevServerError({ cause: error, message: 'Failed to start wrangler dev server', port: -1 })), Effect.withSpan('WranglerDevServerService', {
71
+ attributes: { preferredPort: args.preferredPort ?? 'auto', cwd: args.cwd },
72
+ })),
73
+ }) {
74
+ }
75
+ /**
76
+ * Verifies the server is actually accepting HTTP connections by making a test request
77
+ */
78
+ const verifyHttpConnectivity = ({ url, showLogs, connectTimeout, }) => Effect.gen(function* () {
79
+ const client = yield* HttpClient.HttpClient;
80
+ if (showLogs) {
81
+ yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}`);
82
+ }
83
+ // Try to connect with retries using exponential backoff
84
+ yield* client.get(url).pipe(Effect.retryOrElse(Schedule.exponential('50 millis', 2).pipe(Schedule.jittered, Schedule.intersect(Schedule.elapsed.pipe(Schedule.whileOutput(Duration.lessThanOrEqualTo(connectTimeout)))), Schedule.compose(Schedule.count)), (error, attemptCount) => Effect.fail(new WranglerDevServerError({
85
+ cause: error,
86
+ message: `Failed to establish HTTP connection to Wrangler server at ${url} after ${attemptCount} attempts (timeout: ${Duration.toMillis(connectTimeout)}ms)`,
87
+ port: 0,
88
+ }))), Effect.tap(() => (showLogs ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)), Effect.asVoid, Effect.withSpan('verifyHttpConnectivity'));
89
+ });
90
+ //# sourceMappingURL=WranglerDevServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WranglerDevServer.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"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cAAc,CAAC,CAAC,CAAC,CAAC,EAC3G,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CACjC,EACD,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,CACtB,MAAM,CAAC,IAAI,CACT,IAAI,sBAAsB,CAAC;QACzB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,6DAA6D,GAAG,UAAU,YAAY,uBAAuB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK;QAC5J,IAAI,EAAE,CAAC;KACR,CAAC,CACH,CACJ,EACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EACrG,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAC1C,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=WranglerDevServer.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WranglerDevServer.test.d.ts","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ import { Effect, FetchHttpClient, Layer } from '@livestore/utils/effect';
2
+ import { getFreePort, PlatformNode } from '@livestore/utils/node';
3
+ import { Vitest } from '@livestore/utils-dev/node-vitest';
4
+ import { expect } from 'vitest';
5
+ import { WranglerDevServerError, WranglerDevServerService, } from "./WranglerDevServer.js";
6
+ const testTimeout = 60_000;
7
+ const WranglerDevServerTest = (args = {}) => WranglerDevServerService.Default({
8
+ cwd: `${import.meta.dirname}/fixtures`,
9
+ ...args,
10
+ }).pipe(Layer.provide(FetchHttpClient.layer));
11
+ Vitest.describe('WranglerDevServer', { timeout: testTimeout }, () => {
12
+ Vitest.describe('Basic Operations', () => {
13
+ const withBasicTest = (args = {}) => Vitest.makeWithTestCtx({
14
+ timeout: testTimeout,
15
+ makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
16
+ });
17
+ Vitest.scopedLive('should start wrangler dev server and return port', (test) => Effect.gen(function* () {
18
+ const server = yield* WranglerDevServerService;
19
+ expect(server.port).toBeGreaterThan(0);
20
+ expect(server.url).toMatch(/http:\/\/127.0.0.1:\d+/);
21
+ }).pipe(withBasicTest()(test)));
22
+ Vitest.scopedLive('should use specified port when provided', (test) => Effect.andThen(getFreePort, (port) => Effect.gen(function* () {
23
+ const server = yield* WranglerDevServerService;
24
+ expect(server.port).toBe(port);
25
+ expect(server.url).toBe(`http://127.0.0.1:${port}`);
26
+ }).pipe(withBasicTest({ preferredPort: port })(test))));
27
+ });
28
+ Vitest.describe('Error Handling', () => {
29
+ const withErrorTest = (args = {}) => Vitest.makeWithTestCtx({
30
+ timeout: testTimeout,
31
+ makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
32
+ });
33
+ Vitest.scopedLive('should handle missing wrangler.toml but should timeout', (test) => Effect.gen(function* () {
34
+ const error = yield* WranglerDevServerService.pipe(Effect.provide(WranglerDevServerTest({
35
+ cwd: '/tmp',
36
+ wranglerConfigPath: '/dev/null',
37
+ connectTimeout: '500 millis',
38
+ }).pipe(Layer.provide(PlatformNode.NodeContext.layer))), Effect.flip);
39
+ expect(error).toBeInstanceOf(WranglerDevServerError);
40
+ }).pipe(Vitest.withTestCtx(test)));
41
+ Vitest.scopedLive('should handle invalid working directory', (test) => Effect.gen(function* () {
42
+ const result = yield* WranglerDevServerService.pipe(Effect.provide(WranglerDevServerTest({
43
+ cwd: '/completely/nonexistent/directory',
44
+ }).pipe(Layer.provide(PlatformNode.NodeContext.layer))), Effect.either);
45
+ expect(result._tag).toBe('Left');
46
+ if (result._tag === 'Left') {
47
+ expect(result.left).toBeInstanceOf(WranglerDevServerError);
48
+ }
49
+ }).pipe(Vitest.withTestCtx(test)));
50
+ Vitest.scopedLive('should timeout if server fails to start', (test) => Effect.gen(function* () {
51
+ // Create a command that will never output "Ready on"
52
+ const result = yield* WranglerDevServerService.pipe(
53
+ // Override the timeout for this test to be shorter
54
+ Effect.timeout('5 seconds'), Effect.either);
55
+ // This might succeed or fail depending on actual wrangler behavior
56
+ // The main point is testing timeout functionality
57
+ expect(['Left', 'Right']).toContain(result._tag);
58
+ }).pipe(withErrorTest()(test)));
59
+ });
60
+ Vitest.describe('Service Pattern', () => {
61
+ const withServiceTest = (args = {}) => Vitest.makeWithTestCtx({
62
+ timeout: testTimeout,
63
+ makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
64
+ });
65
+ Vitest.scopedLive('should work with service pattern', (test) => Effect.gen(function* () {
66
+ const server = yield* WranglerDevServerService;
67
+ expect(server.port).toBeGreaterThan(0);
68
+ expect(server.url).toMatch(/http:\/\/127.0.0.1:\d+/);
69
+ }).pipe(withServiceTest()(test)));
70
+ Vitest.scopedLive('should work with custom port via service', (test) => Effect.andThen(getFreePort, (port) => Effect.gen(function* () {
71
+ const server = yield* WranglerDevServerService;
72
+ expect(server.port).toBe(port);
73
+ expect(server.url).toBe(`http://127.0.0.1:${port}`);
74
+ }).pipe(withServiceTest({ preferredPort: port })(test))));
75
+ });
76
+ });
77
+ //# sourceMappingURL=WranglerDevServer.test.js.map
@@ -0,0 +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,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AAC,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"}
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ fetch(_request: Request): Promise<Response>;
3
+ };
4
+ export default _default;
5
+ export declare class TestDO {
6
+ fetch(_request: Request): Promise<Response>;
7
+ }
8
+ //# sourceMappingURL=cf-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cf-worker.d.ts","sourceRoot":"","sources":["../../../src/wrangler/fixtures/cf-worker.ts"],"names":[],"mappings":";oBACwB,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;;AADnD,wBAIC;AAED,qBAAa,MAAM;IACX,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAGlD"}
@@ -0,0 +1,11 @@
1
+ export default {
2
+ async fetch(_request) {
3
+ return new Response('Hello from Wrangler Dev Server test worker!');
4
+ },
5
+ };
6
+ export class TestDO {
7
+ async fetch(_request) {
8
+ return new Response('Hello from Test Durable Object!');
9
+ }
10
+ }
11
+ //# sourceMappingURL=cf-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cf-worker.js","sourceRoot":"","sources":["../../../src/wrangler/fixtures/cf-worker.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,KAAK,CAAC,KAAK,CAAC,QAAiB;QAC3B,OAAO,IAAI,QAAQ,CAAC,6CAA6C,CAAC,CAAA;IACpE,CAAC;CACF,CAAA;AAED,MAAM,OAAO,MAAM;IACjB,KAAK,CAAC,KAAK,CAAC,QAAiB;QAC3B,OAAO,IAAI,QAAQ,CAAC,iCAAiC,CAAC,CAAA;IACxD,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export { type StartWranglerDevServerArgs, type WranglerDevServer, WranglerDevServerError, WranglerDevServerService, } from './WranglerDevServer.ts';
2
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/wrangler/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { WranglerDevServerError, WranglerDevServerService, } from "./WranglerDevServer.js";
2
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/wrangler/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAA"}