viberails 0.6.0 → 0.6.1

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
@@ -3080,7 +3080,7 @@ var fs18 = __toESM(require("fs"), 1);
3080
3080
  var path18 = __toESM(require("path"), 1);
3081
3081
  var import_chalk11 = __toESM(require("chalk"), 1);
3082
3082
  var import_yaml2 = require("yaml");
3083
- function addPreCommitStep(projectRoot, name, command, marker) {
3083
+ function addPreCommitStep(projectRoot, name, command, marker, lefthookExtra) {
3084
3084
  const lefthookPath = path18.join(projectRoot, "lefthook.yml");
3085
3085
  if (fs18.existsSync(lefthookPath)) {
3086
3086
  const content = fs18.readFileSync(lefthookPath, "utf-8");
@@ -3088,7 +3088,7 @@ function addPreCommitStep(projectRoot, name, command, marker) {
3088
3088
  const doc = (0, import_yaml2.parse)(content) ?? {};
3089
3089
  if (!doc["pre-commit"]) doc["pre-commit"] = { commands: {} };
3090
3090
  if (!doc["pre-commit"].commands) doc["pre-commit"].commands = {};
3091
- doc["pre-commit"].commands[name] = { run: command };
3091
+ doc["pre-commit"].commands[name] = { run: command, ...lefthookExtra };
3092
3092
  fs18.writeFileSync(lefthookPath, (0, import_yaml2.stringify)(doc));
3093
3093
  return "lefthook.yml";
3094
3094
  }
@@ -3148,9 +3148,21 @@ function setupTypecheckHook(projectRoot, packageManager) {
3148
3148
  return target;
3149
3149
  }
3150
3150
  function setupLintHook(projectRoot, linter) {
3151
- const command = linter === "biome" ? "npx biome check ." : "npx eslint .";
3151
+ const isLefthook = fs18.existsSync(path18.join(projectRoot, "lefthook.yml"));
3152
3152
  const linterName = linter === "biome" ? "Biome" : "ESLint";
3153
- const target = addPreCommitStep(projectRoot, "lint", command, linter);
3153
+ let command;
3154
+ let lefthookExtra;
3155
+ if (isLefthook) {
3156
+ command = linter === "biome" ? "npx biome check {staged_files}" : "npx eslint {staged_files}";
3157
+ lefthookExtra = {
3158
+ glob: linter === "biome" ? "*.{js,ts,jsx,tsx,json,css}" : "*.{js,ts,jsx,tsx}"
3159
+ };
3160
+ } else {
3161
+ const exts = linter === "biome" ? "'*.js' '*.ts' '*.jsx' '*.tsx' '*.json' '*.css'" : "'*.js' '*.ts' '*.jsx' '*.tsx'";
3162
+ const lintCmd = linter === "biome" ? "biome check" : "eslint";
3163
+ command = `git diff --cached --name-only --diff-filter=ACMR -- ${exts} | xargs npx ${lintCmd}`;
3164
+ }
3165
+ const target = addPreCommitStep(projectRoot, "lint", command, linter, lefthookExtra);
3154
3166
  if (target) {
3155
3167
  console.log(` ${import_chalk11.default.green("\u2713")} ${target} \u2014 added ${linterName} lint check`);
3156
3168
  }
@@ -3486,7 +3498,7 @@ ${import_chalk13.default.bold("Synced:")}`);
3486
3498
  }
3487
3499
 
3488
3500
  // src/index.ts
3489
- var VERSION = "0.6.0";
3501
+ var VERSION = "0.6.1";
3490
3502
  var program = new import_commander.Command();
3491
3503
  program.name("viberails").description("Guardrails for vibe coding").version(VERSION);
3492
3504
  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) => {