@livestore/utils-dev 0.3.2-dev.9 → 0.4.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.
@@ -1,5 +1,5 @@
1
1
  import type { CommandExecutor, PlatformError, Tracer } from '@livestore/utils/effect';
2
- import { Effect, Layer, OtelTracer } from '@livestore/utils/effect';
2
+ import { Effect, Layer, OtelTracer, Schema } from '@livestore/utils/effect';
3
3
  import * as otel from '@opentelemetry/api';
4
4
  export { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
5
5
  export { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
@@ -16,13 +16,26 @@ export declare const logTraceUiUrlForSpan: (printMsg?: (url: string) => string)
16
16
  export declare const getTracingBackendUrl: (span: otel.Span) => Effect.Effect<string | undefined, never, never>;
17
17
  export declare const cmd: (commandInput: string | (string | undefined)[], options?: {
18
18
  cwd?: string;
19
+ stderr?: 'inherit' | 'pipe';
20
+ stdout?: 'inherit' | 'pipe';
19
21
  shell?: boolean;
20
22
  env?: Record<string, string | undefined>;
21
- } | undefined) => Effect.Effect<CommandExecutor.ExitCode, PlatformError.PlatformError, CommandExecutor.CommandExecutor>;
23
+ } | undefined) => Effect.Effect<CommandExecutor.ExitCode, PlatformError.PlatformError | CmdError, CommandExecutor.CommandExecutor>;
22
24
  export declare const cmdText: (commandInput: string | (string | undefined)[], options?: {
23
25
  cwd?: string;
24
26
  stderr?: 'inherit' | 'pipe';
25
27
  runInShell?: boolean;
26
28
  env?: Record<string, string | undefined>;
27
29
  }) => Effect.Effect<string, PlatformError.PlatformError, CommandExecutor.CommandExecutor>;
30
+ declare const CmdError_base: Schema.TaggedErrorClass<CmdError, "CmdError", {
31
+ readonly _tag: Schema.tag<"CmdError">;
32
+ } & {
33
+ command: typeof Schema.String;
34
+ args: Schema.Array$<typeof Schema.String>;
35
+ cwd: typeof Schema.String;
36
+ env: Schema.Record$<typeof Schema.String, Schema.UndefinedOr<typeof Schema.String>>;
37
+ stderr: Schema.Literal<["inherit", "pipe"]>;
38
+ }>;
39
+ export declare class CmdError extends CmdError_base {
40
+ }
28
41
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/node/mod.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAmB,MAAM,EAAY,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAE9F,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAM1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAE3E,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C,eAAO,MAAM,YAAY,GAAI,iGAO1B;IACD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,OAAO,CAAA;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CACxB,KAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CA8ExC,CAAA;AAEpC,eAAO,MAAM,oBAAoB,GAAI,WAAW,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,MAAM,MAAM,IAAI,CAAC,IAAI,oDAazF,CAAA;AAEH,eAAO,MAAM,oBAAoB,GAAI,MAAM,IAAI,CAAC,IAAI,oDAqBhD,CAAA;AAEJ,eAAO,MAAM,GAAG,EAAE,CAChB,YAAY,EAAE,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,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACzC,KACE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,eAAe,CAyBtF,CAAA;;;;;;;;;;AAED,qBAAa,QAAS,SAAQ,aAM5B;CAAG"}
package/dist/node/mod.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import * as OtelNodeSdk from '@effect/opentelemetry/NodeSdk';
3
3
  import { IS_BUN, isNonEmptyString, isNotUndefined, shouldNeverHappen } from '@livestore/utils';
4
- import { Command, Config, Effect, identity, Layer, OtelTracer } from '@livestore/utils/effect';
4
+ import { Command, Config, Effect, FiberRef, identity, Layer, LogLevel, OtelTracer, Schema, } from '@livestore/utils/effect';
5
5
  import { OtelLiveDummy } from '@livestore/utils/node';
6
6
  import * as otel from '@opentelemetry/api';
