opencode-sonarqube 0.1.10 → 0.1.12

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 +31 -3
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -19219,6 +19219,18 @@ async function bootstrap(options) {
19219
19219
  appendFileSync("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [BOOTSTRAP] Starting bootstrap directory=${directory} config.projectKey="${config2.projectKey || "(empty)"}"
19220
19220
  `);
19221
19221
  } catch {}
19222
+ if (!directory || directory === "/" || directory === "." || directory.length < 2) {
19223
+ logger5.error("Invalid directory for bootstrap", { directory });
19224
+ return {
19225
+ success: false,
19226
+ projectKey: "",
19227
+ projectToken: "",
19228
+ qualityGate: "",
19229
+ languages: [],
19230
+ message: `Invalid directory: ${directory}. OpenCode may have passed the wrong working directory.`,
19231
+ isNewProject: false
19232
+ };
19233
+ }
19222
19234
  logger5.info("Starting SonarQube bootstrap", { directory });
19223
19235
  if (!force) {
19224
19236
  const state2 = await loadProjectState(directory);
@@ -20147,19 +20159,35 @@ function shouldIgnoreFile2(filePath) {
20147
20159
  return IGNORED_FILE_PATTERNS2.some((pattern) => pattern.test(filePath));
20148
20160
  }
20149
20161
  var SonarQubePlugin = async ({ client, directory, worktree }) => {
20150
- debugLog.info("=== PLUGIN START ===", { directory, worktree });
20162
+ debugLog.info("=== PLUGIN START ===", { directory, worktree, cwd: process.cwd() });
20163
+ const resolveValidDirectory = () => {
20164
+ if (worktree && worktree !== "/" && worktree.length > 1) {
20165
+ return worktree;
20166
+ }
20167
+ if (directory && directory !== "/" && directory.length > 1) {
20168
+ return directory;
20169
+ }
20170
+ const cwd = process.cwd();
20171
+ if (cwd && cwd !== "/" && cwd.length > 1) {
20172
+ return cwd;
20173
+ }
20174
+ const homeDir = process.env["HOME"] || "/Users";
20175
+ return homeDir;
20176
+ };
20177
+ const effectiveDirectory = resolveValidDirectory();
20178
+ debugLog.info("Resolved directory", { original: directory, effective: effectiveDirectory });
20151
20179
  await client.app.log({
20152
20180
  body: {
20153
20181
  service: "opencode-sonarqube",
20154
20182
  level: "info",
20155
20183
  message: "SonarQube plugin initialized",
20156
- extra: { directory, worktree }
20184
+ extra: { directory, worktree, effectiveDirectory }
20157
20185
  }
20158
20186
  });
20159
20187
  let pluginConfig;
20160
20188
  let lastAnalysisResult;
20161
20189
  const getConfig = () => pluginConfig;
20162
- const getDirectory = () => worktree ?? directory;
20190
+ const getDirectory = () => effectiveDirectory;
20163
20191
  const loadPluginConfig = async () => {
20164
20192
  debugLog.info("loadPluginConfig called", { hasExistingConfig: !!pluginConfig });
20165
20193
  if (pluginConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sonarqube",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
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.9",
41
+ "opencode-sonarqube": "0.1.11",
42
42
  "zod": "^3.24.0"
43
43
  },
44
44
  "devDependencies": {