@mannyc1/ts-release 0.0.0 → 0.0.2
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/ARCHITECTURE.md +53 -0
- package/README.md +243 -43
- package/SPEC.md +8 -1
- package/dist/cli/command.d.ts +1 -1
- package/dist/cli/command.d.ts.map +1 -1
- package/dist/cli/command.js +116 -33
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/main.js +3 -6
- package/dist/cli/main.js.map +1 -1
- package/dist/domain/evidence.d.ts +49 -3
- package/dist/domain/evidence.d.ts.map +1 -1
- package/dist/domain/evidence.js +43 -2
- package/dist/domain/evidence.js.map +1 -1
- package/dist/domain/operation.d.ts +56 -2
- package/dist/domain/operation.d.ts.map +1 -1
- package/dist/domain/operation.js +78 -2
- package/dist/domain/operation.js.map +1 -1
- package/dist/domain/release.d.ts +4 -4
- package/dist/domain/remote-state.d.ts +90 -0
- package/dist/domain/remote-state.d.ts.map +1 -0
- package/dist/domain/remote-state.js +85 -0
- package/dist/domain/remote-state.js.map +1 -0
- package/dist/domain/status.d.ts +43 -0
- package/dist/domain/status.d.ts.map +1 -0
- package/dist/domain/status.js +50 -0
- package/dist/domain/status.js.map +1 -0
- package/dist/domain/target.d.ts +63 -3
- package/dist/domain/target.d.ts.map +1 -1
- package/dist/domain/target.js +75 -5
- package/dist/domain/target.js.map +1 -1
- package/dist/host/host.d.ts +7 -23
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.js +3 -22
- package/dist/host/host.js.map +1 -1
- package/dist/host/http-live.d.ts +6 -0
- package/dist/host/http-live.d.ts.map +1 -0
- package/dist/host/http-live.js +82 -0
- package/dist/host/http-live.js.map +1 -0
- package/dist/host/http.d.ts +40 -0
- package/dist/host/http.d.ts.map +1 -0
- package/dist/host/http.js +56 -0
- package/dist/host/http.js.map +1 -0
- package/dist/host/platform.d.ts +10 -0
- package/dist/host/platform.d.ts.map +1 -0
- package/dist/host/platform.js +121 -0
- package/dist/host/platform.js.map +1 -0
- package/dist/host/test.d.ts +6 -3
- package/dist/host/test.d.ts.map +1 -1
- package/dist/host/test.js +111 -25
- package/dist/host/test.js.map +1 -1
- package/dist/planner/artifact-inventory.d.ts +9 -0
- package/dist/planner/artifact-inventory.d.ts.map +1 -0
- package/dist/planner/artifact-inventory.js +66 -0
- package/dist/planner/artifact-inventory.js.map +1 -0
- package/dist/planner/create-release-plan.d.ts +1 -1
- package/dist/planner/create-release-plan.d.ts.map +1 -1
- package/dist/planner/errors.d.ts +41 -3
- package/dist/planner/errors.d.ts.map +1 -1
- package/dist/planner/errors.js +35 -3
- package/dist/planner/errors.js.map +1 -1
- package/dist/planner/evidence-recorder.d.ts +16 -8
- package/dist/planner/evidence-recorder.d.ts.map +1 -1
- package/dist/planner/evidence-recorder.js +244 -17
- package/dist/planner/evidence-recorder.js.map +1 -1
- package/dist/planner/executor.d.ts +54 -15
- package/dist/planner/executor.d.ts.map +1 -1
- package/dist/planner/executor.js +117 -38
- package/dist/planner/executor.js.map +1 -1
- package/dist/planner/normalize-release.d.ts +2 -2
- package/dist/planner/normalize-release.d.ts.map +1 -1
- package/dist/planner/normalize-release.js +80 -42
- package/dist/planner/normalize-release.js.map +1 -1
- package/dist/planner/reconcile.d.ts +17 -0
- package/dist/planner/reconcile.d.ts.map +1 -0
- package/dist/planner/reconcile.js +280 -0
- package/dist/planner/reconcile.js.map +1 -0
- package/dist/planner/release-eligibility.d.ts +33 -0
- package/dist/planner/release-eligibility.d.ts.map +1 -0
- package/dist/planner/release-eligibility.js +172 -0
- package/dist/planner/release-eligibility.js.map +1 -0
- package/dist/planner/render-plan.d.ts.map +1 -1
- package/dist/planner/render-plan.js +30 -0
- package/dist/planner/render-plan.js.map +1 -1
- package/dist/planner/status.d.ts +40 -0
- package/dist/planner/status.d.ts.map +1 -0
- package/dist/planner/status.js +336 -0
- package/dist/planner/status.js.map +1 -0
- package/dist/runtime/bun.d.ts +9 -0
- package/dist/runtime/bun.d.ts.map +1 -0
- package/dist/runtime/bun.js +10 -0
- package/dist/runtime/bun.js.map +1 -0
- package/dist/targets/adapter-helpers.d.ts +31 -0
- package/dist/targets/adapter-helpers.d.ts.map +1 -0
- package/dist/targets/adapter-helpers.js +67 -0
- package/dist/targets/adapter-helpers.js.map +1 -0
- package/dist/targets/adapter.d.ts +3 -1
- package/dist/targets/adapter.d.ts.map +1 -1
- package/dist/targets/github.d.ts +2 -2
- package/dist/targets/github.d.ts.map +1 -1
- package/dist/targets/github.js +74 -83
- package/dist/targets/github.js.map +1 -1
- package/dist/targets/homebrew.d.ts +2 -2
- package/dist/targets/homebrew.d.ts.map +1 -1
- package/dist/targets/homebrew.js +45 -75
- package/dist/targets/homebrew.js.map +1 -1
- package/dist/targets/live.d.ts.map +1 -1
- package/dist/targets/live.js +10 -0
- package/dist/targets/live.js.map +1 -1
- package/dist/targets/npm.d.ts +2 -3
- package/dist/targets/npm.d.ts.map +1 -1
- package/dist/targets/npm.js +90 -55
- package/dist/targets/npm.js.map +1 -1
- package/dist/targets/pypi.d.ts +11 -0
- package/dist/targets/pypi.d.ts.map +1 -0
- package/dist/targets/pypi.js +115 -0
- package/dist/targets/pypi.js.map +1 -0
- package/dist/targets/registry.d.ts +3 -3
- package/dist/targets/registry.d.ts.map +1 -1
- package/dist/targets/scoop.d.ts +11 -0
- package/dist/targets/scoop.d.ts.map +1 -0
- package/dist/targets/scoop.js +93 -0
- package/dist/targets/scoop.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/workflows/config.d.ts +81 -0
- package/dist/workflows/config.d.ts.map +1 -0
- package/dist/workflows/config.js +191 -0
- package/dist/workflows/config.js.map +1 -0
- package/dist/workflows/evidence.d.ts +21 -0
- package/dist/workflows/evidence.d.ts.map +1 -0
- package/dist/workflows/evidence.js +45 -0
- package/dist/workflows/evidence.js.map +1 -0
- package/dist/workflows/live.d.ts +7 -0
- package/dist/workflows/live.d.ts.map +1 -0
- package/dist/workflows/live.js +5 -0
- package/dist/workflows/live.js.map +1 -0
- package/examples/README.md +20 -3
- package/examples/github-release/release.config.json +2 -1
- package/examples/multi-target/artifacts/release-example-multi-target-0.1.0.tgz +1 -0
- package/examples/multi-target/index.js +1 -0
- package/examples/multi-target/package.json +7 -0
- package/examples/multi-target/release.config.json +67 -0
- package/examples/non-strict-skips/release.config.json +1 -0
- package/examples/npm-first-publish/release.config.json +32 -0
- package/examples/npm-only/release.config.json +6 -1
- package/examples/pypi-registry/artifacts/release_example_pypi-0.1.0-py3-none-any.whl +1 -0
- package/examples/pypi-registry/release.config.json +30 -0
- package/examples/scoop-bucket/artifacts/release-example-scoop-0.1.0.zip +1 -0
- package/examples/scoop-bucket/release.config.json +36 -0
- package/package.json +48 -9
- package/dist/cli/programmatic.d.ts +0 -25
- package/dist/cli/programmatic.d.ts.map +0 -1
- package/dist/cli/programmatic.js +0 -48
- package/dist/cli/programmatic.js.map +0 -1
- package/dist/host/bun.d.ts +0 -9
- package/dist/host/bun.d.ts.map +0 -1
- package/dist/host/bun.js +0 -156
- package/dist/host/bun.js.map +0 -1
package/dist/host/host.d.ts
CHANGED
|
@@ -2,22 +2,13 @@ import * as Context from "effect/Context";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
|
-
import { ChecksumAlgorithm } from "../domain/artifact.js";
|
|
6
5
|
import { CommandSpec } from "../domain/operation.js";
|
|
7
6
|
export type * from "../types/effect-internal.js";
|
|
8
|
-
declare const
|
|
7
|
+
declare const CommandRunnerError_base: Schema.Class<CommandRunnerError, Schema.TaggedStruct<"CommandRunnerError", {
|
|
9
8
|
readonly operation: Schema.String;
|
|
10
|
-
readonly path: Schema.optionalKey<Schema.String>;
|
|
11
9
|
readonly reason: Schema.String;
|
|
12
10
|
}>, import("effect/Cause").YieldableError>;
|
|
13
|
-
export declare class
|
|
14
|
-
}
|
|
15
|
-
declare const FileInfo_base: Schema.Class<FileInfo, Schema.Struct<{
|
|
16
|
-
readonly path: Schema.String;
|
|
17
|
-
readonly sizeBytes: Schema.Number;
|
|
18
|
-
readonly kind: Schema.Literals<readonly ["file", "directory", "other"]>;
|
|
19
|
-
}>, {}>;
|
|
20
|
-
export declare class FileInfo extends FileInfo_base {
|
|
11
|
+
export declare class CommandRunnerError extends CommandRunnerError_base {
|
|
21
12
|
}
|
|
22
13
|
declare const CommandResult_base: Schema.Class<CommandResult, Schema.Struct<{
|
|
23
14
|
readonly command: typeof CommandSpec;
|
|
@@ -30,18 +21,11 @@ declare const CommandResult_base: Schema.Class<CommandResult, Schema.Struct<{
|
|
|
30
21
|
}>, {}>;
|
|
31
22
|
export declare class CommandResult extends CommandResult_base {
|
|
32
23
|
}
|
|
33
|
-
export interface
|
|
34
|
-
readonly
|
|
35
|
-
readonly writeFileString: (path: string, contents: string) => Effect.Effect<void, HostError>;
|
|
36
|
-
readonly stat: (path: string) => Effect.Effect<FileInfo, HostError>;
|
|
37
|
-
readonly hashFile: (path: string, algorithm: ChecksumAlgorithm) => Effect.Effect<string, HostError>;
|
|
38
|
-
readonly readEnv: (name: string) => Effect.Effect<string | undefined, never>;
|
|
39
|
-
readonly runCommand: (command: CommandSpec) => Effect.Effect<CommandResult, HostError>;
|
|
40
|
-
readonly now: Effect.Effect<string, never>;
|
|
24
|
+
export interface ReleaseCommandRunnerShape {
|
|
25
|
+
readonly runCommand: (command: CommandSpec) => Effect.Effect<CommandResult, CommandRunnerError>;
|
|
41
26
|
}
|
|
42
|
-
declare const
|
|
43
|
-
export declare class
|
|
27
|
+
declare const ReleaseCommandRunner_base: Context.ServiceClass<ReleaseCommandRunner, "ReleaseCommandRunner", ReleaseCommandRunnerShape>;
|
|
28
|
+
export declare class ReleaseCommandRunner extends ReleaseCommandRunner_base {
|
|
44
29
|
}
|
|
45
|
-
export declare const
|
|
46
|
-
export declare const missingEnvNames: (command: CommandSpec) => Effect.Effect<string[], never, ReleaseHost>;
|
|
30
|
+
export declare const ReleaseCommandRunnerTestLayer: (commandRunner: ReleaseCommandRunnerShape) => Layer.Layer<ReleaseCommandRunner>;
|
|
47
31
|
//# sourceMappingURL=host.d.ts.map
|
package/dist/host/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/host/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/host/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,mBAAmB,6BAA6B,CAAA;;;;;AAEhD,qBAAa,kBAAmB,SAAQ,uBAGtC;CAAG;;;;;;;;;;AAEL,qBAAa,aAAc,SAAQ,kBAQjC;CAAG;AAEL,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAA;CAChG;;AAED,qBAAa,oBAAqB,SAAQ,yBAGf;CAAG;AAE9B,eAAO,MAAM,6BAA6B,GACxC,eAAe,yBAAyB,KACvC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CACiB,CAAA"}
|
package/dist/host/host.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
2
|
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Schema from "effect/Schema";
|
|
5
4
|
import { CommandSpec } from "../domain/operation.js";
|
|
6
|
-
export class
|
|
5
|
+
export class CommandRunnerError extends Schema.TaggedErrorClass()("CommandRunnerError", {
|
|
7
6
|
operation: Schema.String,
|
|
8
|
-
path: Schema.optionalKey(Schema.String),
|
|
9
7
|
reason: Schema.String
|
|
10
8
|
}) {
|
|
11
9
|
}
|
|
12
|
-
export class FileInfo extends Schema.Class("FileInfo")({
|
|
13
|
-
path: Schema.String,
|
|
14
|
-
sizeBytes: Schema.Number,
|
|
15
|
-
kind: Schema.Literals(["file", "directory", "other"])
|
|
16
|
-
}) {
|
|
17
|
-
}
|
|
18
10
|
export class CommandResult extends Schema.Class("CommandResult")({
|
|
19
11
|
command: CommandSpec,
|
|
20
12
|
exitCode: Schema.Number,
|
|
@@ -25,18 +17,7 @@ export class CommandResult extends Schema.Class("CommandResult")({
|
|
|
25
17
|
durationMillis: Schema.Number
|
|
26
18
|
}) {
|
|
27
19
|
}
|
|
28
|
-
export class
|
|
20
|
+
export class ReleaseCommandRunner extends Context.Service()("ReleaseCommandRunner") {
|
|
29
21
|
}
|
|
30
|
-
export const
|
|
31
|
-
export const missingEnvNames = Effect.fn("missingEnvNames")(function* (command) {
|
|
32
|
-
const host = yield* ReleaseHost;
|
|
33
|
-
const missing = [];
|
|
34
|
-
for (const name of command.requiredEnv) {
|
|
35
|
-
const value = yield* host.readEnv(name);
|
|
36
|
-
if (value === undefined) {
|
|
37
|
-
missing.push(name);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return missing;
|
|
41
|
-
});
|
|
22
|
+
export const ReleaseCommandRunnerTestLayer = (commandRunner) => Layer.succeed(ReleaseCommandRunner)(commandRunner);
|
|
42
23
|
//# sourceMappingURL=host.js.map
|
package/dist/host/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/host/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/host/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIpD,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,gBAAgB,EAAsB,CAAC,oBAAoB,EAAE;IAC1G,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC;CAAG;AAEL,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,KAAK,CAAgB,eAAe,CAAC,CAAC;IAC9E,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM;CAC9B,CAAC;CAAG;AAML,MAAM,OAAO,oBAAqB,SAAQ,OAAO,CAAC,OAAO,EAGtD,CAAC,sBAAsB,CAAC;CAAG;AAE9B,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,aAAwC,EACL,EAAE,CACrC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,aAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
3
|
+
import { ReleaseHttp } from "./http.js";
|
|
4
|
+
export type * from "../types/effect-internal.js";
|
|
5
|
+
export declare const LiveReleaseHttpLayer: Layer.Layer<ReleaseHttp, never, HttpClient.HttpClient>;
|
|
6
|
+
//# sourceMappingURL=http-live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-live.d.ts","sourceRoot":"","sources":["../../src/host/http-live.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAG7D,OAAO,EAAyB,WAAW,EAAE,MAAM,WAAW,CAAA;AAE9D,mBAAmB,6BAA6B,CAAA;AAsDhD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CA4CrF,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as Config from "effect/Config";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
6
|
+
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
7
|
+
import { HttpError, HttpResult, ReleaseHttp } from "./http.js";
|
|
8
|
+
const formatUnknown = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
9
|
+
const nowIso = Effect.fn("http.nowIso")(function* () {
|
|
10
|
+
const millis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
|
|
11
|
+
return new Date(millis).toISOString();
|
|
12
|
+
});
|
|
13
|
+
const readOptionalEnv = (name) => Config.string(name).pipe(Effect.option, Effect.map(Option.getOrUndefined));
|
|
14
|
+
const resolveHeaders = Effect.fn("resolveHeaders")(function* (request) {
|
|
15
|
+
const envNames = new Set([
|
|
16
|
+
...request.requiredEnv,
|
|
17
|
+
...request.envHeaders.map((header) => header.valueEnv)
|
|
18
|
+
]);
|
|
19
|
+
const env = new Map();
|
|
20
|
+
const missing = [];
|
|
21
|
+
for (const name of envNames) {
|
|
22
|
+
const value = yield* readOptionalEnv(name);
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
missing.push(name);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
env.set(name, value);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (missing.length > 0) {
|
|
31
|
+
return yield* Effect.fail(HttpError.make({
|
|
32
|
+
operation: "resolveHeaders",
|
|
33
|
+
url: request.url,
|
|
34
|
+
reason: `Missing required environment variables: ${missing.join(", ")}`
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
const headers = {};
|
|
38
|
+
for (const header of request.headers) {
|
|
39
|
+
headers[header.name] = header.value;
|
|
40
|
+
}
|
|
41
|
+
for (const header of request.envHeaders) {
|
|
42
|
+
const value = env.get(header.valueEnv);
|
|
43
|
+
if (value !== undefined) {
|
|
44
|
+
headers[header.name] = `${header.prefix ?? ""}${value}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return headers;
|
|
48
|
+
});
|
|
49
|
+
export const LiveReleaseHttpLayer = Layer.effect(ReleaseHttp)(Effect.gen(function* () {
|
|
50
|
+
const client = yield* HttpClient.HttpClient;
|
|
51
|
+
return {
|
|
52
|
+
runJson: (request) => Effect.gen(function* () {
|
|
53
|
+
const headers = yield* resolveHeaders(request);
|
|
54
|
+
const startedAt = yield* nowIso();
|
|
55
|
+
const started = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
|
|
56
|
+
const httpRequest = HttpClientRequest.make(request.method)(request.url, { headers });
|
|
57
|
+
const response = yield* client.execute(httpRequest).pipe(Effect.mapError((error) => HttpError.make({
|
|
58
|
+
operation: "execute",
|
|
59
|
+
url: request.url,
|
|
60
|
+
reason: formatUnknown(error)
|
|
61
|
+
})));
|
|
62
|
+
const json = request.method === "HEAD"
|
|
63
|
+
? null
|
|
64
|
+
: yield* response.json.pipe(Effect.mapError((error) => HttpError.make({
|
|
65
|
+
operation: "json",
|
|
66
|
+
url: request.url,
|
|
67
|
+
reason: formatUnknown(error)
|
|
68
|
+
})));
|
|
69
|
+
const endedAt = yield* nowIso();
|
|
70
|
+
const ended = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
|
|
71
|
+
return HttpResult.make({
|
|
72
|
+
request,
|
|
73
|
+
status: response.status,
|
|
74
|
+
json,
|
|
75
|
+
startedAt,
|
|
76
|
+
endedAt,
|
|
77
|
+
durationMillis: Math.max(0, ended - started)
|
|
78
|
+
});
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
}));
|
|
82
|
+
//# sourceMappingURL=http-live.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-live.js","sourceRoot":"","sources":["../../src/host/http-live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAC7D,OAAO,KAAK,iBAAiB,MAAM,wCAAwC,CAAA;AAE3E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAI9D,MAAM,aAAa,GAAG,CAAC,KAAc,EAAU,EAAE,CAC/C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAExD,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAA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0,0 +1,40 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { HttpRequestSpec } from "../domain/operation.js";
|
|
6
|
+
export type * from "../types/effect-internal.js";
|
|
7
|
+
declare const HttpError_base: Schema.Class<HttpError, Schema.TaggedStruct<"HttpError", {
|
|
8
|
+
readonly operation: Schema.String;
|
|
9
|
+
readonly url: Schema.String;
|
|
10
|
+
readonly reason: Schema.String;
|
|
11
|
+
}>, import("effect/Cause").YieldableError>;
|
|
12
|
+
export declare class HttpError extends HttpError_base {
|
|
13
|
+
}
|
|
14
|
+
declare const HttpResult_base: Schema.Class<HttpResult, Schema.Struct<{
|
|
15
|
+
readonly request: typeof HttpRequestSpec;
|
|
16
|
+
readonly status: Schema.Number;
|
|
17
|
+
readonly json: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
18
|
+
readonly startedAt: Schema.String;
|
|
19
|
+
readonly endedAt: Schema.String;
|
|
20
|
+
readonly durationMillis: Schema.Number;
|
|
21
|
+
}>, {}>;
|
|
22
|
+
export declare class HttpResult extends HttpResult_base {
|
|
23
|
+
}
|
|
24
|
+
export interface ReleaseHttpShape {
|
|
25
|
+
readonly runJson: (request: HttpRequestSpec) => Effect.Effect<HttpResult, HttpError>;
|
|
26
|
+
}
|
|
27
|
+
declare const ReleaseHttp_base: Context.ServiceClass<ReleaseHttp, "ReleaseHttp", ReleaseHttpShape>;
|
|
28
|
+
export declare class ReleaseHttp extends ReleaseHttp_base {
|
|
29
|
+
}
|
|
30
|
+
export interface TestHttpResponse {
|
|
31
|
+
readonly status: number;
|
|
32
|
+
readonly json: Schema.Json;
|
|
33
|
+
}
|
|
34
|
+
export interface TestReleaseHttpOptions {
|
|
35
|
+
readonly responses?: ReadonlyMap<string, TestHttpResponse> | undefined;
|
|
36
|
+
readonly timestamps?: ReadonlyArray<string> | undefined;
|
|
37
|
+
}
|
|
38
|
+
export declare const httpRequestKey: (request: HttpRequestSpec) => string;
|
|
39
|
+
export declare const makeTestReleaseHttpLayer: (options?: TestReleaseHttpOptions) => Layer.Layer<ReleaseHttp>;
|
|
40
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/host/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,mBAAmB,6BAA6B,CAAA;;;;;;AAEhD,qBAAa,SAAU,SAAQ,cAI7B;CAAG;;;;;;;;;AAEL,qBAAa,UAAW,SAAQ,eAO9B;CAAG;AAEL,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;CACrF;;AAED,qBAAa,WAAY,SAAQ,gBAA+D;CAAG;AAEnG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAA;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS,CAAA;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CACxD;AAED,eAAO,MAAM,cAAc,GAAI,SAAS,eAAe,KAAG,MACjB,CAAA;AAEzC,eAAO,MAAM,wBAAwB,GACnC,UAAS,sBAA2B,KACnC,KAAK,CAAC,KAAK,CAAC,WAAW,CAoCzB,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { HttpRequestSpec } from "../domain/operation.js";
|
|
6
|
+
export class HttpError extends Schema.TaggedErrorClass()("HttpError", {
|
|
7
|
+
operation: Schema.String,
|
|
8
|
+
url: Schema.String,
|
|
9
|
+
reason: Schema.String
|
|
10
|
+
}) {
|
|
11
|
+
}
|
|
12
|
+
export class HttpResult extends Schema.Class("HttpResult")({
|
|
13
|
+
request: HttpRequestSpec,
|
|
14
|
+
status: Schema.Number,
|
|
15
|
+
json: Schema.Json,
|
|
16
|
+
startedAt: Schema.String,
|
|
17
|
+
endedAt: Schema.String,
|
|
18
|
+
durationMillis: Schema.Number
|
|
19
|
+
}) {
|
|
20
|
+
}
|
|
21
|
+
export class ReleaseHttp extends Context.Service()("ReleaseHttp") {
|
|
22
|
+
}
|
|
23
|
+
export const httpRequestKey = (request) => `${request.method}\u0000${request.url}`;
|
|
24
|
+
export const makeTestReleaseHttpLayer = (options = {}) => {
|
|
25
|
+
const responses = new Map(options.responses ?? []);
|
|
26
|
+
const timestamps = [...(options.timestamps ?? ["2026-06-16T00:00:00.000Z"])];
|
|
27
|
+
let timestampIndex = 0;
|
|
28
|
+
const nextTimestamp = () => {
|
|
29
|
+
const value = timestamps[timestampIndex] ?? timestamps[timestamps.length - 1] ?? "2026-06-16T00:00:00.000Z";
|
|
30
|
+
timestampIndex += 1;
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
33
|
+
return Layer.succeed(ReleaseHttp)({
|
|
34
|
+
runJson: (request) => Effect.gen(function* () {
|
|
35
|
+
const startedAt = nextTimestamp();
|
|
36
|
+
const response = responses.get(httpRequestKey(request));
|
|
37
|
+
if (response === undefined) {
|
|
38
|
+
return yield* Effect.fail(HttpError.make({
|
|
39
|
+
operation: "runJson",
|
|
40
|
+
url: request.url,
|
|
41
|
+
reason: "No test HTTP response configured"
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
const endedAt = nextTimestamp();
|
|
45
|
+
return HttpResult.make({
|
|
46
|
+
request,
|
|
47
|
+
status: response.status,
|
|
48
|
+
json: response.json,
|
|
49
|
+
startedAt,
|
|
50
|
+
endedAt,
|
|
51
|
+
durationMillis: 0
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/host/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,gBAAgB,EAAa,CAAC,WAAW,EAAE;IAC/E,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC;CAAG;AAEL,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,KAAK,CAAa,YAAY,CAAC,CAAC;IACrE,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM;CAC9B,CA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C,CAAC,CACH,CAAA;YACH,CAAC;YACD,MAAM,OAAO,GAAG,aAAa,EAAE,CAAA;YAC/B,OAAO,UAAU,CAAC,IAAI,CAAC;gBACrB,OAAO;gBACP,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,SAAS;gBACT,OAAO;gBACP,cAAc,EAAE,CAAC;aAClB,CAAC,CAAA;QACJ,CAAC,CAAC;KACL,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
3
|
+
import { ReleaseCommandRunner } from "./host.js";
|
|
4
|
+
export type * from "../types/effect-internal.js";
|
|
5
|
+
export interface PlatformCommandRunnerOptions {
|
|
6
|
+
readonly root?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const makePlatformCommandRunnerLayer: (options?: PlatformCommandRunnerOptions) => Layer.Layer<ReleaseCommandRunner, never, ChildProcessSpawner>;
|
|
9
|
+
export declare const PlatformCommandRunnerLayer: Layer.Layer<ReleaseCommandRunner, never, ChildProcessSpawner>;
|
|
10
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/host/platform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAEjF,OAAO,EAAqC,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEnF,mBAAmB,6BAA6B,CAAA;AAEhD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC;AAoFD,eAAO,MAAM,8BAA8B,GACzC,UAAS,4BAAiC,KACzC,KAAK,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,EAAE,mBAAmB,CAyD5D,CAAA;AAEH,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,KAAK,CAClD,oBAAoB,EACpB,KAAK,EACL,mBAAmB,CACe,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as Config from "effect/Config";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
6
|
+
import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
7
|
+
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
8
|
+
import { CommandResult, CommandRunnerError, ReleaseCommandRunner } from "./host.js";
|
|
9
|
+
const inheritedEnvNames = [
|
|
10
|
+
"PATH",
|
|
11
|
+
"HOME",
|
|
12
|
+
"USERPROFILE",
|
|
13
|
+
"SystemRoot",
|
|
14
|
+
"TEMP",
|
|
15
|
+
"TMP",
|
|
16
|
+
"CI",
|
|
17
|
+
"GITHUB_ACTIONS",
|
|
18
|
+
"GITHUB_API_URL",
|
|
19
|
+
"GITHUB_EVENT_NAME",
|
|
20
|
+
"GITHUB_GRAPHQL_URL",
|
|
21
|
+
"GITHUB_REF",
|
|
22
|
+
"GITHUB_REF_NAME",
|
|
23
|
+
"GITHUB_REF_TYPE",
|
|
24
|
+
"GITHUB_REPOSITORY",
|
|
25
|
+
"GITHUB_REPOSITORY_ID",
|
|
26
|
+
"GITHUB_REPOSITORY_OWNER",
|
|
27
|
+
"GITHUB_REPOSITORY_OWNER_ID",
|
|
28
|
+
"GITHUB_RUN_ATTEMPT",
|
|
29
|
+
"GITHUB_RUN_ID",
|
|
30
|
+
"GITHUB_RUN_NUMBER",
|
|
31
|
+
"GITHUB_SERVER_URL",
|
|
32
|
+
"GITHUB_SHA",
|
|
33
|
+
"GITHUB_WORKFLOW",
|
|
34
|
+
"GITHUB_WORKFLOW_REF",
|
|
35
|
+
"GITHUB_WORKFLOW_SHA",
|
|
36
|
+
"RUNNER_ENVIRONMENT",
|
|
37
|
+
"RUNNER_OS"
|
|
38
|
+
];
|
|
39
|
+
const formatUnknown = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
40
|
+
const readOptionalEnv = (name) => Config.string(name).pipe(Effect.option, Effect.map(Option.getOrUndefined));
|
|
41
|
+
const commandEnv = Effect.fn("platform.commandEnv")(function* (command) {
|
|
42
|
+
const names = new Set([
|
|
43
|
+
...inheritedEnvNames,
|
|
44
|
+
...command.requiredEnv
|
|
45
|
+
]);
|
|
46
|
+
const env = {};
|
|
47
|
+
for (const name of names) {
|
|
48
|
+
const value = yield* readOptionalEnv(name);
|
|
49
|
+
if (value !== undefined) {
|
|
50
|
+
env[name] = value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return env;
|
|
54
|
+
});
|
|
55
|
+
const validateEnv = (command) => Effect.gen(function* () {
|
|
56
|
+
const missing = [];
|
|
57
|
+
for (const name of command.requiredEnv) {
|
|
58
|
+
const value = yield* readOptionalEnv(name);
|
|
59
|
+
if (value === undefined) {
|
|
60
|
+
missing.push(name);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (missing.length > 0) {
|
|
64
|
+
return yield* Effect.fail(CommandRunnerError.make({
|
|
65
|
+
operation: "runCommand",
|
|
66
|
+
reason: `Missing required environment variables: ${missing.join(", ")}`
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const nowIso = Effect.fn("platform.nowIso")(function* () {
|
|
71
|
+
const millis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
|
|
72
|
+
return new Date(millis).toISOString();
|
|
73
|
+
});
|
|
74
|
+
const commandOutput = (stream) => Stream.mkString(Stream.decodeText(stream));
|
|
75
|
+
export const makePlatformCommandRunnerLayer = (options = {}) => Layer.effect(ReleaseCommandRunner)(Effect.gen(function* () {
|
|
76
|
+
const spawner = yield* ChildProcessSpawner;
|
|
77
|
+
const commandCwd = (command) => command.cwd === undefined
|
|
78
|
+
? options.root
|
|
79
|
+
: command.cwd;
|
|
80
|
+
return {
|
|
81
|
+
runCommand: (command) => Effect.gen(function* () {
|
|
82
|
+
yield* validateEnv(command);
|
|
83
|
+
const startedAt = yield* nowIso();
|
|
84
|
+
const startedMillis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
|
|
85
|
+
const env = yield* commandEnv(command);
|
|
86
|
+
const cwd = commandCwd(command);
|
|
87
|
+
const childCommand = ChildProcess.make(command.executable, command.args, {
|
|
88
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
89
|
+
env,
|
|
90
|
+
extendEnv: false,
|
|
91
|
+
stdin: "ignore",
|
|
92
|
+
stdout: "pipe",
|
|
93
|
+
stderr: "pipe"
|
|
94
|
+
});
|
|
95
|
+
const output = yield* Effect.scoped(Effect.gen(function* () {
|
|
96
|
+
const handle = yield* spawner.spawn(childCommand);
|
|
97
|
+
return yield* Effect.all({
|
|
98
|
+
stdout: commandOutput(handle.stdout),
|
|
99
|
+
stderr: commandOutput(handle.stderr),
|
|
100
|
+
exitCode: handle.exitCode
|
|
101
|
+
}, { concurrency: "unbounded" });
|
|
102
|
+
})).pipe(Effect.mapError((cause) => CommandRunnerError.make({
|
|
103
|
+
operation: "runCommand",
|
|
104
|
+
reason: formatUnknown(cause)
|
|
105
|
+
})));
|
|
106
|
+
const endedAt = yield* nowIso();
|
|
107
|
+
const endedMillis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
|
|
108
|
+
return CommandResult.make({
|
|
109
|
+
command,
|
|
110
|
+
exitCode: Number(output.exitCode),
|
|
111
|
+
stdout: output.stdout,
|
|
112
|
+
stderr: output.stderr,
|
|
113
|
+
startedAt,
|
|
114
|
+
endedAt,
|
|
115
|
+
durationMillis: Math.max(0, endedMillis - startedMillis)
|
|
116
|
+
});
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
}));
|
|
120
|
+
export const PlatformCommandRunnerLayer = makePlatformCommandRunnerLayer();
|
|
121
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/host/platform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,YAAY,MAAM,sCAAsC,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAEjF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAQnF,MAAM,iBAAiB,GAAG;IACxB,MAAM;IACN,MAAM;IACN,aAAa;IACb,YAAY;IACZ,MAAM;IACN,KAAK;IACL,IAAI;IACJ,gBAAgB;IAChB,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;IACnB,sBAAsB;IACtB,yBAAyB;IACzB,4BAA4B;IAC5B,oBAAoB;IACpB,eAAe;IACf,mBAAmB;IACnB,mBAAmB;IACnB,YAAY;IACZ,iBAAiB;IACjB,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;IACpB,WAAW;CACZ,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,KAAc,EAAU,EAAE,CAC/C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAExD,MAAM,eAAe,GAAG,CAAC,IAAY,EAAqC,EAAE,CAC1E,MAAM,CAAC,MAAM,CAAC,IAAI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AAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;YAC/E,OAAO,aAAa,CAAC,IAAI,CAAC;gBACxB,OAAO;gBACP,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACjC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS;gBACT,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC;aACzD,CAAC,CAAA;QACJ,CAAC,CAAC;KACL,CAAA;AACH,CAAC,CAAC,CACH,CAAA;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAInC,8BAA8B,EAAE,CAAA"}
|
package/dist/host/test.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import * as Crypto from "effect/Crypto";
|
|
2
|
+
import * as FileSystem from "effect/FileSystem";
|
|
1
3
|
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Path from "effect/Path";
|
|
2
5
|
import { CommandSpec } from "../domain/operation.js";
|
|
3
|
-
import {
|
|
6
|
+
import { ReleaseCommandRunner } from "./host.js";
|
|
4
7
|
export type * from "../types/effect-internal.js";
|
|
5
8
|
export interface TestCommandResponse {
|
|
6
9
|
readonly exitCode: number;
|
|
7
10
|
readonly stdout: string;
|
|
8
11
|
readonly stderr: string;
|
|
9
12
|
}
|
|
10
|
-
export interface
|
|
13
|
+
export interface TestCommandRunnerOptions {
|
|
11
14
|
readonly files?: ReadonlyMap<string, string> | undefined;
|
|
12
15
|
readonly directories?: ReadonlySet<string> | undefined;
|
|
13
16
|
readonly env?: ReadonlyMap<string, string> | undefined;
|
|
@@ -15,5 +18,5 @@ export interface TestReleaseHostOptions {
|
|
|
15
18
|
readonly timestamps?: ReadonlyArray<string> | undefined;
|
|
16
19
|
}
|
|
17
20
|
export declare const commandKey: (command: CommandSpec) => string;
|
|
18
|
-
export declare const
|
|
21
|
+
export declare const makeTestCommandRunnerLayer: (options?: TestCommandRunnerOptions) => Layer.Layer<FileSystem.FileSystem | Path.Path | ReleaseCommandRunner | Crypto.Crypto, never, never>;
|
|
19
22
|
//# sourceMappingURL=test.d.ts.map
|
package/dist/host/test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/host/test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/host/test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAqC,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEnF,mBAAmB,6BAA6B,CAAA;AAEhD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;IACxD,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IACtD,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;I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