7
7
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
@@ -35,7 +35,18 @@ export const OtelLiveHttp = ({ serviceName, rootSpanName, rootSpanAttributes, pa
35
35
  resource,
36
36
  metricReader,
37
37
  spanProcessor: new BatchSpanProcessor(new OTLPTraceExporter({ url: `${config.exporterUrl}/v1/traces`, headers: {} }), { scheduledDelayMillis: 50 }),
38
- }));
38
+ })).pipe(
39
+ // If an OpenTelemetry backend is not available, the `OtelNodeSdk` layer
40
+ // will ignore the error when attempting to connect and emit a debug log
41
+ // stating the reason for the error (in this case `ECONNREFUSED`). This
42
+ // can cause problems for programs which rely on clean `stdout` (e.g.
43
+ // command-line applications). To remedy this, the below code sets the
44
+ // minimum log level `FiberRef` to `"None"` for the duration of the
45
+ // `OtelNodeSdk`'s layer constructor.
46
+ //
47
+ // This can likely be removed when Livestore is migrated to the Effect
48
+ // native Otlp exporters.
49
+ Layer.locally(FiberRef.currentMinimumLogLevel, LogLevel.None));
39
50
  const RootSpanLive = Layer.span(config.rootSpanName, {
40
51
  attributes: { config, ...rootSpanAttributes },
41
52
  onEnd: skipLogUrl ? undefined : (span) => logTraceUiUrlForSpan()(span.span),
@@ -100,19 +111,31 @@ export const getTracingBackendUrl = (span) => Effect.gen(function* () {
100
111
  });
101
112
  export const cmd = Effect.fn('cmd')(function* (commandInput, options) {
102
113
  const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set');
103
- const [command, ...args] = Array.isArray(commandInput) ? commandInput.filter(isNotUndefined) : commandInput.split(' ');
114
+ const [command, ...args] = Array.isArray(commandInput)
115
+ ? commandInput.filter(isNotUndefined)
116
+ : commandInput.split(' ');
104
117
  const debugEnvStr = Object.entries(options?.env ?? {})
105
118
  .map(([key, value]) => `${key}='${value}' `)
106
119
  .join('');
120
+ const subshellStr = options?.shell ? ' (in subshell)' : '';
107
121
  const commandDebugStr = debugEnvStr + [command, ...args].join(' ');
108
- yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'`);
122
+ yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'${subshellStr}`);
109
123
  yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, cwd, command, args });
110
124
  return yield* Command.make(command, ...args).pipe(
111
125
  // TODO don't forward abort signal to the command
112
126
  Command.stdin('inherit'), // Forward stdin to the command
113
- Command.stdout('inherit'), // Stream stdout to process.stdout
114
- Command.stderr('inherit'), // Stream stderr to process.stderr
115
- Command.workingDirectory(cwd), options?.shell ? Command.runInShell(true) : identity, Command.env(options?.env ?? {}), Command.exitCode, Effect.tap((exitCode) => (exitCode === 0 ? Effect.void : Effect.die(`${commandDebugStr} failed`))));
127
+ // inherit = Stream stdout to process.stdout, pipe = Stream stdout to process.stderr
128
+ Command.stdout(options?.stdout ?? 'inherit'),
129
+ // inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
130
+ Command.stderr(options?.stderr ?? 'inherit'), Command.workingDirectory(cwd), options?.shell ? Command.runInShell(true) : identity, Command.env(options?.env ?? {}), Command.exitCode, Effect.tap((exitCode) => exitCode === 0
131
+ ? Effect.void
132
+ : Effect.fail(CmdError.make({
133
+ command: command,
134
+ args,
135
+ cwd,
136
+ env: options?.env ?? {},
137
+ stderr: options?.stderr ?? 'inherit',
138
+ }))));
116
139
  });
117
140
  export const cmdText = Effect.fn('cmdText')(function* (commandInput, options) {
118
141
  const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set');
@@ -123,10 +146,19 @@ export const cmdText = Effect.fn('cmdText')(function* (commandInput, options) {
123
146
  .map(([key, value]) => `${key}='${value}' `)
124
147
  .join('');
125
148
  const commandDebugStr = debugEnvStr + [command, ...args].join(' ');
126
- yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'`);
149
+ const subshellStr = options?.runInShell ? ' (in subshell)' : '';
150
+ yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'${subshellStr}`);
127
151
  yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, command, cwd });
128
152
  return yield* Command.make(command, ...args).pipe(
129
153
  // inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
130
154
  Command.stderr(options?.stderr ?? 'inherit'), Command.workingDirectory(cwd), options?.runInShell ? Command.runInShell(true) : identity, Command.env(options?.env ?? {}), Command.string);
131
155
  });
