viberails 0.5.2 → 0.5.3

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.cjs CHANGED
@@ -1683,13 +1683,15 @@ function displayInitSummary(config, exemptedPackages) {
1683
1683
  console.log("");
1684
1684
  console.log(` ${import_chalk4.default.bold("Rules to apply:")}`);
1685
1685
  console.log(` ${ok} Max file size: ${import_chalk4.default.cyan(`${config.rules.maxFileLines} lines`)}`);
1686
- if (config.rules.enforceNaming && root?.conventions?.fileNaming) {
1687
- console.log(` ${ok} File naming: ${import_chalk4.default.cyan(root.conventions.fileNaming)}`);
1686
+ const fileNaming = root?.conventions?.fileNaming ?? config.packages.find((p) => p.conventions?.fileNaming)?.conventions?.fileNaming;
1687
+ if (config.rules.enforceNaming && fileNaming) {
1688
+ console.log(` ${ok} File naming: ${import_chalk4.default.cyan(fileNaming)}`);
1688
1689
  } else {
1689
1690
  console.log(` ${off} File naming: ${import_chalk4.default.dim("not enforced")}`);
1690
1691
  }
1691
- if (config.rules.enforceMissingTests && root?.structure?.testPattern) {
1692
- console.log(` ${ok} Missing tests: ${import_chalk4.default.cyan(`enforced (${root.structure.testPattern})`)}`);
1692
+ const testPattern = root?.structure?.testPattern ?? config.packages.find((p) => p.structure?.testPattern)?.structure?.testPattern;
1693
+ if (config.rules.enforceMissingTests && testPattern) {
1694
+ console.log(` ${ok} Missing tests: ${import_chalk4.default.cyan(`enforced (${testPattern})`)}`);
1693
1695
  } else if (config.rules.enforceMissingTests) {
1694
1696
  console.log(` ${ok} Missing tests: ${import_chalk4.default.cyan("enforced")}`);
1695
1697
  } else {
@@ -2487,30 +2489,35 @@ var path14 = __toESM(require("path"), 1);
2487
2489
  var clack7 = __toESM(require("@clack/prompts"), 1);
2488
2490
  var import_chalk8 = __toESM(require("chalk"), 1);
2489
2491
  function checkCoveragePrereqs(projectRoot, scanResult) {
2490
- const testRunner = scanResult.stack.testRunner;
2491
- if (!testRunner) return [];
2492
- const runner = testRunner.name;
2493
2492
  const pm = scanResult.stack.packageManager.name;
2494
- if (runner === "vitest") {
2495
- const hasV8 = hasDependency(projectRoot, "@vitest/coverage-v8");
2496
- const hasIstanbul = hasDependency(projectRoot, "@vitest/coverage-istanbul");
2497
- const installed = hasV8 || hasIstanbul;
2498
- const addCmd = pm === "yarn" ? "yarn add -D" : pm === "npm" ? "npm install -D" : `${pm} add -D`;
2499
- return [
2500
- {
2501
- label: "@vitest/coverage-v8",
2502
- installed,
2503
- installCommand: installed ? void 0 : `${addCmd} @vitest/coverage-v8`,
2504
- reason: "Required for coverage percentage checks with vitest"
2505
- }
2506
- ];
2493
+ const vitestPackages = scanResult.packages.filter((pkg) => pkg.stack.testRunner?.name === "vitest").map((pkg) => pkg.relativePath);
2494
+ const hasVitest = vitestPackages.length > 0 || scanResult.stack.testRunner?.name === "vitest";
2495
+ if (!hasVitest) return [];
2496
+ let installed = hasDependency(projectRoot, "@vitest/coverage-v8") || hasDependency(projectRoot, "@vitest/coverage-istanbul");
2497
+ if (!installed && vitestPackages.length > 0) {
2498
+ installed = vitestPackages.every((rel) => {
2499
+ const pkgDir = path14.join(projectRoot, rel);
2500
+ return hasDependency(pkgDir, "@vitest/coverage-v8") || hasDependency(pkgDir, "@vitest/coverage-istanbul");
2501
+ });
2507
2502
  }
2508
- return [];
2503
+ const addCmd = pm === "yarn" ? "yarn add -D" : pm === "npm" ? "npm install -D" : `${pm} add -D`;
2504
+ const affectedPackages = vitestPackages.length > 1 ? vitestPackages : void 0;
2505
+ const reason = affectedPackages ? `Required for coverage in: ${affectedPackages.join(", ")}` : "Required for coverage percentage checks with vitest";
2506
+ return [
2507
+ {
2508
+ label: "@vitest/coverage-v8",
2509
+ installed,
2510
+ installCommand: installed ? void 0 : `${addCmd} @vitest/coverage-v8`,
2511
+ reason,
2512
+ affectedPackages
2513
+ }
2514
+ ];
2509
2515
  }
2510
2516
  function displayMissingPrereqs(prereqs) {
2511
2517
  const missing = prereqs.filter((p) => !p.installed);
2512
2518
  for (const m of missing) {
2513
- console.log(` ${import_chalk8.default.yellow("!")} ${m.label} not installed \u2014 ${m.reason}`);
2519
+ const suffix = m.affectedPackages ? ` \u2014 needed for coverage in: ${m.affectedPackages.join(", ")}` : ` \u2014 ${m.reason}`;
2520
+ console.log(` ${import_chalk8.default.yellow("!")} ${m.label} not installed${suffix}`);
2514
2521
  if (m.installCommand) {
2515
2522
  console.log(` Install: ${import_chalk8.default.cyan(m.installCommand)}`);
2516
2523
  }
@@ -2519,15 +2526,19 @@ function displayMissingPrereqs(prereqs) {
2519
2526
  async function promptMissingPrereqs(projectRoot, prereqs) {
2520
2527
  const missing = prereqs.filter((p) => !p.installed);
2521
2528
  if (missing.length === 0) return { disableCoverage: false };
2522
- const prereqLines = prereqs.map(
2523
- (p) => `${p.installed ? "\u2713" : "\u2717"} ${p.label}${p.installed ? "" : ` \u2014 ${p.reason}`}`
2524
- ).join("\n");
2529
+ const prereqLines = prereqs.map((p) => {
2530
+ if (p.installed) return `\u2713 ${p.label}`;
2531
+ const detail = p.affectedPackages ? `needed by: ${p.affectedPackages.join(", ")}` : p.reason;
2532
+ return `\u2717 ${p.label} \u2014 ${detail}`;
2533
+ }).join("\n");
2525
2534
  clack7.note(prereqLines, "Coverage prerequisites");
2526
2535
  let disableCoverage = false;
2527
2536
  for (const m of missing) {
2528
2537
  if (!m.installCommand) continue;
2538
+ const pkgCount = m.affectedPackages?.length;
2539
+ const message = pkgCount ? `${m.label} is not installed. Required for coverage in ${pkgCount} packages using vitest.` : `${m.label} is not installed. It is required for coverage percentage checks.`;
2529
2540
  const choice = await clack7.select({
2530
- message: `${m.label} is not installed. It is required for coverage percentage checks.`,
2541
+ message,
2531
2542
  options: [
2532
2543
  {
2533
2544
  value: "install",
@@ -3202,7 +3213,7 @@ ${import_chalk12.default.bold("Synced:")}`);
3202
3213
  }
3203
3214
 
3204
3215
  // src/index.ts
3205
- var VERSION = "0.5.2";
3216
+ var VERSION = "0.5.3";
3206
3217
  var program = new import_commander.Command();
3207
3218
  program.name("viberails").description("Guardrails for vibe coding").version(VERSION);
3208
3219
  program.command("init", { isDefault: true }).description("Scan your project and set up enforcement guardrails").option("-y, --yes", "Non-interactive mode (use defaults, high-confidence only)").option("-f, --force", "Re-initialize, replacing existing config").action(async (options) => {