opencode-sonarqube 1.2.25 → 1.2.27
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 +12 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20089,7 +20089,7 @@ function getSeveritiesFromLevel(level) {
|
|
|
20089
20089
|
}
|
|
20090
20090
|
|
|
20091
20091
|
// src/index.ts
|
|
20092
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
20092
|
+
import { readFileSync, writeFileSync, appendFileSync } from "node:fs";
|
|
20093
20093
|
|
|
20094
20094
|
// src/cli.ts
|
|
20095
20095
|
var CLI_HELP = `
|
|
@@ -20309,7 +20309,10 @@ function shouldIgnoreFile2(filePath) {
|
|
|
20309
20309
|
return IGNORED_FILE_PATTERNS2.some((pattern) => pattern.test(filePath));
|
|
20310
20310
|
}
|
|
20311
20311
|
var SonarQubePlugin = async ({ client, directory, worktree }) => {
|
|
20312
|
-
const safeLog = (
|
|
20312
|
+
const safeLog = (msg) => {
|
|
20313
|
+
appendFileSync("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} ${msg}
|
|
20314
|
+
`);
|
|
20315
|
+
};
|
|
20313
20316
|
const pluginImportUrl = import.meta.url;
|
|
20314
20317
|
const resolveDirectoryFromImportUrl = () => {
|
|
20315
20318
|
try {
|
|
@@ -20677,13 +20680,15 @@ Fix these issues before ${operationType === "commit" ? "committing" : "pushing"}
|
|
|
20677
20680
|
return { block: false };
|
|
20678
20681
|
await loadPluginConfig();
|
|
20679
20682
|
const sonarConfig = pluginConfig?.["sonarqube"];
|
|
20683
|
+
safeLog(`[handleGitOperationCheck] sonarConfig=${JSON.stringify(sonarConfig)}`);
|
|
20680
20684
|
const config2 = loadConfig(sonarConfig);
|
|
20681
|
-
safeLog(`[handleGitOperationCheck] ${operationType}: level=${config2?.level}`);
|
|
20685
|
+
safeLog(`[handleGitOperationCheck] ${operationType}: level=${config2?.level}, blockCommit=${config2?.blockCommit}, blockPush=${config2?.blockPush}`);
|
|
20682
20686
|
if (!config2 || config2.level === "off")
|
|
20683
20687
|
return { block: false };
|
|
20684
20688
|
const { analyzeBeforeCommit = true, blockCommit = false, blockPush = false } = config2;
|
|
20685
20689
|
const { fixBeforeCommit = false, blockingSeverity = "CRITICAL", autoFix = false } = config2;
|
|
20686
20690
|
const shouldBlock = operationType === "commit" ? blockCommit : blockPush;
|
|
20691
|
+
safeLog(`[handleGitOperationCheck] shouldBlock=${shouldBlock}, blockCommit=${blockCommit}, blockPush=${blockPush}, blockingSeverity=${blockingSeverity}`);
|
|
20687
20692
|
try {
|
|
20688
20693
|
const dir = getDirectory();
|
|
20689
20694
|
const state = await getProjectState(dir);
|
|
@@ -20697,7 +20702,9 @@ Fix these issues before ${operationType === "commit" ? "committing" : "pushing"}
|
|
|
20697
20702
|
await showToast("SonarQube: Running pre-commit analysis...", "info");
|
|
20698
20703
|
const analysisResult = await runAnalysis(config2, state, { projectKey: state.projectKey }, dir);
|
|
20699
20704
|
safeLog(`[handleGitOperationCheck] qualityGate=${analysisResult.qualityGateStatus}`);
|
|
20700
|
-
|
|
20705
|
+
const result = await processAnalysisResult(analysisResult, blockingSeverity, shouldBlock, fixBeforeCommit, autoFix);
|
|
20706
|
+
safeLog(`[handleGitOperationCheck] processResult block=${result.block}, message=${result.message}`);
|
|
20707
|
+
return result;
|
|
20701
20708
|
} catch (err) {
|
|
20702
20709
|
safeLog(`[handleGitOperationCheck] ERROR: ${err instanceof Error ? err.message : String(err)}`);
|
|
20703
20710
|
return { block: false };
|
|
@@ -20840,6 +20847,7 @@ Git operation completed with changes. Consider running:
|
|
|
20840
20847
|
if (/git\s+commit\b/.test(command) && !/--amend/.test(command)) {
|
|
20841
20848
|
safeLog(`[pre-check] Detected git commit, running quality check...`);
|
|
20842
20849
|
const result = await handleGitOperationCheck(output, "commit");
|
|
20850
|
+
safeLog(`[pre-check] commit check result: block=${result.block}, message=${result.message}`);
|
|
20843
20851
|
if (result.block && args) {
|
|
20844
20852
|
args.command = `echo "\uD83D\uDEAB BLOCKED BY SONARQUBE: ${result.message || "Quality gate failed"}" && exit 1`;
|
|
20845
20853
|
safeLog(`[pre-check] Commit BLOCKED - command replaced`);
|