opencode-sonarqube 0.1.17 → 0.1.19
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 +70 -65
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4120,6 +4120,7 @@ var init_types2 = __esm(() => {
|
|
|
4120
4120
|
});
|
|
4121
4121
|
|
|
4122
4122
|
// src/utils/state.ts
|
|
4123
|
+
import { appendFileSync as appendFileSync2 } from "node:fs";
|
|
4123
4124
|
function getStatePath(directory) {
|
|
4124
4125
|
return `${directory}/${STATE_DIR}/${STATE_FILE}`;
|
|
4125
4126
|
}
|
|
@@ -4209,21 +4210,33 @@ ${entry}
|
|
|
4209
4210
|
await Bun.write(gitignorePath, newContent);
|
|
4210
4211
|
logger4.info("Added SonarQube exclusion to .gitignore");
|
|
4211
4212
|
}
|
|
4212
|
-
var logger4, STATE_DIR = ".sonarqube", STATE_FILE = "project.json";
|
|
4213
|
+
var LOG_FILE2 = "/tmp/sonarqube-plugin-debug.log", logger4, STATE_DIR = ".sonarqube", STATE_FILE = "project.json";
|
|
4213
4214
|
var init_state = __esm(() => {
|
|
4214
4215
|
init_types2();
|
|
4215
4216
|
logger4 = {
|
|
4216
4217
|
info: (msg, extra) => {
|
|
4217
|
-
|
|
4218
|
+
try {
|
|
4219
|
+
appendFileSync2(LOG_FILE2, `${new Date().toISOString()} [STATE] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
4220
|
+
`);
|
|
4221
|
+
} catch {}
|
|
4218
4222
|
},
|
|
4219
4223
|
warn: (msg, extra) => {
|
|
4220
|
-
|
|
4224
|
+
try {
|
|
4225
|
+
appendFileSync2(LOG_FILE2, `${new Date().toISOString()} [STATE-WARN] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
4226
|
+
`);
|
|
4227
|
+
} catch {}
|
|
4221
4228
|
},
|
|
4222
4229
|
error: (msg, extra) => {
|
|
4223
|
-
|
|
4230
|
+
try {
|
|
4231
|
+
appendFileSync2(LOG_FILE2, `${new Date().toISOString()} [STATE-ERROR] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
4232
|
+
`);
|
|
4233
|
+
} catch {}
|
|
4224
4234
|
},
|
|
4225
4235
|
debug: (msg, extra) => {
|
|
4226
|
-
|
|
4236
|
+
try {
|
|
4237
|
+
appendFileSync2(LOG_FILE2, `${new Date().toISOString()} [STATE-DEBUG] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
4238
|
+
`);
|
|
4239
|
+
} catch {}
|
|
4227
4240
|
}
|
|
4228
4241
|
};
|
|
4229
4242
|
});
|
|
@@ -16550,15 +16563,26 @@ function tool(input) {
|
|
|
16550
16563
|
tool.schema = exports_external;
|
|
16551
16564
|
// src/utils/config.ts
|
|
16552
16565
|
init_types2();
|
|
16566
|
+
import { appendFileSync } from "node:fs";
|
|
16567
|
+
var LOG_FILE = "/tmp/sonarqube-plugin-debug.log";
|
|
16553
16568
|
var configLogger = {
|
|
16554
16569
|
info: (msg, extra) => {
|
|
16555
|
-
|
|
16570
|
+
try {
|
|
16571
|
+
appendFileSync(LOG_FILE, `${new Date().toISOString()} [CONFIG] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
16572
|
+
`);
|
|
16573
|
+
} catch {}
|
|
16556
16574
|
},
|
|
16557
16575
|
warn: (msg, extra) => {
|
|
16558
|
-
|
|
16576
|
+
try {
|
|
16577
|
+
appendFileSync(LOG_FILE, `${new Date().toISOString()} [CONFIG-WARN] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
16578
|
+
`);
|
|
16579
|
+
} catch {}
|
|
16559
16580
|
},
|
|
16560
16581
|
error: (msg, extra) => {
|
|
16561
|
-
|
|
16582
|
+
try {
|
|
16583
|
+
appendFileSync(LOG_FILE, `${new Date().toISOString()} [CONFIG-ERROR] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
16584
|
+
`);
|
|
16585
|
+
} catch {}
|
|
16562
16586
|
}
|
|
16563
16587
|
};
|
|
16564
16588
|
var DEFAULT_CONFIG = {
|
|
@@ -17103,7 +17127,6 @@ class SonarQubeClient {
|
|
|
17103
17127
|
constructor(config2, _logger) {
|
|
17104
17128
|
this.baseUrl = normalizeUrl(config2.url);
|
|
17105
17129
|
this.auth = config2.auth;
|
|
17106
|
-
console.log(`[SONARQUBE-CLIENT] Created client for ${this.baseUrl}`);
|
|
17107
17130
|
}
|
|
17108
17131
|
async request(endpoint, options = {}) {
|
|
17109
17132
|
const { method = "GET", params, body } = options;
|
|
@@ -17116,42 +17139,23 @@ class SonarQubeClient {
|
|
|
17116
17139
|
if (requestBody) {
|
|
17117
17140
|
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
17118
17141
|
}
|
|
17119
|
-
const logLine = `${new Date().toISOString()} [API] >>> ${method} ${endpoint} ${JSON.stringify({ url: url2, params, hasBody: !!body, bodyKeys: body ? Object.keys(body) : [] })}
|
|
17120
|
-
`;
|
|
17121
17142
|
try {
|
|
17122
|
-
const { appendFileSync } = await import("node:fs");
|
|
17123
|
-
|
|
17143
|
+
const { appendFileSync: appendFileSync2 } = await import("node:fs");
|
|
17144
|
+
appendFileSync2("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [API] >>> ${method} ${endpoint} ${JSON.stringify({ url: url2, params, hasBody: !!body, bodyKeys: body ? Object.keys(body) : [] })}
|
|
17145
|
+
`);
|
|
17124
17146
|
} catch {}
|
|
17125
|
-
console.log(`[SONARQUBE-API] >>> ${method} ${endpoint}`, JSON.stringify({
|
|
17126
|
-
url: url2,
|
|
17127
|
-
params,
|
|
17128
|
-
hasBody: !!body,
|
|
17129
|
-
bodyKeys: body ? Object.keys(body) : []
|
|
17130
|
-
}));
|
|
17131
17147
|
try {
|
|
17132
17148
|
const response = await fetch(url2, {
|
|
17133
17149
|
method,
|
|
17134
17150
|
headers,
|
|
17135
17151
|
body: requestBody
|
|
17136
17152
|
});
|
|
17137
|
-
console.log(`[SONARQUBE-API] <<< ${method} ${endpoint}`, JSON.stringify({
|
|
17138
|
-
status: response.status,
|
|
17139
|
-
ok: response.ok
|
|
17140
|
-
}));
|
|
17141
17153
|
if (!response.ok) {
|
|
17142
|
-
console.error(`[SONARQUBE-API] ERROR: ${method} ${endpoint}`, JSON.stringify({
|
|
17143
|
-
status: response.status,
|
|
17144
|
-
url: url2
|
|
17145
|
-
}));
|
|
17146
17154
|
await handleResponseError(response);
|
|
17147
17155
|
}
|
|
17148
17156
|
const text = await response.text();
|
|
17149
17157
|
return parseResponseBody(text);
|
|
17150
17158
|
} catch (error45) {
|
|
17151
|
-
console.error(`[SONARQUBE-API] EXCEPTION: ${method} ${endpoint}`, JSON.stringify({
|
|
17152
|
-
error: String(error45),
|
|
17153
|
-
url: url2
|
|
17154
|
-
}));
|
|
17155
17159
|
handleFetchError(error45, this.baseUrl);
|
|
17156
17160
|
}
|
|
17157
17161
|
}
|
|
@@ -18881,16 +18885,6 @@ function createSonarQubeAPIWithToken(url2, token, logger3) {
|
|
|
18881
18885
|
return new SonarQubeAPI(client, logger3);
|
|
18882
18886
|
}
|
|
18883
18887
|
function createSonarQubeAPI(config2, state, logger3) {
|
|
18884
|
-
console.log(`[SONARQUBE-API] >>> createSonarQubeAPI called`, JSON.stringify({
|
|
18885
|
-
url: config2.url,
|
|
18886
|
-
projectKey: state.projectKey,
|
|
18887
|
-
projectKeyLength: state.projectKey?.length,
|
|
18888
|
-
hasToken: !!state.projectToken,
|
|
18889
|
-
tokenLength: state.projectToken?.length
|
|
18890
|
-
}));
|
|
18891
|
-
if (!state.projectToken) {
|
|
18892
|
-
console.error(`[SONARQUBE-API] createSonarQubeAPI: projectToken is missing!`);
|
|
18893
|
-
}
|
|
18894
18888
|
return createSonarQubeAPIWithToken(config2.url, state.projectToken, logger3);
|
|
18895
18889
|
}
|
|
18896
18890
|
|
|
@@ -19169,15 +19163,26 @@ function shouldBlockOnResult(result, level) {
|
|
|
19169
19163
|
// src/bootstrap/index.ts
|
|
19170
19164
|
init_types2();
|
|
19171
19165
|
init_state();
|
|
19166
|
+
import { appendFileSync as appendFileSync3 } from "node:fs";
|
|
19167
|
+
var LOG_FILE3 = "/tmp/sonarqube-plugin-debug.log";
|
|
19172
19168
|
var logger5 = {
|
|
19173
19169
|
info: (msg, extra) => {
|
|
19174
|
-
|
|
19170
|
+
try {
|
|
19171
|
+
appendFileSync3(LOG_FILE3, `${new Date().toISOString()} [BOOTSTRAP] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
19172
|
+
`);
|
|
19173
|
+
} catch {}
|
|
19175
19174
|
},
|
|
19176
19175
|
warn: (msg, extra) => {
|
|
19177
|
-
|
|
19176
|
+
try {
|
|
19177
|
+
appendFileSync3(LOG_FILE3, `${new Date().toISOString()} [BOOTSTRAP-WARN] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
19178
|
+
`);
|
|
19179
|
+
} catch {}
|
|
19178
19180
|
},
|
|
19179
19181
|
error: (msg, extra) => {
|
|
19180
|
-
|
|
19182
|
+
try {
|
|
19183
|
+
appendFileSync3(LOG_FILE3, `${new Date().toISOString()} [BOOTSTRAP-ERROR] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
19184
|
+
`);
|
|
19185
|
+
} catch {}
|
|
19181
19186
|
}
|
|
19182
19187
|
};
|
|
19183
19188
|
var QUALITY_GATE_MAPPING = {
|
|
@@ -19215,14 +19220,14 @@ function generateTokenName(projectKey) {
|
|
|
19215
19220
|
async function bootstrap(options) {
|
|
19216
19221
|
let { config: config2, directory, force = false } = options;
|
|
19217
19222
|
try {
|
|
19218
|
-
const { appendFileSync } = await import("node:fs");
|
|
19219
|
-
|
|
19223
|
+
const { appendFileSync: appendFileSync4 } = await import("node:fs");
|
|
19224
|
+
appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [BOOTSTRAP] Starting bootstrap directory=${directory} config.projectKey="${config2.projectKey || "(empty)"}"
|
|
19220
19225
|
`);
|
|
19221
19226
|
} catch {}
|
|
19222
19227
|
if (!directory || directory === "/" || directory === "." || directory.length < 2) {
|
|
19223
19228
|
try {
|
|
19224
19229
|
const pluginUrl = import.meta.url;
|
|
19225
|
-
const pluginPath = pluginUrl.replace("file://", "");
|
|
19230
|
+
const pluginPath = decodeURIComponent(pluginUrl.replace("file://", ""));
|
|
19226
19231
|
const pathParts = pluginPath.split("/");
|
|
19227
19232
|
const nodeModulesIndex = pathParts.findIndex((p) => p === "node_modules");
|
|
19228
19233
|
if (nodeModulesIndex > 0) {
|
|
@@ -19230,8 +19235,8 @@ async function bootstrap(options) {
|
|
|
19230
19235
|
if (projectPath && projectPath !== "/" && projectPath.length > 1) {
|
|
19231
19236
|
directory = projectPath;
|
|
19232
19237
|
try {
|
|
19233
|
-
const { appendFileSync } = await import("node:fs");
|
|
19234
|
-
|
|
19238
|
+
const { appendFileSync: appendFileSync4 } = await import("node:fs");
|
|
19239
|
+
appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [BOOTSTRAP] Fixed directory from import.meta.url: ${directory}
|
|
19235
19240
|
`);
|
|
19236
19241
|
} catch {}
|
|
19237
19242
|
}
|
|
@@ -19452,9 +19457,9 @@ function formatActionPrompt(result, config2) {
|
|
|
19452
19457
|
function createIdleHook(getConfig, getDirectory) {
|
|
19453
19458
|
return async function handleSessionIdle() {
|
|
19454
19459
|
try {
|
|
19455
|
-
const { appendFileSync } = await import("node:fs");
|
|
19460
|
+
const { appendFileSync: appendFileSync4 } = await import("node:fs");
|
|
19456
19461
|
const dir = getDirectory();
|
|
19457
|
-
|
|
19462
|
+
appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [IDLE-HOOK] getDirectory()=${dir}
|
|
19458
19463
|
`);
|
|
19459
19464
|
} catch {}
|
|
19460
19465
|
const rawConfig = getConfig()?.["sonarqube"];
|
|
@@ -20142,21 +20147,20 @@ function getSeveritiesFromLevel(level) {
|
|
|
20142
20147
|
|
|
20143
20148
|
// src/index.ts
|
|
20144
20149
|
init_types2();
|
|
20145
|
-
import { appendFileSync } from "node:fs";
|
|
20150
|
+
import { appendFileSync as appendFileSync4 } from "node:fs";
|
|
20146
20151
|
try {
|
|
20147
|
-
|
|
20152
|
+
appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [LOAD] Plugin module loaded! CWD=${process.cwd()}
|
|
20148
20153
|
`);
|
|
20149
20154
|
} catch {}
|
|
20150
|
-
var
|
|
20155
|
+
var LOG_FILE4 = "/tmp/sonarqube-plugin-debug.log";
|
|
20151
20156
|
var debugLog = {
|
|
20152
20157
|
_write: (level, msg, extra) => {
|
|
20153
20158
|
const timestamp = new Date().toISOString();
|
|
20154
20159
|
const logLine = `${timestamp} [${level}] ${msg} ${extra ? JSON.stringify(extra) : ""}
|
|
20155
20160
|
`;
|
|
20156
20161
|
try {
|
|
20157
|
-
|
|
20162
|
+
appendFileSync4(LOG_FILE4, logLine);
|
|
20158
20163
|
} catch {}
|
|
20159
|
-
console.log(`[SONARQUBE-DEBUG] ${msg}`, extra ? JSON.stringify(extra) : "");
|
|
20160
20164
|
},
|
|
20161
20165
|
info: (msg, extra) => {
|
|
20162
20166
|
debugLog._write("INFO", msg, extra);
|
|
@@ -20188,7 +20192,7 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
|
|
|
20188
20192
|
const resolveValidDirectory = () => {
|
|
20189
20193
|
const log = (msg) => {
|
|
20190
20194
|
try {
|
|
20191
|
-
|
|
20195
|
+
appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [RESOLVE] ${msg}
|
|
20192
20196
|
`);
|
|
20193
20197
|
} catch {}
|
|
20194
20198
|
};
|
|
@@ -20229,7 +20233,7 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
|
|
|
20229
20233
|
};
|
|
20230
20234
|
const effectiveDirectory = resolveValidDirectory();
|
|
20231
20235
|
try {
|
|
20232
|
-
|
|
20236
|
+
appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [RESOLVE] FINAL effective=${effectiveDirectory}
|
|
20233
20237
|
`);
|
|
20234
20238
|
} catch {}
|
|
20235
20239
|
await client.app.log({
|
|
@@ -20333,8 +20337,8 @@ Use \`sonarqube({ action: "issues" })\` to see details or \`sonarqube({ action:
|
|
|
20333
20337
|
}
|
|
20334
20338
|
} catch (error45) {
|
|
20335
20339
|
try {
|
|
20336
|
-
const { appendFileSync:
|
|
20337
|
-
|
|
20340
|
+
const { appendFileSync: appendFileSync5 } = await import("node:fs");
|
|
20341
|
+
appendFileSync5("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [ERROR] performInitialQualityCheck FAILED: ${error45}
|
|
20338
20342
|
`);
|
|
20339
20343
|
} catch {}
|
|
20340
20344
|
}
|
|
@@ -20648,8 +20652,8 @@ Git operation completed with changes. Consider running:
|
|
|
20648
20652
|
},
|
|
20649
20653
|
"experimental.chat.system.transform": async (_input, output) => {
|
|
20650
20654
|
try {
|
|
20651
|
-
const { appendFileSync:
|
|
20652
|
-
|
|
20655
|
+
const { appendFileSync: appendFileSync5 } = await import("node:fs");
|
|
20656
|
+
appendFileSync5("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [HOOK] experimental.chat.system.transform ENTERED
|
|
20653
20657
|
`);
|
|
20654
20658
|
} catch {}
|
|
20655
20659
|
debugLog.info("=== experimental.chat.system.transform START ===");
|
|
@@ -20715,8 +20719,8 @@ ${config2.level === "enterprise" ? `This project follows enterprise-level qualit
|
|
|
20715
20719
|
output.system.push(systemContext);
|
|
20716
20720
|
} catch (error45) {
|
|
20717
20721
|
try {
|
|
20718
|
-
const { appendFileSync:
|
|
20719
|
-
|
|
20722
|
+
const { appendFileSync: appendFileSync5 } = await import("node:fs");
|
|
20723
|
+
appendFileSync5("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [ERROR] experimental.chat.system.transform FAILED: ${error45}
|
|
20720
20724
|
`);
|
|
20721
20725
|
} catch {}
|
|
20722
20726
|
}
|
|
@@ -20950,7 +20954,8 @@ async function executeCLI(args = process.argv.slice(2), log = console.log, exit
|
|
|
20950
20954
|
log(result.output);
|
|
20951
20955
|
exit(result.exitCode);
|
|
20952
20956
|
}
|
|
20953
|
-
|
|
20957
|
+
var isDirectCLI = __require.main == __require.module && process.argv[1]?.includes("index.ts");
|
|
20958
|
+
if (isDirectCLI) {
|
|
20954
20959
|
await executeCLI();
|
|
20955
20960
|
}
|
|
20956
20961
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sonarqube",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
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.
|
|
41
|
+
"opencode-sonarqube": "0.1.19",
|
|
42
42
|
"zod": "^3.24.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|