bun-git-hooks 0.2.14 → 0.2.15

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/bin/cli.js CHANGED
@@ -3554,7 +3554,7 @@ class CAC extends EventEmitter {
3554
3554
  }
3555
3555
  }
3556
3556
  // package.json
3557
- var version = "0.2.14";
3557
+ var version = "0.2.15";
3558
3558
 
3559
3559
  // src/git-hooks.ts
3560
3560
  import fs from "fs";
@@ -5313,8 +5313,9 @@ function getGitProjectRoot(directory = process14.cwd()) {
5313
5313
  }
5314
5314
  function setHooksFromConfig(projectRootPath = process14.cwd(), options) {
5315
5315
  if (!config6 || Object.keys(config6).length === 0)
5316
- throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or `git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
5317
- const configFile = options?.configFile ? options.configFile : config6;
5316
+ throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,json}` or `git-hooks.config.{ts,js,mjs,cjs,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
5317
+ const configFile = options?.configFile || { ...config6 };
5318
+ _validateStagedLintConfig(configFile);
5318
5319
  const hookKeys = Object.keys(configFile).filter((key) => !VALID_OPTIONS.includes(key));
5319
5320
  const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
5320
5321
  if (!isValidConfig)
@@ -5457,6 +5458,16 @@ async function runStagedLint(hook) {
5457
5458
  console.error(`[ERROR] No staged lint configuration found for hook ${hook}`);
5458
5459
  return false;
5459
5460
  }
5461
+ function _validateStagedLintConfig(config4) {
5462
+ for (const hook of VALID_GIT_HOOKS) {
5463
+ if (hook !== "pre-commit" && config4[hook] && typeof config4[hook] === "object") {
5464
+ const hookConfig = config4[hook];
5465
+ if (hookConfig["stagedLint"] || hookConfig["staged-lint"]) {
5466
+ throw new Error(`staged-lint is only allowed in pre-commit hook. Found in ${hook} hook.`);
5467
+ }
5468
+ }
5469
+ }
5470
+ }
5460
5471
 
5461
5472
  // bin/cli.ts
5462
5473
  var cli = new CAC("git-hooks");
@@ -5482,7 +5493,7 @@ cli.command("[configPath]", "Install git hooks, optionally from specified config
5482
5493
  }
5483
5494
  log4.success("Successfully set all git hooks");
5484
5495
  } catch (err) {
5485
- log4.error("Was not able to set git hooks. Error:", err);
5496
+ log4.error(err);
5486
5497
  process15.exit(1);
5487
5498
  }
5488
5499
  });
@@ -1,4 +1,4 @@
1
- import type { SetHooksFromConfigOptions, StagedLintConfig } from './types';
1
+ import type { GitHooksConfig, SetHooksFromConfigOptions, StagedLintConfig } from './types';
2
2
 
3
3
  declare const execAsync: unknown;
4
4
  export declare const VALID_GIT_HOOKS: Array<
@@ -47,6 +47,7 @@ export declare function removeHooks(projectRoot: string, verbose): void;
47
47
  declare function _removeHook(hook: string, projectRoot, verbose): void;
48
48
  export declare function runStagedLint(hook: string): Promise<boolean>;
49
49
  declare function _validateHooks(config: Record<string, any>): boolean;
50
+ declare function _validateStagedLintConfig(config: GitHooksConfig): void;
50
51
  declare const gitHooks: {
51
52
  PREPEND_SCRIPT: typeof PREPEND_SCRIPT
52
53
  setHooksFromConfig: typeof setHooksFromConfig
@@ -1,4 +1,4 @@
1
- import type { SetHooksFromConfigOptions, StagedLintConfig } from './types';
1
+ import type { GitHooksConfig, SetHooksFromConfigOptions, StagedLintConfig } from './types';
2
2
 
3
3
  declare const execAsync: unknown;
4
4
  export declare const VALID_GIT_HOOKS: Array<
@@ -47,6 +47,7 @@ export declare function removeHooks(projectRoot: string, verbose): void;
47
47
  declare function _removeHook(hook: string, projectRoot, verbose): void;
48
48
  export declare function runStagedLint(hook: string): Promise<boolean>;
49
49
  declare function _validateHooks(config: Record<string, any>): boolean;
50
+ declare function _validateStagedLintConfig(config: GitHooksConfig): void;
50
51
  declare const gitHooks: {
51
52
  PREPEND_SCRIPT: typeof PREPEND_SCRIPT
52
53
  setHooksFromConfig: typeof setHooksFromConfig
package/dist/index.js CHANGED
@@ -4748,8 +4748,9 @@ function _getPackageJson(projectPath = process12.cwd()) {
4748
4748
  }
4749
4749
  function setHooksFromConfig(projectRootPath = process12.cwd(), options) {
4750
4750
  if (!config3 || Object.keys(config3).length === 0)
4751
- throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or `git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
4752
- const configFile = options?.configFile ? options.configFile : config3;
4751
+ throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,json}` or `git-hooks.config.{ts,js,mjs,cjs,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
4752
+ const configFile = options?.configFile || { ...config3 };
4753
+ _validateStagedLintConfig(configFile);
4753
4754
  const hookKeys = Object.keys(configFile).filter((key) => !VALID_OPTIONS.includes(key));
4754
4755
  const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
4755
4756
  if (!isValidConfig)
@@ -4892,6 +4893,16 @@ async function runStagedLint(hook) {
4892
4893
  console.error(`[ERROR] No staged lint configuration found for hook ${hook}`);
4893
4894
  return false;
4894
4895
  }
4896
+ function _validateStagedLintConfig(config5) {
4897
+ for (const hook of VALID_GIT_HOOKS) {
4898
+ if (hook !== "pre-commit" && config5[hook] && typeof config5[hook] === "object") {
4899
+ const hookConfig = config5[hook];
4900
+ if (hookConfig["stagedLint"] || hookConfig["staged-lint"]) {
4901
+ throw new Error(`staged-lint is only allowed in pre-commit hook. Found in ${hook} hook.`);
4902
+ }
4903
+ }
4904
+ }
4905
+ }
4895
4906
  export {
4896
4907
  setHooksFromConfig,
4897
4908
  runStagedLint,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-git-hooks",
3
3
  "type": "module",
4
- "version": "0.2.14",
4
+ "version": "0.2.15",
5
5
  "description": "A modern, zero dependency tool for managing git hooks in Bun projects.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",