@vibgrate/cli 2026.4.30 → 2026.6.5

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.
@@ -0,0 +1,9 @@
1
+ import {
2
+ baselineCommand,
3
+ runBaseline
4
+ } from "./chunk-42GW43JE.js";
5
+ import "./chunk-JSBRDJBE.js";
6
+ export {
7
+ baselineCommand,
8
+ runBaseline
9
+ };
@@ -0,0 +1,97 @@
1
+ // src/commands/baseline.ts
2
+ import * as path3 from "path";
3
+ import { Command } from "commander";
4
+ import chalk from "chalk";
5
+ import { runScan } from "@vibgrate/core";
6
+
7
+ // src/utils/fs.ts
8
+ import { execFile } from "child_process";
9
+ import * as fs from "fs/promises";
10
+ import * as os from "os";
11
+ import * as path2 from "path";
12
+ import { promisify } from "util";
13
+
14
+ // src/utils/semaphore.ts
15
+ var Semaphore = class {
16
+ available;
17
+ queue = [];
18
+ constructor(max) {
19
+ this.available = max;
20
+ }
21
+ async run(fn) {
22
+ await this.acquire();
23
+ try {
24
+ return await fn();
25
+ } finally {
26
+ this.release();
27
+ }
28
+ }
29
+ acquire() {
30
+ if (this.available > 0) {
31
+ this.available--;
32
+ return Promise.resolve();
33
+ }
34
+ return new Promise((resolve3) => this.queue.push(resolve3));
35
+ }
36
+ release() {
37
+ const next = this.queue.shift();
38
+ if (next) next();
39
+ else this.available++;
40
+ }
41
+ };
42
+
43
+ // src/utils/glob.ts
44
+ import * as path from "path";
45
+
46
+ // src/utils/fs.ts
47
+ var execFileAsync = promisify(execFile);
48
+ async function readJsonFile(filePath) {
49
+ const txt = await fs.readFile(filePath, "utf8");
50
+ return JSON.parse(txt);
51
+ }
52
+ async function pathExists(p) {
53
+ try {
54
+ await fs.access(p);
55
+ return true;
56
+ } catch {
57
+ return false;
58
+ }
59
+ }
60
+ async function ensureDir(dir) {
61
+ await fs.mkdir(dir, { recursive: true });
62
+ }
63
+ async function writeJsonFile(filePath, data) {
64
+ await ensureDir(path2.dirname(filePath));
65
+ await fs.writeFile(filePath, JSON.stringify(data, null, 2) + "\n", "utf8");
66
+ }
67
+ async function writeTextFile(filePath, content) {
68
+ await ensureDir(path2.dirname(filePath));
69
+ await fs.writeFile(filePath, content, "utf8");
70
+ }
71
+
72
+ // src/commands/baseline.ts
73
+ async function runBaseline(rootDir) {
74
+ console.log(chalk.dim("Creating baseline..."));
75
+ const artifact = await runScan(rootDir, {
76
+ format: "text",
77
+ concurrency: 8
78
+ });
79
+ const baselinePath = path3.join(rootDir, ".vibgrate", "baseline.json");
80
+ await writeJsonFile(baselinePath, artifact);
81
+ console.log(chalk.green("\u2714") + ` Baseline saved to ${chalk.bold(".vibgrate/baseline.json")}`);
82
+ console.log(chalk.dim(` Baseline score: ${artifact.drift.score}/100`));
83
+ }
84
+ var baselineCommand = new Command("baseline").description("Create a drift baseline snapshot").argument("[path]", "Path to baseline", ".").action(async (targetPath) => {
85
+ const rootDir = path3.resolve(targetPath);
86
+ await runBaseline(rootDir);
87
+ });
88
+
89
+ export {
90
+ Semaphore,
91
+ readJsonFile,
92
+ pathExists,
93
+ ensureDir,
94
+ writeTextFile,
95
+ runBaseline,
96
+ baselineCommand
97
+ };