azdo-cli 0.5.0-017-pr-comments-threads.237 → 0.5.0-017-pr-comments-threads.240

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2340,7 +2340,7 @@ function mapPullRequest(repo, pullRequest) {
2340
2340
  targetRefName: pullRequest.targetRefName,
2341
2341
  status: pullRequest.status,
2342
2342
  createdBy: pullRequest.createdBy?.displayName ?? null,
2343
- url: pullRequest._links.web.href
2343
+ url: pullRequest._links?.web?.href ?? null
2344
2344
  };
2345
2345
  }
2346
2346
  function mapPullRequestCheckName(status) {
@@ -2385,9 +2385,6 @@ function mapComment(comment) {
2385
2385
  };
2386
2386
  }
2387
2387
  function mapThread(thread) {
2388
- if (thread.status !== "active" && thread.status !== "pending") {
2389
- return null;
2390
- }
2391
2388
  const comments = thread.comments.map(mapComment).filter((comment) => comment !== null);
2392
2389
  if (comments.length === 0) {
2393
2390
  return null;
@@ -2480,25 +2477,30 @@ function formatBranchName(refName) {
2480
2477
  function writeError(message) {
2481
2478
  process.stderr.write(`Error: ${message}
2482
2479
  `);
2483
- process.exit(1);
2480
+ process.exitCode = 1;
2484
2481
  }
2485
2482
  function handlePrCommandError(err, context, mode = "read") {
2486
2483
  const error = err instanceof Error ? err : new Error(String(err));
2487
2484
  if (error.message === "AUTH_FAILED") {
2488
2485
  const scopeLabel = mode === "write" ? "Code (Read & Write)" : "Code (Read)";
2489
2486
  writeError(`Authentication failed. Check that your PAT is valid and has the "${scopeLabel}" scope.`);
2487
+ return;
2490
2488
  }
2491
2489
  if (error.message === "PERMISSION_DENIED") {
2492
2490
  writeError(`Access denied. Your PAT may lack ${mode} permissions for project "${context?.project}".`);
2491
+ return;
2493
2492
  }
2494
2493
  if (error.message === "NETWORK_ERROR") {
2495
2494
  writeError("Could not connect to Azure DevOps. Check your network connection.");
2495
+ return;
2496
2496
  }
2497
2497
  if (error.message.startsWith("NOT_FOUND")) {
2498
2498
  writeError(`Azure DevOps repository not found in ${context?.org}/${context?.project}.`);
2499
+ return;
2499
2500
  }
2500
2501
  if (error.message.startsWith("HTTP_")) {
2501
2502
  writeError(`Azure DevOps request failed with ${error.message}.`);
2503
+ return;
2502
2504
  }
2503
2505
  writeError(error.message);
2504
2506
  }
@@ -2519,7 +2521,7 @@ function formatPullRequestBlock(pullRequest) {
2519
2521
  return [
2520
2522
  `#${pullRequest.id} [${pullRequest.status}] ${pullRequest.title}`,
2521
2523
  `${formatBranchName(pullRequest.sourceRefName)} -> ${formatBranchName(pullRequest.targetRefName)}`,
2522
- pullRequest.url,
2524
+ pullRequest.url ?? "\u2014",
2523
2525
  ...formatPullRequestChecks(pullRequest.checks)
2524
2526
  ].join("\n");
2525
2527
  }
@@ -2587,10 +2589,12 @@ function createPrOpenCommand() {
2587
2589
  const title = options.title?.trim();
2588
2590
  if (!title) {
2589
2591
  writeError("--title is required for pull request creation.");
2592
+ return;
2590
2593
  }
2591
2594
  const description = options.description?.trim();
2592
2595
  if (!description) {
2593
2596
  writeError("--description is required for pull request creation.");
2597
+ return;
2594
2598
  }
2595
2599
  let context;
2596
2600
  try {
@@ -2598,6 +2602,7 @@ function createPrOpenCommand() {
2598
2602
  context = resolved.context;
2599
2603
  if (resolved.branch === "develop") {
2600
2604
  writeError("Pull request creation requires a source branch other than develop.");
2605
+ return;
2601
2606
  }
2602
2607
  const result = await openPullRequest(
2603
2608
  resolved.context,
@@ -2614,19 +2619,20 @@ function createPrOpenCommand() {
2614
2619
  }
2615
2620
  if (result.created) {
2616
2621
  process.stdout.write(`Created pull request #${result.pullRequest.id}: ${result.pullRequest.title}
2617
- ${result.pullRequest.url}
2622
+ ${result.pullRequest.url ?? "\u2014"}
2618
2623
  `);
2619
2624
  return;
2620
2625
  }
2621
2626
  process.stdout.write(
2622
2627
  `Active pull request already exists for ${resolved.branch} -> develop: #${result.pullRequest.id}
2623
- ${result.pullRequest.url}
2628
+ ${result.pullRequest.url ?? "\u2014"}
2624
2629
  `
2625
2630
  );
2626
2631
  } catch (err) {
2627
2632
  if (err instanceof Error && err.message.startsWith("AMBIGUOUS_PRS:")) {
2628
2633
  const ids = err.message.replace("AMBIGUOUS_PRS:", "").split(",").map((id) => `#${id}`).join(", ");
2629
2634
  writeError(`Multiple active pull requests already exist for this branch targeting develop: ${ids}. Use pr status to review them.`);
2635
+ return;
2630
2636
  }
2631
2637
  handlePrCommandError(err, context, "write");
2632
2638
  }
@@ -2646,10 +2652,12 @@ function createPrCommentsCommand() {
2646
2652
  });
2647
2653
  if (pullRequests.length === 0) {
2648
2654
  writeError(`No active pull request found for branch ${resolved.branch}.`);
2655
+ return;
2649
2656
  }
2650
2657
  if (pullRequests.length > 1) {
2651
2658
  const ids = pullRequests.map((pullRequest2) => `#${pullRequest2.id}`).join(", ");
2652
2659
  writeError(`Multiple active pull requests found for branch ${resolved.branch}: ${ids}. Use pr status to review them.`);
2660
+ return;
2653
2661
  }
2654
2662
  const pullRequest = pullRequests[0];
2655
2663
  const threads = await getPullRequestThreads(resolved.context, resolved.repo, resolved.pat, pullRequest.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.5.0-017-pr-comments-threads.237",
3
+ "version": "0.5.0-017-pr-comments-threads.240",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {