@staff0rd/assist 0.848.0 → 0.849.0

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/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.848.0",
9
+ version: "0.849.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -36906,20 +36906,22 @@ function runReviewSubmission(mutation, body) {
36906
36906
  const prId = getCurrentPrNodeId();
36907
36907
  runGhGraphql(mutation, { prId, body });
36908
36908
  console.log("Submitted review.");
36909
+ return true;
36909
36910
  } catch (error) {
36910
36911
  if (isGhNotInstalled(error)) {
36911
36912
  console.error("Error: GitHub CLI (gh) is not installed.");
36912
- return;
36913
+ return false;
36913
36914
  }
36914
36915
  const message3 = error instanceof Error ? error.message : String(error);
36915
36916
  console.error(`Failed to submit review: ${message3}`);
36917
+ return false;
36916
36918
  }
36917
36919
  }
36918
36920
 
36919
36921
  // src/commands/review/submitBodyOnlyReview.ts
36920
36922
  var MUTATION6 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
36921
36923
  function submitBodyOnlyReview(body) {
36922
- runReviewSubmission(MUTATION6, body);
36924
+ return runReviewSubmission(MUTATION6, body);
36923
36925
  }
36924
36926
 
36925
36927
  // src/commands/review/submitFailedReview.ts
@@ -38468,12 +38470,6 @@ async function postFindings(findings) {
38468
38470
  return { posted, failed: failed3 };
38469
38471
  }
38470
38472
 
38471
- // src/commands/review/submitPendingReview.ts
38472
- var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
38473
- function submitPendingReview(body) {
38474
- runReviewSubmission(MUTATION7, body);
38475
- }
38476
-
38477
38473
  // src/commands/review/buildReviewBody.ts
38478
38474
  function buildReviewBody(markdown, unanchored, ciFooter) {
38479
38475
  return appendCiFooter(
@@ -38482,11 +38478,23 @@ function buildReviewBody(markdown, unanchored, ciFooter) {
38482
38478
  );
38483
38479
  }
38484
38480
 
38485
- // src/commands/review/postAndMaybeSubmit.ts
38486
- function submitReview(body, posted) {
38487
- if (posted > 0) submitPendingReview(body);
38488
- else submitBodyOnlyReview(body);
38481
+ // src/commands/review/submitPendingReview.ts
38482
+ var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
38483
+ function submitPendingReview(body) {
38484
+ return runReviewSubmission(MUTATION7, body);
38489
38485
  }
38486
+
38487
+ // src/commands/review/submitReview.ts
38488
+ function submitReview(body, result) {
38489
+ if (result.posted > 0) return submitPendingReview(body);
38490
+ if (submitPendingLeftByFailedThreads(body, result)) return true;
38491
+ return submitBodyOnlyReview(body);
38492
+ }
38493
+ function submitPendingLeftByFailedThreads(body, result) {
38494
+ return result.failed > 0 && submitPendingReview(body);
38495
+ }
38496
+
38497
+ // src/commands/review/postAndMaybeSubmit.ts
38490
38498
  async function decideSubmit(options2) {
38491
38499
  if (!options2.prompt) return options2.submit;
38492
38500
  await setSessionStatus("waiting");
@@ -38505,11 +38513,13 @@ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
38505
38513
  return { posted: 0, submitted: false };
38506
38514
  const shouldSubmit = await decideSubmit(options2);
38507
38515
  if (shouldSubmit) {
38508
- submitReview(
38516
+ const submitted = submitReview(
38509
38517
  buildReviewBody(markdown, unanchored, options2.ciFooter),
38510
- result.posted
38518
+ result
38511
38519
  );
38512
- return { posted: result.posted, submitted: true };
38520
+ if (!submitted && options2.ciFooter)
38521
+ throw new Error("the review could not be submitted to the PR");
38522
+ return { posted: result.posted, submitted };
38513
38523
  }
38514
38524
  console.log("Leaving the review unsubmitted.");
38515
38525
  return { posted: result.posted, submitted: false };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.848.0",
3
+ "version": "0.849.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {