opencode-sonarqube 0.1.3 → 0.1.5
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 +181 -143
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
3
18
|
var __export = (target, all) => {
|
|
4
19
|
for (var name in all)
|
|
5
20
|
__defProp(target, name, {
|
|
@@ -4104,94 +4119,6 @@ var init_types2 = __esm(() => {
|
|
|
4104
4119
|
};
|
|
4105
4120
|
});
|
|
4106
4121
|
|
|
4107
|
-
// src/utils/logger.ts
|
|
4108
|
-
class Logger {
|
|
4109
|
-
service;
|
|
4110
|
-
minLevel;
|
|
4111
|
-
client;
|
|
4112
|
-
constructor(service, options) {
|
|
4113
|
-
this.service = service;
|
|
4114
|
-
this.minLevel = options?.minLevel ?? "info";
|
|
4115
|
-
this.client = options?.client;
|
|
4116
|
-
}
|
|
4117
|
-
shouldLog(level) {
|
|
4118
|
-
const levels = ["debug", "info", "warn", "error"];
|
|
4119
|
-
return levels.indexOf(level) >= levels.indexOf(this.minLevel);
|
|
4120
|
-
}
|
|
4121
|
-
formatMessage(level, message, extra) {
|
|
4122
|
-
const timestamp = new Date().toISOString();
|
|
4123
|
-
const color = LOG_COLORS[level];
|
|
4124
|
-
const prefix = `${color}[${this.service}]${RESET}`;
|
|
4125
|
-
const levelStr = `${color}${level.toUpperCase()}${RESET}`;
|
|
4126
|
-
let formatted = `${prefix} ${timestamp} ${levelStr}: ${message}`;
|
|
4127
|
-
if (extra && Object.keys(extra).length > 0) {
|
|
4128
|
-
formatted += ` ${JSON.stringify(extra)}`;
|
|
4129
|
-
}
|
|
4130
|
-
return formatted;
|
|
4131
|
-
}
|
|
4132
|
-
async log(level, message, extra) {
|
|
4133
|
-
if (!this.shouldLog(level))
|
|
4134
|
-
return;
|
|
4135
|
-
if (this.client) {
|
|
4136
|
-
try {
|
|
4137
|
-
await this.client.app.log({
|
|
4138
|
-
service: this.service,
|
|
4139
|
-
level,
|
|
4140
|
-
message,
|
|
4141
|
-
extra
|
|
4142
|
-
});
|
|
4143
|
-
return;
|
|
4144
|
-
} catch {}
|
|
4145
|
-
}
|
|
4146
|
-
const formatted = this.formatMessage(level, message, extra);
|
|
4147
|
-
switch (level) {
|
|
4148
|
-
case "debug":
|
|
4149
|
-
console.debug(formatted);
|
|
4150
|
-
break;
|
|
4151
|
-
case "info":
|
|
4152
|
-
console.info(formatted);
|
|
4153
|
-
break;
|
|
4154
|
-
case "warn":
|
|
4155
|
-
console.warn(formatted);
|
|
4156
|
-
break;
|
|
4157
|
-
case "error":
|
|
4158
|
-
console.error(formatted);
|
|
4159
|
-
break;
|
|
4160
|
-
}
|
|
4161
|
-
}
|
|
4162
|
-
debug(message, extra) {
|
|
4163
|
-
this.log("debug", message, extra);
|
|
4164
|
-
}
|
|
4165
|
-
info(message, extra) {
|
|
4166
|
-
this.log("info", message, extra);
|
|
4167
|
-
}
|
|
4168
|
-
warn(message, extra) {
|
|
4169
|
-
this.log("warn", message, extra);
|
|
4170
|
-
}
|
|
4171
|
-
error(message, extra) {
|
|
4172
|
-
this.log("error", message, extra);
|
|
4173
|
-
}
|
|
4174
|
-
child(subService) {
|
|
4175
|
-
return new Logger(`${this.service}:${subService}`, {
|
|
4176
|
-
minLevel: this.minLevel,
|
|
4177
|
-
client: this.client
|
|
4178
|
-
});
|
|
4179
|
-
}
|
|
4180
|
-
}
|
|
4181
|
-
function createLogger(service, client) {
|
|
4182
|
-
return new Logger(service, { client });
|
|
4183
|
-
}
|
|
4184
|
-
var LOG_COLORS, RESET = "\x1B[0m", logger;
|
|
4185
|
-
var init_logger = __esm(() => {
|
|
4186
|
-
LOG_COLORS = {
|
|
4187
|
-
debug: "\x1B[90m",
|
|
4188
|
-
info: "\x1B[36m",
|
|
4189
|
-
warn: "\x1B[33m",
|
|
4190
|
-
error: "\x1B[31m"
|
|
4191
|
-
};
|
|
4192
|
-
logger = new Logger("opencode-sonarqube");
|
|
4193
|
-
});
|
|
4194
|
-
|
|
4195
4122
|
// src/utils/state.ts
|
|
4196
4123
|
function getStatePath(directory) {
|
|
4197
4124
|
return `${directory}/${STATE_DIR}/${STATE_FILE}`;
|
|
@@ -4285,8 +4212,20 @@ ${entry}
|
|
|
4285
4212
|
var logger4, STATE_DIR = ".sonarqube", STATE_FILE = "project.json";
|
|
4286
4213
|
var init_state = __esm(() => {
|
|
4287
4214
|
init_types2();
|
|
4288
|
-
|
|
4289
|
-
|
|
4215
|
+
logger4 = {
|
|
4216
|
+
info: (msg, extra) => {
|
|
4217
|
+
console.log(`[SONARQUBE-STATE] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
4218
|
+
},
|
|
4219
|
+
warn: (msg, extra) => {
|
|
4220
|
+
console.warn(`[SONARQUBE-STATE] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
4221
|
+
},
|
|
4222
|
+
error: (msg, extra) => {
|
|
4223
|
+
console.error(`[SONARQUBE-STATE] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
4224
|
+
},
|
|
4225
|
+
debug: (msg, extra) => {
|
|
4226
|
+
console.log(`[SONARQUBE-STATE] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
4227
|
+
}
|
|
4228
|
+
};
|
|
4290
4229
|
});
|
|
4291
4230
|
|
|
4292
4231
|
// node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/external.js
|
|
@@ -16611,8 +16550,17 @@ function tool(input) {
|
|
|
16611
16550
|
tool.schema = exports_external;
|
|
16612
16551
|
// src/utils/config.ts
|
|
16613
16552
|
init_types2();
|
|
16614
|
-
|
|
16615
|
-
|
|
16553
|
+
var configLogger = {
|
|
16554
|
+
info: (msg, extra) => {
|
|
16555
|
+
console.log(`[SONARQUBE-CONFIG] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
16556
|
+
},
|
|
16557
|
+
warn: (msg, extra) => {
|
|
16558
|
+
console.warn(`[SONARQUBE-CONFIG] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
16559
|
+
},
|
|
16560
|
+
error: (msg, extra) => {
|
|
16561
|
+
console.error(`[SONARQUBE-CONFIG] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
16562
|
+
}
|
|
16563
|
+
};
|
|
16616
16564
|
var DEFAULT_CONFIG = {
|
|
16617
16565
|
level: "enterprise",
|
|
16618
16566
|
autoAnalyze: true,
|
|
@@ -16701,8 +16649,94 @@ function sanitizeProjectKey(input) {
|
|
|
16701
16649
|
return input.toLowerCase().replaceAll(/[^a-z0-9-_]/g, "-").replaceAll(/-+/g, "-").replaceAll(/(?:^-)|(?:-$)/g, "").slice(0, 400);
|
|
16702
16650
|
}
|
|
16703
16651
|
|
|
16652
|
+
// src/utils/logger.ts
|
|
16653
|
+
var LOG_COLORS = {
|
|
16654
|
+
debug: "\x1B[90m",
|
|
16655
|
+
info: "\x1B[36m",
|
|
16656
|
+
warn: "\x1B[33m",
|
|
16657
|
+
error: "\x1B[31m"
|
|
16658
|
+
};
|
|
16659
|
+
var RESET = "\x1B[0m";
|
|
16660
|
+
|
|
16661
|
+
class Logger {
|
|
16662
|
+
service;
|
|
16663
|
+
minLevel;
|
|
16664
|
+
client;
|
|
16665
|
+
constructor(service, options) {
|
|
16666
|
+
this.service = service;
|
|
16667
|
+
this.minLevel = options?.minLevel ?? "info";
|
|
16668
|
+
this.client = options?.client;
|
|
16669
|
+
}
|
|
16670
|
+
shouldLog(level) {
|
|
16671
|
+
const levels = ["debug", "info", "warn", "error"];
|
|
16672
|
+
return levels.indexOf(level) >= levels.indexOf(this.minLevel);
|
|
16673
|
+
}
|
|
16674
|
+
formatMessage(level, message, extra) {
|
|
16675
|
+
const timestamp = new Date().toISOString();
|
|
16676
|
+
const color = LOG_COLORS[level];
|
|
16677
|
+
const prefix = `${color}[${this.service}]${RESET}`;
|
|
16678
|
+
const levelStr = `${color}${level.toUpperCase()}${RESET}`;
|
|
16679
|
+
let formatted = `${prefix} ${timestamp} ${levelStr}: ${message}`;
|
|
16680
|
+
if (extra && Object.keys(extra).length > 0) {
|
|
16681
|
+
formatted += ` ${JSON.stringify(extra)}`;
|
|
16682
|
+
}
|
|
16683
|
+
return formatted;
|
|
16684
|
+
}
|
|
16685
|
+
async log(level, message, extra) {
|
|
16686
|
+
if (!this.shouldLog(level))
|
|
16687
|
+
return;
|
|
16688
|
+
if (this.client) {
|
|
16689
|
+
try {
|
|
16690
|
+
await this.client.app.log({
|
|
16691
|
+
service: this.service,
|
|
16692
|
+
level,
|
|
16693
|
+
message,
|
|
16694
|
+
extra
|
|
16695
|
+
});
|
|
16696
|
+
return;
|
|
16697
|
+
} catch {}
|
|
16698
|
+
}
|
|
16699
|
+
const formatted = this.formatMessage(level, message, extra);
|
|
16700
|
+
switch (level) {
|
|
16701
|
+
case "debug":
|
|
16702
|
+
console.debug(formatted);
|
|
16703
|
+
break;
|
|
16704
|
+
case "info":
|
|
16705
|
+
console.info(formatted);
|
|
16706
|
+
break;
|
|
16707
|
+
case "warn":
|
|
16708
|
+
console.warn(formatted);
|
|
16709
|
+
break;
|
|
16710
|
+
case "error":
|
|
16711
|
+
console.error(formatted);
|
|
16712
|
+
break;
|
|
16713
|
+
}
|
|
16714
|
+
}
|
|
16715
|
+
debug(message, extra) {
|
|
16716
|
+
this.log("debug", message, extra);
|
|
16717
|
+
}
|
|
16718
|
+
info(message, extra) {
|
|
16719
|
+
this.log("info", message, extra);
|
|
16720
|
+
}
|
|
16721
|
+
warn(message, extra) {
|
|
16722
|
+
this.log("warn", message, extra);
|
|
16723
|
+
}
|
|
16724
|
+
error(message, extra) {
|
|
16725
|
+
this.log("error", message, extra);
|
|
16726
|
+
}
|
|
16727
|
+
child(subService) {
|
|
16728
|
+
return new Logger(`${this.service}:${subService}`, {
|
|
16729
|
+
minLevel: this.minLevel,
|
|
16730
|
+
client: this.client
|
|
16731
|
+
});
|
|
16732
|
+
}
|
|
16733
|
+
}
|
|
16734
|
+
var logger = new Logger("opencode-sonarqube");
|
|
16735
|
+
function createLogger(service, client) {
|
|
16736
|
+
return new Logger(service, { client });
|
|
16737
|
+
}
|
|
16738
|
+
|
|
16704
16739
|
// src/scanner/config.ts
|
|
16705
|
-
init_logger();
|
|
16706
16740
|
var logger2 = new Logger("scanner-config");
|
|
16707
16741
|
async function checkProjectFiles(directory) {
|
|
16708
16742
|
const checks3 = await Promise.all([
|
|
@@ -16970,7 +17004,6 @@ async function writePropertiesFile(options, config2, directory) {
|
|
|
16970
17004
|
}
|
|
16971
17005
|
// src/api/client.ts
|
|
16972
17006
|
init_types2();
|
|
16973
|
-
init_logger();
|
|
16974
17007
|
function buildUrl(baseUrl, endpoint, params) {
|
|
16975
17008
|
let url2 = `${baseUrl}${endpoint}`;
|
|
16976
17009
|
if (!params) {
|
|
@@ -17057,11 +17090,10 @@ function buildAuthHeader(auth) {
|
|
|
17057
17090
|
class SonarQubeClient {
|
|
17058
17091
|
baseUrl;
|
|
17059
17092
|
auth;
|
|
17060
|
-
|
|
17061
|
-
constructor(config2, logger3) {
|
|
17093
|
+
constructor(config2, _logger) {
|
|
17062
17094
|
this.baseUrl = normalizeUrl(config2.url);
|
|
17063
17095
|
this.auth = config2.auth;
|
|
17064
|
-
|
|
17096
|
+
console.log(`[SONARQUBE-CLIENT] Created client for ${this.baseUrl}`);
|
|
17065
17097
|
}
|
|
17066
17098
|
async request(endpoint, options = {}) {
|
|
17067
17099
|
const { method = "GET", params, body } = options;
|
|
@@ -17074,36 +17106,42 @@ class SonarQubeClient {
|
|
|
17074
17106
|
if (requestBody) {
|
|
17075
17107
|
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
17076
17108
|
}
|
|
17077
|
-
|
|
17109
|
+
const logLine = `${new Date().toISOString()} [API] >>> ${method} ${endpoint} ${JSON.stringify({ url: url2, params, hasBody: !!body, bodyKeys: body ? Object.keys(body) : [] })}
|
|
17110
|
+
`;
|
|
17111
|
+
try {
|
|
17112
|
+
const { appendFileSync } = await import("node:fs");
|
|
17113
|
+
appendFileSync("/tmp/sonarqube-plugin-debug.log", logLine);
|
|
17114
|
+
} catch {}
|
|
17115
|
+
console.log(`[SONARQUBE-API] >>> ${method} ${endpoint}`, JSON.stringify({
|
|
17078
17116
|
url: url2,
|
|
17079
|
-
params
|
|
17117
|
+
params,
|
|
17080
17118
|
hasBody: !!body,
|
|
17081
17119
|
bodyKeys: body ? Object.keys(body) : []
|
|
17082
|
-
});
|
|
17120
|
+
}));
|
|
17083
17121
|
try {
|
|
17084
17122
|
const response = await fetch(url2, {
|
|
17085
17123
|
method,
|
|
17086
17124
|
headers,
|
|
17087
17125
|
body: requestBody
|
|
17088
17126
|
});
|
|
17089
|
-
|
|
17127
|
+
console.log(`[SONARQUBE-API] <<< ${method} ${endpoint}`, JSON.stringify({
|
|
17090
17128
|
status: response.status,
|
|
17091
17129
|
ok: response.ok
|
|
17092
|
-
});
|
|
17130
|
+
}));
|
|
17093
17131
|
if (!response.ok) {
|
|
17094
|
-
|
|
17132
|
+
console.error(`[SONARQUBE-API] ERROR: ${method} ${endpoint}`, JSON.stringify({
|
|
17095
17133
|
status: response.status,
|
|
17096
17134
|
url: url2
|
|
17097
|
-
});
|
|
17135
|
+
}));
|
|
17098
17136
|
await handleResponseError(response);
|
|
17099
17137
|
}
|
|
17100
17138
|
const text = await response.text();
|
|
17101
17139
|
return parseResponseBody(text);
|
|
17102
17140
|
} catch (error45) {
|
|
17103
|
-
|
|
17141
|
+
console.error(`[SONARQUBE-API] EXCEPTION: ${method} ${endpoint}`, JSON.stringify({
|
|
17104
17142
|
error: String(error45),
|
|
17105
17143
|
url: url2
|
|
17106
|
-
});
|
|
17144
|
+
}));
|
|
17107
17145
|
handleFetchError(error45, this.baseUrl);
|
|
17108
17146
|
}
|
|
17109
17147
|
}
|
|
@@ -17169,8 +17207,6 @@ function createClientWithCredentials(url2, user, password, logger3) {
|
|
|
17169
17207
|
}
|
|
17170
17208
|
// src/api/projects.ts
|
|
17171
17209
|
init_types2();
|
|
17172
|
-
init_logger();
|
|
17173
|
-
|
|
17174
17210
|
class ProjectsAPI {
|
|
17175
17211
|
client;
|
|
17176
17212
|
logger;
|
|
@@ -17271,8 +17307,6 @@ class ProjectsAPI {
|
|
|
17271
17307
|
}
|
|
17272
17308
|
}
|
|
17273
17309
|
// src/api/issues.ts
|
|
17274
|
-
init_logger();
|
|
17275
|
-
|
|
17276
17310
|
class IssuesAPI {
|
|
17277
17311
|
client;
|
|
17278
17312
|
logger;
|
|
@@ -17422,7 +17456,6 @@ class IssuesAPI {
|
|
|
17422
17456
|
}
|
|
17423
17457
|
// src/api/quality-gate.ts
|
|
17424
17458
|
init_types2();
|
|
17425
|
-
init_logger();
|
|
17426
17459
|
var METRIC_KEYS = {
|
|
17427
17460
|
coverage: "coverage",
|
|
17428
17461
|
newCoverage: "new_coverage",
|
|
@@ -17759,8 +17792,6 @@ class QualityGateAPI {
|
|
|
17759
17792
|
}
|
|
17760
17793
|
}
|
|
17761
17794
|
// src/api/rules.ts
|
|
17762
|
-
init_logger();
|
|
17763
|
-
|
|
17764
17795
|
class RulesAPI {
|
|
17765
17796
|
client;
|
|
17766
17797
|
logger;
|
|
@@ -17864,8 +17895,6 @@ class RulesAPI {
|
|
|
17864
17895
|
}
|
|
17865
17896
|
}
|
|
17866
17897
|
// src/api/sources.ts
|
|
17867
|
-
init_logger();
|
|
17868
|
-
|
|
17869
17898
|
class SourcesAPI {
|
|
17870
17899
|
client;
|
|
17871
17900
|
logger;
|
|
@@ -18004,8 +18033,6 @@ class SourcesAPI {
|
|
|
18004
18033
|
}
|
|
18005
18034
|
}
|
|
18006
18035
|
// src/api/duplications.ts
|
|
18007
|
-
init_logger();
|
|
18008
|
-
|
|
18009
18036
|
class DuplicationsAPI {
|
|
18010
18037
|
client;
|
|
18011
18038
|
logger;
|
|
@@ -18114,8 +18141,6 @@ class DuplicationsAPI {
|
|
|
18114
18141
|
}
|
|
18115
18142
|
}
|
|
18116
18143
|
// src/api/ce.ts
|
|
18117
|
-
init_logger();
|
|
18118
|
-
|
|
18119
18144
|
class ComputeEngineAPI {
|
|
18120
18145
|
client;
|
|
18121
18146
|
logger;
|
|
@@ -18231,8 +18256,6 @@ class ComputeEngineAPI {
|
|
|
18231
18256
|
}
|
|
18232
18257
|
}
|
|
18233
18258
|
// src/api/analyses.ts
|
|
18234
|
-
init_logger();
|
|
18235
|
-
|
|
18236
18259
|
class ProjectAnalysesAPI {
|
|
18237
18260
|
client;
|
|
18238
18261
|
logger;
|
|
@@ -18301,8 +18324,6 @@ class ProjectAnalysesAPI {
|
|
|
18301
18324
|
}
|
|
18302
18325
|
}
|
|
18303
18326
|
// src/api/profiles.ts
|
|
18304
|
-
init_logger();
|
|
18305
|
-
|
|
18306
18327
|
class QualityProfilesAPI {
|
|
18307
18328
|
client;
|
|
18308
18329
|
logger;
|
|
@@ -18395,8 +18416,6 @@ class QualityProfilesAPI {
|
|
|
18395
18416
|
}
|
|
18396
18417
|
}
|
|
18397
18418
|
// src/api/branches.ts
|
|
18398
|
-
init_logger();
|
|
18399
|
-
|
|
18400
18419
|
class BranchesAPI {
|
|
18401
18420
|
client;
|
|
18402
18421
|
logger;
|
|
@@ -18519,7 +18538,6 @@ class BranchesAPI {
|
|
|
18519
18538
|
}
|
|
18520
18539
|
}
|
|
18521
18540
|
// src/api/metrics.ts
|
|
18522
|
-
init_logger();
|
|
18523
18541
|
var COMMON_METRICS = [
|
|
18524
18542
|
"ncloc",
|
|
18525
18543
|
"lines",
|
|
@@ -18679,8 +18697,6 @@ class MetricsAPI {
|
|
|
18679
18697
|
}
|
|
18680
18698
|
}
|
|
18681
18699
|
// src/api/components.ts
|
|
18682
|
-
init_logger();
|
|
18683
|
-
|
|
18684
18700
|
class ComponentsAPI {
|
|
18685
18701
|
client;
|
|
18686
18702
|
logger;
|
|
@@ -18794,8 +18810,6 @@ class ComponentsAPI {
|
|
|
18794
18810
|
}
|
|
18795
18811
|
}
|
|
18796
18812
|
// src/api/index.ts
|
|
18797
|
-
init_logger();
|
|
18798
|
-
|
|
18799
18813
|
class SonarQubeAPI {
|
|
18800
18814
|
client;
|
|
18801
18815
|
projects;
|
|
@@ -18857,18 +18871,17 @@ function createSonarQubeAPIWithToken(url2, token, logger3) {
|
|
|
18857
18871
|
return new SonarQubeAPI(client, logger3);
|
|
18858
18872
|
}
|
|
18859
18873
|
function createSonarQubeAPI(config2, state, logger3) {
|
|
18860
|
-
|
|
18861
|
-
apiLogger.info(">>> createSonarQubeAPI called", {
|
|
18874
|
+
console.log(`[SONARQUBE-API] >>> createSonarQubeAPI called`, JSON.stringify({
|
|
18862
18875
|
url: config2.url,
|
|
18863
18876
|
projectKey: state.projectKey,
|
|
18864
18877
|
projectKeyLength: state.projectKey?.length,
|
|
18865
18878
|
hasToken: !!state.projectToken,
|
|
18866
18879
|
tokenLength: state.projectToken?.length
|
|
18867
|
-
});
|
|
18880
|
+
}));
|
|
18868
18881
|
if (!state.projectToken) {
|
|
18869
|
-
|
|
18882
|
+
console.error(`[SONARQUBE-API] createSonarQubeAPI: projectToken is missing!`);
|
|
18870
18883
|
}
|
|
18871
|
-
return createSonarQubeAPIWithToken(config2.url, state.projectToken,
|
|
18884
|
+
return createSonarQubeAPIWithToken(config2.url, state.projectToken, logger3);
|
|
18872
18885
|
}
|
|
18873
18886
|
|
|
18874
18887
|
// src/utils/severity.ts
|
|
@@ -18972,7 +18985,6 @@ function formatIssueBlock(issue2, _number2) {
|
|
|
18972
18985
|
}
|
|
18973
18986
|
|
|
18974
18987
|
// src/scanner/runner.ts
|
|
18975
|
-
init_logger();
|
|
18976
18988
|
var logger3 = new Logger("scanner-runner");
|
|
18977
18989
|
async function runScanner(config2, state, options, directory) {
|
|
18978
18990
|
const dir = directory ?? process.cwd();
|
|
@@ -19147,8 +19159,17 @@ function shouldBlockOnResult(result, level) {
|
|
|
19147
19159
|
// src/bootstrap/index.ts
|
|
19148
19160
|
init_types2();
|
|
19149
19161
|
init_state();
|
|
19150
|
-
|
|
19151
|
-
|
|
19162
|
+
var logger5 = {
|
|
19163
|
+
info: (msg, extra) => {
|
|
19164
|
+
console.log(`[SONARQUBE-BOOTSTRAP] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
19165
|
+
},
|
|
19166
|
+
warn: (msg, extra) => {
|
|
19167
|
+
console.warn(`[SONARQUBE-BOOTSTRAP] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
19168
|
+
},
|
|
19169
|
+
error: (msg, extra) => {
|
|
19170
|
+
console.error(`[SONARQUBE-BOOTSTRAP] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
19171
|
+
}
|
|
19172
|
+
};
|
|
19152
19173
|
var QUALITY_GATE_MAPPING = {
|
|
19153
19174
|
enterprise: "Sonar way",
|
|
19154
19175
|
standard: "Sonar way",
|
|
@@ -19308,7 +19329,6 @@ async function configureProjectSettings(client, projectKey, languages, config2)
|
|
|
19308
19329
|
}
|
|
19309
19330
|
|
|
19310
19331
|
// src/hooks/index.ts
|
|
19311
|
-
init_logger();
|
|
19312
19332
|
var logger6 = new Logger("sonarqube-hooks");
|
|
19313
19333
|
var editedFiles = new Set;
|
|
19314
19334
|
var lastAnalysisTime = 0;
|
|
@@ -19469,7 +19489,6 @@ function createHooks(getConfig, getDirectory) {
|
|
|
19469
19489
|
|
|
19470
19490
|
// src/tools/sonarqube.ts
|
|
19471
19491
|
init_zod();
|
|
19472
|
-
init_logger();
|
|
19473
19492
|
var logger7 = new Logger("sonarqube-tool");
|
|
19474
19493
|
var SonarQubeToolArgsSchema = exports_external2.object({
|
|
19475
19494
|
action: exports_external2.enum(["analyze", "issues", "newissues", "status", "init", "setup", "validate", "hotspots", "duplications", "rule", "history", "profile", "branches", "metrics", "worstfiles"]).describe("Action to perform: analyze (run scanner), issues (all issues), newissues (only new code issues), status (quality gate), init/setup (initialize), validate (enterprise check), hotspots (security review), duplications (code duplicates), rule (explain rule), history (past analyses), profile (quality profile), branches (branch status), metrics (detailed metrics), worstfiles (files with most issues)"),
|
|
@@ -20070,10 +20089,29 @@ function getSeveritiesFromLevel(level) {
|
|
|
20070
20089
|
}
|
|
20071
20090
|
|
|
20072
20091
|
// src/index.ts
|
|
20073
|
-
init_logger();
|
|
20074
|
-
init_logger();
|
|
20075
20092
|
init_types2();
|
|
20076
|
-
|
|
20093
|
+
import { appendFileSync } from "node:fs";
|
|
20094
|
+
var LOG_FILE = "/tmp/sonarqube-plugin-debug.log";
|
|
20095
|
+
var debugLog = {
|
|
20096
|
+
_write: (level, msg, extra) => {
|
|
20097
|
+
const timestamp = new Date().toISOString();
|
|
20098
|
+
const logLine = `${timestamp} [${level}] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
20099
|
+
`;
|
|
20100
|
+
try {
|
|
20101
|
+
appendFileSync(LOG_FILE, logLine);
|
|
20102
|
+
} catch {}
|
|
20103
|
+
console.log(`[SONARQUBE-DEBUG] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
20104
|
+
},
|
|
20105
|
+
info: (msg, extra) => {
|
|
20106
|
+
debugLog._write("INFO", msg, extra);
|
|
20107
|
+
},
|
|
20108
|
+
warn: (msg, extra) => {
|
|
20109
|
+
debugLog._write("WARN", msg, extra);
|
|
20110
|
+
},
|
|
20111
|
+
error: (msg, extra) => {
|
|
20112
|
+
debugLog._write("ERROR", msg, extra);
|
|
20113
|
+
}
|
|
20114
|
+
};
|
|
20077
20115
|
var IGNORED_FILE_PATTERNS2 = [
|
|
20078
20116
|
/node_modules/,
|
|
20079
20117
|
/\.git/,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sonarqube",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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,6 +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.4",
|
|
41
42
|
"zod": "^3.24.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|