156
+ export class CmdError extends Schema.TaggedError()('CmdError', {
157
+ command: Schema.String,
158
+ args: Schema.Array(Schema.String),
159
+ cwd: Schema.String,
160
+ env: Schema.Record({ key: Schema.String, value: Schema.String.pipe(Schema.UndefinedOr) }),
161
+ stderr: Schema.Literal('inherit', 'pipe'),
162
+ }) {
163
+ }
132
164
  //# sourceMappingURL=mod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod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AAW,EAAY,CAAC,UAAU,EAAE;IACvE,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;IACzF,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;CAC1C,CAAC;CAAG"}
@@ -0,0 +1,18 @@
1
+ import type * as Vitest from '@effect/vitest';
2
+ import { type Cause, Duration, Effect, Layer, type OtelTracer, type Scope } from '@livestore/utils/effect';
3
+ export * from '@effect/vitest';
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> = {
7
+ suffix?: string;
8
+ makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>;
9
+ timeout?: Duration.DurationInput;
10
+ forceOtel?: boolean;
11
+ };
12
+ export declare const withTestCtx: <R1 = never, E1 = never>(testContext: Vitest.TestContext, { suffix, makeLayer, timeout, forceOtel, }?: {
13
+ suffix?: string;
14
+ makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>;
15
+ timeout?: Duration.DurationInput;
16
+ forceOtel?: boolean;
17
+ }) => <A, E>(self: Effect.Effect<A, E, Scope.Scope | OtelTracer.OtelTracer | R1>) => Effect.Effect<A, E | Cause.TimeoutException | E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C,CAAA;IACjF,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;IAChC,SAAS,CAAC,EAAE,OAAO,CAAA;CACf,MAEP,CAAC,EAAE,CAAC,EACH,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,GAAG,EAAE,CAAC,KAClE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,gBAAgB,GAAG,EAAE,EAAE,KAAK,CAAC,KAAK,CAqB/D,CAAA"}
@@ -0,0 +1,21 @@
1
+ import * as inspector from 'node:inspector';
2
+ import { IS_CI } from '@livestore/utils';
3
+ import { Duration, Effect, identity, Layer } from '@livestore/utils/effect';
4
+ import { OtelLiveDummy } from '@livestore/utils/node';
5
+ import { OtelLiveHttp } from "../node/mod.js";
6
+ export * from '@effect/vitest';
7
+ export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.url() !== undefined);
8
+ export const makeWithTestCtx = (ctxParams) => (testContext) => withTestCtx(testContext, ctxParams);
9
+ export const withTestCtx = (testContext, { suffix, makeLayer, timeout = IS_CI ? 60_000 : 10_000, forceOtel = false, } = {}) => (self) => {
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;
13
+ return self.pipe(DEBUGGER_ACTIVE
14
+ ? identity
15
+ : Effect.logWarnIfTakesLongerThan({
16
+ duration: Duration.toMillis(timeout) * 0.8,
17
+ 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 }));
20
+ };
21
+ //# sourceMappingURL=Vitest.js.map
@@ -0,0 +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,SAAS,EACT,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EACjC,SAAS,GAAG,KAAK,MAMf,EAAE,EACN,EAAE,CACJ,CACE,IAAmE,EACH,EAAE;IAClE,MAAM,QAAQ,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IACxG,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC,WAAW,CAAC,CAAA;IAEtC,MAAM,SAAS,GACb,eAAe,IAAI,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAA;IAElH,OAAO,IAAI,CAAC,IAAI,CACd,eAAe;QACb,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC;YAC9B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,GAAG;YAC1C,KAAK,EAAE,GAAG,QAAQ,kCAAkC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG;SAChF,CAAC,EACN,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EACpD,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EACzB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,EACpC,MAAM,CAAC,MAAM,EAAE,qFAAqF;IACpG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EACzB,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CACzB,CAAA;AACV,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=global.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/node-vitest/global.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ process.stdout.isTTY = true;
2
+ export {};
3
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/node-vitest/global.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAA"}
@@ -1,2 +1,3 @@
1
- export * as Vitest from '@effect/vitest';
1
+ import './global.ts';
2
+ export * as Vitest from './Vitest.ts';
2
3
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
@@ -1,2 +1,3 @@
1
- export * as Vitest from '@effect/vitest';
1
+ import "./global.js";
2
+ export * as Vitest from "./Vitest.js";
2
3
  //# sourceMappingURL=mod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,25 +1,24 @@
