opencode-sonarqube 0.2.6 → 0.2.7

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 +37 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -20095,7 +20095,8 @@ function getSeveritiesFromLevel(level) {
20095
20095
  // src/index.ts
20096
20096
  import { appendFileSync as appendFileSync4 } from "node:fs";
20097
20097
  try {
20098
- appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [LOAD] Plugin module loaded! CWD=${process.cwd()}
20098
+ const moduleLoadId = Math.random().toString(36).substring(7);
20099
+ appendFileSync4("/tmp/sonarqube-plugin-debug.log", `${new Date().toISOString()} [LOAD] Module loaded! id=${moduleLoadId} cwd=${process.cwd()} import.meta.url=${import.meta.url}
20099
20100
  `);
20100
20101
  } catch {}
20101
20102
  var IGNORED_FILE_PATTERNS2 = [
@@ -20125,7 +20126,27 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
20125
20126
  safeLog(` worktree param: "${worktree}"`);
20126
20127
  safeLog(` process.cwd(): "${process.cwd()}"`);
20127
20128
  safeLog(` import.meta.url: "${import.meta.url}"`);
20129
+ const pluginImportUrl = import.meta.url;
20130
+ const resolveDirectoryFromImportUrl = () => {
20131
+ try {
20132
+ const pluginPath = decodeURIComponent(pluginImportUrl.replace("file://", ""));
20133
+ const pathParts = pluginPath.split("/");
20134
+ const nodeModulesIndex = pathParts.indexOf("node_modules");
20135
+ if (nodeModulesIndex > 0) {
20136
+ const projectPath = pathParts.slice(0, nodeModulesIndex).join("/");
20137
+ if (projectPath && projectPath !== "/" && projectPath.length > 1) {
20138
+ return projectPath;
20139
+ }
20140
+ }
20141
+ } catch {}
20142
+ return null;
20143
+ };
20128
20144
  const resolveValidDirectory = () => {
20145
+ const fromImportUrl = resolveDirectoryFromImportUrl();
20146
+ if (fromImportUrl) {
20147
+ safeLog(`USING import.meta.url derived path=${fromImportUrl}`);
20148
+ return fromImportUrl;
20149
+ }
20129
20150
  if (worktree && worktree !== "/" && worktree.length > 1) {
20130
20151
  safeLog(`USING worktree=${worktree}`);
20131
20152
  return worktree;
@@ -20139,19 +20160,6 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
20139
20160
  safeLog(`USING cwd=${cwd}`);
20140
20161
  return cwd;
20141
20162
  }
20142
- try {
20143
- const pluginUrl = import.meta.url;
20144
- const pluginPath = decodeURIComponent(pluginUrl.replace("file://", ""));
20145
- const pathParts = pluginPath.split("/");
20146
- const nodeModulesIndex = pathParts.indexOf("node_modules");
20147
- if (nodeModulesIndex > 0) {
20148
- const projectPath = pathParts.slice(0, nodeModulesIndex).join("/");
20149
- if (projectPath && projectPath !== "/" && projectPath.length > 1) {
20150
- safeLog(`USING import.meta.url derived path=${projectPath}`);
20151
- return projectPath;
20152
- }
20153
- }
20154
- } catch {}
20155
20163
  const homeDir = process.env["HOME"] || "/Users";
20156
20164
  safeLog(`FALLBACK home=${homeDir}`);
20157
20165
  return homeDir;
@@ -20173,7 +20181,13 @@ var SonarQubePlugin = async ({ client, directory, worktree }) => {
20173
20181
  let pluginConfig;
20174
20182
  let lastAnalysisResult;
20175
20183
  const getConfig = () => pluginConfig;
20176
- const getDirectory = () => effectiveDirectory;
20184
+ const getDirectory = () => {
20185
+ const fromImportUrl = resolveDirectoryFromImportUrl();
20186
+ if (fromImportUrl) {
20187
+ return fromImportUrl;
20188
+ }
20189
+ return effectiveDirectory;
20190
+ };
20177
20191
  const loadPluginConfig = async () => {
20178
20192
  if (pluginConfig)
20179
20193
  return;
@@ -20530,6 +20544,9 @@ Git operation completed with changes. Consider running:
20530
20544
  }
20531
20545
  };
20532
20546
  };
20547
+ safeLog(`=== PLUGIN INIT COMPLETE, returning hooks ===`);
20548
+ safeLog(` This instance's pluginImportUrl: "${pluginImportUrl}"`);
20549
+ safeLog(` This instance's effectiveDirectory: "${effectiveDirectory}"`);
20533
20550
  const returnHooks = {
20534
20551
  event: safeAsync(async ({ event }) => {
20535
20552
  handleSessionTrackingEvent(event);
@@ -20565,16 +20582,18 @@ Git operation completed with changes. Consider running:
20565
20582
  }
20566
20583
  }, "experimental.session.compacting"),
20567
20584
  "experimental.chat.system.transform": safeAsync(async (_input, output) => {
20568
- safeLog("experimental.chat.system.transform ENTERED");
20585
+ safeLog(`=== system.transform ENTERED ===`);
20586
+ safeLog(` pluginImportUrl: "${pluginImportUrl}"`);
20587
+ safeLog(` effectiveDirectory: "${effectiveDirectory}"`);
20569
20588
  await loadPluginConfig();
20570
20589
  const sonarConfig = pluginConfig?.["sonarqube"];
20571
20590
  const config2 = loadConfig(sonarConfig);
20572
20591
  if (!config2 || config2.level === "off") {
20592
+ safeLog(` config level is off or null, returning early`);
20573
20593
  return;
20574
20594
  }
20575
20595
  const dir = getDirectory();
20576
- safeLog(`system.transform: getDirectory() returned: "${dir}"`);
20577
- safeLog(`system.transform: effectiveDirectory is: "${effectiveDirectory}"`);
20596
+ safeLog(` getDirectory() returned: "${dir}"`);
20578
20597
  const state = await getProjectState(dir);
20579
20598
  if (!state?.projectKey)
20580
20599
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sonarqube",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
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",