@livestore/utils-dev 0.4.0 → 0.5.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +73 -36
- package/dist/node/cmd.js.map +1 -1
- package/dist/node/cmd.test.js +17 -17
- 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 +58 -55
- 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 +17 -8
- package/dist/node-vitest/Vitest.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.js +5 -5
- package/dist/node-vitest/Vitest.js.map +1 -1
- package/dist/node-vitest/Vitest.test.d.ts +3 -5
- package/dist/node-vitest/Vitest.test.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.test.js +14 -3
- package/dist/node-vitest/Vitest.test.js.map +1 -1
- 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/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 +19 -37
- 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 -86
- package/src/node/mod.ts +112 -104
- package/src/node/workspace.ts +9 -10
- package/src/node-vitest/Vitest.test.ts +22 -3
- package/src/node-vitest/Vitest.ts +32 -42
- 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/src/node/DockerComposeService/DockerComposeService.ts +0 -343
- /package/src/node/{DockerComposeService → DockerCompose}/test-fixtures/docker-compose.yml +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import * as Toml from '@iarna/toml';
|
|
3
|
+
import * as wrangler from 'wrangler';
|
|
3
4
|
import { IS_CI } from '@livestore/utils';
|
|
4
|
-
import { Cause, Duration, Effect, FileSystem, HttpClient, Schedule, Schema } from '@livestore/utils/effect';
|
|
5
|
+
import { Cause, Context, Duration, Effect, FileSystem, HttpClient, Layer, Schedule, Schema, } from '@livestore/utils/effect';
|
|
5
6
|
import { getFreePort } from '@livestore/utils/node';
|
|
6
|
-
import * as wrangler from 'wrangler';
|
|
7
7
|
/**
|
|
8
8
|
* Error type for WranglerDevServer operations
|
|
9
9
|
*/
|
|
10
10
|
export class WranglerDevServerError extends Schema.TaggedError('~@livestore/utils-dev/WranglerDevServerError')('WranglerDevServerError', {
|
|
11
|
-
cause: Schema.
|
|
11
|
+
cause: Schema.Defect(),
|
|
12
12
|
message: Schema.String,
|
|
13
|
-
port: Schema.
|
|
13
|
+
port: Schema.Finite,
|
|
14
14
|
}) {
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* WranglerDevServer as an Effect.
|
|
17
|
+
* WranglerDevServer as an Effect service.
|
|
18
18
|
*
|
|
19
19
|
* This service provides the WranglerDevServer properties and can be accessed
|
|
20
20
|
* directly to get port and url.
|
|
@@ -22,69 +22,76 @@ export class WranglerDevServerError extends Schema.TaggedError('~@livestore/util
|
|
|
22
22
|
* TODO: Allow for config to be passed in via code instead of `wrangler.toml` file
|
|
23
23
|
* (would need to be placed in temporary file as wrangler only accepts files as config)
|
|
24
24
|
*/
|
|
25
|
-
export class
|
|
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 readiness = args.readiness ?? {};
|
|
38
|
-
const startupTimeout = readiness.startupTimeout ?? Duration.seconds(IS_CI === true ? 30 : 10);
|
|
39
|
-
const devServer = yield* Effect.promise(() => wrangler.unstable_dev(resolvedMainPath, {
|
|
40
|
-
config: configPath,
|
|
41
|
-
port: preferredPort,
|
|
42
|
-
inspectorPort: args.inspectorPort ?? 0,
|
|
43
|
-
persistTo: path.join(args.cwd, '.wrangler/state'),
|
|
44
|
-
logLevel: showLogs === true ? 'debug' : 'none',
|
|
45
|
-
experimental: {
|
|
46
|
-
disableExperimentalWarning: true,
|
|
47
|
-
},
|
|
48
|
-
})).pipe(Effect.timeout(startupTimeout), Effect.mapError((cause) => new WranglerDevServerError({
|
|
49
|
-
cause,
|
|
50
|
-
message: `Failed to start wrangler dev server within ${Duration.format(startupTimeout)}`,
|
|
51
|
-
port: preferredPort,
|
|
52
|
-
})), Effect.tapError((error) => Effect.logError('Wrangler dev server failed to start', {
|
|
53
|
-
message: error.message,
|
|
54
|
-
preferredPort,
|
|
55
|
-
cwd: args.cwd,
|
|
56
|
-
})), Effect.retry(readiness.retrySchedule ?? Schedule.recurs(1)));
|
|
57
|
-
yield* Effect.addFinalizer(Effect.fn(function* (exit) {
|
|
58
|
-
if (exit._tag === 'Failure' && Cause.isInterruptedOnly(exit.cause) === false) {
|
|
59
|
-
yield* Effect.logError('Closing wrangler dev server on failure', exit.cause);
|
|
60
|
-
}
|
|
61
|
-
yield* Effect.tryPromise(async () => {
|
|
62
|
-
await devServer.stop();
|
|
63
|
-
// TODO investigate whether we need to wait until exit (see workers-sdk repo/talk to Cloudflare team)
|
|
64
|
-
// await devServer.waitUntilExit()
|
|
65
|
-
});
|
|
66
|
-
}, Effect.timeout('5 seconds'), Effect.orDie, Effect.tapCauseLogPretty, Effect.withSpan('WranglerDevServerService:stopDevServer')));
|
|
67
|
-
const actualPort = devServer.port;
|
|
68
|
-
const actualHost = devServer.address;
|
|
69
|
-
const url = `http://${actualHost}:${actualPort}`;
|
|
70
|
-
// Use longer timeout in CI environments to account for slower HTTP readiness
|
|
71
|
-
const defaultConnectivityTimeout = Duration.seconds(IS_CI === true ? 30 : 5);
|
|
72
|
-
const connectivityTimeout = readiness.connectTimeout ?? defaultConnectivityTimeout;
|
|
73
|
-
yield* verifyHttpConnectivity({ url, showLogs, connectTimeout: connectivityTimeout });
|
|
74
|
-
if (showLogs === true) {
|
|
75
|
-
yield* Effect.logDebug(`Wrangler dev server ready and accepting connections on port ${actualPort} (preferred: ${preferredPort})`);
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
port: actualPort,
|
|
79
|
-
url,
|
|
80
|
-
};
|
|
81
|
-
}).pipe(Effect.mapError((error) => error instanceof WranglerDevServerError
|
|
82
|
-
? error
|
|
83
|
-
: new WranglerDevServerError({ cause: error, message: 'Failed to start wrangler dev server', port: -1 })), Effect.withSpan('WranglerDevServerService', {
|
|
84
|
-
attributes: { preferredPort: args.preferredPort ?? 'auto', cwd: args.cwd },
|
|
85
|
-
})),
|
|
86
|
-
}) {
|
|
25
|
+
export class WranglerDevServer extends Context.Service()('@livestore/utils-dev/WranglerDevServer') {
|
|
87
26
|
}
|
|
27
|
+
export const make = (args) => Effect.gen(function* () {
|
|
28
|
+
const showLogs = args.showLogs ?? false;
|
|
29
|
+
// Allocate preferred port (Wrangler may bind a different one if unavailable)
|
|
30
|
+
const preferredPort = args.preferredPort ??
|
|
31
|
+
(yield* getFreePort.pipe(Effect.mapError((cause) => new WranglerDevServerError({ cause, message: 'Failed to get free port', port: -1 }))));
|
|
32
|
+
yield* Effect.annotateCurrentSpan({ preferredPort });
|
|
33
|
+
const configPath = path.resolve(args.wranglerConfigPath ?? path.join(args.cwd, 'wrangler.toml'));
|
|
34
|
+
const fs = yield* FileSystem.FileSystem;
|
|
35
|
+
const configContent = yield* fs.readFileString(configPath);
|
|
36
|
+
const parsedConfig = yield* Effect.try({
|
|
37
|
+
try: () => Toml.parse(configContent),
|
|
38
|
+
catch: (cause) => new Cause.UnknownError(cause),
|
|
39
|
+
}).pipe(Effect.andThen(Schema.decodeUnknownEffect(Schema.Struct({ main: Schema.String }))), Effect.mapError((error) => new WranglerDevServerError({ cause: error, message: 'Failed to parse wrangler config', port: -1 })));
|
|
40
|
+
const resolvedMainPath = yield* Effect.try({
|
|
41
|
+
try: () => path.resolve(args.cwd, parsedConfig.main),
|
|
42
|
+
catch: (cause) => new Cause.UnknownError(cause),
|
|
43
|
+
});
|
|
44
|
+
const readiness = args.readiness ?? {};
|
|
45
|
+
const startupTimeout = readiness.startupTimeout ?? Duration.seconds(IS_CI === true ? 30 : 10);
|
|
46
|
+
const startupTimeoutDuration = Duration.fromInputUnsafe(startupTimeout);
|
|
47
|
+
const devServer = yield* Effect.promise(() => wrangler.unstable_dev(resolvedMainPath, {
|
|
48
|
+
config: configPath,
|
|
49
|
+
port: preferredPort,
|
|
50
|
+
inspectorPort: args.inspectorPort ?? 0,
|
|
51
|
+
persistTo: path.join(args.cwd, '.wrangler/state'),
|
|
52
|
+
logLevel: showLogs === true ? 'debug' : 'none',
|
|
53
|
+
experimental: {
|
|
54
|
+
disableExperimentalWarning: true,
|
|
55
|
+
},
|
|
56
|
+
})).pipe(Effect.timeout(startupTimeout), Effect.mapError((cause) => new WranglerDevServerError({
|
|
57
|
+
cause,
|
|
58
|
+
message: `Failed to start wrangler dev server within ${Duration.format(startupTimeoutDuration)}`,
|
|
59
|
+
port: preferredPort,
|
|
60
|
+
})), Effect.tapError((error) => Effect.logError('Wrangler dev server failed to start', {
|
|
61
|
+
message: error.message,
|
|
62
|
+
preferredPort,
|
|
63
|
+
cwd: args.cwd,
|
|
64
|
+
})), Effect.retry(readiness.retrySchedule ?? Schedule.recurs(1)));
|
|
65
|
+
yield* Effect.addFinalizer(Effect.fn(function* (exit) {
|
|
66
|
+
if (exit._tag === 'Failure' && Cause.hasInterruptsOnly(exit.cause) === false) {
|
|
67
|
+
yield* Effect.logError('Closing wrangler dev server on failure', exit.cause);
|
|
68
|
+
}
|
|
69
|
+
yield* Effect.tryPromise(async () => {
|
|
70
|
+
await devServer.stop();
|
|
71
|
+
// TODO investigate whether we need to wait until exit (see workers-sdk repo/talk to Cloudflare team)
|
|
72
|
+
// await devServer.waitUntilExit()
|
|
73
|
+
});
|
|
74
|
+
}, Effect.timeout('5 seconds'), Effect.orDie, Effect.tapCauseLogPretty, Effect.withSpan('WranglerDevServer:stopDevServer')));
|
|
75
|
+
const actualPort = devServer.port;
|
|
76
|
+
const actualHost = devServer.address;
|
|
77
|
+
const url = `http://${actualHost}:${actualPort}`;
|
|
78
|
+
// Use longer timeout in CI environments to account for slower HTTP readiness
|
|
79
|
+
const defaultConnectivityTimeout = Duration.seconds(IS_CI === true ? 30 : 5);
|
|
80
|
+
const connectivityTimeout = readiness.connectTimeout ?? defaultConnectivityTimeout;
|
|
81
|
+
yield* verifyHttpConnectivity({ url, showLogs, connectTimeout: connectivityTimeout });
|
|
82
|
+
if (showLogs === true) {
|
|
83
|
+
yield* Effect.logDebug(`Wrangler dev server ready and accepting connections on port ${actualPort} (preferred: ${preferredPort})`);
|
|
84
|
+
}
|
|
85
|
+
return WranglerDevServer.of({
|
|
86
|
+
port: actualPort,
|
|
87
|
+
url,
|
|
88
|
+
});
|
|
89
|
+
}).pipe(Effect.mapError((error) => error instanceof WranglerDevServerError
|
|
90
|
+
? error
|
|
91
|
+
: new WranglerDevServerError({ cause: error, message: 'Failed to start wrangler dev server', port: -1 })), Effect.withSpan('WranglerDevServer', {
|
|
92
|
+
attributes: { preferredPort: args.preferredPort ?? 'auto', cwd: args.cwd },
|
|
93
|
+
}));
|
|
94
|
+
export const layer = (options) => Layer.effect(WranglerDevServer, make(options));
|
|
88
95
|
/**
|
|
89
96
|
* Verifies the server is actually accepting HTTP connections by making a test request
|
|
90
97
|
*/
|
|
@@ -93,11 +100,10 @@ const verifyHttpConnectivity = ({ url, showLogs, connectTimeout, }) => Effect.ge
|
|
|
93
100
|
if (showLogs === true) {
|
|
94
101
|
yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}`);
|
|
95
102
|
}
|
|
96
|
-
|
|
97
|
-
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({
|
|
103
|
+
yield* client.get(url).pipe(Effect.retry(Schedule.exponential('50 millis', 2).pipe(Schedule.jittered)), Effect.timeout(connectTimeout), Effect.mapError((error) => new WranglerDevServerError({
|
|
98
104
|
cause: error,
|
|
99
|
-
message: `Failed to establish HTTP connection to Wrangler server at ${url}
|
|
105
|
+
message: `Failed to establish HTTP connection to Wrangler server at ${url} (timeout: ${Duration.toMillis(Duration.fromInputUnsafe(connectTimeout))}ms)`,
|
|
100
106
|
port: 0,
|
|
101
|
-
}))
|
|
107
|
+
})), Effect.tap(() => (showLogs === true ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)), Effect.asVoid, Effect.withSpan('verifyHttpConnectivity'));
|
|
102
108
|
});
|
|
103
109
|
//# sourceMappingURL=WranglerDevServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerDevServer.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"WranglerDevServer.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,UAAU,EACV,UAAU,EACV,KAAK,EACL,QAAQ,EACR,MAAM,GACP,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,WAAW,CAC5D,8CAA8C,CAC/C,CAAC,wBAAwB,EAAE;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC;CAAG;AA2CL;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO,CAAC,OAAO,EAA8B,CAClF,wCAAwC,CACzC;CAAG;AAEJ,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAa,EAAE,EAAE,CACpC,MAAM,CAAC,GAAG,C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ect, FetchHttpClient, Layer } from '@livestore/utils/effect';
|
|
3
|
+
import { Effect, FetchHttpClient, Layer, Result } from '@livestore/utils/effect';
|
|
4
4
|
import { getFreePort, PlatformNode } from '@livestore/utils/node';
|
|
5
|
-
import
|
|
5
|
+
import * as WranglerDevServer from "./WranglerDevServer.js";
|
|
6
6
|
const testTimeout = 60_000;
|
|
7
|
-
const WranglerDevServerTest = (args = {}) =>
|
|
7
|
+
const WranglerDevServerTest = (args = {}) => WranglerDevServer.layer({
|
|
8
8
|
cwd: `${import.meta.dirname}/fixtures`,
|
|
9
9
|
...args,
|
|
10
10
|
}).pipe(Layer.provide(FetchHttpClient.layer));
|
|
@@ -12,15 +12,15 @@ Vitest.describe('WranglerDevServer', { timeout: testTimeout }, () => {
|
|
|
12
12
|
Vitest.describe('Basic Operations', () => {
|
|
13
13
|
const withBasicTest = (args = {}) => Vitest.makeWithTestCtx({
|
|
14
14
|
timeout: testTimeout,
|
|
15
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.
|
|
15
|
+
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
16
16
|
});
|
|
17
|
-
Vitest.
|
|
18
|
-
const server = yield*
|
|
17
|
+
Vitest.live('should start wrangler dev server and return port', (test) => Effect.gen(function* () {
|
|
18
|
+
const server = yield* WranglerDevServer.WranglerDevServer;
|
|
19
19
|
expect(server.port).toBeGreaterThan(0);
|
|
20
20
|
expect(server.url).toMatch(/http:\/\/127.0.0.1:\d+/);
|
|
21
21
|
}).pipe(withBasicTest()(test)));
|
|
22
|
-
Vitest.
|
|
23
|
-
const server = yield*
|
|
22
|
+
Vitest.live('should use specified port when provided', (test) => Effect.andThen(getFreePort, (port) => Effect.gen(function* () {
|
|
23
|
+
const server = yield* WranglerDevServer.WranglerDevServer;
|
|
24
24
|
expect(server.port).toBe(port);
|
|
25
25
|
expect(server.url).toBe(`http://127.0.0.1:${port}`);
|
|
26
26
|
}).pipe(withBasicTest({ preferredPort: port })(test))));
|
|
@@ -28,47 +28,47 @@ Vitest.describe('WranglerDevServer', { timeout: testTimeout }, () => {
|
|
|
28
28
|
Vitest.describe('Error Handling', () => {
|
|
29
29
|
const withErrorTest = (args = {}) => Vitest.makeWithTestCtx({
|
|
30
30
|
timeout: testTimeout,
|
|
31
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.
|
|
31
|
+
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
32
32
|
});
|
|
33
|
-
Vitest.
|
|
34
|
-
const error = yield*
|
|
33
|
+
Vitest.live('should handle missing wrangler.toml but should timeout', (test) => Effect.gen(function* () {
|
|
34
|
+
const error = yield* WranglerDevServer.WranglerDevServer.pipe(Effect.provide(WranglerDevServerTest({
|
|
35
35
|
cwd: '/tmp',
|
|
36
36
|
wranglerConfigPath: '/dev/null',
|
|
37
37
|
readiness: { connectTimeout: '500 millis' },
|
|
38
|
-
}).pipe(Layer.provide(PlatformNode.
|
|
39
|
-
expect(error).toBeInstanceOf(WranglerDevServerError);
|
|
38
|
+
}).pipe(Layer.provide(PlatformNode.NodeServices.layer))), Effect.flip);
|
|
39
|
+
expect(error).toBeInstanceOf(WranglerDevServer.WranglerDevServerError);
|
|
40
40
|
}).pipe(Vitest.withTestCtx(test)));
|
|
41
|
-
Vitest.
|
|
42
|
-
const result = yield*
|
|
41
|
+
Vitest.live('should handle invalid working directory', (test) => Effect.gen(function* () {
|
|
42
|
+
const result = yield* WranglerDevServer.WranglerDevServer.pipe(Effect.provide(WranglerDevServerTest({
|
|
43
43
|
cwd: '/completely/nonexistent/directory',
|
|
44
|
-
}).pipe(Layer.provide(PlatformNode.
|
|
45
|
-
expect(result._tag).toBe('
|
|
46
|
-
if (result._tag === '
|
|
47
|
-
expect(result.
|
|
44
|
+
}).pipe(Layer.provide(PlatformNode.NodeServices.layer))), Effect.result);
|
|
45
|
+
expect(result._tag).toBe('Failure');
|
|
46
|
+
if (result._tag === 'Failure') {
|
|
47
|
+
expect(result.failure).toBeInstanceOf(WranglerDevServer.WranglerDevServerError);
|
|
48
48
|
}
|
|
49
49
|
}).pipe(Vitest.withTestCtx(test)));
|
|
50
|
-
Vitest.
|
|
50
|
+
Vitest.live('should timeout if server fails to start', (test) => Effect.gen(function* () {
|
|
51
51
|
// Create a command that will never output "Ready on"
|
|
52
|
-
const result = yield*
|
|
52
|
+
const result = yield* WranglerDevServer.WranglerDevServer.pipe(
|
|
53
53
|
// Override the timeout for this test to be shorter
|
|
54
|
-
Effect.timeout('5 seconds'), Effect.
|
|
54
|
+
Effect.timeout('5 seconds'), Effect.result);
|
|
55
55
|
// This might succeed or fail depending on actual wrangler behavior
|
|
56
56
|
// The main point is testing timeout functionality
|
|
57
|
-
expect(['
|
|
57
|
+
expect(['Failure', 'Success']).toContain(result._tag);
|
|
58
58
|
}).pipe(withErrorTest()(test)));
|
|
59
59
|
});
|
|
60
60
|
Vitest.describe('Service Pattern', () => {
|
|
61
61
|
const withServiceTest = (args = {}) => Vitest.makeWithTestCtx({
|
|
62
62
|
timeout: testTimeout,
|
|
63
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.
|
|
63
|
+
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
64
64
|
});
|
|
65
|
-
Vitest.
|
|
66
|
-
const server = yield*
|
|
65
|
+
Vitest.live('should work with service pattern', (test) => Effect.gen(function* () {
|
|
66
|
+
const server = yield* WranglerDevServer.WranglerDevServer;
|
|
67
67
|
expect(server.port).toBeGreaterThan(0);
|
|
68
68
|
expect(server.url).toMatch(/http:\/\/127.0.0.1:\d+/);
|
|
69
69
|
}).pipe(withServiceTest()(test)));
|
|
70
|
-
Vitest.
|
|
71
|
-
const server = yield*
|
|
70
|
+
Vitest.live('should work with custom port via service', (test) => Effect.andThen(getFreePort, (port) => Effect.gen(function* () {
|
|
71
|
+
const server = yield* WranglerDevServer.WranglerDevServer;
|
|
72
72
|
expect(server.port).toBe(port);
|
|
73
73
|
expect(server.url).toBe(`http://127.0.0.1:${port}`);
|
|
74
74
|
}).pipe(withServiceTest({ preferredPort: port })(test))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerDevServer.test.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"WranglerDevServer.test.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEjE,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAE3D,MAAM,WAAW,GAAG,MAAM,CAAA;AAE1B,MAAM,qBAAqB,GAAG,CAAC,OAA2C,EAAE,EAAE,EAAE,CAC9E,iBAAiB,CAAC,KAAK,CAAC;IACtB,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW;IACtC,GAAG,IAAI;CACR,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;AAE/C,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE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AAA"}
|
package/dist/wrangler/mod.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * as WranglerDevServer from './WranglerDevServer.ts';
|
|
2
2
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/wrangler/mod.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/wrangler/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA"}
|
package/dist/wrangler/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * as WranglerDevServer from "./WranglerDevServer.js";
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
package/dist/wrangler/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/wrangler/mod.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/wrangler/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/utils-dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-dev.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@effect/opentelemetry": "0.
|
|
29
|
-
"@effect/vitest": "0.
|
|
28
|
+
"@effect/opentelemetry": "4.0.0-rc.111",
|
|
29
|
+
"@effect/vitest": "4.0.0-rc.111",
|
|
30
30
|
"@iarna/toml": "3.0.0",
|
|
31
31
|
"@opentelemetry/api": "1.9.0",
|
|
32
32
|
"@opentelemetry/exporter-metrics-otlp-http": "0.208.0",
|
|
@@ -35,50 +35,32 @@
|
|
|
35
35
|
"@opentelemetry/sdk-trace-base": "2.2.0",
|
|
36
36
|
"@opentelemetry/sdk-trace-node": "2.2.0",
|
|
37
37
|
"wrangler": "4.42.2",
|
|
38
|
-
"@livestore/utils": "^0.
|
|
38
|
+
"@livestore/utils": "^0.5.0-dev.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@effect/
|
|
42
|
-
"@effect/
|
|
43
|
-
"@effect/
|
|
44
|
-
"@effect/
|
|
45
|
-
"@effect/
|
|
46
|
-
"@effect/
|
|
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",
|
|
41
|
+
"@effect/opentelemetry": "4.0.0-rc.111",
|
|
42
|
+
"@effect/platform-browser": "4.0.0-rc.111",
|
|
43
|
+
"@effect/platform-bun": "4.0.0-rc.111",
|
|
44
|
+
"@effect/platform-node": "4.0.0-rc.111",
|
|
45
|
+
"@effect/platform-node-shared": "4.0.0-rc.111",
|
|
46
|
+
"@effect/vitest": "4.0.0-rc.111",
|
|
56
47
|
"@opentelemetry/api": "1.9.0",
|
|
57
48
|
"@opentelemetry/resources": "2.2.0",
|
|
58
49
|
"@standard-schema/spec": "1.1.0",
|
|
59
|
-
"effect": "
|
|
60
|
-
"vitest": "
|
|
50
|
+
"effect": "4.0.0-rc.111",
|
|
51
|
+
"vitest": "4.1.9"
|
|
61
52
|
},
|
|
62
53
|
"peerDependencies": {
|
|
63
|
-
"@effect/
|
|
64
|
-
"@effect/
|
|
65
|
-
"@effect/
|
|
66
|
-
"@effect/
|
|
67
|
-
"@effect/
|
|
68
|
-
"@effect/
|
|
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",
|
|
54
|
+
"@effect/opentelemetry": "^4.0.0-rc.111",
|
|
55
|
+
"@effect/platform-browser": "^4.0.0-rc.111",
|
|
56
|
+
"@effect/platform-bun": "^4.0.0-rc.111",
|
|
57
|
+
"@effect/platform-node": "^4.0.0-rc.111",
|
|
58
|
+
"@effect/platform-node-shared": "^4.0.0-rc.111",
|
|
59
|
+
"@effect/vitest": "^4.0.0-rc.111",
|
|
78
60
|
"@opentelemetry/api": "^1.9.0",
|
|
79
61
|
"@opentelemetry/resources": "^2.2.0",
|
|
80
62
|
"@standard-schema/spec": "^1.1.0",
|
|
81
|
-
"effect": "^
|
|
63
|
+
"effect": "^4.0.0-rc.111"
|
|
82
64
|
},
|
|
83
65
|
"$genie": {
|
|
84
66
|
"source": "package.json.genie.ts",
|
|
@@ -6,37 +6,37 @@ import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
|
6
6
|
import { Duration, Effect, Layer, Stream } from '@livestore/utils/effect'
|
|
7
7
|
import { PlatformNode } from '@livestore/utils/node'
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import * as DockerCompose from './DockerCompose.ts'
|
|
10
10
|
|
|
11
11
|
const testTimeout = 30_000
|
|
12
12
|
const testFixturePath = path.join(import.meta.dirname, 'test-fixtures')
|
|
13
13
|
|
|
14
|
-
const DockerComposeTest = (args: Partial<
|
|
15
|
-
|
|
14
|
+
const DockerComposeTest = (args: Partial<DockerCompose.Options> = {}) =>
|
|
15
|
+
DockerCompose.layer({
|
|
16
16
|
cwd: testFixturePath,
|
|
17
17
|
...args,
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
Vitest.describe('
|
|
20
|
+
Vitest.describe('DockerCompose', { timeout: testTimeout }, () => {
|
|
21
21
|
Vitest.describe('Basic Operations', () => {
|
|
22
|
-
const withBasicTest = (args: Partial<
|
|
22
|
+
const withBasicTest = (args: Partial<DockerCompose.Options> = {}) =>
|
|
23
23
|
Vitest.makeWithTestCtx({
|
|
24
24
|
timeout: testTimeout,
|
|
25
|
-
makeLayer: () => DockerComposeTest(args).pipe(Layer.provide(PlatformNode.
|
|
25
|
+
makeLayer: () => DockerComposeTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
Vitest.
|
|
28
|
+
Vitest.live('can pull docker images', (test) =>
|
|
29
29
|
Effect.gen(function* () {
|
|
30
|
-
const dockerCompose = yield*
|
|
30
|
+
const dockerCompose = yield* DockerCompose.DockerCompose
|
|
31
31
|
|
|
32
32
|
// Test that pull operation works (should succeed for hello-world image)
|
|
33
33
|
yield* dockerCompose.pull
|
|
34
34
|
}).pipe(withBasicTest()(test)),
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
-
Vitest.
|
|
37
|
+
Vitest.live('can start and stop docker compose services', (test) =>
|
|
38
38
|
Effect.gen(function* () {
|
|
39
|
-
const dockerCompose = yield*
|
|
39
|
+
const dockerCompose = yield* DockerCompose.DockerCompose
|
|
40
40
|
|
|
41
41
|
// Start the service
|
|
42
42
|
yield* dockerCompose.start({ detached: true })
|
|
@@ -46,9 +46,9 @@ Vitest.describe('DockerComposeService', { timeout: testTimeout }, () => {
|
|
|
46
46
|
}).pipe(withBasicTest({ serviceName: 'hello-world' })(test)),
|
|
47
47
|
)
|
|
48
48
|
|
|
49
|
-
Vitest.
|
|
49
|
+
Vitest.live('can get logs from docker compose services', (test) =>
|
|
50
50
|
Effect.gen(function* () {
|
|
51
|
-
const dockerCompose = yield*
|
|
51
|
+
const dockerCompose = yield* DockerCompose.DockerCompose
|
|
52
52
|
|
|
53
53
|
// Start the service first
|
|
54
54
|
yield* dockerCompose.start({ detached: true })
|
|
@@ -65,15 +65,15 @@ Vitest.describe('DockerComposeService', { timeout: testTimeout }, () => {
|
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
Vitest.describe('Health Check Operations', () => {
|
|
68
|
-
const withHealthCheckTest = (args: Partial<
|
|
68
|
+
const withHealthCheckTest = (args: Partial<DockerCompose.Options> = {}) =>
|
|
69
69
|
Vitest.makeWithTestCtx({
|
|
70
70
|
timeout: testTimeout,
|
|
71
|
-
makeLayer: () => DockerComposeTest(args).pipe(Layer.provide(PlatformNode.
|
|
71
|
+
makeLayer: () => DockerComposeTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
Vitest.
|
|
74
|
+
Vitest.live('handles health check timeout gracefully', (test) =>
|
|
75
75
|
Effect.gen(function* () {
|
|
76
|
-
const dockerCompose = yield*
|
|
76
|
+
const dockerCompose = yield* DockerCompose.DockerCompose
|
|
77
77
|
|
|
78
78
|
// Test starting with a health check that will timeout (invalid URL)
|
|
79
79
|
const result = yield* dockerCompose
|
|
@@ -84,10 +84,10 @@ Vitest.describe('DockerComposeService', { timeout: testTimeout }, () => {
|
|
|
84
84
|
timeout: Duration.seconds(2),
|
|
85
85
|
},
|
|
86
86
|
})
|
|
87
|
-
.pipe(Effect.
|
|
87
|
+
.pipe(Effect.result)
|
|
88
88
|
|
|
89
89
|
// Should fail due to health check timeout
|
|
90
|
-
expect(result._tag).toBe('
|
|
90
|
+
expect(result._tag).toBe('Failure')
|
|
91
91
|
}).pipe(withHealthCheckTest({ serviceName: 'hello-world' })(test)),
|
|
92
92
|
)
|
|
93
93
|
})
|