1
1
  {
2
2
  "name": "@livestore/utils-dev",
3
- "version": "0.3.2-dev.9",
3
+ "version": "0.4.0-dev.0",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
- "./dist/node-vitest/polyfill.js"
6
+ "./src/node-vitest/polyfill.ts"
7
7
  ],
8
8
  "exports": {
9
9
  "./node": "./dist/node/mod.js",
10
- "./node-vitest": "./dist/node-vitest/mod.js",
11
- "./node-vitest-polyfill": "./dist/node-vitest/polyfill.js"
10
+ "./node-vitest": "./dist/node-vitest/mod.js"
12
11
  },
13
12
  "dependencies": {
14
- "@effect/opentelemetry": "0.53.11",
15
- "@effect/vitest": "0.23.12",
13
+ "@effect/opentelemetry": "0.56.1",
14
+ "@effect/vitest": "0.25.0",
16
15
  "@opentelemetry/api": "1.9.0",
17
- "@opentelemetry/exporter-metrics-otlp-http": "0.200.0",
18
- "@opentelemetry/exporter-trace-otlp-http": "0.200.0",
19
- "@opentelemetry/sdk-metrics": "2.0.0",
20
- "@opentelemetry/sdk-trace-base": "2.0.0",
21
- "@opentelemetry/sdk-trace-node": "2.0.0",
22
- "@livestore/utils": "0.3.2-dev.9"
16
+ "@opentelemetry/exporter-metrics-otlp-http": "0.203.0",
17
+ "@opentelemetry/exporter-trace-otlp-http": "0.203.0",
18
+ "@opentelemetry/sdk-metrics": "2.0.1",
19
+ "@opentelemetry/sdk-trace-base": "2.0.1",
20
+ "@opentelemetry/sdk-trace-node": "2.0.1",
21
+ "@livestore/utils": "0.4.0-dev.0"
23
22
  },
24
23
  "devDependencies": {},
25
24
  "files": [
@@ -30,7 +29,10 @@
30
29
  "license": "Apache-2.0",
31
30
  "peerDependencies": {},
32
31
  "publishConfig": {
33
- "access": "public"
32
+ "access": "public",
33
+ "sideEffects": [
34
+ "./dist/node-vitest/polyfill.js"
35
+ ]
34
36
  },
35
37
  "scripts": {
36
38
  "test": "echo 'No tests for utils-dev'"
package/src/node/mod.ts CHANGED
@@ -3,7 +3,17 @@ import { performance } from 'node:perf_hooks'
3
3
  import * as OtelNodeSdk from '@effect/opentelemetry/NodeSdk'
4
4
  import { IS_BUN, isNonEmptyString, isNotUndefined, shouldNeverHappen } from '@livestore/utils'
5
5
  import type { CommandExecutor, PlatformError, Tracer } from '@livestore/utils/effect'
6
- import { Command, Config, Effect, identity, Layer, OtelTracer } from '@livestore/utils/effect'
6
+ import {
7
+ Command,
8
+ Config,
9
+ Effect,
10
+ FiberRef,
11
+ identity,
12
+ Layer,
13
+ LogLevel,
14
+ OtelTracer,
15
+ Schema,
16
+ } from '@livestore/utils/effect'
7
17
  import { OtelLiveDummy } from '@livestore/utils/node'
8
18
  import * as otel from '@opentelemetry/api'
9
19
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
@@ -65,7 +75,19 @@ export const OtelLiveHttp = ({
65
75
  new OTLPTraceExporter({ url: `${config.exporterUrl}/v1/traces`, headers: {} }),
66
76
  { scheduledDelayMillis: 50 },
67
77
  ),
68
- }))
78
+ })).pipe(
79
+ // If an OpenTelemetry backend is not available, the `OtelNodeSdk` layer
80
+ // will ignore the error when attempting to connect and emit a debug log
81
+ // stating the reason for the error (in this case `ECONNREFUSED`). This
82
+ // can cause problems for programs which rely on clean `stdout` (e.g.
83
+ // command-line applications). To remedy this, the below code sets the
84
+ // minimum log level `FiberRef` to `"None"` for the duration of the
85
+ // `OtelNodeSdk`'s layer constructor.
86
+ //
87
+ // This can likely be removed when Livestore is migrated to the Effect
88
+ // native Otlp exporters.
89
+ Layer.locally(FiberRef.currentMinimumLogLevel, LogLevel.None),
90
+ )
69
91
 
