opencode-sonarqube 1.4.1 → 1.5.1
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 +94 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4284,14 +4284,17 @@ function getTestPatterns(languages) {
|
|
|
4284
4284
|
}
|
|
4285
4285
|
return patterns.join(",");
|
|
4286
4286
|
}
|
|
4287
|
-
var SOURCE_DIRECTORY_PATTERNS;
|
|
4287
|
+
var MONOREPO_PATTERNS, SOURCE_SUBDIR_PATTERNS, SOURCE_DIRECTORY_PATTERNS;
|
|
4288
4288
|
var init_patterns = __esm(() => {
|
|
4289
|
-
|
|
4289
|
+
MONOREPO_PATTERNS = [
|
|
4290
4290
|
"apps",
|
|
4291
4291
|
"packages",
|
|
4292
4292
|
"modules",
|
|
4293
4293
|
"services",
|
|
4294
|
-
"libs"
|
|
4294
|
+
"libs"
|
|
4295
|
+
];
|
|
4296
|
+
SOURCE_SUBDIR_PATTERNS = ["src", "source", "lib"];
|
|
4297
|
+
SOURCE_DIRECTORY_PATTERNS = [
|
|
4295
4298
|
"src",
|
|
4296
4299
|
"source",
|
|
4297
4300
|
"lib",
|
|
@@ -4404,19 +4407,83 @@ function detectLanguages(checks3) {
|
|
|
4404
4407
|
}
|
|
4405
4408
|
return languages.length > 0 ? languages : ["generic"];
|
|
4406
4409
|
}
|
|
4407
|
-
function
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4410
|
+
function directoryExists(path) {
|
|
4411
|
+
try {
|
|
4412
|
+
return Bun.spawnSync(["test", "-d", path]).exitCode === 0;
|
|
4413
|
+
} catch {
|
|
4414
|
+
return false;
|
|
4415
|
+
}
|
|
4416
|
+
}
|
|
4417
|
+
function getSubdirectories(path) {
|
|
4418
|
+
try {
|
|
4419
|
+
const result = Bun.spawnSync(["ls", "-1", path]);
|
|
4420
|
+
if (result.exitCode !== 0)
|
|
4421
|
+
return [];
|
|
4422
|
+
const output = result.stdout.toString().trim();
|
|
4423
|
+
if (!output)
|
|
4424
|
+
return [];
|
|
4425
|
+
return output.split(`
|
|
4426
|
+
`).filter((name) => {
|
|
4427
|
+
if (name.startsWith("."))
|
|
4428
|
+
return false;
|
|
4429
|
+
if (name === "node_modules")
|
|
4430
|
+
return false;
|
|
4431
|
+
return directoryExists(`${path}/${name}`);
|
|
4432
|
+
});
|
|
4433
|
+
} catch {
|
|
4434
|
+
return [];
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
function findSourcesInMonorepoContainer(directory, monoPattern) {
|
|
4438
|
+
const sources = [];
|
|
4439
|
+
const monoPath = `${directory}/${monoPattern}`;
|
|
4440
|
+
if (!directoryExists(monoPath))
|
|
4441
|
+
return sources;
|
|
4442
|
+
const subdirs = getSubdirectories(monoPath);
|
|
4443
|
+
let foundSrcSubdirs = false;
|
|
4444
|
+
for (const subdir of subdirs) {
|
|
4445
|
+
for (const srcPattern of SOURCE_SUBDIR_PATTERNS) {
|
|
4446
|
+
const srcPath = `${monoPattern}/${subdir}/${srcPattern}`;
|
|
4447
|
+
if (directoryExists(`${directory}/${srcPath}`)) {
|
|
4448
|
+
sources.push(srcPath);
|
|
4449
|
+
foundSrcSubdirs = true;
|
|
4414
4450
|
}
|
|
4415
|
-
}
|
|
4451
|
+
}
|
|
4416
4452
|
}
|
|
4417
|
-
if (
|
|
4418
|
-
|
|
4419
|
-
|
|
4453
|
+
if (!foundSrcSubdirs && subdirs.length > 0) {
|
|
4454
|
+
for (const subdir of subdirs) {
|
|
4455
|
+
sources.push(`${monoPattern}/${subdir}`);
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4458
|
+
return sources;
|
|
4459
|
+
}
|
|
4460
|
+
function detectMonorepoSources(directory) {
|
|
4461
|
+
const sources = [];
|
|
4462
|
+
for (const monoPattern of MONOREPO_PATTERNS) {
|
|
4463
|
+
const found = findSourcesInMonorepoContainer(directory, monoPattern);
|
|
4464
|
+
sources.push(...found);
|
|
4465
|
+
}
|
|
4466
|
+
return sources;
|
|
4467
|
+
}
|
|
4468
|
+
function detectStandardSources(directory) {
|
|
4469
|
+
const sources = [];
|
|
4470
|
+
for (const pattern of SOURCE_DIRECTORY_PATTERNS) {
|
|
4471
|
+
if (directoryExists(`${directory}/${pattern}`)) {
|
|
4472
|
+
sources.push(pattern);
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
return sources;
|
|
4476
|
+
}
|
|
4477
|
+
function detectSourceDirectories(directory) {
|
|
4478
|
+
const monoSources = detectMonorepoSources(directory);
|
|
4479
|
+
if (monoSources.length > 0) {
|
|
4480
|
+
logger2.info("Detected monorepo source directories", { directories: monoSources });
|
|
4481
|
+
return monoSources.join(",");
|
|
4482
|
+
}
|
|
4483
|
+
const standardSources = detectStandardSources(directory);
|
|
4484
|
+
if (standardSources.length > 0) {
|
|
4485
|
+
logger2.info("Detected source directories", { directories: standardSources });
|
|
4486
|
+
return standardSources.join(",");
|
|
4420
4487
|
}
|
|
4421
4488
|
logger2.info("No common source directories found, scanning entire project");
|
|
4422
4489
|
return ".";
|
|
@@ -19382,24 +19449,22 @@ async function runScanner(config3, state, options, directory) {
|
|
|
19382
19449
|
const exitCode = await proc.exited;
|
|
19383
19450
|
const output = stdout + (stderr ? `
|
|
19384
19451
|
${stderr}` : "");
|
|
19452
|
+
const taskId = extractTaskId(output);
|
|
19385
19453
|
if (exitCode === 0) {
|
|
19386
|
-
const taskId = extractTaskId(output);
|
|
19387
19454
|
logger4.info("Scanner completed successfully", { taskId });
|
|
19388
|
-
return {
|
|
19389
|
-
success: true,
|
|
19390
|
-
output,
|
|
19391
|
-
exitCode,
|
|
19392
|
-
taskId
|
|
19393
|
-
};
|
|
19394
|
-
} else {
|
|
19395
|
-
logger4.error(`Scanner failed with exit code ${exitCode}`);
|
|
19396
|
-
return {
|
|
19397
|
-
success: false,
|
|
19398
|
-
output,
|
|
19399
|
-
error: `Scanner exited with code ${exitCode}`,
|
|
19400
|
-
exitCode
|
|
19401
|
-
};
|
|
19455
|
+
return { success: true, output, exitCode, taskId };
|
|
19402
19456
|
}
|
|
19457
|
+
if (taskId) {
|
|
19458
|
+
logger4.warn(`Scanner exited with code ${exitCode} but analysis was uploaded`, { taskId });
|
|
19459
|
+
return { success: true, output, exitCode, taskId };
|
|
19460
|
+
}
|
|
19461
|
+
logger4.error(`Scanner failed with exit code ${exitCode}`);
|
|
19462
|
+
return {
|
|
19463
|
+
success: false,
|
|
19464
|
+
output,
|
|
19465
|
+
error: `Scanner exited with code ${exitCode}`,
|
|
19466
|
+
exitCode
|
|
19467
|
+
};
|
|
19403
19468
|
} catch (error45) {
|
|
19404
19469
|
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
19405
19470
|
logger4.error(`Scanner execution failed: ${errorMessage}`);
|