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.js CHANGED
@@ -1662,13 +1662,15 @@ function displayInitSummary(config, exemptedPackages) {
1662
1662
  console.log("");
1663
1663
  console.log(` ${chalk4.bold("Rules to apply:")}`);
1664
1664
  console.log(` ${ok} Max file size: ${chalk4.cyan(`${config.rules.maxFileLines} lines`)}`);
1665
- if (config.rules.enforceNaming && root?.conventions?.fileNaming) {
1666
- console.log(` ${ok} File naming: ${chalk4.cyan(root.conventions.fileNaming)}`);
1665
+ const fileNaming = root?.conventions?.fileNaming ?? config.packages.find((p) => p.conventions?.fileNaming)?.conventions?.fileNaming;
1666
+ if (config.rules.enforceNaming && fileNaming) {
1667
+ console.log(` ${ok} File naming: ${chalk4.cyan(fileNaming)}`);
1667
1668
  } else {
1668
1669
  console.log(` ${off} File naming: ${chalk4.dim("not enforced")}`);
1669
1670
  }
1670
- if (config.rules.enforceMissingTests && root?.structure?.testPattern) {
1671
- console.log(` ${ok} Missing tests: ${chalk4.cyan(`enforced (${root.structure.testPattern})`)}`);
1671
+ const testPattern = root?.structure?.testPattern ?? config.packages.find((p) => p.structure?.testPattern)?.structure?.testPattern;
1672
+ if (config.rules.enforceMissingTests && testPattern) {
1673
+ console.log(` ${ok} Missing tests: ${chalk4.cyan(`enforced (${testPattern})`)}`);
1672
1674
  } else if (config.rules.enforceMissingTests) {
1673
1675
  console.log(` ${ok} Missing tests: ${chalk4.cyan("enforced")}`);
1674
1676
  } else {
@@ -2466,30 +2468,35 @@ import * as path14 from "path";
2466
2468
  import * as clack7 from "@clack/prompts";
2467
2469
  import chalk8 from "chalk";
2468
2470
  function checkCoveragePrereqs(projectRoot, scanResult) {
2469
- const testRunner = scanResult.stack.testRunner;
2470
- if (!testRunner) return [];
2471
- const runner = testRunner.name;
2472
2471
  const pm = scanResult.stack.packageManager.name;
2473
- if (runner === "vitest") {
2474
- const hasV8 = hasDependency(projectRoot, "@vitest/coverage-v8");
2475
- const hasIstanbul = hasDependency(projectRoot, "@vitest/coverage-istanbul");
2476
- const installed = hasV8 || hasIstanbul;
2477
- const addCmd = pm === "yarn" ? "yarn add -D" : pm === "npm" ? "npm install -D" : `${pm} add -D`;
2478
- return [
2479
- {
2480
- label: "@vitest/coverage-v8",
2481
- installed,
2482
- installCommand: installed ? void 0 : `${addCmd} @vitest/coverage-v8`,
2483
- reason: "Required for coverage percentage checks with vitest"
2484
- }
2485
- ];
2472
+ const vitestPackages = scanResult.packages.filter((pkg) => pkg.stack.testRunner?.name === "vitest").map((pkg) => pkg.relativePath);
2473
+ const hasVitest = vitestPackages.length > 0 || scanResult.stack.testRunner?.name === "vitest";
2474
+ if (!hasVitest) return [];
2475
+ let installed = hasDependency(projectRoot, "@vitest/coverage-v8") || hasDependency(projectRoot, "@vitest/coverage-istanbul");
2476
+ if (!installed && vitestPackages.length > 0) {
2477
+ installed = vitestPackages.every((rel) => {
2478
+ const pkgDir = path14.join(projectRoot, rel);
2479
+ return hasDependency(pkgDir, "@vitest/coverage-v8") || hasDependency(pkgDir, "@vitest/coverage-istanbul");
2480
+ });
2486
2481
  }
2487
- return [];
2482
+ const addCmd = pm === "yarn" ? "yarn add -D" : pm === "npm" ? "npm install -D" : `${pm} add -D`;
2483
+ const affectedPackages = vitestPackages.length > 1 ? vitestPackages : void 0;
2484
+ const reason = affectedPackages ? `Required for coverage in: ${affectedPackages.join(", ")}` : "Required for coverage percentage checks with vitest";
2485
+ return [
2486
+ {
2487
+ label: "@vitest/coverage-v8",
2488
+ installed,
2489
+ installCommand: installed ? void 0 : `${addCmd} @vitest/coverage-v8`,
2490
+ reason,
2491
+ affectedPackages
2492
+ }
2493
+ ];
2488
2494
  }
2489
2495
  function displayMissingPrereqs(prereqs) {
2490
2496
  const missing = prereqs.filter((p) => !p.installed);
2491
2497
  for (const m of missing) {
2492
- console.log(` ${chalk8.yellow("!")} ${m.label} not installed \u2014 ${m.reason}`);
2498
+ const suffix = m.affectedPackages ? ` \u2014 needed for coverage in: ${m.affectedPackages.join(", ")}` : ` \u2014 ${m.reason}`;
2499
+ console.log(` ${chalk8.yellow("!")} ${m.label} not installed${suffix}`);
2493
2500
  if (m.installCommand) {
2494
2501
  console.log(` Install: ${chalk8.cyan(m.installCommand)}`);
2495
2502
  }
@@ -2498,15 +2505,19 @@ function displayMissingPrereqs(prereqs) {
2498
2505
  async function promptMissingPrereqs(projectRoot, prereqs) {
2499
2506
  const missing = prereqs.filter((p) => !p.installed);
2500
2507
  if (missing.length === 0) return { disableCoverage: false };
2501
- const prereqLines = prereqs.map(
2502
- (p) => `${p.installed ? "\u2713" : "\u2717"} ${p.label}${p.installed ? "" : ` \u2014 ${p.reason}`}`
2503
- ).join("\n");
2508
+ const prereqLines = prereqs.map((p) => {
2509
+ if (p.installed) return `\u2713 ${p.label}`;
2510
+ const detail = p.affectedPackages ? `needed by: ${p.affectedPackages.join(", ")}` : p.reason;
2511
+ return `\u2717 ${p.label} \u2014 ${detail}`;
2512
+ }).join("\n");
2504
2513
  clack7.note(prereqLines, "Coverage prerequisites");
2505
2514
  let disableCoverage = false;
2506
2515
  for (const m of missing) {
2507
2516
  if (!m.installCommand) continue;
2517
+ const pkgCount = m.affectedPackages?.length;
2518
+ 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.`;
2508
2519
  const choice = await clack7.select({
2509
- message: `${m.label} is not installed. It is required for coverage percentage checks.`,
2520
+ message,
2510
2521
  options: [
2511
2522
  {
2512
2523
  value: "install",
@@ -3181,7 +3192,7 @@ ${chalk12.bold("Synced:")}`);
3181
3192
  }
3182
3193
 
3183
3194
  // src/index.ts
3184
- var VERSION = "0.5.2";
3195
+ var VERSION = "0.5.3";
3185
3196
  var program = new Command();
3186
3197
  program.name("viberails").description("Guardrails for vibe coding").version(VERSION);
3187
3198
  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) => {