bun-git-hooks 0.2.18 → 0.3.0

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/config.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import type { GitHooksConfig } from './types';
2
-
1
+ // eslint-disable-next-line antfu/no-top-level-await
3
2
  export declare const config: GitHooksConfig;
@@ -1,64 +1,40 @@
1
- import type { GitHooksConfig, SetHooksFromConfigOptions, StagedLintConfig } from './types';
2
-
3
- declare const execAsync: unknown;
4
- export declare const VALID_GIT_HOOKS: Array<
5
- 'applypatch-msg' |
6
- 'pre-applypatch' |
7
- 'post-applypatch' |
8
- 'pre-commit' |
9
- 'pre-merge-commit' |
10
- 'prepare-commit-msg' |
11
- 'commit-msg' |
12
- 'post-commit' |
13
- 'pre-rebase' |
14
- 'post-checkout' |
15
- 'post-merge' |
16
- 'pre-push' |
17
- 'pre-receive' |
18
- 'update' |
19
- 'proc-receive' |
20
- 'post-receive' |
21
- 'post-update' |
22
- 'reference-transaction' |
23
- 'push-to-checkout' |
24
- 'pre-auto-gc' |
25
- 'post-rewrite' |
26
- 'sendemail-validate' |
27
- 'fsmonitor-watchman' |
28
- 'p4-changelist' |
29
- 'p4-prepare-changelist' |
30
- 'p4-post-changelist' |
31
- 'p4-pre-submit' |
32
- 'post-index-change'
33
- >;
34
- export declare const VALID_OPTIONS: Array<'preserveUnused' | 'verbose' | 'staged-lint'>;
35
- export declare const PREPEND_SCRIPT: unknown;
1
+ import type { SetHooksFromConfigOptions } from './types';
2
+ /**
3
+ * Recursively gets the .git folder path from provided directory
4
+ */
36
5
  export declare function getGitProjectRoot(directory?: string): string | undefined;
6
+ /**
7
+ * Transforms the <project>/node_modules/bun-git-hooks to <project>
8
+ */
9
+ export declare function getProjectRootDirectoryFromNodeModules(projectPath: string): string | undefined;
10
+ /**
11
+ * Checks the 'bun-git-hooks' in dependencies of the project
12
+ */
37
13
  export declare function checkBunGitHooksInDependencies(projectRootPath: string): boolean;
38
- declare function _getPackageJson(projectPath?: any): void;
14
+ /**
15
+ * Checks if git hooks are already installed and up-to-date
16
+ */
17
+ export declare function areHooksInstalled(projectRootPath?: string): boolean;
18
+ /**
19
+ * Parses the config and sets git hooks
20
+ */
39
21
  export declare function setHooksFromConfig(projectRootPath?: string, options?: SetHooksFromConfigOptions): void;
40
- declare function getStagedFiles(projectRoot?: string): Promise<string[]>;
41
- declare function expandBracePattern(pattern: string): string[];
42
- declare const results: string[];
43
- declare function matchesGlob(file: string, pattern: string): boolean;
44
- declare function filterFilesByPattern(files: string[], pattern: string): string[];
45
- declare function runCommandOnStagedFiles(command: string | string[], files: string[], projectRoot?: string, verbose?: boolean): Promise<boolean>;
46
- declare function processStagedLint(stagedLintConfig: StagedLintConfig, projectRoot: string, verbose?: boolean): Promise<boolean>;
47
- declare function _setHook(hook: string, commandOrConfig: string | { stagedLint?: StagedLintConfig; 'staged-lint'?: StagedLintConfig }, projectRoot: string = process.cwd()): void;
48
- export declare function removeHooks(projectRoot?: string, verbose?: boolean): void;
49
- declare function _removeHook(hook: string, projectRoot?: any, verbose?: boolean): void;
50
- export declare function runStagedLint(hook: string): Promise<boolean>;
51
- declare function _validateHooks(config: Record<string, any>): boolean;
52
- declare function _validateStagedLintConfig(config: GitHooksConfig): void;
53
- declare const gitHooks: {
54
- PREPEND_SCRIPT: typeof PREPEND_SCRIPT
55
- setHooksFromConfig: typeof setHooksFromConfig
56
- removeHooks: typeof removeHooks
57
- checkBunGitHooksInDependencies: typeof checkBunGitHooksInDependencies
58
- getProjectRootDirectoryFromNodeModules: typeof getProjectRootDirectoryFromNodeModules
59
- getGitProjectRoot: typeof getGitProjectRoot
60
- runStagedLint: typeof runStagedLint
61
- getStagedFiles: typeof getStagedFiles
62
- };
22
+ /**
23
+ * Deletes all git hooks
24
+ */
25
+ export declare function removeHooks(projectRoot?: string, verbose?: any): void;
26
+ export declare const VALID_GIT_HOOKS: readonly ['applypatch-msg', 'pre-applypatch', 'post-applypatch', 'pre-commit', 'pre-merge-commit', 'prepare-commit-msg', 'commit-msg', 'post-commit', 'pre-rebase', 'post-checkout', 'post-merge', 'pre-push', 'pre-receive', 'update', 'proc-receive', 'post-receive', 'post-update', 'reference-transaction', 'push-to-checkout', 'pre-auto-gc', 'post-rewrite', 'sendemail-validate', 'fsmonitor-watchman', 'p4-changelist', 'p4-prepare-changelist', 'p4-post-changelist', 'p4-pre-submit', 'post-index-change'];
27
+ export declare const VALID_OPTIONS: readonly ['preserveUnused', 'verbose', 'staged-lint'];
28
+ export declare const PREPEND_SCRIPT: `#!/bin/sh
29
+
30
+ if [ "$SKIP_BUN_GIT_HOOKS" = "1" ]; then
31
+ echo "[INFO] SKIP_BUN_GIT_HOOKS is set to 1, skipping hook."
32
+ exit 0
33
+ fi
34
+
35
+ if [ -f "$BUN_GIT_HOOKS_RC" ]; then
36
+ . "$BUN_GIT_HOOKS_RC"
37
+ fi
63
38
 
39
+ `;
64
40
  export default gitHooks;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from './config'
2
- export * from './git-hooks'
3
- export * from './types'
1
+ export * from './config';
2
+ export * from './git-hooks';
3
+ export * from './staged-lint';
4
+ export * from './types';