opencode-sonarqube 1.2.11 → 1.2.13

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 +47 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18118,6 +18118,22 @@ class ComputeEngineAPI {
18118
18118
  const { current, queue } = await this.getComponentTasks(componentKey);
18119
18119
  return current !== undefined || queue.length > 0;
18120
18120
  }
18121
+ async waitForTask(taskId, pollIntervalMs = 2000) {
18122
+ this.logger.info(`Waiting for task to complete: ${taskId}`);
18123
+ while (true) {
18124
+ const task = await this.getTask(taskId);
18125
+ if (!task) {
18126
+ this.logger.warn(`Task ${taskId} not found`);
18127
+ return;
18128
+ }
18129
+ if (task.status === "SUCCESS" || task.status === "FAILED" || task.status === "CANCELED") {
18130
+ this.logger.info(`Task completed with status: ${task.status}`);
18131
+ return task;
18132
+ }
18133
+ this.logger.debug(`Task in progress: ${task.status}`);
18134
+ await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
18135
+ }
18136
+ }
18121
18137
  async waitForAnalysis(componentKey, timeoutMs = 300000, pollIntervalMs = 2000) {
18122
18138
  this.logger.info(`Waiting for analysis to complete: ${componentKey}`);
18123
18139
  const startTime = Date.now();
@@ -18887,6 +18903,16 @@ function formatIssueBlock(issue2, _number2) {
18887
18903
 
18888
18904
  // src/scanner/runner.ts
18889
18905
  var logger3 = new Logger("scanner-runner");
18906
+ function extractTaskId(output) {
18907
+ const taskIdRegex = /api\/ce\/task\?id=(\w+)/;
18908
+ const taskIdMatch = taskIdRegex.exec(output);
18909
+ if (taskIdMatch) {
18910
+ return taskIdMatch[1];
18911
+ }
18912
+ const altRegex = /task\s*id(?::|=|\s)\s*(\w+)/i;
18913
+ const altMatch = altRegex.exec(output);
18914
+ return altMatch?.[1];
18915
+ }
18890
18916
  async function runScanner(config2, state, options, directory) {
18891
18917
  const dir = directory ?? process.cwd();
18892
18918
  logger3.info(`Starting SonarQube analysis for ${options.projectKey}`);
@@ -18934,11 +18960,13 @@ async function runScanner(config2, state, options, directory) {
18934
18960
  const output = stdout + (stderr ? `
18935
18961
  ${stderr}` : "");
18936
18962
  if (exitCode === 0) {
18937
- logger3.info("Scanner completed successfully");
18963
+ const taskId = extractTaskId(output);
18964
+ logger3.info("Scanner completed successfully", { taskId });
18938
18965
  return {
18939
18966
  success: true,
18940
18967
  output,
18941
- exitCode
18968
+ exitCode,
18969
+ taskId
18942
18970
  };
18943
18971
  } else {
18944
18972
  logger3.error(`Scanner failed with exit code ${exitCode}`);
@@ -18984,8 +19012,23 @@ async function runAnalysis(config2, state, options, directory) {
18984
19012
  pullRequest: options.pullRequest,
18985
19013
  branch: options.branch
18986
19014
  }, dir);
18987
- if (scannerResult.success) {
18988
- logger3.info("Waiting for SonarQube to process results...");
19015
+ if (scannerResult.success && scannerResult.taskId) {
19016
+ logger3.info(`Waiting for analysis task ${scannerResult.taskId} to complete...`);
19017
+ try {
19018
+ const task = await api2.ce.waitForTask(scannerResult.taskId);
19019
+ if (task) {
19020
+ logger3.info(`Analysis task completed: ${task.status}`);
19021
+ if (task.status === "FAILED") {
19022
+ logger3.error(`Analysis failed: ${task.errorMessage ?? "Unknown error"}`);
19023
+ }
19024
+ } else {
19025
+ logger3.warn("Task not found - continuing with available results");
19026
+ }
19027
+ } catch (waitError) {
19028
+ logger3.debug("Could not wait for task via CE API", { waitError });
19029
+ }
19030
+ } else if (scannerResult.success) {
19031
+ logger3.debug("No task ID in scanner output, waiting briefly...");
18989
19032
  await Bun.sleep(3000);
18990
19033
  }
18991
19034
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sonarqube",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
4
4
  "description": "OpenCode Plugin for SonarQube integration - Enterprise-level code quality from the start",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",