@leitwerk-dev/test-support 0.2.0 → 0.2.1
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/{chunk-7I4OCTF3.js → chunk-2PCDTYVH.js} +7 -2
- package/dist/chunk-2PCDTYVH.js.map +1 -0
- package/dist/{chunk-KPSK7EMY.js → chunk-5BZSJ4OO.js} +22 -157
- package/dist/chunk-5BZSJ4OO.js.map +1 -0
- package/dist/{chunk-2IICIB6D.js → chunk-ECAWLVYB.js} +38 -4
- package/dist/chunk-ECAWLVYB.js.map +1 -0
- package/dist/{chunk-JUH3LUYK.js → chunk-EXHTWQAE.js} +5 -1
- package/dist/chunk-EXHTWQAE.js.map +1 -0
- package/dist/compact-process-detail-fixture.d.ts +3 -0
- package/dist/compact-process-detail-fixture.d.ts.map +1 -1
- package/dist/fakes/fake-git-ops.d.ts +12 -0
- package/dist/fakes/fake-git-ops.d.ts.map +1 -1
- package/dist/fakes/fake-llm.d.ts +11 -0
- package/dist/fakes/fake-llm.d.ts.map +1 -1
- package/dist/fakes/index.d.ts +1 -1
- package/dist/fakes/index.d.ts.map +1 -1
- package/dist/fakes/index.js +105 -4
- package/dist/fakes/index.js.map +1 -1
- package/dist/fixtures.js +104 -2
- package/dist/fixtures.js.map +1 -1
- package/dist/http-launch.d.ts +2 -1
- package/dist/http-launch.d.ts.map +1 -1
- package/dist/index.d.ts +23 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -53
- package/dist/index.js.map +1 -1
- package/dist/integration-harness.d.ts +36 -1
- package/dist/integration-harness.d.ts.map +1 -1
- package/dist/integration.d.ts +2 -3
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +131 -13
- package/dist/integration.js.map +1 -1
- package/dist/local-git.d.ts +105 -8
- package/dist/local-git.d.ts.map +1 -1
- package/dist/local-git.js +155 -24
- package/dist/local-git.js.map +1 -1
- package/dist/model-provider-fixtures.d.ts +9 -1
- package/dist/model-provider-fixtures.d.ts.map +1 -1
- package/dist/polling.d.ts +1 -0
- package/dist/polling.d.ts.map +1 -1
- package/dist/process-driver.d.ts +5 -1
- package/dist/process-driver.d.ts.map +1 -1
- package/dist/question-fixtures.d.ts +2 -0
- package/dist/question-fixtures.d.ts.map +1 -1
- package/dist/server-extension-test-harness.d.ts +43 -3
- package/dist/server-extension-test-harness.d.ts.map +1 -1
- package/dist/stub-worker-entry.js +1 -1
- package/dist/test-diagnostics.d.ts +14 -0
- package/dist/test-diagnostics.d.ts.map +1 -0
- package/dist/worker-testing/in-process-worker-spawn.d.ts +17 -1
- package/dist/worker-testing/in-process-worker-spawn.d.ts.map +1 -1
- package/dist/worker-testing/index.d.ts +6 -7
- package/dist/worker-testing/index.d.ts.map +1 -1
- package/dist/worker-testing/index.js +32 -22
- package/dist/worker-testing/index.js.map +1 -1
- package/dist/worker-testing/schema-driven-stub-pi.d.ts +5 -0
- package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-controls.d.ts +4 -0
- package/dist/worker-testing/stub-pi-controls.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +76 -2
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/dist/worker-testing/worker-runtime-harness.d.ts +37 -2
- package/dist/worker-testing/worker-runtime-harness.d.ts.map +1 -1
- package/dist/worker-testing/worker-start-payload.d.ts +17 -1
- package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/compact-process-detail-fixture.ts +9 -1
- package/src/fakes/fake-git-ops.ts +12 -0
- package/src/fakes/fake-llm.ts +11 -0
- package/src/fakes/index.ts +1 -1
- package/src/http-launch.ts +2 -1
- package/src/index.ts +28 -42
- package/src/integration-harness.ts +100 -9
- package/src/integration.ts +2 -9
- package/src/local-git.ts +195 -45
- package/src/model-provider-fixtures.ts +15 -2
- package/src/polling.ts +1 -0
- package/src/process-driver.ts +7 -1
- package/src/question-fixtures.ts +2 -0
- package/src/server-extension-test-harness.ts +64 -7
- package/src/test-diagnostics.ts +69 -0
- package/src/worker-testing/in-process-worker-spawn.ts +29 -2
- package/src/worker-testing/index.ts +4 -30
- package/src/worker-testing/schema-driven-stub-pi.ts +8 -1
- package/src/worker-testing/stub-pi-controls.ts +4 -0
- package/src/worker-testing/stub-pi-tree-handle.ts +82 -3
- package/src/worker-testing/worker-runtime-harness.ts +57 -6
- package/src/worker-testing/worker-start-payload.ts +17 -1
- package/dist/chunk-2IICIB6D.js.map +0 -1
- package/dist/chunk-3MQO3NCX.js +0 -15
- package/dist/chunk-3MQO3NCX.js.map +0 -1
- package/dist/chunk-7I4OCTF3.js.map +0 -1
- package/dist/chunk-7ZK5QRGP.js +0 -98
- package/dist/chunk-7ZK5QRGP.js.map +0 -1
- package/dist/chunk-JUH3LUYK.js.map +0 -1
- package/dist/chunk-KPSK7EMY.js.map +0 -1
- package/dist/chunk-MV4W6NOO.js +0 -105
- package/dist/chunk-MV4W6NOO.js.map +0 -1
- package/dist/test-app.d.ts +0 -23
- package/dist/test-app.d.ts.map +0 -1
- package/src/test-app.ts +0 -82
|
@@ -1,21 +1,56 @@
|
|
|
1
1
|
import type { ExtensionCatalog } from "@leitwerk-dev/extension-runtime";
|
|
2
2
|
import type { ProvidedCapability } from "@leitwerk-dev/process-sdk";
|
|
3
3
|
import { type AppContext, type AppOptions, type LeitwerkConfig } from "@leitwerk-dev/server";
|
|
4
|
+
import { type InProcessWorkerSpawnOptions } from "./in-process-worker.js";
|
|
5
|
+
/** @public */
|
|
4
6
|
export interface IntegrationHarness<TResources extends Record<string, unknown> = Record<string, never>> {
|
|
7
|
+
/** @public */
|
|
5
8
|
ctx: AppContext;
|
|
9
|
+
/** @public */
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
/** @internal */
|
|
6
12
|
config: LeitwerkConfig;
|
|
13
|
+
/** @public */
|
|
7
14
|
address: string;
|
|
15
|
+
/** @internal */
|
|
8
16
|
resources: TResources;
|
|
9
17
|
}
|
|
18
|
+
/** @public */
|
|
10
19
|
export interface IntegrationHarnessOptions<TResources extends Record<string, unknown> = Record<string, never>> {
|
|
20
|
+
/** @internal */
|
|
11
21
|
config?: LeitwerkConfig;
|
|
22
|
+
/** @public */
|
|
12
23
|
configOverride?: (config: LeitwerkConfig) => void;
|
|
24
|
+
/** @public */
|
|
13
25
|
appOverrides?: Partial<AppOptions>;
|
|
26
|
+
/** @internal */
|
|
14
27
|
listen?: boolean;
|
|
15
|
-
|
|
28
|
+
/** Start background services when binding a listener. Defaults to true. @public */
|
|
29
|
+
backgroundServices?: boolean;
|
|
30
|
+
/** @internal */
|
|
31
|
+
inProcessWorkers?: boolean | Omit<InProcessWorkerSpawnOptions, "extensionCatalog">;
|
|
32
|
+
/** @public */
|
|
16
33
|
extensionCatalog: ExtensionCatalog | Promise<ExtensionCatalog>;
|
|
34
|
+
/** @internal */
|
|
17
35
|
preProvidedCapabilities?: readonly ProvidedCapability[];
|
|
36
|
+
/** @internal */
|
|
18
37
|
resources?: TResources;
|
|
19
38
|
}
|
|
39
|
+
/** Owns disposable file-backed storage; close retains it for the next open, dispose removes it. @internal */
|
|
40
|
+
export declare function createPersistentIntegrationFixture(prefix: string, configure?: (config: LeitwerkConfig) => void): {
|
|
41
|
+
/** @internal */
|
|
42
|
+
root: string;
|
|
43
|
+
/** @internal */
|
|
44
|
+
createConfig: () => LeitwerkConfig;
|
|
45
|
+
/** @internal */
|
|
46
|
+
context(): AppContext;
|
|
47
|
+
/** @internal */
|
|
48
|
+
open(options: IntegrationHarnessOptions): Promise<IntegrationHarness<Record<string, never>>>;
|
|
49
|
+
/** @internal */
|
|
50
|
+
close: () => Promise<void>;
|
|
51
|
+
/** @internal */
|
|
52
|
+
dispose(): Promise<void>;
|
|
53
|
+
};
|
|
54
|
+
/** @public */
|
|
20
55
|
export declare function createIntegrationHarness<TResources extends Record<string, unknown> = Record<string, never>>(opts: IntegrationHarnessOptions<TResources>): Promise<IntegrationHarness<TResources>>;
|
|
21
56
|
//# sourceMappingURL=integration-harness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-harness.d.ts","sourceRoot":"","sources":["../src/integration-harness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integration-harness.d.ts","sourceRoot":"","sources":["../src/integration-harness.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACN,KAAK,UAAU,EACf,KAAK,UAAU,EAGf,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEN,KAAK,2BAA2B,EAChC,MAAM,wBAAwB,CAAC;AAEhC,cAAc;AACd,MAAM,WAAW,kBAAkB,CAClC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAElE,cAAc;IACd,GAAG,EAAE,UAAU,CAAC;IAChB,cAAc;IACd,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,gBAAgB;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,SAAS,EAAE,UAAU,CAAC;CACtB;AAED,cAAc;AACd,MAAM,WAAW,yBAAyB,CACzC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAElE,gBAAgB;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,cAAc;IACd,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,cAAc;IACd,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,gBAAgB;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB;IAChB,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,CAAC;IACnF,cAAc;IACd,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/D,gBAAgB;IAChB,uBAAuB,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACxD,gBAAgB;IAChB,SAAS,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,6GAA6G;AAC7G,wBAAgB,kCAAkC,CACjD,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI;IAoB3C,gBAAgB;;IAEhB,gBAAgB;;IAEhB,gBAAgB;;IAKhB,gBAAgB;kBACI,yBAAyB;IAO7C,gBAAgB;;IAEhB,gBAAgB;;EASjB;AACD,cAAc;AACd,wBAAsB,wBAAwB,CAC7C,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjE,IAAI,EAAE,yBAAyB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAqDtF"}
|
package/dist/integration.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { createIntegrationHarness,
|
|
1
|
+
export { createIntegrationHarness, createPersistentIntegrationFixture, type IntegrationHarness, } from "./integration-harness.js";
|
|
2
2
|
export { waitForValue } from "./polling.js";
|
|
3
3
|
export { createProcessDriver } from "./process-driver.js";
|
|
4
|
-
export {
|
|
5
|
-
export { createTestApp, type TestApp, type TestAppOptions } from "./test-app.js";
|
|
4
|
+
export { createTestServerSetupCapability } from "./server-extension-test-harness.js";
|
|
6
5
|
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../src/integration.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../src/integration.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,kCAAkC,EAClC,KAAK,kBAAkB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/integration.js
CHANGED
|
@@ -1,14 +1,130 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import "
|
|
11
|
-
import "
|
|
2
|
+
createTestServerSetupCapability
|
|
3
|
+
} from "./chunk-5BZSJ4OO.js";
|
|
4
|
+
import {
|
|
5
|
+
createInProcessWorkerSpawn
|
|
6
|
+
} from "./chunk-2PCDTYVH.js";
|
|
7
|
+
import "./chunk-ECAWLVYB.js";
|
|
8
|
+
|
|
9
|
+
// src/integration-harness.ts
|
|
10
|
+
import { mkdtempSync, rmSync } from "fs";
|
|
11
|
+
import { tmpdir } from "os";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import {
|
|
14
|
+
createAppContext,
|
|
15
|
+
getDefaultConfig
|
|
16
|
+
} from "@leitwerk-dev/server";
|
|
17
|
+
function createPersistentIntegrationFixture(prefix, configure) {
|
|
18
|
+
const root = mkdtempSync(path.join(tmpdir(), prefix));
|
|
19
|
+
let harness;
|
|
20
|
+
function createConfig() {
|
|
21
|
+
const config = getDefaultConfig();
|
|
22
|
+
config.storage.sqlite_path = path.join(root, "state.sqlite");
|
|
23
|
+
config.storage.process_workspaces_dir = path.join(root, "workspaces");
|
|
24
|
+
config.storage.tree_files_dir = path.join(root, "trees");
|
|
25
|
+
config.pi.agent_dir = path.join(root, "pi");
|
|
26
|
+
configure?.(config);
|
|
27
|
+
return config;
|
|
28
|
+
}
|
|
29
|
+
async function close() {
|
|
30
|
+
await harness?.close();
|
|
31
|
+
harness = void 0;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
/** @internal */
|
|
35
|
+
root,
|
|
36
|
+
/** @internal */
|
|
37
|
+
createConfig,
|
|
38
|
+
/** @internal */
|
|
39
|
+
context() {
|
|
40
|
+
if (!harness) throw new Error("Fixture is not open");
|
|
41
|
+
return harness.ctx;
|
|
42
|
+
},
|
|
43
|
+
/** @internal */
|
|
44
|
+
async open(options) {
|
|
45
|
+
harness = await createIntegrationHarness({
|
|
46
|
+
...options,
|
|
47
|
+
config: options.config ?? createConfig()
|
|
48
|
+
});
|
|
49
|
+
return harness;
|
|
50
|
+
},
|
|
51
|
+
/** @internal */
|
|
52
|
+
close,
|
|
53
|
+
/** @internal */
|
|
54
|
+
async dispose() {
|
|
55
|
+
try {
|
|
56
|
+
await close();
|
|
57
|
+
} finally {
|
|
58
|
+
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function createIntegrationHarness(opts) {
|
|
64
|
+
const config = opts.config ?? getDefaultConfig();
|
|
65
|
+
if (!opts.appOverrides?.workerRunnerRuntime) {
|
|
66
|
+
config.workers.runner = "local";
|
|
67
|
+
}
|
|
68
|
+
opts.configOverride?.(config);
|
|
69
|
+
const extensionCatalog = await Promise.resolve(opts.extensionCatalog);
|
|
70
|
+
const appOpts = {
|
|
71
|
+
logger: false,
|
|
72
|
+
config,
|
|
73
|
+
extensionCatalog,
|
|
74
|
+
preProvidedCapabilities: opts.preProvidedCapabilities,
|
|
75
|
+
...opts.appOverrides
|
|
76
|
+
};
|
|
77
|
+
if (opts.inProcessWorkers !== false && !appOpts.localWorkerSpawnImpl) {
|
|
78
|
+
appOpts.localWorkerSpawnImpl = createInProcessWorkerSpawn({
|
|
79
|
+
...typeof opts.inProcessWorkers === "object" ? opts.inProcessWorkers : {},
|
|
80
|
+
extensionCatalog
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const ctx = await createAppContext(appOpts);
|
|
84
|
+
let address = "";
|
|
85
|
+
try {
|
|
86
|
+
if (opts.listen !== false) {
|
|
87
|
+
if (opts.backgroundServices !== false) {
|
|
88
|
+
({ address } = await ctx.listen({
|
|
89
|
+
host: "127.0.0.1",
|
|
90
|
+
port: 0,
|
|
91
|
+
useBoundAddressAsBaseUrl: true
|
|
92
|
+
}));
|
|
93
|
+
} else {
|
|
94
|
+
address = await ctx.app.listen({ host: "127.0.0.1", port: 0 });
|
|
95
|
+
ctx.config.server.base_url = address;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
await ctx.close().catch(() => {
|
|
100
|
+
});
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
ctx,
|
|
105
|
+
close: () => ctx.close(),
|
|
106
|
+
config,
|
|
107
|
+
get address() {
|
|
108
|
+
return address || (ctx.app.server.listening ? ctx.config.server.base_url : "");
|
|
109
|
+
},
|
|
110
|
+
resources: opts.resources ?? {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/polling.ts
|
|
115
|
+
async function waitForValue(read, predicate, timeoutMs = 5e3) {
|
|
116
|
+
const deadline = Date.now() + timeoutMs;
|
|
117
|
+
while (true) {
|
|
118
|
+
const value = await read();
|
|
119
|
+
if (predicate(value)) {
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
if (Date.now() >= deadline) {
|
|
123
|
+
throw new Error("Timed out waiting for value");
|
|
124
|
+
}
|
|
125
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
12
128
|
|
|
13
129
|
// src/process-driver.ts
|
|
14
130
|
function createProcessDriver(context) {
|
|
@@ -41,8 +157,11 @@ function createProcessDriver(context) {
|
|
|
41
157
|
}
|
|
42
158
|
}
|
|
43
159
|
return {
|
|
160
|
+
/** @public */
|
|
44
161
|
post,
|
|
162
|
+
/** @public */
|
|
45
163
|
waitForProcess,
|
|
164
|
+
/** @public */
|
|
46
165
|
wait: (id, turn, lifecycle = "waiting", timeout = 12e3) => waitForProcess(
|
|
47
166
|
id,
|
|
48
167
|
(p) => p.selectedTurnId === turn && p.lifecycleStatus === lifecycle,
|
|
@@ -50,18 +169,17 @@ function createProcessDriver(context) {
|
|
|
50
169
|
timeout,
|
|
51
170
|
lifecycle === "error"
|
|
52
171
|
),
|
|
172
|
+
/** @public */
|
|
53
173
|
action: (id, action, input = {}) => post(`/api/processes/${encodeURIComponent(id)}/actions/${encodeURIComponent(action)}`, {
|
|
54
174
|
input
|
|
55
175
|
})
|
|
56
176
|
};
|
|
57
177
|
}
|
|
58
178
|
export {
|
|
59
|
-
createInMemoryExternalWriteLog,
|
|
60
179
|
createIntegrationHarness,
|
|
180
|
+
createPersistentIntegrationFixture,
|
|
61
181
|
createProcessDriver,
|
|
62
|
-
createTestApp,
|
|
63
182
|
createTestServerSetupCapability,
|
|
64
|
-
setupServerExtensionTest,
|
|
65
183
|
waitForValue
|
|
66
184
|
};
|
|
67
185
|
//# sourceMappingURL=integration.js.map
|
package/dist/integration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/process-driver.ts"],"sourcesContent":["import type { ProcessInstance } from \"@leitwerk-dev/domain\";\nimport type { AppContext } from \"@leitwerk-dev/server\";\nimport { waitForValue } from \"./polling.js\";\n\n/** Drive a running or restarted app without bypassing process HTTP actions. */\nexport function createProcessDriver(context: () => AppContext) {\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await context().app.inject({ method: \"POST\", url, payload });\n\t\tif (response.statusCode !== 200)\n\t\t\tthrow new Error(`POST ${url} failed with ${response.statusCode}: ${response.body}`);\n\t\treturn response;\n\t}\n\tasync function waitForProcess(\n\t\tid: string,\n\t\tpredicate: (process: ProcessInstance) => boolean,\n\t\tdescription: string,\n\t\ttimeout = 12000,\n\t\tallowError = false,\n\t): Promise<ProcessInstance> {\n\t\ttry {\n\t\t\tconst process = await waitForValue(\n\t\t\t\t() => {\n\t\t\t\t\tconst current = context().deps.processes.getById(id);\n\t\t\t\t\tif (current?.lifecycleStatus === \"error\" && !allowError)\n\t\t\t\t\t\tthrow new Error(\"Process entered error lifecycle\");\n\t\t\t\t\treturn current;\n\t\t\t\t},\n\t\t\t\t(process) => !!process && predicate(process),\n\t\t\t\ttimeout,\n\t\t\t);\n\t\t\tif (!process) throw new Error(\"Missing process\");\n\t\t\treturn process;\n\t\t} catch (error) {\n\t\t\tconst { processes, turnRecords } = context().deps;\n\t\t\tthrow new Error(\n\t\t\t\t`Waiting for ${id}: ${description}; ${JSON.stringify({ process: processes.getById(id), turns: turnRecords.listByInstance(id) })}`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\tpost,\n\t\twaitForProcess,\n\t\twait: (id: string, turn: string | null, lifecycle = \"waiting\", timeout = 12000) =>\n\t\t\twaitForProcess(\n\t\t\t\tid,\n\t\t\t\t(p) => p.selectedTurnId === turn && p.lifecycleStatus === lifecycle,\n\t\t\t\t`${turn}/${lifecycle}`,\n\t\t\t\ttimeout,\n\t\t\t\tlifecycle === \"error\",\n\t\t\t),\n\t\taction: (id: string, action: string, input: Record<string, unknown> = {}) =>\n\t\t\tpost(`/api/processes/${encodeURIComponent(id)}/actions/${encodeURIComponent(action)}`, {\n\t\t\t\tinput,\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAKO,SAAS,oBAAoB,SAA2B;AAC9D,iBAAe,KAAK,KAAa,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BAAkB,mBAAmB,EAAE,CAAC,YAAY,mBAAmB,MAAM,CAAC,IAAI;AAAA,MACtF;AAAA,IACD,CAAC;AAAA,EACH;AACD;","names":["process"]}
|
|
1
|
+
{"version":3,"sources":["../src/integration-harness.ts","../src/polling.ts","../src/process-driver.ts"],"sourcesContent":["import { mkdtempSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport type { ExtensionCatalog } from \"@leitwerk-dev/extension-runtime\";\nimport type { ProvidedCapability } from \"@leitwerk-dev/process-sdk\";\nimport {\n\ttype AppContext,\n\ttype AppOptions,\n\tcreateAppContext,\n\tgetDefaultConfig,\n\ttype LeitwerkConfig,\n} from \"@leitwerk-dev/server\";\nimport {\n\tcreateInProcessWorkerSpawn,\n\ttype InProcessWorkerSpawnOptions,\n} from \"./in-process-worker.js\";\n\n/** @public */\nexport interface IntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @public */\n\tctx: AppContext;\n\t/** @public */\n\tclose(): Promise<void>;\n\t/** @internal */\n\tconfig: LeitwerkConfig;\n\t/** @public */\n\taddress: string;\n\t/** @internal */\n\tresources: TResources;\n}\n\n/** @public */\nexport interface IntegrationHarnessOptions<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @internal */\n\tconfig?: LeitwerkConfig;\n\t/** @public */\n\tconfigOverride?: (config: LeitwerkConfig) => void;\n\t/** @public */\n\tappOverrides?: Partial<AppOptions>;\n\t/** @internal */\n\tlisten?: boolean;\n\t/** Start background services when binding a listener. Defaults to true. @public */\n\tbackgroundServices?: boolean;\n\t/** @internal */\n\tinProcessWorkers?: boolean | Omit<InProcessWorkerSpawnOptions, \"extensionCatalog\">;\n\t/** @public */\n\textensionCatalog: ExtensionCatalog | Promise<ExtensionCatalog>;\n\t/** @internal */\n\tpreProvidedCapabilities?: readonly ProvidedCapability[];\n\t/** @internal */\n\tresources?: TResources;\n}\n\n/** Owns disposable file-backed storage; close retains it for the next open, dispose removes it. @internal */\nexport function createPersistentIntegrationFixture(\n\tprefix: string,\n\tconfigure?: (config: LeitwerkConfig) => void,\n) {\n\tconst root = mkdtempSync(path.join(tmpdir(), prefix));\n\tlet harness: IntegrationHarness | undefined;\n\t/** @internal */\n\tfunction createConfig() {\n\t\tconst config = getDefaultConfig();\n\t\tconfig.storage.sqlite_path = path.join(root, \"state.sqlite\");\n\t\tconfig.storage.process_workspaces_dir = path.join(root, \"workspaces\");\n\t\tconfig.storage.tree_files_dir = path.join(root, \"trees\");\n\t\tconfig.pi.agent_dir = path.join(root, \"pi\");\n\t\tconfigure?.(config);\n\t\treturn config;\n\t}\n\t/** @internal */\n\tasync function close() {\n\t\tawait harness?.close();\n\t\tharness = undefined;\n\t}\n\treturn {\n\t\t/** @internal */\n\t\troot,\n\t\t/** @internal */\n\t\tcreateConfig,\n\t\t/** @internal */\n\t\tcontext() {\n\t\t\tif (!harness) throw new Error(\"Fixture is not open\");\n\t\t\treturn harness.ctx;\n\t\t},\n\t\t/** @internal */\n\t\tasync open(options: IntegrationHarnessOptions) {\n\t\t\tharness = await createIntegrationHarness({\n\t\t\t\t...options,\n\t\t\t\tconfig: options.config ?? createConfig(),\n\t\t\t});\n\t\t\treturn harness;\n\t\t},\n\t\t/** @internal */\n\t\tclose,\n\t\t/** @internal */\n\t\tasync dispose() {\n\t\t\ttry {\n\t\t\t\tawait close();\n\t\t\t} finally {\n\t\t\t\trmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n\t\t\t}\n\t\t},\n\t};\n}\n/** @public */\nexport async function createIntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n>(opts: IntegrationHarnessOptions<TResources>): Promise<IntegrationHarness<TResources>> {\n\tconst config = opts.config ?? getDefaultConfig();\n\tif (!opts.appOverrides?.workerRunnerRuntime) {\n\t\tconfig.workers.runner = \"local\";\n\t}\n\topts.configOverride?.(config);\n\n\tconst extensionCatalog = await Promise.resolve(opts.extensionCatalog);\n\n\tconst appOpts: AppOptions = {\n\t\tlogger: false,\n\t\tconfig,\n\t\textensionCatalog,\n\t\tpreProvidedCapabilities: opts.preProvidedCapabilities,\n\t\t...opts.appOverrides,\n\t};\n\n\tif (opts.inProcessWorkers !== false && !appOpts.localWorkerSpawnImpl) {\n\t\tappOpts.localWorkerSpawnImpl = createInProcessWorkerSpawn({\n\t\t\t...(typeof opts.inProcessWorkers === \"object\" ? opts.inProcessWorkers : {}),\n\t\t\textensionCatalog,\n\t\t});\n\t}\n\tconst ctx = await createAppContext(appOpts);\n\n\tlet address = \"\";\n\ttry {\n\t\tif (opts.listen !== false) {\n\t\t\tif (opts.backgroundServices !== false) {\n\t\t\t\t({ address } = await ctx.listen({\n\t\t\t\t\thost: \"127.0.0.1\",\n\t\t\t\t\tport: 0,\n\t\t\t\t\tuseBoundAddressAsBaseUrl: true,\n\t\t\t\t}));\n\t\t\t} else {\n\t\t\t\taddress = await ctx.app.listen({ host: \"127.0.0.1\", port: 0 });\n\t\t\t\tctx.config.server.base_url = address;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait ctx.close().catch(() => {});\n\t\tthrow error;\n\t}\n\n\treturn {\n\t\tctx,\n\t\tclose: () => ctx.close(),\n\t\tconfig,\n\t\tget address() {\n\t\t\treturn address || (ctx.app.server.listening ? ctx.config.server.base_url : \"\");\n\t\t},\n\t\tresources: opts.resources ?? ({} as TResources),\n\t};\n}\n","/** @public */\nexport async function waitForValue<T>(\n\tread: () => T | Promise<T>,\n\tpredicate: (value: T) => boolean,\n\ttimeoutMs = 5_000,\n): Promise<T> {\n\tconst deadline = Date.now() + timeoutMs;\n\twhile (true) {\n\t\tconst value = await read();\n\t\tif (predicate(value)) {\n\t\t\treturn value;\n\t\t}\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\"Timed out waiting for value\");\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, 25));\n\t}\n}\n","import type { ProcessInstance } from \"@leitwerk-dev/domain\";\nimport type { AppContext } from \"@leitwerk-dev/server\";\nimport { waitForValue } from \"./polling.js\";\n\n/** Drive a running or restarted app without bypassing process HTTP actions. @public */\nexport function createProcessDriver(context: () => AppContext) {\n\t/** @public */\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await context().app.inject({ method: \"POST\", url, payload });\n\t\tif (response.statusCode !== 200)\n\t\t\tthrow new Error(`POST ${url} failed with ${response.statusCode}: ${response.body}`);\n\t\treturn response;\n\t}\n\t/** @public */\n\tasync function waitForProcess(\n\t\tid: string,\n\t\tpredicate: (process: ProcessInstance) => boolean,\n\t\tdescription: string,\n\t\ttimeout = 12000,\n\t\tallowError = false,\n\t): Promise<ProcessInstance> {\n\t\ttry {\n\t\t\tconst process = await waitForValue(\n\t\t\t\t() => {\n\t\t\t\t\tconst current = context().deps.processes.getById(id);\n\t\t\t\t\tif (current?.lifecycleStatus === \"error\" && !allowError)\n\t\t\t\t\t\tthrow new Error(\"Process entered error lifecycle\");\n\t\t\t\t\treturn current;\n\t\t\t\t},\n\t\t\t\t(process) => !!process && predicate(process),\n\t\t\t\ttimeout,\n\t\t\t);\n\t\t\tif (!process) throw new Error(\"Missing process\");\n\t\t\treturn process;\n\t\t} catch (error) {\n\t\t\tconst { processes, turnRecords } = context().deps;\n\t\t\tthrow new Error(\n\t\t\t\t`Waiting for ${id}: ${description}; ${JSON.stringify({ process: processes.getById(id), turns: turnRecords.listByInstance(id) })}`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\t/** @public */\n\t\tpost,\n\t\t/** @public */\n\t\twaitForProcess,\n\t\t/** @public */\n\t\twait: (id: string, turn: string | null, lifecycle = \"waiting\", timeout = 12000) =>\n\t\t\twaitForProcess(\n\t\t\t\tid,\n\t\t\t\t(p) => p.selectedTurnId === turn && p.lifecycleStatus === lifecycle,\n\t\t\t\t`${turn}/${lifecycle}`,\n\t\t\t\ttimeout,\n\t\t\t\tlifecycle === \"error\",\n\t\t\t),\n\t\t/** @public */\n\t\taction: (id: string, action: string, input: Record<string, unknown> = {}) =>\n\t\t\tpost(`/api/processes/${encodeURIComponent(id)}/actions/${encodeURIComponent(action)}`, {\n\t\t\t\tinput,\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,cAAc;AACpC,SAAS,cAAc;AACvB,OAAO,UAAU;AAGjB;AAAA,EAGC;AAAA,EACA;AAAA,OAEM;AA+CA,SAAS,mCACf,QACA,WACC;AACD,QAAM,OAAO,YAAY,KAAK,KAAK,OAAO,GAAG,MAAM,CAAC;AACpD,MAAI;AAEJ,WAAS,eAAe;AACvB,UAAM,SAAS,iBAAiB;AAChC,WAAO,QAAQ,cAAc,KAAK,KAAK,MAAM,cAAc;AAC3D,WAAO,QAAQ,yBAAyB,KAAK,KAAK,MAAM,YAAY;AACpE,WAAO,QAAQ,iBAAiB,KAAK,KAAK,MAAM,OAAO;AACvD,WAAO,GAAG,YAAY,KAAK,KAAK,MAAM,IAAI;AAC1C,gBAAY,MAAM;AAClB,WAAO;AAAA,EACR;AAEA,iBAAe,QAAQ;AACtB,UAAM,SAAS,MAAM;AACrB,cAAU;AAAA,EACX;AACA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA,UAAU;AACT,UAAI,CAAC,QAAS,OAAM,IAAI,MAAM,qBAAqB;AACnD,aAAO,QAAQ;AAAA,IAChB;AAAA;AAAA,IAEA,MAAM,KAAK,SAAoC;AAC9C,gBAAU,MAAM,yBAAyB;AAAA,QACxC,GAAG;AAAA,QACH,QAAQ,QAAQ,UAAU,aAAa;AAAA,MACxC,CAAC;AACD,aAAO;AAAA,IACR;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA,MAAM,UAAU;AACf,UAAI;AACH,cAAM,MAAM;AAAA,MACb,UAAE;AACD,eAAO,MAAM,EAAE,WAAW,MAAM,OAAO,MAAM,YAAY,GAAG,YAAY,IAAI,CAAC;AA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AW,KAAK,KAAK,UAAU,EAAE,SAAS,UAAU,QAAQ,EAAE,GAAG,OAAO,YAAY,eAAe,EAAE,EAAE,CAAC,CAAC;AAAA,QAC/H,EAAE,OAAO,MAAM;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AACA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA,MAAM,CAAC,IAAY,MAAqB,YAAY,WAAW,UAAU,SACxE;AAAA,MACC;AAAA,MACA,CAAC,MAAM,EAAE,mBAAmB,QAAQ,EAAE,oBAAoB;AAAA,MAC1D,GAAG,IAAI,IAAI,SAAS;AAAA,MACpB;AAAA,MACA,cAAc;AAAA,IACf;AAAA;AAAA,IAED,QAAQ,CAAC,IAAY,QAAgB,QAAiC,CAAC,MACtE,KAAK,kBAAkB,mBAAmB,EAAE,CAAC,YAAY,mBAAmB,MAAM,CAAC,IAAI;AAAA,MACtF;AAAA,IACD,CAAC;AAAA,EACH;AACD;","names":["process"]}
|
package/dist/local-git.d.ts
CHANGED
|
@@ -1,134 +1,231 @@
|
|
|
1
1
|
import type { RepositoryFeedbackItem, RepositoryPullRequest } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export { createTestDiagnostics } from "./test-diagnostics.js";
|
|
3
|
+
/** @public */
|
|
2
4
|
export interface LocalRepositorySeed {
|
|
5
|
+
/** @public */
|
|
3
6
|
owner: string;
|
|
7
|
+
/** @public */
|
|
4
8
|
name: string;
|
|
9
|
+
/** @internal */
|
|
5
10
|
defaultBranch?: string;
|
|
11
|
+
/** @public */
|
|
6
12
|
files?: Record<string, string>;
|
|
7
|
-
/** Retain a pre-existing sandbox checkout layout. */
|
|
13
|
+
/** Retain a pre-existing sandbox checkout layout. @internal */
|
|
8
14
|
directoryName?: string;
|
|
15
|
+
/** @internal */
|
|
9
16
|
commitMessage?: string;
|
|
17
|
+
/** @internal */
|
|
10
18
|
signoff?: boolean;
|
|
11
19
|
}
|
|
12
|
-
/** Reject escaping paths and symlinks, including a not-yet-created file's parents. */
|
|
20
|
+
/** Reject escaping paths and symlinks, including a not-yet-created file's parents. @public */
|
|
13
21
|
export declare function localPath(root: string, relative: string): string;
|
|
22
|
+
/** @public */
|
|
14
23
|
export declare function readLocalJson<T extends {
|
|
24
|
+
/** @internal */
|
|
15
25
|
version: number;
|
|
16
26
|
}>(root: string, file: string, initial: T): T;
|
|
27
|
+
/** @public */
|
|
17
28
|
export declare function writeLocalJson(root: string, file: string, value: unknown): void;
|
|
18
|
-
/** Persist local adapter state with a shared clock and monotonically increasing ids. */
|
|
29
|
+
/** Persist local adapter state with a shared clock and monotonically increasing ids. @public */
|
|
19
30
|
export declare class LocalProviderStore<S extends {
|
|
31
|
+
/** @internal */
|
|
20
32
|
version: number;
|
|
33
|
+
/** @internal */
|
|
21
34
|
sequence: number;
|
|
22
35
|
}, O extends {
|
|
36
|
+
/** @internal */
|
|
23
37
|
root: string;
|
|
38
|
+
/** @internal */
|
|
24
39
|
now?: () => number;
|
|
40
|
+
/** @internal */
|
|
25
41
|
nextId?: () => number;
|
|
26
42
|
}> {
|
|
43
|
+
/** @public */
|
|
27
44
|
readonly options: O;
|
|
28
45
|
private readonly file;
|
|
46
|
+
/** @public */
|
|
29
47
|
readonly git: LocalGit;
|
|
48
|
+
/** @public */
|
|
30
49
|
state: S;
|
|
31
|
-
|
|
50
|
+
/** @public */
|
|
51
|
+
constructor(
|
|
52
|
+
/** @public */
|
|
53
|
+
options: O, file: string, initial: S);
|
|
54
|
+
/** @public */
|
|
32
55
|
save(): void;
|
|
56
|
+
/** @internal */
|
|
33
57
|
id(): number;
|
|
58
|
+
/** @internal */
|
|
34
59
|
timestamp(): string;
|
|
35
60
|
}
|
|
61
|
+
/** @public */
|
|
36
62
|
type LocalPullRequest = Pick<RepositoryPullRequest, "number" | "title" | "body" | "state" | "merged" | "merge_commit_sha" | "head" | "base">;
|
|
63
|
+
/** @public */
|
|
37
64
|
interface LocalPullRequestRepository<P extends LocalPullRequest> {
|
|
65
|
+
/** @public */
|
|
38
66
|
repository: {
|
|
67
|
+
/** @internal */
|
|
39
68
|
ssh_url: string;
|
|
40
69
|
};
|
|
70
|
+
/** @public */
|
|
41
71
|
pulls: P[];
|
|
42
72
|
}
|
|
43
|
-
/** Common PR operations; adapters retain their provider-specific state and clients. */
|
|
73
|
+
/** Common PR operations; adapters retain their provider-specific state and clients. @public */
|
|
44
74
|
export declare class LocalForgeStore<S extends {
|
|
75
|
+
/** @internal */
|
|
45
76
|
version: number;
|
|
77
|
+
/** @internal */
|
|
46
78
|
sequence: number;
|
|
47
79
|
}, O extends {
|
|
80
|
+
/** @internal */
|
|
48
81
|
root: string;
|
|
82
|
+
/** @internal */
|
|
49
83
|
baseUrl: string;
|
|
84
|
+
/** @internal */
|
|
50
85
|
now?: () => number;
|
|
86
|
+
/** @internal */
|
|
51
87
|
nextId?: () => number;
|
|
52
88
|
}> extends LocalProviderStore<S, O> {
|
|
89
|
+
/** @public */
|
|
53
90
|
newRepository(seed: LocalRepositorySeed): {
|
|
91
|
+
/** @public */
|
|
54
92
|
id: number;
|
|
93
|
+
/** @public */
|
|
55
94
|
owner: {
|
|
95
|
+
/** @internal */
|
|
56
96
|
login: string;
|
|
57
97
|
};
|
|
98
|
+
/** @public */
|
|
58
99
|
name: string;
|
|
100
|
+
/** @public */
|
|
59
101
|
full_name: string;
|
|
102
|
+
/** @public */
|
|
60
103
|
ssh_url: string;
|
|
104
|
+
/** @public */
|
|
61
105
|
html_url: string;
|
|
106
|
+
/** @public */
|
|
62
107
|
default_branch: string;
|
|
63
108
|
};
|
|
109
|
+
/** @internal */
|
|
64
110
|
pullRequestClient<P extends LocalPullRequest>(repo: (owner: string, name: string) => LocalPullRequestRepository<P>, missing?: string): {
|
|
111
|
+
/** @internal */
|
|
65
112
|
getPullRequest: (owner: string, name: string, number: number) => Promise<P>;
|
|
113
|
+
/** @internal */
|
|
66
114
|
listPullRequests: (owner: string, name: string, state?: string) => Promise<P[]>;
|
|
115
|
+
/** @internal */
|
|
67
116
|
updatePullRequest: (owner: string, name: string, number: number, patch: Record<string, unknown>) => Promise<P>;
|
|
68
117
|
};
|
|
118
|
+
/** @public */
|
|
69
119
|
refresh<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, pr: P): P;
|
|
120
|
+
/** @public */
|
|
70
121
|
merge<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, number: number): P;
|
|
122
|
+
/** @public */
|
|
71
123
|
addFeedback<F extends RepositoryFeedbackItem>(repo: {
|
|
124
|
+
/** @public */
|
|
72
125
|
pulls: Array<{
|
|
126
|
+
/** @internal */
|
|
73
127
|
number: number;
|
|
74
128
|
}>;
|
|
129
|
+
/** @public */
|
|
75
130
|
feedback: Record<string, F[]>;
|
|
76
131
|
}, number: number, input: Omit<F, "id" | "createdAt">): F;
|
|
132
|
+
/** @public */
|
|
77
133
|
newComment(body: string): {
|
|
134
|
+
/** @internal */
|
|
78
135
|
id: number;
|
|
136
|
+
/** @internal */
|
|
79
137
|
body: string;
|
|
138
|
+
/** @public */
|
|
80
139
|
user: {
|
|
140
|
+
/** @public */
|
|
81
141
|
login: string;
|
|
82
142
|
};
|
|
143
|
+
/** @internal */
|
|
83
144
|
created_at: string;
|
|
84
145
|
};
|
|
146
|
+
/** @internal */
|
|
85
147
|
newPullRequest(repo: {
|
|
148
|
+
/** @internal */
|
|
86
149
|
repository: {
|
|
150
|
+
/** @internal */
|
|
87
151
|
ssh_url: string;
|
|
88
152
|
};
|
|
89
153
|
}, input: {
|
|
154
|
+
/** @internal */
|
|
90
155
|
title: string;
|
|
156
|
+
/** @internal */
|
|
91
157
|
body: string;
|
|
158
|
+
/** @internal */
|
|
92
159
|
head: string;
|
|
160
|
+
/** @internal */
|
|
93
161
|
base: string;
|
|
94
162
|
}): {
|
|
163
|
+
/** @internal */
|
|
95
164
|
number: number;
|
|
165
|
+
/** @internal */
|
|
96
166
|
title: string;
|
|
167
|
+
/** @internal */
|
|
97
168
|
body: string;
|
|
169
|
+
/** @internal */
|
|
98
170
|
state: string;
|
|
171
|
+
/** @internal */
|
|
99
172
|
merged: boolean;
|
|
173
|
+
/** @internal */
|
|
100
174
|
merge_commit_sha: null;
|
|
175
|
+
/** @internal */
|
|
101
176
|
html_url: string;
|
|
177
|
+
/** @internal */
|
|
102
178
|
head: {
|
|
179
|
+
/** @internal */
|
|
103
180
|
ref: string;
|
|
181
|
+
/** @internal */
|
|
104
182
|
sha: string;
|
|
105
183
|
};
|
|
184
|
+
/** @internal */
|
|
106
185
|
base: {
|
|
186
|
+
/** @internal */
|
|
107
187
|
ref: string;
|
|
188
|
+
/** @internal */
|
|
108
189
|
sha: string;
|
|
109
190
|
};
|
|
110
191
|
};
|
|
111
192
|
}
|
|
112
|
-
/** Real Git with file-only transport and no ambient credentials or hooks. */
|
|
193
|
+
/** Real Git with file-only transport and no ambient credentials or hooks. @public */
|
|
113
194
|
export declare class LocalGit {
|
|
195
|
+
/** @internal */
|
|
114
196
|
readonly root: string;
|
|
115
|
-
|
|
197
|
+
/** @public */
|
|
198
|
+
constructor(
|
|
199
|
+
/** @internal */
|
|
200
|
+
root: string);
|
|
201
|
+
/** @public */
|
|
116
202
|
run(directory: string, args: string[]): string;
|
|
203
|
+
/** @public */
|
|
117
204
|
head(directory: string, ref: string): string;
|
|
205
|
+
/** @internal */
|
|
118
206
|
isAncestor(directory: string, ancestor: string, descendant: string): boolean;
|
|
119
207
|
private isAncestorCommit;
|
|
208
|
+
/** @internal */
|
|
120
209
|
mergeability(directory: string, head: string, base: string): {
|
|
210
|
+
/** @internal */
|
|
121
211
|
headSha: string;
|
|
212
|
+
/** @internal */
|
|
122
213
|
baseSha: string;
|
|
214
|
+
/** @internal */
|
|
123
215
|
mergeable: boolean;
|
|
216
|
+
/** @internal */
|
|
124
217
|
mergeable_state: string;
|
|
125
218
|
};
|
|
219
|
+
/** @internal */
|
|
126
220
|
merge(directory: string, head: string, base: string): string;
|
|
221
|
+
/** @internal */
|
|
127
222
|
seed(seed: LocalRepositorySeed): {
|
|
223
|
+
/** @internal */
|
|
128
224
|
bare: string;
|
|
225
|
+
/** @internal */
|
|
129
226
|
worktree: string;
|
|
227
|
+
/** @internal */
|
|
130
228
|
branch: string;
|
|
131
229
|
};
|
|
132
230
|
}
|
|
133
|
-
export {};
|
|
134
231
|
//# sourceMappingURL=local-git.d.ts.map
|
package/dist/local-git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-git.d.ts","sourceRoot":"","sources":["../src/local-git.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"local-git.d.ts","sourceRoot":"","sources":["../src/local-git.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAG/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,cAAc;AACd,MAAM,WAAW,mBAAmB;IACnC,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,8FAA8F;AAC9F,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAchE;AAED,cAAc;AACd,wBAAgB,aAAa,CAC5B,CAAC,SAAS;IACT,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB,EACA,IAAI,EAAE,MA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