70
92
  const RootSpanLive = Layer.span(config.rootSpanName, {
71
93
  attributes: { config, ...rootSpanAttributes },
@@ -153,36 +175,54 @@ export const cmd: (
153
175
  options?:
154
176
  | {
155
177
  cwd?: string
178
+ stderr?: 'inherit' | 'pipe'
179
+ stdout?: 'inherit' | 'pipe'
156
180
  shell?: boolean
157
181
  env?: Record<string, string | undefined>
158
182
  }
159
183
  | undefined,
160
- ) => Effect.Effect<CommandExecutor.ExitCode, PlatformError.PlatformError, CommandExecutor.CommandExecutor> = Effect.fn(
161
- 'cmd',
162
- )(function* (commandInput, options) {
163
- const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set')
164
- const [command, ...args] = Array.isArray(commandInput) ? commandInput.filter(isNotUndefined) : commandInput.split(' ')
165
-
166
- const debugEnvStr = Object.entries(options?.env ?? {})
167
- .map(([key, value]) => `${key}='${value}' `)
168
- .join('')
169
- const commandDebugStr = debugEnvStr + [command, ...args].join(' ')
170
-
171
- yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'`)
172
- yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, cwd, command, args })
173
-
174
- return yield* Command.make(command!, ...args).pipe(
175
- // TODO don't forward abort signal to the command
176
- Command.stdin('inherit'), // Forward stdin to the command
177
- Command.stdout('inherit'), // Stream stdout to process.stdout
178
- Command.stderr('inherit'), // Stream stderr to process.stderr
179
- Command.workingDirectory(cwd),
180
- options?.shell ? Command.runInShell(true) : identity,
181
- Command.env(options?.env ?? {}),
182
- Command.exitCode,
183
- Effect.tap((exitCode) => (exitCode === 0 ? Effect.void : Effect.die(`${commandDebugStr} failed`))),
184
- )
185
- })
184
+ ) => Effect.Effect<CommandExecutor.ExitCode, PlatformError.PlatformError | CmdError, CommandExecutor.CommandExecutor> =
185
+ Effect.fn('cmd')(function* (commandInput, options) {
186
+ const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set')
187
+ const [command, ...args] = Array.isArray(commandInput)
188
+ ? commandInput.filter(isNotUndefined)
189
+ : commandInput.split(' ')
190
+
191
+ const debugEnvStr = Object.entries(options?.env ?? {})
192
+ .map(([key, value]) => `${key}='${value}' `)
193
+ .join('')
194
+ const subshellStr = options?.shell ? ' (in subshell)' : ''
195
+ const commandDebugStr = debugEnvStr + [command, ...args].join(' ')
196
+
197
+ yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'${subshellStr}`)
198
+ yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, cwd, command, args })
199
+
200
+ return yield* Command.make(command!, ...args).pipe(
201
+ // TODO don't forward abort signal to the command
202
+ Command.stdin('inherit'), // Forward stdin to the command
203
+ // inherit = Stream stdout to process.stdout, pipe = Stream stdout to process.stderr
204
+ Command.stdout(options?.stdout ?? 'inherit'),
205
+ // inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
206
+ Command.stderr(options?.stderr ?? 'inherit'),
207
+ Command.workingDirectory(cwd),
208
+ options?.shell ? Command.runInShell(true) : identity,
209
+ Command.env(options?.env ?? {}),
210
+ Command.exitCode,
211
+ Effect.tap((exitCode) =>
212
+ exitCode === 0
213
+ ? Effect.void
214
+ : Effect.fail(
215
+ CmdError.make({
216
+ command: command!,
217
+ args,
218
+ cwd,
219
+ env: options?.env ?? {},
220
+ stderr: options?.stderr ?? 'inherit',
221
+ }),
222
+ ),
223
+ ),
224
+ )
225
+ })
186
226
 
