lalph 0.1.66 → 0.1.68

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 CHANGED
@@ -141381,7 +141381,10 @@ var ReviewThreads = class extends Class("github/ReviewThreads")({ edges: Array$1
141381
141381
  //#region src/Github/Cli.ts
141382
141382
  var GithubCli = class extends Service()("lalph/Github/Cli", { make: gen(function* () {
141383
141383
  const spawner = yield* ChildProcessSpawner;
141384
- const [owner, repo] = (yield* make$21`gh repo view --json nameWithOwner -q ${".nameWithOwner"}`.pipe(string, option$1, flatMap((o) => o.pipe(map$11(trim), filter$5(isNonEmpty), fromOption)))).split("/");
141384
+ const [owner, repo] = (yield* make$21`gh repo view --json nameWithOwner -q ${".nameWithOwner"}`.pipe(string, option$1, flatMap((o) => {
141385
+ const candidate = o.pipe(map$11(trim), filter$5(isNonEmpty));
141386
+ return isSome(candidate) ? succeed$1(candidate.value) : fail$4(new GithubCliRepoNotFound());
141387
+ }))).split("/");
141385
141388
  const reviewComments = (pr) => make$21`gh api graphql -f owner=${owner} -f repo=${repo} -F pr=${pr} -f query=${githubReviewCommentsQuery}`.pipe(string, flatMap(decodeEffect(CommentsFromJson)), map$5((data) => {
141386
141389
  return {
141387
141390
  comments: data.data.repository.pullRequest.comments.edges.map((edge) => edge.node),
@@ -141389,8 +141392,8 @@ var GithubCli = class extends Service()("lalph/Github/Cli", { make: gen(function
141389
141392
  };
141390
141393
  }), provideService(ChildProcessSpawner, spawner));
141391
141394
  const prFeedbackMd = (pr) => reviewComments(pr).pipe(map$5(({ comments, reviewThreads }) => {
141392
- if (comments.length === 0 && reviewThreads.length === 0) return `No review comments found.`;
141393
141395
  const eligibleReviewThreads = reviewThreads.filter((thread) => thread.shouldDisplayThread);
141396
+ if (comments.length === 0 && eligibleReviewThreads.length === 0) return `No review comments found.`;
141394
141397
  let content = `# PR feedback
141395
141398
 
141396
141399
  Comments are rendered in XML format.`;
@@ -141423,6 +141426,9 @@ ${generalCommentsXml}
141423
141426
  }) }) {
141424
141427
  static layer = effect(this, this.make);
141425
141428
  };
141429
+ var GithubCliRepoNotFound = class extends TaggedError("GithubCliRepoNotFound") {
141430
+ message = "GitHub repository not found. Ensure the current directory is inside a git repo with a GitHub remote.";
141431
+ };
141426
141432
  const renderReviewComments = (comment, followup) => `<comment author="${comment.author.login}" path="${comment.path}"${comment.originalLine ? ` originalLine="${comment.originalLine}"` : ""}>
141427
141433
  <diffHunk><![CDATA[${comment.diffHunk}]]></diffHunk>
141428
141434
  <body><![CDATA[${comment.body}]]></body>${followup.length > 0 ? `
@@ -142436,7 +142442,7 @@ const commandSource = make$27("source").pipe(withDescription("Select the issue s
142436
142442
 
142437
142443
  //#endregion
142438
142444
  //#region package.json
142439
- var version = "0.1.66";
142445
+ var version = "0.1.68";
142440
142446
 
142441
142447
  //#endregion
142442
142448
  //#region src/cli.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lalph",
3
3
  "type": "module",
4
- "version": "0.1.66",
4
+ "version": "0.1.68",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/src/Github/Cli.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Effect, Layer, Option, Schema, ServiceMap, String } from "effect"
1
+ import { Data, Effect, Layer, Option, Schema, ServiceMap, String } from "effect"
2
2
  import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
3
3
  import {
4
4
  CommentsData,
@@ -16,13 +16,15 @@ export class GithubCli extends ServiceMap.Service<GithubCli>()(
16
16
  yield* ChildProcess.make`gh repo view --json nameWithOwner -q ${".nameWithOwner"}`.pipe(
17
17
  ChildProcess.string,
18
18
  Effect.option,
19
- Effect.flatMap((o) =>
20
- o.pipe(
19
+ Effect.flatMap((o) => {
20
+ const candidate = o.pipe(
21
21
  Option.map(String.trim),
22
22
  Option.filter(String.isNonEmpty),
23
- Effect.fromOption,
24
- ),
25
- ),
23
+ )
24
+ return Option.isSome(candidate)
25
+ ? Effect.succeed(candidate.value)
26
+ : Effect.fail(new GithubCliRepoNotFound())
27
+ }),
26
28
  )
27
29
  const [owner, repo] = nameWithOwner.split("/") as [string, string]
28
30
 
@@ -50,14 +52,14 @@ export class GithubCli extends ServiceMap.Service<GithubCli>()(
50
52
  const prFeedbackMd = (pr: number) =>
51
53
  reviewComments(pr).pipe(
52
54
  Effect.map(({ comments, reviewThreads }) => {
53
- if (comments.length === 0 && reviewThreads.length === 0) {
54
- return `No review comments found.`
55
- }
56
-
57
55
  const eligibleReviewThreads = reviewThreads.filter(
58
56
  (thread) => thread.shouldDisplayThread,
59
57
  )
60
58
 
59
+ if (comments.length === 0 && eligibleReviewThreads.length === 0) {
60
+ return `No review comments found.`
61
+ }
62
+
61
63
  let content = `# PR feedback
62
64
 
63
65
  Comments are rendered in XML format.`
@@ -102,6 +104,13 @@ ${generalCommentsXml}
102
104
  static layer = Layer.effect(this, this.make)
103
105
  }
104
106
 
107
+ export class GithubCliRepoNotFound extends Data.TaggedError(
108
+ "GithubCliRepoNotFound",
109
+ ) {
110
+ readonly message =
111
+ "GitHub repository not found. Ensure the current directory is inside a git repo with a GitHub remote."
112
+ }
113
+
105
114
  // markdown helper functions
106
115
 
107
116
  const renderReviewComments = (