@livestore/utils-dev 0.0.0-snapshot-fc0b067f7a1a4978217d597eb833d5651856ffc0 → 0.0.0-snapshot-e2791c1dd47e87a551d7e87838bfabada0da8857
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.json +1 -1
- package/dist/node/mod.d.ts +15 -2
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +24 -5
- package/dist/node/mod.js.map +1 -1
- package/package.json +2 -2
- package/src/node/mod.ts +52 -27
package/dist/node/mod.d.ts
CHANGED
|
@@ -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
|
package/dist/node/mod.d.ts.map
CHANGED
|
@@ -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;
|
|
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,EAAE,MAAM,yBAAyB,CAAA;AAEtG,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAM1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,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AA;AAEJ,eAAO,MAAM,OAAO,EAAE,CACpB,YAAY,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAC7C,OAAO,CAAC,EAAE;IACR,GAAG,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,CAwBtF,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, identity, Layer, 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';
|
|
@@ -100,7 +100,9 @@ export const getTracingBackendUrl = (span) => Effect.gen(function* () {
|
|
|
100
100
|
});
|
|
101
101
|
export const cmd = Effect.fn('cmd')(function* (commandInput, options) {
|
|
102
102
|
const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set');
|
|
103
|
-
const [command, ...args] = Array.isArray(commandInput)
|
|
103
|
+
const [command, ...args] = Array.isArray(commandInput)
|
|
104
|
+
? commandInput.filter(isNotUndefined)
|
|
105
|
+
: commandInput.split(' ');
|
|
104
106
|
const debugEnvStr = Object.entries(options?.env ?? {})
|
|
105
107
|
.map(([key, value]) => `${key}='${value}' `)
|
|
106
108
|
.join('');
|
|
@@ -110,9 +112,18 @@ export const cmd = Effect.fn('cmd')(function* (commandInput, options) {
|
|
|
110
112
|
return yield* Command.make(command, ...args).pipe(
|
|
111
113
|
// TODO don't forward abort signal to the command
|
|
112
114
|
Command.stdin('inherit'), // Forward stdin to the command
|
|
113
|
-
|
|
114
|
-
Command.
|
|
115
|
-
|
|
115
|
+
// inherit = Stream stdout to process.stdout, pipe = Stream stdout to process.stderr
|
|
116
|
+
Command.stdout(options?.stdout ?? 'inherit'),
|
|
117
|
+
// inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
|
|
118
|
+
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
|
|
119
|
+
? Effect.void
|
|
120
|
+
: Effect.fail(CmdError.make({
|
|
121
|
+
command: command,
|
|
122
|
+
args,
|
|
123
|
+
cwd,
|
|
124
|
+
env: options?.env ?? {},
|
|
125
|
+
stderr: options?.stderr ?? 'inherit',
|
|
126
|
+
}))));
|
|
116
127
|
});
|
|
117
128
|
export const cmdText = Effect.fn('cmdText')(function* (commandInput, options) {
|
|
118
129
|
const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set');
|
|
@@ -129,4 +140,12 @@ export const cmdText = Effect.fn('cmdText')(function* (commandInput, options) {
|
|
|
129
140
|
// inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
|
|
130
141
|
Command.stderr(options?.stderr ?? 'inherit'), Command.workingDirectory(cwd), options?.runInShell ? Command.runInShell(true) : identity, Command.env(options?.env ?? {}), Command.string);
|
|
131
142
|
});
|
|
143
|
+
export class CmdError extends Schema.TaggedError()('CmdError', {
|
|
144
|
+
command: Schema.String,
|
|
145
|
+
args: Schema.Array(Schema.String),
|
|
146
|
+
cwd: Schema.String,
|
|
147
|
+
env: Schema.Record({ key: Schema.String, value: Schema.String.pipe(Schema.UndefinedOr) }),
|
|
148
|
+
stderr: Schema.Literal('inherit', 'pipe'),
|
|
149
|
+
}) {
|
|
150
|
+
}
|
|
132
151
|
//# sourceMappingURL=mod.js.map
|
package/dist/node/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE9F,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,WAAW,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE9F,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACtG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,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AAY,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/utils-dev",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-e2791c1dd47e87a551d7e87838bfabada0da8857",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./dist/node-vitest/polyfill.js"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@opentelemetry/sdk-metrics": "2.0.1",
|
|
20
20
|
"@opentelemetry/sdk-trace-base": "2.0.1",
|
|
21
21
|
"@opentelemetry/sdk-trace-node": "2.0.1",
|
|
22
|
-
"@livestore/utils": "0.0.0-snapshot-
|
|
22
|
+
"@livestore/utils": "0.0.0-snapshot-e2791c1dd47e87a551d7e87838bfabada0da8857"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {},
|
|
25
25
|
"files": [
|
package/src/node/mod.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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 { Command, Config, Effect, identity, Layer, OtelTracer, Schema } from '@livestore/utils/effect'
|
|
7
7
|
import { OtelLiveDummy } from '@livestore/utils/node'
|
|
8
8
|
import * as otel from '@opentelemetry/api'
|
|
9
9
|
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
|
|
@@ -153,36 +153,53 @@ export const cmd: (
|
|
|
153
153
|
options?:
|
|
154
154
|
| {
|
|
155
155
|
cwd?: string
|
|
156
|
+
stderr?: 'inherit' | 'pipe'
|
|
157
|
+
stdout?: 'inherit' | 'pipe'
|
|
156
158
|
shell?: boolean
|
|
157
159
|
env?: Record<string, string | undefined>
|
|
158
160
|
}
|
|
159
161
|
| undefined,
|
|
160
|
-
) => Effect.Effect<CommandExecutor.ExitCode, PlatformError.PlatformError, CommandExecutor.CommandExecutor> =
|
|
161
|
-
'cmd',
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
162
|
+
) => Effect.Effect<CommandExecutor.ExitCode, PlatformError.PlatformError | CmdError, CommandExecutor.CommandExecutor> =
|
|
163
|
+
Effect.fn('cmd')(function* (commandInput, options) {
|
|
164
|
+
const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set')
|
|
165
|
+
const [command, ...args] = Array.isArray(commandInput)
|
|
166
|
+
? commandInput.filter(isNotUndefined)
|
|
167
|
+
: commandInput.split(' ')
|
|
168
|
+
|
|
169
|
+
const debugEnvStr = Object.entries(options?.env ?? {})
|
|
170
|
+
.map(([key, value]) => `${key}='${value}' `)
|
|
171
|
+
.join('')
|
|
172
|
+
const commandDebugStr = debugEnvStr + [command, ...args].join(' ')
|
|
173
|
+
|
|
174
|
+
yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'`)
|
|
175
|
+
yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, cwd, command, args })
|
|
176
|
+
|
|
177
|
+
return yield* Command.make(command!, ...args).pipe(
|
|
178
|
+
// TODO don't forward abort signal to the command
|
|
179
|
+
Command.stdin('inherit'), // Forward stdin to the command
|
|
180
|
+
// inherit = Stream stdout to process.stdout, pipe = Stream stdout to process.stderr
|
|
181
|
+
Command.stdout(options?.stdout ?? 'inherit'),
|
|
182
|
+
// inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
|
|
183
|
+
Command.stderr(options?.stderr ?? 'inherit'),
|
|
184
|
+
Command.workingDirectory(cwd),
|
|
185
|
+
options?.shell ? Command.runInShell(true) : identity,
|
|
186
|
+
Command.env(options?.env ?? {}),
|
|
187
|
+
Command.exitCode,
|
|
188
|
+
Effect.tap((exitCode) =>
|
|
189
|
+
exitCode === 0
|
|
190
|
+
? Effect.void
|
|
191
|
+
: Effect.fail(
|
|
192
|
+
CmdError.make({
|
|
193
|
+
command: command!,
|
|
194
|
+
args,
|
|
195
|
+
cwd,
|
|
196
|
+
env: options?.env ?? {},
|
|
197
|
+
stderr: options?.stderr ?? 'inherit',
|
|
198
|
+
}),
|
|
199
|
+
),
|
|
200
|
+
),
|
|
201
|
+
)
|
|
202
|
+
})
|
|
186
203
|
|
|
187
204
|
export const cmdText: (
|
|
188
205
|
commandInput: string | (string | undefined)[],
|
|
@@ -217,3 +234,11 @@ export const cmdText: (
|
|
|
217
234
|
)
|
|
218
235
|
},
|
|
219
236
|
)
|
|
237
|
+
|
|
238
|
+
export class CmdError extends Schema.TaggedError<CmdError>()('CmdError', {
|
|
239
|
+
command: Schema.String,
|
|
240
|
+
args: Schema.Array(Schema.String),
|
|
241
|
+
cwd: Schema.String,
|
|
242
|
+
env: Schema.Record({ key: Schema.String, value: Schema.String.pipe(Schema.UndefinedOr) }),
|
|
243
|
+
stderr: Schema.Literal('inherit', 'pipe'),
|
|
244
|
+
}) {}
|