@vibgrate/cli 1.0.12 → 1.0.14
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.
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
// src/utils/fs.ts
|
|
2
2
|
import * as fs from "fs/promises";
|
|
3
|
+
import * as os from "os";
|
|
3
4
|
import * as path from "path";
|
|
5
|
+
|
|
6
|
+
// src/utils/semaphore.ts
|
|
7
|
+
var Semaphore = class {
|
|
8
|
+
available;
|
|
9
|
+
queue = [];
|
|
10
|
+
constructor(max) {
|
|
11
|
+
this.available = max;
|
|
12
|
+
}
|
|
13
|
+
async run(fn) {
|
|
14
|
+
await this.acquire();
|
|
15
|
+
try {
|
|
16
|
+
return await fn();
|
|
17
|
+
} finally {
|
|
18
|
+
this.release();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
acquire() {
|
|
22
|
+
if (this.available > 0) {
|
|
23
|
+
this.available--;
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
}
|
|
26
|
+
return new Promise((resolve6) => this.queue.push(resolve6));
|
|
27
|
+
}
|
|
28
|
+
release() {
|
|
29
|
+
const next = this.queue.shift();
|
|
30
|
+
if (next) next();
|
|
31
|
+
else this.available++;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/utils/fs.ts
|
|
4
36
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
5
37
|
"node_modules",
|
|
6
38
|
".git",
|
|
@@ -20,28 +52,27 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
20
52
|
]);
|
|
21
53
|
async function findFiles(rootDir, predicate) {
|
|
22
54
|
const results = [];
|
|
55
|
+
const maxConcurrentReads = Math.max(8, Math.min(64, os.availableParallelism() * 4));
|
|
56
|
+
const readDirSemaphore = new Semaphore(maxConcurrentReads);
|
|
23
57
|
async function walk(dir) {
|
|
24
58
|
let entries;
|
|
25
59
|
try {
|
|
26
|
-
|
|
27
|
-
entries = dirents.map((d) => ({
|
|
28
|
-
name: d.name,
|
|
29
|
-
isDirectory: d.isDirectory(),
|
|
30
|
-
isFile: d.isFile()
|
|
31
|
-
}));
|
|
60
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
32
61
|
} catch {
|
|
33
62
|
return;
|
|
34
63
|
}
|
|
64
|
+
const subDirectoryWalks = [];
|
|
35
65
|
for (const e of entries) {
|
|
36
|
-
if (e.isDirectory) {
|
|
66
|
+
if (e.isDirectory()) {
|
|
37
67
|
if (SKIP_DIRS.has(e.name)) continue;
|
|
38
|
-
|
|
39
|
-
} else if (e.isFile && predicate(e.name)) {
|
|
68
|
+
subDirectoryWalks.push(readDirSemaphore.run(() => walk(path.join(dir, e.name))));
|
|
69
|
+
} else if (e.isFile() && predicate(e.name)) {
|
|
40
70
|
results.push(path.join(dir, e.name));
|
|
41
71
|
}
|
|
42
72
|
}
|
|
73
|
+
await Promise.all(subDirectoryWalks);
|
|
43
74
|
}
|
|
44
|
-
await walk(rootDir);
|
|
75
|
+
await readDirSemaphore.run(() => walk(rootDir));
|
|
45
76
|
return results;
|
|
46
77
|
}
|
|
47
78
|
async function findPackageJsonFiles(rootDir) {
|
|
@@ -1620,35 +1651,6 @@ async function scanOneCsproj(csprojPath, rootDir) {
|
|
|
1620
1651
|
};
|
|
1621
1652
|
}
|
|
1622
1653
|
|
|
1623
|
-
// src/utils/semaphore.ts
|
|
1624
|
-
var Semaphore = class {
|
|
1625
|
-
available;
|
|
1626
|
-
queue = [];
|
|
1627
|
-
constructor(max) {
|
|
1628
|
-
this.available = max;
|
|
1629
|
-
}
|
|
1630
|
-
async run(fn) {
|
|
1631
|
-
await this.acquire();
|
|
1632
|
-
try {
|
|
1633
|
-
return await fn();
|
|
1634
|
-
} finally {
|
|
1635
|
-
this.release();
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
acquire() {
|
|
1639
|
-
if (this.available > 0) {
|
|
1640
|
-
this.available--;
|
|
1641
|
-
return Promise.resolve();
|
|
1642
|
-
}
|
|
1643
|
-
return new Promise((resolve6) => this.queue.push(resolve6));
|
|
1644
|
-
}
|
|
1645
|
-
release() {
|
|
1646
|
-
const next = this.queue.shift();
|
|
1647
|
-
if (next) next();
|
|
1648
|
-
else this.available++;
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
|
|
1652
1654
|
// src/config.ts
|
|
1653
1655
|
import * as path6 from "path";
|
|
1654
1656
|
import * as fs2 from "fs/promises";
|
|
@@ -4234,7 +4236,7 @@ async function autoPush(artifact, rootDir, opts) {
|
|
|
4234
4236
|
const result = await response.json();
|
|
4235
4237
|
console.log(chalk5.green("\u2714") + ` Uploaded successfully (${result.ingestId ?? "ok"})`);
|
|
4236
4238
|
if (result.ingestId) {
|
|
4237
|
-
console.log(chalk5.dim(` See full report: `) + chalk5.cyan(`https://dash.vibgrate.com/${parsed.workspaceId}/scan/${result.ingestId}`));
|
|
4239
|
+
console.log(chalk5.dim(` See Dashboard for full report: `) + chalk5.cyan(`https://dash.vibgrate.com/${parsed.workspaceId}/scan/${result.ingestId}`));
|
|
4238
4240
|
}
|
|
4239
4241
|
} catch (e) {
|
|
4240
4242
|
const msg = e instanceof Error ? e.message : String(e);
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-VXZT34Y5.js";
|
|
5
5
|
import {
|
|
6
6
|
baselineCommand
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-POMRKRQN.js";
|
|
8
8
|
import {
|
|
9
9
|
VERSION,
|
|
10
10
|
dsnCommand,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
readJsonFile,
|
|
16
16
|
scanCommand,
|
|
17
17
|
writeDefaultConfig
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4N4BALQQ.js";
|
|
19
19
|
|
|
20
20
|
// src/cli.ts
|
|
21
21
|
import { Command as Command4 } from "commander";
|
|
@@ -38,7 +38,7 @@ var initCommand = new Command("init").description("Initialize vibgrate in a proj
|
|
|
38
38
|
console.log(chalk.green("\u2714") + ` Created ${chalk.bold("vibgrate.config.ts")}`);
|
|
39
39
|
}
|
|
40
40
|
if (opts.baseline) {
|
|
41
|
-
const { runBaseline } = await import("./baseline-
|
|
41
|
+
const { runBaseline } = await import("./baseline-RV3GAW72.js");
|
|
42
42
|
await runBaseline(rootDir);
|
|
43
43
|
}
|
|
44
44
|
console.log("");
|
package/dist/index.js
CHANGED