toolcraft 0.0.11 → 0.0.13
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/cli.js +274 -160
- package/dist/renderer.d.ts +8 -2
- package/dist/renderer.js +71 -12
- package/node_modules/@poe-code/design-system/dist/components/help-formatter-plain.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter-plain.js +132 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.js +116 -7
- package/node_modules/@poe-code/design-system/dist/components/index.d.ts +2 -2
- package/node_modules/@poe-code/design-system/dist/components/index.js +1 -1
- package/node_modules/@poe-code/design-system/dist/components/text.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/components/text.js +8 -0
- package/node_modules/@poe-code/design-system/dist/index.d.ts +3 -2
- package/node_modules/@poe-code/design-system/dist/index.js +2 -1
- package/node_modules/@poe-code/process-runner/README.md +41 -0
- package/node_modules/@poe-code/process-runner/dist/docker/args.d.ts +2 -0
- package/node_modules/@poe-code/process-runner/dist/docker/args.js +40 -0
- package/node_modules/@poe-code/process-runner/dist/docker/context.d.ts +3 -0
- package/node_modules/@poe-code/process-runner/dist/docker/context.js +30 -0
- package/node_modules/@poe-code/process-runner/dist/docker/docker-execution-env.d.ts +28 -0
- package/node_modules/@poe-code/process-runner/dist/docker/docker-execution-env.js +428 -0
- package/node_modules/@poe-code/process-runner/dist/docker/docker-runner.d.ts +2 -0
- package/node_modules/@poe-code/process-runner/dist/docker/docker-runner.js +131 -0
- package/node_modules/@poe-code/process-runner/dist/docker/engine.d.ts +3 -0
- package/node_modules/@poe-code/process-runner/dist/docker/engine.js +24 -0
- package/node_modules/@poe-code/process-runner/dist/host/host-execution-env.d.ts +2 -0
- package/node_modules/@poe-code/process-runner/dist/host/host-execution-env.js +48 -0
- package/node_modules/@poe-code/process-runner/dist/host/host-runner.d.ts +3 -0
- package/node_modules/@poe-code/process-runner/dist/host/host-runner.js +74 -0
- package/node_modules/@poe-code/process-runner/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/process-runner/dist/index.js +7 -0
- package/node_modules/@poe-code/process-runner/dist/testing/index.d.ts +2 -0
- package/node_modules/@poe-code/process-runner/dist/testing/index.js +1 -0
- package/node_modules/@poe-code/process-runner/dist/testing/mock-runner.d.ts +3 -0
- package/node_modules/@poe-code/process-runner/dist/testing/mock-runner.js +115 -0
- package/node_modules/@poe-code/process-runner/dist/testing/verify.d.ts +1 -0
- package/node_modules/@poe-code/process-runner/dist/testing/verify.js +359 -0
- package/node_modules/@poe-code/process-runner/dist/types.d.ts +180 -0
- package/node_modules/@poe-code/process-runner/dist/types.js +1 -0
- package/node_modules/@poe-code/process-runner/package.json +27 -0
- package/node_modules/@poe-code/task-list/README.md +49 -5
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +19 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +62 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues.d.ts +13 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues.js +627 -0
- package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +253 -41
- package/node_modules/@poe-code/task-list/dist/backends/utils.d.ts +7 -1
- package/node_modules/@poe-code/task-list/dist/backends/utils.js +21 -0
- package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +171 -16
- package/node_modules/@poe-code/task-list/dist/index.d.ts +3 -1
- package/node_modules/@poe-code/task-list/dist/index.js +1 -1
- package/node_modules/@poe-code/task-list/dist/open.d.ts +4 -2
- package/node_modules/@poe-code/task-list/dist/open.js +27 -3
- package/node_modules/@poe-code/task-list/dist/types.d.ts +51 -3
- package/node_modules/@poe-code/task-list/dist/types.js +25 -0
- package/node_modules/@poe-code/task-list/package.json +1 -0
- package/package.json +11 -4
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { Readable, Writable } from "node:stream";
|
|
2
|
+
export interface RunHandle {
|
|
3
|
+
readonly pid: number | null;
|
|
4
|
+
readonly stdout: Readable | null;
|
|
5
|
+
readonly stderr: Readable | null;
|
|
6
|
+
readonly stdin: Writable | null;
|
|
7
|
+
readonly result: Promise<RunResult>;
|
|
8
|
+
kill(signal?: NodeJS.Signals): void;
|
|
9
|
+
}
|
|
10
|
+
export interface RunResult {
|
|
11
|
+
exitCode: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RunSpec {
|
|
14
|
+
command: string;
|
|
15
|
+
args?: string[];
|
|
16
|
+
cwd?: string;
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
stdin?: "pipe" | "inherit" | "ignore";
|
|
19
|
+
stdout?: "pipe" | "inherit";
|
|
20
|
+
stderr?: "pipe" | "inherit";
|
|
21
|
+
tty?: boolean;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
export interface Runner {
|
|
25
|
+
exec(spec: RunSpec): RunHandle;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
}
|
|
28
|
+
export interface HostRunnerOptions {
|
|
29
|
+
detached?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type ExecutionEnvType = "host" | "docker" | "e2b";
|
|
32
|
+
export type JobStatus = "running" | "exited" | "killed" | "lost";
|
|
33
|
+
export interface ExecutionEnvFactory {
|
|
34
|
+
readonly type: ExecutionEnvType;
|
|
35
|
+
readonly supportsDetach?: boolean;
|
|
36
|
+
open(spec: OpenSpec): Promise<OpenedEnv>;
|
|
37
|
+
attach(envId: string, context?: AttachedJobContext): Promise<OpenedEnv>;
|
|
38
|
+
}
|
|
39
|
+
export interface OpenSpec {
|
|
40
|
+
cwd: string;
|
|
41
|
+
runtime: unknown;
|
|
42
|
+
runner?: unknown;
|
|
43
|
+
state?: ExecutionState;
|
|
44
|
+
hostRunner?: Runner;
|
|
45
|
+
env: Record<string, string>;
|
|
46
|
+
uploadIgnoreFiles: string[];
|
|
47
|
+
jobLabel: {
|
|
48
|
+
tool: string;
|
|
49
|
+
argv: string[];
|
|
50
|
+
};
|
|
51
|
+
execution?: {
|
|
52
|
+
wrapForLogTee?: boolean;
|
|
53
|
+
stdin?: RunSpec["stdin"];
|
|
54
|
+
stdout?: RunSpec["stdout"];
|
|
55
|
+
stderr?: RunSpec["stderr"];
|
|
56
|
+
env?: RunSpec["env"];
|
|
57
|
+
tty?: boolean;
|
|
58
|
+
input?: string | Buffer;
|
|
59
|
+
captureOutput?: boolean;
|
|
60
|
+
activityTimeoutMs?: number;
|
|
61
|
+
onStdout?(chunk: string): void;
|
|
62
|
+
onStderr?(chunk: string): void;
|
|
63
|
+
};
|
|
64
|
+
shellSpec?: RunSpec;
|
|
65
|
+
}
|
|
66
|
+
export interface ExecutionState {
|
|
67
|
+
templates: {
|
|
68
|
+
get(backend: "docker" | "e2b", hash: string): Promise<TemplateEntry | null>;
|
|
69
|
+
put(backend: "docker" | "e2b", entry: TemplateEntry): Promise<void>;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export interface TemplateEntry {
|
|
73
|
+
hash: string;
|
|
74
|
+
template_id?: string;
|
|
75
|
+
image?: string;
|
|
76
|
+
runtime_type: string;
|
|
77
|
+
dockerfile_path: string;
|
|
78
|
+
built_at: string;
|
|
79
|
+
}
|
|
80
|
+
export interface UploadResult {
|
|
81
|
+
files: number;
|
|
82
|
+
bytes: number;
|
|
83
|
+
skipped: {
|
|
84
|
+
path: string;
|
|
85
|
+
bytes: number;
|
|
86
|
+
reason: "max_size";
|
|
87
|
+
}[];
|
|
88
|
+
}
|
|
89
|
+
export interface DownloadResult {
|
|
90
|
+
files: number;
|
|
91
|
+
bytes: number;
|
|
92
|
+
conflicts: {
|
|
93
|
+
path: string;
|
|
94
|
+
reason: "local_modified";
|
|
95
|
+
}[];
|
|
96
|
+
}
|
|
97
|
+
export interface LogChunk {
|
|
98
|
+
byteOffset: number;
|
|
99
|
+
data: string;
|
|
100
|
+
}
|
|
101
|
+
export interface AttachedJobContext {
|
|
102
|
+
jobId: string;
|
|
103
|
+
tool: string;
|
|
104
|
+
argv: string[];
|
|
105
|
+
cwd: string;
|
|
106
|
+
}
|
|
107
|
+
export interface OpenedEnv {
|
|
108
|
+
readonly id: string;
|
|
109
|
+
readonly job: JobHandle | null;
|
|
110
|
+
uploadWorkspace(): Promise<UploadResult>;
|
|
111
|
+
downloadWorkspace(opts: {
|
|
112
|
+
conflictPolicy: "refuse" | "overwrite";
|
|
113
|
+
}): Promise<DownloadResult>;
|
|
114
|
+
exec(spec: RunSpec): RunHandle;
|
|
115
|
+
detach(): Promise<JobHandle>;
|
|
116
|
+
shell(): RunHandle;
|
|
117
|
+
close(): Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
export interface JobHandle {
|
|
120
|
+
readonly id: string;
|
|
121
|
+
readonly envId: string;
|
|
122
|
+
readonly tool: string;
|
|
123
|
+
readonly argv: string[];
|
|
124
|
+
status(): Promise<JobStatus>;
|
|
125
|
+
stream(opts?: {
|
|
126
|
+
sinceByte?: number;
|
|
127
|
+
since?: Date;
|
|
128
|
+
}): AsyncIterable<LogChunk>;
|
|
129
|
+
wait(): Promise<{
|
|
130
|
+
exitCode: number;
|
|
131
|
+
}>;
|
|
132
|
+
kill(signal?: NodeJS.Signals): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
export type Engine = "docker" | "podman";
|
|
135
|
+
export interface DockerMount {
|
|
136
|
+
source: string;
|
|
137
|
+
target: string;
|
|
138
|
+
readonly?: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface DockerPortMapping {
|
|
141
|
+
host: number;
|
|
142
|
+
container: number;
|
|
143
|
+
protocol?: "tcp" | "udp";
|
|
144
|
+
}
|
|
145
|
+
export interface DockerRunnerOptions {
|
|
146
|
+
image: string;
|
|
147
|
+
engine?: Engine;
|
|
148
|
+
context?: string;
|
|
149
|
+
mounts?: DockerMount[];
|
|
150
|
+
ports?: DockerPortMapping[];
|
|
151
|
+
network?: string;
|
|
152
|
+
extraArgs?: string[];
|
|
153
|
+
containerName?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface DockerRunArgs {
|
|
156
|
+
engine: Engine;
|
|
157
|
+
context: string | null;
|
|
158
|
+
image: string;
|
|
159
|
+
command: string;
|
|
160
|
+
args: string[];
|
|
161
|
+
cwd?: string;
|
|
162
|
+
env?: Record<string, string>;
|
|
163
|
+
mounts: DockerMount[];
|
|
164
|
+
ports: DockerPortMapping[];
|
|
165
|
+
network?: string;
|
|
166
|
+
containerName: string;
|
|
167
|
+
detached: boolean;
|
|
168
|
+
interactive: boolean;
|
|
169
|
+
tty: boolean;
|
|
170
|
+
rm: boolean;
|
|
171
|
+
extraArgs: string[];
|
|
172
|
+
}
|
|
173
|
+
export interface MockRunBehavior {
|
|
174
|
+
pid?: number;
|
|
175
|
+
exitCode: number;
|
|
176
|
+
exitAfterMs?: number;
|
|
177
|
+
stdout?: string[];
|
|
178
|
+
stderr?: string[];
|
|
179
|
+
stdoutInterval?: number;
|
|
180
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@poe-code/process-runner",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./testing": {
|
|
14
|
+
"types": "./dist/testing/index.d.ts",
|
|
15
|
+
"import": "./dist/testing/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"test": "cd ../.. && vitest run --config vitest.config.ts packages/process-runner/src/**/*.test.ts",
|
|
21
|
+
"test:unit": "cd ../.. && vitest run --config vitest.config.ts packages/process-runner/src/**/*.test.ts",
|
|
22
|
+
"lint": "cd ../.. && eslint packages/process-runner/src --ext ts && tsc -p packages/process-runner/tsconfig.json --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -4,10 +4,13 @@ Multi-list task manager with pluggable storage backends.
|
|
|
4
4
|
|
|
5
5
|
## Backends
|
|
6
6
|
|
|
7
|
-
`@poe-code/task-list` exposes one API over
|
|
7
|
+
`@poe-code/task-list` exposes one API over these backends:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
| Backend | Storage |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `markdown-dir` | One Markdown file per task, organized into subdirectories per list. |
|
|
12
|
+
| `yaml-file` | One YAML document with a top-level `lists:` mapping. |
|
|
13
|
+
| `gh-issues` | GitHub Issues in one repository, ordered and state-tracked through a GitHub Project v2 Status field. |
|
|
11
14
|
|
|
12
15
|
The task lifecycle is `draft -> planned -> in-progress -> done -> archived`. `archived` is terminal.
|
|
13
16
|
|
|
@@ -47,7 +50,7 @@ Pass a custom machine with `openTaskList({ stateMachine })`. If omitted, the pac
|
|
|
47
50
|
|
|
48
51
|
| Option | Type | Default | Behavior |
|
|
49
52
|
| --- | --- | --- | --- |
|
|
50
|
-
| `type` | `"markdown-dir" \| "yaml-file"` | required | Selects the backend implementation. |
|
|
53
|
+
| `type` | `"markdown-dir" \| "yaml-file" \| "gh-issues"` | required | Selects the backend implementation. |
|
|
51
54
|
| `path` | `string` | required | Root directory for `markdown-dir` or YAML file path for `yaml-file`. |
|
|
52
55
|
| `defaults` | `TaskDefaults` | `{ metadata: {} }` | Seeds omitted metadata on new tasks only. New tasks always start at the configured state machine's initial state. |
|
|
53
56
|
| `create` | `boolean` | `false` | Creates missing storage for the selected backend when enabled. |
|
|
@@ -58,7 +61,9 @@ Pass a custom machine with `openTaskList({ stateMachine })`. If omitted, the pac
|
|
|
58
61
|
|
|
59
62
|
## Env vars
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
| Env var | Behavior |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `GH_HOST` | Defers to gh CLI's host configuration; set GH_HOST to override. |
|
|
62
67
|
|
|
63
68
|
## Usage
|
|
64
69
|
|
|
@@ -105,6 +110,36 @@ await planning.fire("review-release", "plan");
|
|
|
105
110
|
await planning.fire("review-release", "start");
|
|
106
111
|
```
|
|
107
112
|
|
|
113
|
+
### `gh-issues`
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { openTaskList } from "@poe-code/task-list";
|
|
117
|
+
|
|
118
|
+
const taskList = await openTaskList({
|
|
119
|
+
type: "gh-issues",
|
|
120
|
+
repo: "octo-org/octo-repo",
|
|
121
|
+
project: {
|
|
122
|
+
owner: "octo-org",
|
|
123
|
+
number: 7
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const project = taskList.list("octo-org/7");
|
|
128
|
+
|
|
129
|
+
await taskList.lists(); // ["octo-org/7"]
|
|
130
|
+
|
|
131
|
+
const created = await project.create({
|
|
132
|
+
id: "local-id-is-ignored",
|
|
133
|
+
name: "Review release checklist"
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
await project.fire(created.id, "In Progress");
|
|
137
|
+
await project.move(created.id, { position: "top" });
|
|
138
|
+
await project.move(created.id, { after: "42" });
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`gh-issues` exposes one list named `${project.owner}/${project.number}`. `create()` ignores `TaskCreate.id` because GitHub assigns issue numbers. `fire(state)` writes the Project v2 `Status` field to the matching single-select option. `move()` reorders project items.
|
|
142
|
+
|
|
108
143
|
## Notes
|
|
109
144
|
|
|
110
145
|
The package never overwrites existing task files or store files. `defaults.metadata` is applied only when creating new tasks and does not retroactively update existing tasks.
|
|
@@ -112,3 +147,12 @@ The package never overwrites existing task files or store files. `defaults.metad
|
|
|
112
147
|
Task state changes are event-driven: use `fire(id, event)` to move between states, `canFire(id, event)` to check whether an event is currently legal, and `events(id)` to list the currently legal event names. There is no `transition()` API.
|
|
113
148
|
|
|
114
149
|
`create()` always starts new tasks at `stateMachine.initial`. `update()` cannot change `state`; use `fire()` instead.
|
|
150
|
+
|
|
151
|
+
### `gh-issues` limitations
|
|
152
|
+
|
|
153
|
+
- The state machine is fetched at open and frozen for the session; re-open to refresh project Status options.
|
|
154
|
+
- `archived` is not supported and returns an empty result.
|
|
155
|
+
- `update()` does not write labels, assignees, or milestone in v1.
|
|
156
|
+
- `moveBetweenLists()` is unsupported on `gh-issues`.
|
|
157
|
+
- `id` on `TaskCreate` is ignored on this backend.
|
|
158
|
+
- `gh auth token` must be available, or pass `auth: { token }`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Runner } from "@poe-code/process-runner";
|
|
2
|
+
export interface GhClientOptions {
|
|
3
|
+
token: string;
|
|
4
|
+
endpoint?: string;
|
|
5
|
+
fetch?: typeof fetch;
|
|
6
|
+
}
|
|
7
|
+
export interface GhClient {
|
|
8
|
+
graphql<T>(query: string, variables: Record<string, unknown>): Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createGhClient(options: GhClientOptions): GhClient;
|
|
11
|
+
export interface ResolveAuthOptions {
|
|
12
|
+
explicitToken?: string;
|
|
13
|
+
runner?: Runner;
|
|
14
|
+
}
|
|
15
|
+
export declare function resolveAuth(options: ResolveAuthOptions): Promise<string>;
|
|
16
|
+
export interface ResolveEndpointOptions {
|
|
17
|
+
env?: Record<string, string | undefined>;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveEndpoint(options?: ResolveEndpointOptions): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { text } from "node:stream/consumers";
|
|
2
|
+
import { createHostRunner } from "@poe-code/process-runner";
|
|
3
|
+
const DEFAULT_ENDPOINT = "https://api.github.com/graphql";
|
|
4
|
+
const USER_AGENT = "poe-code-task-list/0.0.1";
|
|
5
|
+
const AUTH_ERROR = "gh auth token failed; install gh, run 'gh auth login', or pass auth: { token }";
|
|
6
|
+
export function createGhClient(options) {
|
|
7
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
8
|
+
const endpoint = options.endpoint || DEFAULT_ENDPOINT;
|
|
9
|
+
return {
|
|
10
|
+
async graphql(query, variables) {
|
|
11
|
+
const response = await fetchImpl(endpoint, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${options.token}`,
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
"User-Agent": USER_AGENT
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify({ query, variables })
|
|
19
|
+
});
|
|
20
|
+
const body = await response.text();
|
|
21
|
+
if (response.status !== 200) {
|
|
22
|
+
throw new Error(`GitHub GraphQL request failed with status ${response.status}: ${body}`);
|
|
23
|
+
}
|
|
24
|
+
const parsed = JSON.parse(body);
|
|
25
|
+
const firstError = parsed.errors?.[0];
|
|
26
|
+
if (firstError !== undefined) {
|
|
27
|
+
throw new Error(firstError.message ?? "GitHub GraphQL request failed");
|
|
28
|
+
}
|
|
29
|
+
return parsed.data;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export async function resolveAuth(options) {
|
|
34
|
+
if (options.explicitToken !== undefined) {
|
|
35
|
+
return options.explicitToken;
|
|
36
|
+
}
|
|
37
|
+
const runner = options.runner ?? createHostRunner();
|
|
38
|
+
const handle = runner.exec({
|
|
39
|
+
command: "gh",
|
|
40
|
+
args: ["auth", "token"],
|
|
41
|
+
stdout: "pipe",
|
|
42
|
+
stderr: "pipe"
|
|
43
|
+
});
|
|
44
|
+
const [stdout, , result] = await Promise.all([
|
|
45
|
+
handle.stdout === null ? Promise.resolve("") : text(handle.stdout),
|
|
46
|
+
handle.stderr === null ? Promise.resolve("") : text(handle.stderr),
|
|
47
|
+
handle.result
|
|
48
|
+
]);
|
|
49
|
+
const token = stdout.trim();
|
|
50
|
+
if (result.exitCode !== 0 || token.length === 0) {
|
|
51
|
+
throw new Error(AUTH_ERROR);
|
|
52
|
+
}
|
|
53
|
+
return token;
|
|
54
|
+
}
|
|
55
|
+
export function resolveEndpoint(options = {}) {
|
|
56
|
+
const env = options.env ?? process.env;
|
|
57
|
+
const host = env.GH_HOST;
|
|
58
|
+
if (host !== undefined && host !== "" && host !== "github.com") {
|
|
59
|
+
return `https://${host}/api/graphql`;
|
|
60
|
+
}
|
|
61
|
+
return DEFAULT_ENDPOINT;
|
|
62
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TaskDefaults, TaskList } from "../types.js";
|
|
2
|
+
export interface GhIssuesBackendDeps {
|
|
3
|
+
repo: string;
|
|
4
|
+
project: {
|
|
5
|
+
owner: string;
|
|
6
|
+
number: number;
|
|
7
|
+
};
|
|
8
|
+
defaults: Required<TaskDefaults>;
|
|
9
|
+
token: string;
|
|
10
|
+
endpoint: string;
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
}
|
|
13
|
+
export declare function ghIssuesBackend(deps: GhIssuesBackendDeps): Promise<TaskList>;
|