opencode-sonarqube 0.1.20 → 0.1.21

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 +52 -52
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -4014,7 +4014,49 @@ function numberToRating(num) {
4014
4014
  const ratings = ["A", "B", "C", "D", "E"];
4015
4015
  return ratings[num - 1] ?? "?";
4016
4016
  }
4017
- var SonarQubeConfigSchema, ProjectStateSchema, ENTERPRISE_THRESHOLDS, STANDARD_THRESHOLDS, RELAXED_THRESHOLDS, SonarQubeError, ConnectionError, AuthenticationError, ProjectNotFoundError, RateLimitError, SetupError;
4017
+ function SonarQubeError(message, code, statusCode) {
4018
+ const error45 = new Error(message);
4019
+ error45.name = "SonarQubeError";
4020
+ error45.code = code;
4021
+ error45.statusCode = statusCode;
4022
+ return error45;
4023
+ }
4024
+ function ConnectionError(message) {
4025
+ const error45 = new Error(message);
4026
+ error45.name = "ConnectionError";
4027
+ error45.code = "CONNECTION_ERROR";
4028
+ return error45;
4029
+ }
4030
+ function AuthenticationError(message) {
4031
+ const error45 = new Error(message);
4032
+ error45.name = "AuthenticationError";
4033
+ error45.code = "AUTH_ERROR";
4034
+ error45.statusCode = 401;
4035
+ return error45;
4036
+ }
4037
+ function ProjectNotFoundError(projectKey) {
4038
+ const error45 = new Error(`Project '${projectKey}' not found`);
4039
+ error45.name = "ProjectNotFoundError";
4040
+ error45.code = "PROJECT_NOT_FOUND";
4041
+ error45.statusCode = 404;
4042
+ return error45;
4043
+ }
4044
+ function RateLimitError(retryAfter) {
4045
+ const hasRetryAfter = retryAfter !== undefined && retryAfter > 0;
4046
+ const retryMessage = hasRetryAfter ? `. Retry after ${retryAfter}s` : "";
4047
+ const error45 = new Error(`Rate limit exceeded${retryMessage}`);
4048
+ error45.name = "RateLimitError";
4049
+ error45.code = "RATE_LIMIT";
4050
+ error45.statusCode = 429;
4051
+ return error45;
4052
+ }
4053
+ function SetupError(message) {
4054
+ const error45 = new Error(message);
4055
+ error45.name = "SetupError";
4056
+ error45.code = "SETUP_ERROR";
4057
+ return error45;
4058
+ }
4059
+ var SonarQubeConfigSchema, ProjectStateSchema, ENTERPRISE_THRESHOLDS, STANDARD_THRESHOLDS, RELAXED_THRESHOLDS;
4018
4060
  var init_types2 = __esm(() => {
4019
4061
  init_zod();
4020
4062
  SonarQubeConfigSchema = exports_external2.object({
@@ -4075,48 +4117,6 @@ var init_types2 = __esm(() => {
4075
4117
  minSecurityRating: 2,
4076
4118
  minMaintainabilityRating: 3
4077
4119
  };
4078
- SonarQubeError = class SonarQubeError extends Error {
4079
- code;
4080
- statusCode;
4081
- constructor(message, code, statusCode) {
4082
- super(message);
4083
- this.code = code;
4084
- this.statusCode = statusCode;
4085
- this.name = "SonarQubeError";
4086
- }
4087
- };
4088
- ConnectionError = class ConnectionError extends SonarQubeError {
4089
- constructor(message) {
4090
- super(message, "CONNECTION_ERROR");
4091
- this.name = "ConnectionError";
4092
- }
4093
- };
4094
- AuthenticationError = class AuthenticationError extends SonarQubeError {
4095
- constructor(message) {
4096
- super(message, "AUTH_ERROR", 401);
4097
- this.name = "AuthenticationError";
4098
- }
4099
- };
4100
- ProjectNotFoundError = class ProjectNotFoundError extends SonarQubeError {
4101
- constructor(projectKey) {
4102
- super(`Project '${projectKey}' not found`, "PROJECT_NOT_FOUND", 404);
4103
- this.name = "ProjectNotFoundError";
4104
- }
4105
- };
4106
- RateLimitError = class RateLimitError extends SonarQubeError {
4107
- constructor(retryAfter) {
4108
- const hasRetryAfter = retryAfter !== undefined && retryAfter > 0;
4109
- const retryMessage = hasRetryAfter ? `. Retry after ${retryAfter}s` : "";
4110
- super(`Rate limit exceeded${retryMessage}`, "RATE_LIMIT", 429);
4111
- this.name = "RateLimitError";
4112
- }
4113
- };
4114
- SetupError = class SetupError extends SonarQubeError {
4115
- constructor(message) {
4116
- super(message, "SETUP_ERROR");
4117
- this.name = "SetupError";
4118
- }
4119
- };
4120
4120
  });
4121
4121
 
4122
4122
  // src/utils/state.ts
@@ -17070,17 +17070,17 @@ function buildFormBody(body) {
17070
17070
  async function handleResponseError(response) {
17071
17071
  if (response.status === 429) {
17072
17072
  const retryAfter = response.headers.get("Retry-After");
17073
- throw new RateLimitError(retryAfter ? Number.parseInt(retryAfter, 10) : undefined);
17073
+ throw RateLimitError(retryAfter ? Number.parseInt(retryAfter, 10) : undefined);
17074
17074
  }
17075
17075
  if (response.status === 401) {
17076
- throw new AuthenticationError("Invalid credentials or token");
17076
+ throw AuthenticationError("Invalid credentials or token");
17077
17077
  }
17078
17078
  if (response.status === 403) {
17079
- throw new AuthenticationError("Insufficient permissions");
17079
+ throw AuthenticationError("Insufficient permissions");
17080
17080
  }
17081
17081
  const errorText = await response.text();
17082
17082
  const errorMessage = parseErrorMessage(errorText);
17083
- throw new SonarQubeError(`API Error: ${errorMessage}`, "API_ERROR", response.status);
17083
+ throw SonarQubeError(`API Error: ${errorMessage}`, "API_ERROR", response.status);
17084
17084
  }
17085
17085
  function parseErrorMessage(errorText) {
17086
17086
  try {
@@ -17097,13 +17097,13 @@ function parseResponseBody(text) {
17097
17097
  return JSON.parse(text);
17098
17098
  }
17099
17099
  function handleFetchError(error45, baseUrl) {
17100
- if (error45 instanceof SonarQubeError) {
17100
+ if (error45 instanceof Error && "code" in error45) {
17101
17101
  throw error45;
17102
17102
  }
17103
17103
  if (error45 instanceof TypeError && error45.message.includes("fetch")) {
17104
- throw new ConnectionError(`Cannot connect to SonarQube server at ${baseUrl}`);
17104
+ throw ConnectionError(`Cannot connect to SonarQube server at ${baseUrl}`);
17105
17105
  }
17106
- throw new SonarQubeError(`Request failed: ${error45 instanceof Error ? error45.message : String(error45)}`, "UNKNOWN_ERROR");
17106
+ throw SonarQubeError(`Request failed: ${error45 instanceof Error ? error45.message : String(error45)}`, "UNKNOWN_ERROR");
17107
17107
  }
17108
17108
  function normalizeUrl(url2) {
17109
17109
  let normalized = url2;
@@ -17293,7 +17293,7 @@ class ProjectsAPI {
17293
17293
  if (exists) {
17294
17294
  const project = await this.get(options.projectKey);
17295
17295
  if (!project) {
17296
- throw new ProjectNotFoundError(options.projectKey);
17296
+ throw ProjectNotFoundError(options.projectKey);
17297
17297
  }
17298
17298
  return { created: false, project };
17299
17299
  }
@@ -19274,7 +19274,7 @@ async function bootstrap(options) {
19274
19274
  const adminClient = createClientWithCredentials(config2.url, config2.user, config2.password);
19275
19275
  const health = await adminClient.healthCheck();
19276
19276
  if (!health.healthy) {
19277
- throw new SetupError(`Cannot connect to SonarQube: ${health.error}`);
19277
+ throw SetupError(`Cannot connect to SonarQube: ${health.error}`);
19278
19278
  }
19279
19279
  logger5.info("Connected to SonarQube", { version: health.version });
19280
19280
  const detection = await detectProjectType(directory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sonarqube",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
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",
@@ -38,7 +38,7 @@
38
38
  "homepage": "https://github.com/mguttmann/opencode-sonarqube#readme",
39
39
  "dependencies": {
40
40
  "@opencode-ai/plugin": "^1.1.34",
41
- "opencode-sonarqube": "0.1.20",
41
+ "opencode-sonarqube": "0.1.21",
42
42
  "zod": "^3.24.0"
43
43
  },
44
44
  "devDependencies": {