lalph 0.3.36 → 0.3.37
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 +15 -9
- package/package.json +1 -1
- package/src/Github.ts +82 -41
package/dist/cli.mjs
CHANGED
|
@@ -159140,6 +159140,7 @@ const GithubIssueSource = effect$1(IssueSource, gen(function* () {
|
|
|
159140
159140
|
capacity: Number.POSITIVE_INFINITY
|
|
159141
159141
|
});
|
|
159142
159142
|
const hasLabel = (label, name) => label.some((l) => typeof l === "string" ? l === name : l.name === name);
|
|
159143
|
+
const matchesLabelFilter = (labels, labelFilter) => labelFilter.pipe(map$14((label) => hasLabel(labels, label)), getOrElse$1(() => true));
|
|
159143
159144
|
const listOpenBlockedBy = (issueId) => pipe(github.stream((rest, page) => rest.issues.listDependenciesBlockedBy({
|
|
159144
159145
|
owner: cli.owner,
|
|
159145
159146
|
repo: cli.repo,
|
|
@@ -159147,13 +159148,14 @@ const GithubIssueSource = effect$1(IssueSource, gen(function* () {
|
|
|
159147
159148
|
per_page: 100,
|
|
159148
159149
|
page
|
|
159149
159150
|
})), filter$2((issue) => issue.state === "open"));
|
|
159150
|
-
const recentlyClosed = pipe(github.stream((rest, page) => rest.issues.listForRepo({
|
|
159151
|
+
const recentlyClosed = (labelFilter) => pipe(github.stream((rest, page) => rest.issues.listForRepo({
|
|
159151
159152
|
owner: cli.owner,
|
|
159152
159153
|
repo: cli.repo,
|
|
159153
159154
|
state: "closed",
|
|
159154
159155
|
per_page: 100,
|
|
159155
159156
|
page,
|
|
159156
|
-
since: nowUnsafe().pipe(subtract({ days: 3 }), formatIso)
|
|
159157
|
+
since: nowUnsafe().pipe(subtract({ days: 3 }), formatIso),
|
|
159158
|
+
labels: getOrUndefined(labelFilter)
|
|
159157
159159
|
})), filter$2((issue) => issue.state_reason !== "not_planned"));
|
|
159158
159160
|
const presets = yield* getPresetsWithMetadata("github", PresetMetadata);
|
|
159159
159161
|
const issuePresetMap = /* @__PURE__ */ new Map();
|
|
@@ -159181,16 +159183,16 @@ const GithubIssueSource = effect$1(IssueSource, gen(function* () {
|
|
|
159181
159183
|
return yield* projectFilterSelect;
|
|
159182
159184
|
});
|
|
159183
159185
|
const repository = `${cli.owner}/${cli.repo}`.toLowerCase();
|
|
159184
|
-
const projectIssues = (
|
|
159186
|
+
const projectIssues = (options) => {
|
|
159185
159187
|
const threeDaysAgo = nowUnsafe().pipe(subtract({ days: 3 }));
|
|
159186
159188
|
return paginate$1(null, (cursor) => github.graphql(githubProjectItemsQuery, {
|
|
159187
|
-
projectId: project.id,
|
|
159189
|
+
projectId: options.project.id,
|
|
159188
159190
|
after: cursor
|
|
159189
|
-
}).pipe(map$8((data) => [data.node.items.nodes.
|
|
159191
|
+
}).pipe(map$8((data) => [data.node.items.nodes.flatMap((item) => isGithubProjectIssue(item.content) ? [item.content] : []), fromNullOr(data.node.items.pageInfo.endCursor)]))).pipe(filter$2((issue) => issue.repository.nameWithOwner.toLowerCase() === repository && (!issue.closedAt || makeUnsafe$10(issue.closedAt).pipe(isGreaterThan$2(threeDaysAgo)))), map$6((issue) => ({
|
|
159190
159192
|
...issue,
|
|
159191
159193
|
state: issue.state.toLowerCase(),
|
|
159192
159194
|
labels: issue.labels.nodes.map((label) => label.name)
|
|
159193
|
-
})));
|
|
159195
|
+
})), filter$2((issue) => matchesLabelFilter(issue.labels, options.labelFilter)));
|
|
159194
159196
|
};
|
|
159195
159197
|
const repoIssues = (options) => pipe(github.stream((rest, page) => rest.issues.listForRepo({
|
|
159196
159198
|
owner: cli.owner,
|
|
@@ -159199,9 +159201,12 @@ const GithubIssueSource = effect$1(IssueSource, gen(function* () {
|
|
|
159199
159201
|
per_page: 100,
|
|
159200
159202
|
page,
|
|
159201
159203
|
labels: getOrUndefined(options.labelFilter)
|
|
159202
|
-
})), merge$2(recentlyClosed), filter$2((issue) => issue.pull_request === void 0));
|
|
159204
|
+
})), merge$2(recentlyClosed(options.labelFilter)), filter$2((issue) => issue.pull_request === void 0));
|
|
159203
159205
|
const issues = (options) => {
|
|
159204
|
-
return pipe(unify(isSome(options.projectFilter) ? projectIssues(
|
|
159206
|
+
return pipe(unify(isSome(options.projectFilter) ? projectIssues({
|
|
159207
|
+
project: options.projectFilter.value,
|
|
159208
|
+
labelFilter: options.labelFilter
|
|
159209
|
+
}) : repoIssues(options)), mapEffect$1(fnUntraced(function* (issue) {
|
|
159205
159210
|
const id = `#${issue.number}`;
|
|
159206
159211
|
const dependencies = yield* listOpenBlockedBy(issue.number).pipe(runCollect);
|
|
159207
159212
|
const state = issue.state === "closed" ? "done" : hasLabel(issue.labels, "in-progress") ? "in-progress" : hasLabel(issue.labels, "in-review") ? "in-review" : "todo";
|
|
@@ -159426,6 +159431,7 @@ const getOrSelectAutoMergeLabel = gen(function* () {
|
|
|
159426
159431
|
return yield* autoMergeLabelSelect;
|
|
159427
159432
|
});
|
|
159428
159433
|
const PresetMetadata = Struct({ label: NonEmptyString });
|
|
159434
|
+
const isGithubProjectIssue = (content) => content !== null && content.__typename === "Issue";
|
|
159429
159435
|
const githubProjectsQuery = `
|
|
159430
159436
|
query GithubProjects($after: String) {
|
|
159431
159437
|
viewer {
|
|
@@ -161037,7 +161043,7 @@ const commandSource = make$34("source").pipe(withDescription("Select the issue s
|
|
|
161037
161043
|
|
|
161038
161044
|
//#endregion
|
|
161039
161045
|
//#region package.json
|
|
161040
|
-
var version = "0.3.
|
|
161046
|
+
var version = "0.3.37";
|
|
161041
161047
|
|
|
161042
161048
|
//#endregion
|
|
161043
161049
|
//#region src/commands/projects/ls.ts
|
package/package.json
CHANGED
package/src/Github.ts
CHANGED
|
@@ -221,6 +221,20 @@ export const GithubIssueSource = Layer.effect(
|
|
|
221
221
|
): boolean =>
|
|
222
222
|
label.some((l) => (typeof l === "string" ? l === name : l.name === name))
|
|
223
223
|
|
|
224
|
+
const matchesLabelFilter = (
|
|
225
|
+
labels: ReadonlyArray<
|
|
226
|
+
| string
|
|
227
|
+
| {
|
|
228
|
+
readonly name?: string
|
|
229
|
+
}
|
|
230
|
+
>,
|
|
231
|
+
labelFilter: Option.Option<string>,
|
|
232
|
+
): boolean =>
|
|
233
|
+
labelFilter.pipe(
|
|
234
|
+
Option.map((label) => hasLabel(labels, label)),
|
|
235
|
+
Option.getOrElse(() => true),
|
|
236
|
+
)
|
|
237
|
+
|
|
224
238
|
const listOpenBlockedBy = (issueId: number) =>
|
|
225
239
|
pipe(
|
|
226
240
|
github.stream((rest, page) =>
|
|
@@ -235,22 +249,24 @@ export const GithubIssueSource = Layer.effect(
|
|
|
235
249
|
Stream.filter((issue) => issue.state === "open"),
|
|
236
250
|
)
|
|
237
251
|
|
|
238
|
-
const recentlyClosed =
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
DateTime.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
const recentlyClosed = (labelFilter: Option.Option<string>) =>
|
|
253
|
+
pipe(
|
|
254
|
+
github.stream((rest, page) =>
|
|
255
|
+
rest.issues.listForRepo({
|
|
256
|
+
owner: cli.owner,
|
|
257
|
+
repo: cli.repo,
|
|
258
|
+
state: "closed",
|
|
259
|
+
per_page: 100,
|
|
260
|
+
page,
|
|
261
|
+
since: DateTime.nowUnsafe().pipe(
|
|
262
|
+
DateTime.subtract({ days: 3 }),
|
|
263
|
+
DateTime.formatIso,
|
|
264
|
+
),
|
|
265
|
+
labels: Option.getOrUndefined(labelFilter),
|
|
266
|
+
}),
|
|
267
|
+
),
|
|
268
|
+
Stream.filter((issue) => issue.state_reason !== "not_planned"),
|
|
269
|
+
)
|
|
254
270
|
|
|
255
271
|
const presets = yield* getPresetsWithMetadata("github", PresetMetadata)
|
|
256
272
|
const issuePresetMap = new Map<string, CliAgentPreset>()
|
|
@@ -308,28 +324,33 @@ export const GithubIssueSource = Layer.effect(
|
|
|
308
324
|
|
|
309
325
|
const repository = `${cli.owner}/${cli.repo}`.toLowerCase()
|
|
310
326
|
|
|
311
|
-
const projectIssues = (
|
|
327
|
+
const projectIssues = (options: {
|
|
328
|
+
readonly project: GithubProject
|
|
329
|
+
readonly labelFilter: Option.Option<string>
|
|
330
|
+
}) => {
|
|
312
331
|
const threeDaysAgo = DateTime.nowUnsafe().pipe(
|
|
313
332
|
DateTime.subtract({ days: 3 }),
|
|
314
333
|
)
|
|
315
334
|
return Stream.paginate(null, (cursor: string | null) =>
|
|
316
335
|
github
|
|
317
336
|
.graphql<GithubProjectItemsQuery>(githubProjectItemsQuery, {
|
|
318
|
-
projectId: project.id,
|
|
337
|
+
projectId: options.project.id,
|
|
319
338
|
after: cursor,
|
|
320
339
|
})
|
|
321
340
|
.pipe(
|
|
322
341
|
Effect.map((data) => [
|
|
323
|
-
data.node.items.nodes.
|
|
342
|
+
data.node.items.nodes.flatMap((item) =>
|
|
343
|
+
isGithubProjectIssue(item.content) ? [item.content] : [],
|
|
344
|
+
),
|
|
324
345
|
Option.fromNullOr(data.node.items.pageInfo.endCursor),
|
|
325
346
|
]),
|
|
326
347
|
),
|
|
327
348
|
).pipe(
|
|
328
349
|
Stream.filter(
|
|
329
|
-
(
|
|
330
|
-
|
|
331
|
-
(!
|
|
332
|
-
DateTime.makeUnsafe(
|
|
350
|
+
(issue) =>
|
|
351
|
+
issue.repository.nameWithOwner.toLowerCase() === repository &&
|
|
352
|
+
(!issue.closedAt ||
|
|
353
|
+
DateTime.makeUnsafe(issue.closedAt).pipe(
|
|
333
354
|
DateTime.isGreaterThan(threeDaysAgo),
|
|
334
355
|
)),
|
|
335
356
|
),
|
|
@@ -338,6 +359,9 @@ export const GithubIssueSource = Layer.effect(
|
|
|
338
359
|
state: issue.state.toLowerCase(),
|
|
339
360
|
labels: issue.labels.nodes.map((label) => label.name),
|
|
340
361
|
})),
|
|
362
|
+
Stream.filter((issue) =>
|
|
363
|
+
matchesLabelFilter(issue.labels, options.labelFilter),
|
|
364
|
+
),
|
|
341
365
|
)
|
|
342
366
|
}
|
|
343
367
|
|
|
@@ -355,7 +379,7 @@ export const GithubIssueSource = Layer.effect(
|
|
|
355
379
|
labels: Option.getOrUndefined(options.labelFilter),
|
|
356
380
|
}),
|
|
357
381
|
),
|
|
358
|
-
Stream.merge(recentlyClosed),
|
|
382
|
+
Stream.merge(recentlyClosed(options.labelFilter)),
|
|
359
383
|
Stream.filter((issue) => issue.pull_request === undefined),
|
|
360
384
|
)
|
|
361
385
|
|
|
@@ -366,7 +390,10 @@ export const GithubIssueSource = Layer.effect(
|
|
|
366
390
|
}) => {
|
|
367
391
|
const source = Unify.unify(
|
|
368
392
|
Option.isSome(options.projectFilter)
|
|
369
|
-
? projectIssues(
|
|
393
|
+
? projectIssues({
|
|
394
|
+
project: options.projectFilter.value,
|
|
395
|
+
labelFilter: options.labelFilter,
|
|
396
|
+
})
|
|
370
397
|
: repoIssues(options),
|
|
371
398
|
)
|
|
372
399
|
|
|
@@ -827,26 +854,35 @@ type GithubProjectsQuery = {
|
|
|
827
854
|
}
|
|
828
855
|
}
|
|
829
856
|
|
|
857
|
+
type GithubProjectIssue = {
|
|
858
|
+
readonly __typename: "Issue"
|
|
859
|
+
readonly number: number
|
|
860
|
+
readonly repository: {
|
|
861
|
+
readonly nameWithOwner: string
|
|
862
|
+
}
|
|
863
|
+
readonly title: string
|
|
864
|
+
readonly body: string
|
|
865
|
+
readonly state: string
|
|
866
|
+
readonly labels: {
|
|
867
|
+
readonly nodes: ReadonlyArray<{
|
|
868
|
+
readonly name: string
|
|
869
|
+
}>
|
|
870
|
+
}
|
|
871
|
+
readonly closedAt: string | null
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
type GithubProjectItemContent =
|
|
875
|
+
| GithubProjectIssue
|
|
876
|
+
| {
|
|
877
|
+
readonly __typename: string
|
|
878
|
+
}
|
|
879
|
+
| null
|
|
880
|
+
|
|
830
881
|
type GithubProjectItemsQuery = {
|
|
831
882
|
readonly node: {
|
|
832
883
|
readonly items: {
|
|
833
884
|
readonly nodes: ReadonlyArray<{
|
|
834
|
-
readonly content:
|
|
835
|
-
readonly __typename: string
|
|
836
|
-
readonly number: number
|
|
837
|
-
readonly repository: {
|
|
838
|
-
readonly nameWithOwner: string
|
|
839
|
-
}
|
|
840
|
-
readonly title: string
|
|
841
|
-
readonly body: string
|
|
842
|
-
readonly state: string
|
|
843
|
-
readonly labels: {
|
|
844
|
-
readonly nodes: ReadonlyArray<{
|
|
845
|
-
readonly name: string
|
|
846
|
-
}>
|
|
847
|
-
}
|
|
848
|
-
readonly closedAt: string | null
|
|
849
|
-
}
|
|
885
|
+
readonly content: GithubProjectItemContent
|
|
850
886
|
}>
|
|
851
887
|
readonly pageInfo: {
|
|
852
888
|
readonly endCursor: string | null
|
|
@@ -858,6 +894,11 @@ type GithubProjectItemsQuery = {
|
|
|
858
894
|
|
|
859
895
|
// == helpers
|
|
860
896
|
|
|
897
|
+
const isGithubProjectIssue = (
|
|
898
|
+
content: GithubProjectItemContent,
|
|
899
|
+
): content is GithubProjectIssue =>
|
|
900
|
+
content !== null && content.__typename === "Issue"
|
|
901
|
+
|
|
861
902
|
const githubProjectsQuery = `
|
|
862
903
|
query GithubProjects($after: String) {
|
|
863
904
|
viewer {
|