@vibgrate/cli 1.0.78 → 1.0.80
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/DOCS.md +14 -3
- package/HCS-EXTRACT.md +442 -0
- package/HCS-RUNTIME-SETUP.md +73 -0
- package/README.md +1 -1
- package/dist/{baseline-NRKROYVK.js → baseline-WDQNMJ4M.js} +2 -2
- package/dist/{chunk-TKNDQ337.js → chunk-22VJDYG5.js} +20 -15
- package/dist/{chunk-DKSPLRJV.js → chunk-UH7CY33M.js} +1 -1
- package/dist/cli.js +279 -24
- package/dist/hcs-worker.js +562 -25
- package/dist/index.js +1 -1
- package/package.json +4 -2
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
FileCache,
|
|
3
3
|
Semaphore,
|
|
4
4
|
ensureDir,
|
|
5
|
-
findCsprojFiles,
|
|
6
5
|
findFiles,
|
|
7
6
|
findPackageJsonFiles,
|
|
8
7
|
findSolutionFiles,
|
|
@@ -2344,11 +2343,17 @@ function parseTfmMajor(tfm) {
|
|
|
2344
2343
|
if (fxMatch) return null;
|
|
2345
2344
|
return null;
|
|
2346
2345
|
}
|
|
2347
|
-
function
|
|
2346
|
+
function isDotnetProjectFile(name) {
|
|
2347
|
+
return name.endsWith(".csproj") || name.endsWith(".vbproj");
|
|
2348
|
+
}
|
|
2349
|
+
function stripDotnetProjectExtension(filePath) {
|
|
2350
|
+
return path5.basename(filePath).replace(/\.(cs|vb)proj$/i, "");
|
|
2351
|
+
}
|
|
2352
|
+
function parseDotnetProjectFile(xml, filePath) {
|
|
2348
2353
|
const parsed = parser.parse(xml);
|
|
2349
2354
|
const project = parsed?.Project;
|
|
2350
2355
|
if (!project) {
|
|
2351
|
-
return { targetFrameworks: [], packageReferences: [], projectReferences: [], projectName:
|
|
2356
|
+
return { targetFrameworks: [], packageReferences: [], projectReferences: [], projectName: stripDotnetProjectExtension(filePath) };
|
|
2352
2357
|
}
|
|
2353
2358
|
const propertyGroups = Array.isArray(project.PropertyGroup) ? project.PropertyGroup : project.PropertyGroup ? [project.PropertyGroup] : [];
|
|
2354
2359
|
const targetFrameworks = [];
|
|
@@ -2385,34 +2390,34 @@ function parseCsproj(xml, filePath) {
|
|
|
2385
2390
|
targetFrameworks: [...new Set(targetFrameworks)],
|
|
2386
2391
|
packageReferences,
|
|
2387
2392
|
projectReferences,
|
|
2388
|
-
projectName:
|
|
2393
|
+
projectName: stripDotnetProjectExtension(filePath)
|
|
2389
2394
|
};
|
|
2390
2395
|
}
|
|
2391
2396
|
async function scanDotnetProjects(rootDir, nugetCache, cache, projectScanTimeout) {
|
|
2392
|
-
const
|
|
2397
|
+
const projectFiles = cache ? await cache.findFiles(rootDir, isDotnetProjectFile) : await findFiles(rootDir, isDotnetProjectFile);
|
|
2393
2398
|
const slnFiles = cache ? await cache.findSolutionFiles(rootDir) : await findSolutionFiles(rootDir);
|
|
2394
|
-
const
|
|
2399
|
+
const slnProjectPaths = /* @__PURE__ */ new Set();
|
|
2395
2400
|
for (const slnPath of slnFiles) {
|
|
2396
2401
|
try {
|
|
2397
2402
|
const slnContent = cache ? await cache.readTextFile(slnPath) : await readTextFile(slnPath);
|
|
2398
2403
|
const slnDir = path5.dirname(slnPath);
|
|
2399
|
-
const projectRegex = /Project\("[^"]*"\)\s*=\s*"[^"]*",\s*"([^"]+\.
|
|
2404
|
+
const projectRegex = /Project\("[^"]*"\)\s*=\s*"[^"]*",\s*"([^"]+\.(?:cs|vb)proj)"/g;
|
|
2400
2405
|
let match;
|
|
2401
2406
|
while ((match = projectRegex.exec(slnContent)) !== null) {
|
|
2402
2407
|
if (match[1]) {
|
|
2403
2408
|
const csprojPath = path5.resolve(slnDir, match[1].replace(/\\/g, "/"));
|
|
2404
|
-
|
|
2409
|
+
slnProjectPaths.add(csprojPath);
|
|
2405
2410
|
}
|
|
2406
2411
|
}
|
|
2407
2412
|
} catch {
|
|
2408
2413
|
}
|
|
2409
2414
|
}
|
|
2410
|
-
const allCsprojFiles = /* @__PURE__ */ new Set([...
|
|
2415
|
+
const allCsprojFiles = /* @__PURE__ */ new Set([...projectFiles, ...slnProjectPaths]);
|
|
2411
2416
|
const results = [];
|
|
2412
2417
|
const STUCK_TIMEOUT_MS = projectScanTimeout ?? cache?.projectScanTimeout ?? 18e4;
|
|
2413
2418
|
for (const csprojPath of allCsprojFiles) {
|
|
2414
2419
|
try {
|
|
2415
|
-
const scanPromise =
|
|
2420
|
+
const scanPromise = scanOneDotnetProjectFile(csprojPath, rootDir, nugetCache, cache);
|
|
2416
2421
|
const result = await withTimeout(scanPromise, STUCK_TIMEOUT_MS);
|
|
2417
2422
|
if (result.ok) {
|
|
2418
2423
|
results.push(result.value);
|
|
@@ -2433,9 +2438,9 @@ async function scanDotnetProjects(rootDir, nugetCache, cache, projectScanTimeout
|
|
|
2433
2438
|
}
|
|
2434
2439
|
return results;
|
|
2435
2440
|
}
|
|
2436
|
-
async function
|
|
2441
|
+
async function scanOneDotnetProjectFile(csprojPath, rootDir, nugetCache, cache) {
|
|
2437
2442
|
const xml = cache ? await cache.readTextFile(csprojPath) : await readTextFile(csprojPath);
|
|
2438
|
-
const data =
|
|
2443
|
+
const data = parseDotnetProjectFile(xml, csprojPath);
|
|
2439
2444
|
const csprojDir = path5.dirname(csprojPath);
|
|
2440
2445
|
const primaryTfm = data.targetFrameworks[0];
|
|
2441
2446
|
let runtimeMajorsBehind;
|
|
@@ -2516,7 +2521,7 @@ async function scanOneCsproj(csprojPath, rootDir, nugetCache, cache) {
|
|
|
2516
2521
|
const projectReferences = data.projectReferences.map((refPath) => {
|
|
2517
2522
|
const absRefPath = path5.resolve(csprojDir, refPath);
|
|
2518
2523
|
const relRefPath = normalizePath(path5.relative(rootDir, path5.dirname(absRefPath)));
|
|
2519
|
-
const refName =
|
|
2524
|
+
const refName = stripDotnetProjectExtension(absRefPath);
|
|
2520
2525
|
return {
|
|
2521
2526
|
path: relRefPath || ".",
|
|
2522
2527
|
name: refName,
|
|
@@ -7918,7 +7923,7 @@ async function scanPlatformMatrix(rootDir, cache) {
|
|
|
7918
7923
|
}
|
|
7919
7924
|
result.nativeModules.sort();
|
|
7920
7925
|
result.osAssumptions = [...osAssumptions].sort();
|
|
7921
|
-
const csprojFiles = cache ? await cache.
|
|
7926
|
+
const csprojFiles = cache ? await cache.findFiles(rootDir, (name) => name.endsWith(".csproj") || name.endsWith(".vbproj")) : await findFiles(rootDir, (name) => name.endsWith(".csproj") || name.endsWith(".vbproj"));
|
|
7922
7927
|
const tfms = /* @__PURE__ */ new Set();
|
|
7923
7928
|
for (const csprojPath of csprojFiles) {
|
|
7924
7929
|
try {
|
|
@@ -11702,7 +11707,7 @@ async function discoverSolutions(rootDir, fileCache) {
|
|
|
11702
11707
|
const rootBasename = path32.basename(rootDir);
|
|
11703
11708
|
const relSolutionPath = [rootBasename, path32.relative(rootDir, solutionFile).replace(/\\/g, "/")].join("/");
|
|
11704
11709
|
const projectPaths = /* @__PURE__ */ new Set();
|
|
11705
|
-
const projectRegex = /Project\("[^"]*"\)\s*=\s*"([^"]*)",\s*"([^"]+\.
|
|
11710
|
+
const projectRegex = /Project\("[^"]*"\)\s*=\s*"([^"]*)",\s*"([^"]+\.(?:cs|vb)proj)"/g;
|
|
11706
11711
|
let match;
|
|
11707
11712
|
while ((match = projectRegex.exec(content)) !== null) {
|
|
11708
11713
|
const projectRelative = match[2];
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
baselineCommand
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UH7CY33M.js";
|
|
5
5
|
import {
|
|
6
6
|
VERSION,
|
|
7
7
|
computeHmac,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
pushCommand,
|
|
13
13
|
scanCommand,
|
|
14
14
|
writeDefaultConfig
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-22VJDYG5.js";
|
|
16
16
|
import {
|
|
17
17
|
Semaphore,
|
|
18
18
|
ensureDir,
|
|
@@ -42,7 +42,7 @@ var initCommand = new Command("init").description("Initialize vibgrate in a proj
|
|
|
42
42
|
console.log(chalk.green("\u2714") + ` Created ${chalk.bold("vibgrate.config.ts")}`);
|
|
43
43
|
}
|
|
44
44
|
if (opts.baseline) {
|
|
45
|
-
const { runBaseline } = await import("./baseline-
|
|
45
|
+
const { runBaseline } = await import("./baseline-WDQNMJ4M.js");
|
|
46
46
|
await runBaseline(rootDir);
|
|
47
47
|
}
|
|
48
48
|
console.log("");
|
|
@@ -417,7 +417,7 @@ import * as path6 from "path";
|
|
|
417
417
|
import * as os2 from "os";
|
|
418
418
|
import * as fs2 from "fs/promises";
|
|
419
419
|
import { existsSync } from "fs";
|
|
420
|
-
import { spawn } from "child_process";
|
|
420
|
+
import { spawn, spawnSync } from "child_process";
|
|
421
421
|
import { Command as Command5 } from "commander";
|
|
422
422
|
import chalk5 from "chalk";
|
|
423
423
|
var EXIT_SUCCESS = 0;
|
|
@@ -440,7 +440,9 @@ var LANGUAGE_EXTENSIONS = {
|
|
|
440
440
|
go: /* @__PURE__ */ new Set([".go"]),
|
|
441
441
|
python: /* @__PURE__ */ new Set([".py"]),
|
|
442
442
|
java: /* @__PURE__ */ new Set([".java"]),
|
|
443
|
-
csharp: /* @__PURE__ */ new Set([".cs"])
|
|
443
|
+
csharp: /* @__PURE__ */ new Set([".cs"]),
|
|
444
|
+
cplusplus: /* @__PURE__ */ new Set([".cpp", ".cc", ".cxx", ".hpp", ".hh", ".hxx", ".h", ".ixx", ".vcxproj"]),
|
|
445
|
+
vbnet: /* @__PURE__ */ new Set([".vb"])
|
|
444
446
|
};
|
|
445
447
|
var SUPPORTED_LANGUAGES = new Set(Object.keys(LANGUAGE_EXTENSIONS));
|
|
446
448
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
@@ -489,6 +491,13 @@ var TEST_PATTERNS = [
|
|
|
489
491
|
function isTestPath(relPath) {
|
|
490
492
|
return TEST_PATTERNS.some((p) => p.test(relPath));
|
|
491
493
|
}
|
|
494
|
+
function normalizeLanguageToken(language) {
|
|
495
|
+
const normalized = language.trim().toLowerCase();
|
|
496
|
+
if (normalized === "vb.net" || normalized === "visualbasic" || normalized === "visual-basic") {
|
|
497
|
+
return "vbnet";
|
|
498
|
+
}
|
|
499
|
+
return normalized;
|
|
500
|
+
}
|
|
492
501
|
async function detectLanguages(rootDir, includeTests) {
|
|
493
502
|
const counts = /* @__PURE__ */ new Map();
|
|
494
503
|
async function walk(dir, relBase) {
|
|
@@ -582,13 +591,81 @@ var NODE_WORKER_TEXT_LANGS = /* @__PURE__ */ new Set([
|
|
|
582
591
|
"php",
|
|
583
592
|
"dart",
|
|
584
593
|
"scala",
|
|
585
|
-
"cobol"
|
|
594
|
+
"cobol",
|
|
595
|
+
"cplusplus"
|
|
586
596
|
]);
|
|
587
597
|
var NODE_WORKER_ALL_LANGS = /* @__PURE__ */ new Set([
|
|
588
598
|
...NODE_WORKER_AST_LANGS,
|
|
589
599
|
...NODE_WORKER_TEXT_LANGS
|
|
590
600
|
]);
|
|
591
|
-
var
|
|
601
|
+
var NATIVE_AST_LANGS = /* @__PURE__ */ new Set(["go", "python", "java", "csharp", "vbnet"]);
|
|
602
|
+
var ALL_WORKER_LANGS = /* @__PURE__ */ new Set([...NODE_WORKER_ALL_LANGS, ...NATIVE_AST_LANGS]);
|
|
603
|
+
var NATIVE_RUNTIME_REQUIREMENTS = {
|
|
604
|
+
go: {
|
|
605
|
+
command: "go",
|
|
606
|
+
displayName: "Go toolchain",
|
|
607
|
+
installGuideByPlatform: {
|
|
608
|
+
darwin: "brew install go",
|
|
609
|
+
linux: "Install Go 1.22+ from https://go.dev/dl/ or your distro package manager.",
|
|
610
|
+
win32: "winget install GoLang.Go"
|
|
611
|
+
},
|
|
612
|
+
docsUrl: "https://go.dev/doc/install"
|
|
613
|
+
},
|
|
614
|
+
python: {
|
|
615
|
+
command: "python3",
|
|
616
|
+
displayName: "Python 3 runtime",
|
|
617
|
+
installGuideByPlatform: {
|
|
618
|
+
darwin: "brew install python",
|
|
619
|
+
linux: "Install Python 3.10+ from your distro package manager (apt/dnf/pacman).",
|
|
620
|
+
win32: "winget install Python.Python.3.12"
|
|
621
|
+
},
|
|
622
|
+
docsUrl: "https://www.python.org/downloads/"
|
|
623
|
+
},
|
|
624
|
+
java: {
|
|
625
|
+
command: "java",
|
|
626
|
+
displayName: "Java 17+ runtime",
|
|
627
|
+
installGuideByPlatform: {
|
|
628
|
+
darwin: "brew install --cask temurin",
|
|
629
|
+
linux: "Install OpenJDK 17+ (for example: apt install openjdk-17-jre).",
|
|
630
|
+
win32: "winget install EclipseAdoptium.Temurin.17.JRE"
|
|
631
|
+
},
|
|
632
|
+
docsUrl: "https://adoptium.net/"
|
|
633
|
+
},
|
|
634
|
+
csharp: {
|
|
635
|
+
command: "dotnet",
|
|
636
|
+
displayName: ".NET SDK/runtime",
|
|
637
|
+
installGuideByPlatform: {
|
|
638
|
+
darwin: "brew install --cask dotnet-sdk",
|
|
639
|
+
linux: "Install .NET 8 SDK/runtime from https://dotnet.microsoft.com/download.",
|
|
640
|
+
win32: "winget install Microsoft.DotNet.SDK.8"
|
|
641
|
+
},
|
|
642
|
+
docsUrl: "https://dotnet.microsoft.com/download"
|
|
643
|
+
},
|
|
644
|
+
vbnet: {
|
|
645
|
+
command: "dotnet",
|
|
646
|
+
displayName: ".NET SDK/runtime",
|
|
647
|
+
installGuideByPlatform: {
|
|
648
|
+
darwin: "brew install --cask dotnet-sdk",
|
|
649
|
+
linux: "Install .NET 8 SDK/runtime from https://dotnet.microsoft.com/download.",
|
|
650
|
+
win32: "winget install Microsoft.DotNet.SDK.8"
|
|
651
|
+
},
|
|
652
|
+
docsUrl: "https://dotnet.microsoft.com/download"
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
function commandExistsOnPath(command) {
|
|
656
|
+
const probeArgs = process.platform === "win32" ? ["/c", command, "--version"] : ["--version"];
|
|
657
|
+
const probeCmd = process.platform === "win32" ? "cmd" : command;
|
|
658
|
+
const result = spawnSync(probeCmd, probeArgs, { stdio: "ignore" });
|
|
659
|
+
return !result.error && result.status === 0;
|
|
660
|
+
}
|
|
661
|
+
function buildNativeInstallHint(language) {
|
|
662
|
+
const req = NATIVE_RUNTIME_REQUIREMENTS[language];
|
|
663
|
+
if (!req) {
|
|
664
|
+
return "See HCS runtime setup docs for prerequisites: https://vibgrate.com/help";
|
|
665
|
+
}
|
|
666
|
+
const platformHint = req.installGuideByPlatform[process.platform] ?? `Install ${req.displayName} and ensure '${req.command}' is available on PATH.`;
|
|
667
|
+
return `${platformHint} More details: ${req.docsUrl}`;
|
|
668
|
+
}
|
|
592
669
|
async function runNodeWorker(rootDir, language, opts) {
|
|
593
670
|
const workerBin = resolveHcsWorkerBin();
|
|
594
671
|
const args = [];
|
|
@@ -665,6 +742,189 @@ async function runNodeWorker(rootDir, language, opts) {
|
|
|
665
742
|
});
|
|
666
743
|
});
|
|
667
744
|
}
|
|
745
|
+
function resolveDotnetPublishedWorker(workersDir) {
|
|
746
|
+
const candidatesByPlatform = {
|
|
747
|
+
win32: ["hcs-worker-win-x64.exe"],
|
|
748
|
+
linux: ["hcs-worker-linux-x64"],
|
|
749
|
+
darwin: ["hcs-worker-osx-arm64", "hcs-worker-osx-x64"],
|
|
750
|
+
aix: [],
|
|
751
|
+
android: [],
|
|
752
|
+
freebsd: [],
|
|
753
|
+
haiku: [],
|
|
754
|
+
openbsd: [],
|
|
755
|
+
cygwin: [],
|
|
756
|
+
netbsd: [],
|
|
757
|
+
sunos: []
|
|
758
|
+
};
|
|
759
|
+
const candidates = candidatesByPlatform[process.platform] ?? [];
|
|
760
|
+
for (const filename of candidates) {
|
|
761
|
+
const fullPath = path6.join(workersDir, filename);
|
|
762
|
+
if (existsSync(fullPath)) {
|
|
763
|
+
return fullPath;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
return null;
|
|
767
|
+
}
|
|
768
|
+
function resolveNativeWorker(language, projectDir) {
|
|
769
|
+
const base = import.meta.dirname ?? path6.dirname(new URL(import.meta.url).pathname);
|
|
770
|
+
const hcsFromBundle = path6.resolve(base, "..", "..", "vibgrate-hcs");
|
|
771
|
+
const hcsFromSrc = path6.resolve(base, "..", "..", "..", "vibgrate-hcs");
|
|
772
|
+
const hcsRoot = existsSync(hcsFromBundle) ? hcsFromBundle : hcsFromSrc;
|
|
773
|
+
const workersDir = path6.resolve(base, "workers");
|
|
774
|
+
switch (language) {
|
|
775
|
+
case "go": {
|
|
776
|
+
const bin = path6.join(workersDir, process.platform === "win32" ? "vibgrate-hcs-go.exe" : "vibgrate-hcs-go");
|
|
777
|
+
if (existsSync(bin)) {
|
|
778
|
+
return { cmd: bin, args: ["--project", projectDir, "--output", "ndjson"] };
|
|
779
|
+
}
|
|
780
|
+
const src = path6.join(hcsRoot, "go");
|
|
781
|
+
if (existsSync(path6.join(src, "main.go"))) {
|
|
782
|
+
return { cmd: "go", args: ["run", ".", "--project", projectDir, "--output", "ndjson"], cwd: src };
|
|
783
|
+
}
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
case "python": {
|
|
787
|
+
const bin = path6.join(workersDir, "vibgrate-hcs-python");
|
|
788
|
+
if (existsSync(bin)) {
|
|
789
|
+
return { cmd: bin, args: ["--project", projectDir, "--output", "ndjson"] };
|
|
790
|
+
}
|
|
791
|
+
const src = path6.join(hcsRoot, "python");
|
|
792
|
+
if (existsSync(path6.join(src, "pyproject.toml"))) {
|
|
793
|
+
return {
|
|
794
|
+
cmd: "python3",
|
|
795
|
+
args: ["-m", "vibgrate_hcs_python.main", "--project", projectDir, "--output", "ndjson"],
|
|
796
|
+
cwd: src
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
case "java": {
|
|
802
|
+
const jar = path6.join(workersDir, "vibgrate-hcs-jvm.jar");
|
|
803
|
+
if (existsSync(jar)) {
|
|
804
|
+
return { cmd: "java", args: ["-jar", jar, "--project", projectDir, "--output", "ndjson"] };
|
|
805
|
+
}
|
|
806
|
+
const src = path6.join(hcsRoot, "jvm");
|
|
807
|
+
if (existsSync(path6.join(src, "build.gradle.kts"))) {
|
|
808
|
+
const gradlew = path6.join(src, process.platform === "win32" ? "gradlew.bat" : "gradlew");
|
|
809
|
+
const launcher = existsSync(gradlew) ? gradlew : "gradle";
|
|
810
|
+
return {
|
|
811
|
+
cmd: launcher,
|
|
812
|
+
args: ["-q", "--console=plain", "run", `--args=--project ${projectDir} --output ndjson`],
|
|
813
|
+
cwd: src
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
return null;
|
|
817
|
+
}
|
|
818
|
+
case "csharp":
|
|
819
|
+
case "vbnet": {
|
|
820
|
+
const publishedWorker = resolveDotnetPublishedWorker(workersDir);
|
|
821
|
+
if (publishedWorker) {
|
|
822
|
+
return { cmd: publishedWorker, args: ["--project", projectDir, "--output", "ndjson"] };
|
|
823
|
+
}
|
|
824
|
+
const dll = path6.join(workersDir, "VibgrateHcsWorker.dll");
|
|
825
|
+
if (existsSync(dll)) {
|
|
826
|
+
return { cmd: "dotnet", args: [dll, "--project", projectDir, "--output", "ndjson"] };
|
|
827
|
+
}
|
|
828
|
+
const csproj = path6.join(hcsRoot, "dotnet", "src", "VibgrateHcsWorker", "VibgrateHcsWorker.csproj");
|
|
829
|
+
if (existsSync(csproj)) {
|
|
830
|
+
return {
|
|
831
|
+
cmd: "dotnet",
|
|
832
|
+
args: ["run", "--project", csproj, "--", "--project", projectDir, "--output", "ndjson"]
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
default:
|
|
838
|
+
return null;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
async function runNativeWorker(rootDir, language, opts) {
|
|
842
|
+
const spec = resolveNativeWorker(language, rootDir);
|
|
843
|
+
if (!spec) {
|
|
844
|
+
return {
|
|
845
|
+
language,
|
|
846
|
+
facts: [],
|
|
847
|
+
errors: [
|
|
848
|
+
`[error] No native worker found for '${language}'. Build/package workers for this platform or use source mode.`,
|
|
849
|
+
`[hint] ${buildNativeInstallHint(language)}`
|
|
850
|
+
],
|
|
851
|
+
exitCode: EXIT_PARSE_FAILURE
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
return new Promise((resolve6) => {
|
|
855
|
+
const facts = [];
|
|
856
|
+
const errors = [];
|
|
857
|
+
let stdoutBuf = "";
|
|
858
|
+
let killed = false;
|
|
859
|
+
if (opts.verbose) {
|
|
860
|
+
process.stderr.write(chalk5.dim(`[${language}] Spawning: ${spec.cmd} ${spec.args.join(" ")}
|
|
861
|
+
`));
|
|
862
|
+
}
|
|
863
|
+
const runtimeReq = NATIVE_RUNTIME_REQUIREMENTS[language];
|
|
864
|
+
const usesPathCommand = runtimeReq && spec.cmd === runtimeReq.command;
|
|
865
|
+
if (usesPathCommand && !commandExistsOnPath(spec.cmd)) {
|
|
866
|
+
resolve6({
|
|
867
|
+
language,
|
|
868
|
+
facts: [],
|
|
869
|
+
errors: [
|
|
870
|
+
`[error] Required runtime command '${spec.cmd}' is not available on PATH.`,
|
|
871
|
+
`[hint] ${buildNativeInstallHint(language)}`,
|
|
872
|
+
"[hint] You can also package native workers into dist/workers to avoid local toolchain requirements."
|
|
873
|
+
],
|
|
874
|
+
exitCode: EXIT_PARSE_FAILURE
|
|
875
|
+
});
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
const child = spawn(spec.cmd, spec.args, {
|
|
879
|
+
cwd: spec.cwd ?? rootDir,
|
|
880
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
881
|
+
});
|
|
882
|
+
const timer = setTimeout(() => {
|
|
883
|
+
killed = true;
|
|
884
|
+
child.kill("SIGKILL");
|
|
885
|
+
}, opts.timeoutMs);
|
|
886
|
+
child.stdout.on("data", (chunk) => {
|
|
887
|
+
stdoutBuf += chunk.toString();
|
|
888
|
+
const lines = stdoutBuf.split("\n");
|
|
889
|
+
stdoutBuf = lines.pop();
|
|
890
|
+
for (const line of lines) {
|
|
891
|
+
const trimmed = line.trim();
|
|
892
|
+
if (trimmed) facts.push(trimmed);
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
child.stderr.on("data", (chunk) => {
|
|
896
|
+
const text = chunk.toString();
|
|
897
|
+
for (const line of text.split("\n")) {
|
|
898
|
+
const trimmed = line.trim();
|
|
899
|
+
if (!trimmed) continue;
|
|
900
|
+
if (opts.verbose) {
|
|
901
|
+
process.stderr.write(chalk5.dim(`[${language}] ${trimmed}
|
|
902
|
+
`));
|
|
903
|
+
}
|
|
904
|
+
if (trimmed.startsWith("[error]")) {
|
|
905
|
+
errors.push(trimmed);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
child.on("close", (code) => {
|
|
910
|
+
clearTimeout(timer);
|
|
911
|
+
if (stdoutBuf.trim()) facts.push(stdoutBuf.trim());
|
|
912
|
+
if (killed) {
|
|
913
|
+
resolve6({ language, facts, errors: ["Worker killed: timeout exceeded"], exitCode: EXIT_TIMEOUT });
|
|
914
|
+
} else {
|
|
915
|
+
resolve6({ language, facts, errors, exitCode: code ?? 0 });
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
child.on("error", (err) => {
|
|
919
|
+
clearTimeout(timer);
|
|
920
|
+
const isNotFound = err.code === "ENOENT";
|
|
921
|
+
errors.push(
|
|
922
|
+
isNotFound ? `[error] '${spec.cmd}' not found. ${buildNativeInstallHint(language)}` : `[error] Failed to spawn native worker: ${err.message}`
|
|
923
|
+
);
|
|
924
|
+
resolve6({ language, facts, errors, exitCode: EXIT_PARSE_FAILURE });
|
|
925
|
+
});
|
|
926
|
+
});
|
|
927
|
+
}
|
|
668
928
|
async function pushFacts(facts, dsn, verbose) {
|
|
669
929
|
const parsed = parseDsn(dsn);
|
|
670
930
|
if (!parsed) {
|
|
@@ -872,7 +1132,7 @@ var extractCommand = new Command5("extract").description("Analyze source code an
|
|
|
872
1132
|
}
|
|
873
1133
|
let targetLanguages;
|
|
874
1134
|
if (opts.language) {
|
|
875
|
-
targetLanguages = opts.language.split(",").map((l) => l
|
|
1135
|
+
targetLanguages = opts.language.split(",").map((l) => normalizeLanguageToken(l)).filter(Boolean);
|
|
876
1136
|
for (const lang of targetLanguages) {
|
|
877
1137
|
if (!SUPPORTED_LANGUAGES.has(lang)) {
|
|
878
1138
|
process.stderr.write(chalk5.red(`Unknown language: "${lang}"
|
|
@@ -897,25 +1157,16 @@ var extractCommand = new Command5("extract").description("Analyze source code an
|
|
|
897
1157
|
}
|
|
898
1158
|
}
|
|
899
1159
|
}
|
|
900
|
-
const runnableLanguages = targetLanguages.filter((l) =>
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
process.stderr.write(chalk5.yellow(
|
|
907
|
-
`Skipping languages without built-in HCS worker: ${skippedLanguages.join(", ")}
|
|
908
|
-
` + chalk5.dim("These require dedicated external workers.\n")
|
|
1160
|
+
const runnableLanguages = targetLanguages.filter((l) => ALL_WORKER_LANGS.has(l));
|
|
1161
|
+
const unknownWorkerLangs = targetLanguages.filter((l) => !ALL_WORKER_LANGS.has(l));
|
|
1162
|
+
if (unknownWorkerLangs.length > 0 && opts.verbose) {
|
|
1163
|
+
process.stderr.write(chalk5.dim(
|
|
1164
|
+
`No worker registered for: ${unknownWorkerLangs.join(", ")} \u2014 skipping.
|
|
1165
|
+
`
|
|
909
1166
|
));
|
|
910
1167
|
}
|
|
911
1168
|
if (runnableLanguages.length === 0) {
|
|
912
1169
|
process.stderr.write(chalk5.yellow("No languages with available HCS workers found.\n"));
|
|
913
|
-
if (skippedLanguages.length > 0) {
|
|
914
|
-
process.stderr.write(chalk5.dim(
|
|
915
|
-
`Detected: ${skippedLanguages.join(", ")} \u2014 these require external workers not yet integrated.
|
|
916
|
-
`
|
|
917
|
-
));
|
|
918
|
-
}
|
|
919
1170
|
process.exit(EXIT_SUCCESS);
|
|
920
1171
|
}
|
|
921
1172
|
const startTime = Date.now();
|
|
@@ -939,11 +1190,15 @@ var extractCommand = new Command5("extract").description("Analyze source code an
|
|
|
939
1190
|
hasTimeout = true;
|
|
940
1191
|
return;
|
|
941
1192
|
}
|
|
942
|
-
const result = await runNodeWorker(rootDir, language, {
|
|
1193
|
+
const result = NODE_WORKER_ALL_LANGS.has(language) ? await runNodeWorker(rootDir, language, {
|
|
943
1194
|
includeTests: opts.includeTests ?? false,
|
|
944
1195
|
verbose: opts.verbose ?? false,
|
|
945
1196
|
timeoutMs: remaining,
|
|
946
1197
|
onProgress: (event) => progress.onProgress(language, event)
|
|
1198
|
+
}) : await runNativeWorker(rootDir, language, {
|
|
1199
|
+
verbose: opts.verbose ?? false,
|
|
1200
|
+
timeoutMs: remaining,
|
|
1201
|
+
onProgress: (event) => progress.onProgress(language, event)
|
|
947
1202
|
});
|
|
948
1203
|
if (result.exitCode === EXIT_TIMEOUT) {
|
|
949
1204
|
hasTimeout = true;
|