lalph 0.3.28 → 0.3.29
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.mjs +462 -335
- package/package.json +5 -4
- package/src/Github.ts +67 -49
- package/src/Worktree.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lalph",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.29",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -23,12 +23,13 @@
|
|
|
23
23
|
"@changesets/changelog-github": "^0.5.2",
|
|
24
24
|
"@changesets/cli": "^2.29.8",
|
|
25
25
|
"@effect/language-service": "^0.75.1",
|
|
26
|
-
"@effect/platform-node": "4.0.0-beta.
|
|
26
|
+
"@effect/platform-node": "4.0.0-beta.7",
|
|
27
27
|
"@linear/sdk": "^75.0.0",
|
|
28
28
|
"@octokit/plugin-rest-endpoint-methods": "^17.0.0",
|
|
29
29
|
"@octokit/types": "^16.0.0",
|
|
30
|
+
"@typescript/native-preview": "7.0.0-dev.20260219.1",
|
|
30
31
|
"concurrently": "^9.2.1",
|
|
31
|
-
"effect": "4.0.0-beta.
|
|
32
|
+
"effect": "4.0.0-beta.7",
|
|
32
33
|
"husky": "^9.1.7",
|
|
33
34
|
"lint-staged": "^16.2.7",
|
|
34
35
|
"octokit": "^5.0.5",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
]
|
|
49
50
|
},
|
|
50
51
|
"scripts": {
|
|
51
|
-
"check": "concurrently \"
|
|
52
|
+
"check": "concurrently \"pnpm tsgo --noEmit\" \"pnpm oxlint -c .oxlintrc.json\" \"pnpm build\"",
|
|
52
53
|
"build": "tsdown"
|
|
53
54
|
}
|
|
54
55
|
}
|
package/src/Github.ts
CHANGED
|
@@ -31,69 +31,87 @@ export class GithubError extends Data.TaggedError("GithubError")<{
|
|
|
31
31
|
readonly cause: unknown
|
|
32
32
|
}> {}
|
|
33
33
|
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
34
|
+
export type GithubApi = Api["rest"]
|
|
35
|
+
export type GithubResponse<A> = OctokitResponse<A>
|
|
36
|
+
|
|
37
|
+
export interface GithubService {
|
|
38
|
+
readonly request: <A>(
|
|
39
|
+
f: (_: GithubApi) => Promise<A>,
|
|
40
|
+
) => Effect.Effect<A, GithubError, never>
|
|
41
|
+
readonly wrap: <A, Args extends Array<unknown>>(
|
|
42
|
+
f: (_: GithubApi) => (...args: Args) => Promise<GithubResponse<A>>,
|
|
43
|
+
) => (...args: Args) => Effect.Effect<A, GithubError, never>
|
|
44
|
+
readonly stream: <A>(
|
|
45
|
+
f: (_: GithubApi, page: number) => Promise<GithubResponse<Array<A>>>,
|
|
46
|
+
) => Stream.Stream<A, GithubError, never>
|
|
47
|
+
}
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
export class Github extends ServiceMap.Service<Github, GithubService>()(
|
|
50
|
+
"lalph/Github",
|
|
51
|
+
{
|
|
52
|
+
make: Effect.gen(function* () {
|
|
53
|
+
const tokens = yield* TokenManager
|
|
54
|
+
const clients = yield* RcMap.make({
|
|
55
|
+
lookup: (token: string) =>
|
|
56
|
+
Effect.succeed(new Octokit({ auth: token }).rest),
|
|
57
|
+
idleTimeToLive: "1 minute",
|
|
58
|
+
})
|
|
59
|
+
const getClient = tokens.get.pipe(
|
|
60
|
+
Effect.flatMap(({ token }) => RcMap.get(clients, token)),
|
|
61
|
+
Effect.mapError((cause) => new GithubError({ cause })),
|
|
57
62
|
)
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
<A, Args extends Array<unknown>>(
|
|
61
|
-
f: (_: Api["rest"]) => (...args: Args) => Promise<OctokitResponse<A>>,
|
|
62
|
-
) =>
|
|
63
|
-
(...args: Args) =>
|
|
64
|
+
const request = <A>(f: (_: GithubApi) => Promise<A>) =>
|
|
64
65
|
getClient.pipe(
|
|
65
66
|
Effect.flatMap((rest) =>
|
|
66
67
|
Effect.tryPromise({
|
|
67
|
-
try: () => f(rest)
|
|
68
|
+
try: () => f(rest),
|
|
68
69
|
catch: (cause) => new GithubError({ cause }),
|
|
69
70
|
}),
|
|
70
71
|
),
|
|
71
72
|
Effect.scoped,
|
|
72
|
-
Effect.
|
|
73
|
-
Effect.withSpan("Github.wrap"),
|
|
73
|
+
Effect.withSpan("Github.request"),
|
|
74
74
|
)
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Effect.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(_) =>
|
|
76
|
+
const wrap =
|
|
77
|
+
<A, Args extends Array<unknown>>(
|
|
78
|
+
f: (_: GithubApi) => (...args: Args) => Promise<OctokitResponse<A>>,
|
|
79
|
+
) =>
|
|
80
|
+
(...args: Args) =>
|
|
81
|
+
getClient.pipe(
|
|
82
|
+
Effect.flatMap((rest) =>
|
|
83
|
+
Effect.tryPromise({
|
|
84
|
+
try: () => f(rest)(...args),
|
|
85
|
+
catch: (cause) => new GithubError({ cause }),
|
|
86
|
+
}),
|
|
87
|
+
),
|
|
88
|
+
Effect.scoped,
|
|
89
|
+
Effect.map((_) => _.data),
|
|
90
|
+
Effect.withSpan("Github.wrap"),
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
const stream = <A>(
|
|
94
|
+
f: (_: GithubApi, page: number) => Promise<OctokitResponse<Array<A>>>,
|
|
95
|
+
) =>
|
|
96
|
+
Stream.paginate(0, (page) =>
|
|
97
|
+
getClient.pipe(
|
|
98
|
+
Effect.flatMap((rest) =>
|
|
99
|
+
Effect.tryPromise({
|
|
100
|
+
try: () => f(rest, page),
|
|
101
|
+
catch: (cause) => new GithubError({ cause }),
|
|
102
|
+
}),
|
|
103
|
+
),
|
|
104
|
+
Effect.scoped,
|
|
105
|
+
Effect.map(
|
|
106
|
+
(_) => [_.data, maybeNextPage(page, _.headers.link)] as const,
|
|
107
|
+
),
|
|
90
108
|
),
|
|
91
|
-
)
|
|
92
|
-
)
|
|
109
|
+
)
|
|
93
110
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
111
|
+
return { request, wrap, stream } as const
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
) {
|
|
97
115
|
static layer = Layer.effect(this, this.make).pipe(
|
|
98
116
|
Layer.provide(TokenManager.layer),
|
|
99
117
|
)
|
package/src/Worktree.ts
CHANGED
|
@@ -264,7 +264,7 @@ const makeExecHelpers = Effect.fnUntraced(function* (options: {
|
|
|
264
264
|
if (DateTime.isLessThan(deadline, now)) {
|
|
265
265
|
return Effect.fail(new RunnerStalled())
|
|
266
266
|
}
|
|
267
|
-
const timeUntilDeadline = DateTime.
|
|
267
|
+
const timeUntilDeadline = DateTime.distance(deadline, now)
|
|
268
268
|
return Effect.flatMap(Effect.sleep(timeUntilDeadline), loop)
|
|
269
269
|
})
|
|
270
270
|
|