187
227
  export const cmdText: (
188
228
  commandInput: string | (string | undefined)[],
@@ -203,8 +243,9 @@ export const cmdText: (
203
243
  .join('')
204
244
 
205
245
  const commandDebugStr = debugEnvStr + [command, ...args].join(' ')
246
+ const subshellStr = options?.runInShell ? ' (in subshell)' : ''
206
247
 
207
- yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'`)
248
+ yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'${subshellStr}`)
208
249
  yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, command, cwd })
209
250
 
210
251
  return yield* Command.make(command!, ...args).pipe(
@@ -217,3 +258,11 @@ export const cmdText: (
217
258
  )
218
259
  },
219
260
  )
261
+
262
+ export class CmdError extends Schema.TaggedError<CmdError>()('CmdError', {
263
+ command: Schema.String,
264
+ args: Schema.Array(Schema.String),
265
+ cwd: Schema.String,
266
+ env: Schema.Record({ key: Schema.String, value: Schema.String.pipe(Schema.UndefinedOr) }),
267
+ stderr: Schema.Literal('inherit', 'pipe'),
268
+ }) {}
@@ -0,0 +1,62 @@
1
+ import * as inspector from 'node:inspector'
2
+ import type * as Vitest from '@effect/vitest'
3
+ import { IS_CI } from '@livestore/utils'
4
+ import { type Cause, Duration, Effect, identity, Layer, type OtelTracer, type Scope } from '@livestore/utils/effect'
5
+ import { OtelLiveDummy } from '@livestore/utils/node'
6
+ import { OtelLiveHttp } from '../node/mod.ts'
7
+
8
+ export * from '@effect/vitest'
9
+
10
+ export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.url() !== undefined)
11
+
12
+ export const makeWithTestCtx =
13
+ <R1 = never, E1 = never>(ctxParams: WithTestCtxParams<R1, E1>) =>
14
+ (testContext: Vitest.TestContext) =>
15
+ withTestCtx(testContext, ctxParams)
16
+
17
+ export type WithTestCtxParams<R1 = never, E1 = never> = {
18
+ suffix?: string
19
+ makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>
20
+ timeout?: Duration.DurationInput
21
+ forceOtel?: boolean
22
+ }
23
+
24
+ export const withTestCtx =
25
+ <R1 = never, E1 = never>(
26
+ testContext: Vitest.TestContext,
27
+ {
28
+ suffix,
29
+ makeLayer,
30
+ timeout = IS_CI ? 60_000 : 10_000,
31
+ forceOtel = false,
32
+ }: {
33
+ suffix?: string
34
+ makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>
35
+ timeout?: Duration.DurationInput
36
+ forceOtel?: boolean
37
+ } = {},
38
+ ) =>
39
+ <A, E>(
40
+ self: Effect.Effect<A, E, Scope.Scope | OtelTracer.OtelTracer | R1>,
41
+ ): Effect.Effect<A, E | Cause.TimeoutException | E1, Scope.Scope> => {
42
+ const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`
43
+ const layer = makeLayer?.(testContext)
44
+
45
+ const otelLayer =
46
+ DEBUGGER_ACTIVE || forceOtel ? OtelLiveHttp({ serviceName: 'vitest-runner', skipLogUrl: false }) : OtelLiveDummy
47
+
48
+ return self.pipe(
49
+ DEBUGGER_ACTIVE
50
+ ? identity
51
+ : Effect.logWarnIfTakesLongerThan({
52
+ duration: Duration.toMillis(timeout) * 0.8,
53
+ label: `${spanName} approaching timeout (timeout: ${Duration.format(timeout)})`,
54
+ }),
55
+ DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout),
56
+ Effect.provide(otelLayer),
57
+ Effect.provide(layer ?? Layer.empty),
58
+ Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
59
+ Effect.withSpan(spanName),
60
+ Effect.annotateLogs({ suffix }),
61
+ ) as any
62
+ }
@@ -1 +1,3 @@
1
- export * as Vitest from '@effect/vitest'
1
+ import './global.ts'
2
+
3
+ export * as Vitest from './Vitest.ts'
File without changes