@vibgrate/cli 1.0.79 → 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 +131 -11
- 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,14 +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 NATIVE_AST_LANGS = /* @__PURE__ */ new Set(["go", "python", "java", "csharp"]);
|
|
601
|
+
var NATIVE_AST_LANGS = /* @__PURE__ */ new Set(["go", "python", "java", "csharp", "vbnet"]);
|
|
592
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
|
+
}
|
|
593
669
|
async function runNodeWorker(rootDir, language, opts) {
|
|
594
670
|
const workerBin = resolveHcsWorkerBin();
|
|
595
671
|
const args = [];
|
|
@@ -666,6 +742,29 @@ async function runNodeWorker(rootDir, language, opts) {
|
|
|
666
742
|
});
|
|
667
743
|
});
|
|
668
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
|
+
}
|
|
669
768
|
function resolveNativeWorker(language, projectDir) {
|
|
670
769
|
const base = import.meta.dirname ?? path6.dirname(new URL(import.meta.url).pathname);
|
|
671
770
|
const hcsFromBundle = path6.resolve(base, "..", "..", "vibgrate-hcs");
|
|
@@ -716,7 +815,12 @@ function resolveNativeWorker(language, projectDir) {
|
|
|
716
815
|
}
|
|
717
816
|
return null;
|
|
718
817
|
}
|
|
719
|
-
case "csharp":
|
|
818
|
+
case "csharp":
|
|
819
|
+
case "vbnet": {
|
|
820
|
+
const publishedWorker = resolveDotnetPublishedWorker(workersDir);
|
|
821
|
+
if (publishedWorker) {
|
|
822
|
+
return { cmd: publishedWorker, args: ["--project", projectDir, "--output", "ndjson"] };
|
|
823
|
+
}
|
|
720
824
|
const dll = path6.join(workersDir, "VibgrateHcsWorker.dll");
|
|
721
825
|
if (existsSync(dll)) {
|
|
722
826
|
return { cmd: "dotnet", args: [dll, "--project", projectDir, "--output", "ndjson"] };
|
|
@@ -741,7 +845,8 @@ async function runNativeWorker(rootDir, language, opts) {
|
|
|
741
845
|
language,
|
|
742
846
|
facts: [],
|
|
743
847
|
errors: [
|
|
744
|
-
`[error] No native worker found for '${language}'.
|
|
848
|
+
`[error] No native worker found for '${language}'. Build/package workers for this platform or use source mode.`,
|
|
849
|
+
`[hint] ${buildNativeInstallHint(language)}`
|
|
745
850
|
],
|
|
746
851
|
exitCode: EXIT_PARSE_FAILURE
|
|
747
852
|
};
|
|
@@ -755,6 +860,21 @@ async function runNativeWorker(rootDir, language, opts) {
|
|
|
755
860
|
process.stderr.write(chalk5.dim(`[${language}] Spawning: ${spec.cmd} ${spec.args.join(" ")}
|
|
756
861
|
`));
|
|
757
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
|
+
}
|
|
758
878
|
const child = spawn(spec.cmd, spec.args, {
|
|
759
879
|
cwd: spec.cwd ?? rootDir,
|
|
760
880
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -799,7 +919,7 @@ async function runNativeWorker(rootDir, language, opts) {
|
|
|
799
919
|
clearTimeout(timer);
|
|
800
920
|
const isNotFound = err.code === "ENOENT";
|
|
801
921
|
errors.push(
|
|
802
|
-
isNotFound ? `[error] '${spec.cmd}' not found.
|
|
922
|
+
isNotFound ? `[error] '${spec.cmd}' not found. ${buildNativeInstallHint(language)}` : `[error] Failed to spawn native worker: ${err.message}`
|
|
803
923
|
);
|
|
804
924
|
resolve6({ language, facts, errors, exitCode: EXIT_PARSE_FAILURE });
|
|
805
925
|
});
|
|
@@ -1012,7 +1132,7 @@ var extractCommand = new Command5("extract").description("Analyze source code an
|
|
|
1012
1132
|
}
|
|
1013
1133
|
let targetLanguages;
|
|
1014
1134
|
if (opts.language) {
|
|
1015
|
-
targetLanguages = opts.language.split(",").map((l) => l
|
|
1135
|
+
targetLanguages = opts.language.split(",").map((l) => normalizeLanguageToken(l)).filter(Boolean);
|
|
1016
1136
|
for (const lang of targetLanguages) {
|
|
1017
1137
|
if (!SUPPORTED_LANGUAGES.has(lang)) {
|
|
1018
1138
|
process.stderr.write(chalk5.red(`Unknown language: "${lang}"
|