bun-git-hooks 0.2.11 → 0.2.12
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/{cli.js → bin/cli.js} +10 -5
- package/dist/bin/config.d.ts +3 -0
- package/dist/bin/git-hooks.d.ts +52 -0
- package/dist/bin/index.d.ts +3 -0
- package/dist/bin/types.d.ts +47 -0
- package/package.json +4 -4
- package/bin/cli.ts +0 -62
- package/bin/git-hooks +0 -0
- package/bin/git-hooks-darwin-arm64 +0 -0
- package/bin/git-hooks-darwin-x64 +0 -0
- package/bin/git-hooks-linux-arm64 +0 -0
- package/bin/git-hooks-linux-x64 +0 -0
- package/bin/git-hooks-windows-x64.exe +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// bin/cli.ts
|
|
@@ -604,7 +604,7 @@ class CAC extends EventEmitter {
|
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
// package.json
|
|
607
|
-
var version = "0.2.
|
|
607
|
+
var version = "0.2.12";
|
|
608
608
|
|
|
609
609
|
// src/git-hooks.ts
|
|
610
610
|
import fs from "fs";
|
|
@@ -928,20 +928,25 @@ if (["1", "true"].includes(SKIP_INSTALL_GIT_HOOKS || "")) {
|
|
|
928
928
|
console.log(`[INFO] SKIP_INSTALL_GIT_HOOKS is set to "${SKIP_INSTALL_GIT_HOOKS}", skipping installing hooks.`);
|
|
929
929
|
process5.exit(0);
|
|
930
930
|
}
|
|
931
|
-
cli.command("[configPath]", "Install git hooks, optionally from specified config file").option("--verbose", "Enable verbose logging").example("
|
|
931
|
+
cli.command("[configPath]", "Install git hooks, optionally from specified config file").option("--verbose", "Enable verbose logging").example("git-hooks").example("git-hooks ../src/config.ts").example("git-hooks --verbose").action(async (configPath, options) => {
|
|
932
932
|
try {
|
|
933
933
|
if (options?.verbose) {
|
|
934
934
|
console.log("[DEBUG] Config path:", configPath || "using default");
|
|
935
935
|
console.log("[DEBUG] Working directory:", process5.cwd());
|
|
936
936
|
}
|
|
937
|
-
|
|
937
|
+
if (configPath) {
|
|
938
|
+
const config3 = await import(configPath);
|
|
939
|
+
setHooksFromConfig(process5.cwd(), { configFile: config3 });
|
|
940
|
+
} else {
|
|
941
|
+
setHooksFromConfig(process5.cwd());
|
|
942
|
+
}
|
|
938
943
|
console.log("[INFO] Successfully set all git hooks");
|
|
939
944
|
} catch (err) {
|
|
940
945
|
console.error("[ERROR] Was not able to set git hooks. Error:", err);
|
|
941
946
|
process5.exit(1);
|
|
942
947
|
}
|
|
943
948
|
});
|
|
944
|
-
cli.command("uninstall", "Remove all git hooks").alias("remove").option("--verbose", "Enable verbose logging").example("
|
|
949
|
+
cli.command("uninstall", "Remove all git hooks").alias("remove").option("--verbose", "Enable verbose logging").example("git-hooks uninstall").example("git-hooks remove").example("git-hooks uninstall --verbose").action(async (options) => {
|
|
945
950
|
try {
|
|
946
951
|
if (options?.verbose) {
|
|
947
952
|
console.log("[DEBUG] Removing hooks from:", process5.cwd());
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SetHooksFromConfigOptions } from './types';
|
|
2
|
+
|
|
3
|
+
export declare const VALID_GIT_HOOKS: Array<
|
|
4
|
+
'applypatch-msg' |
|
|
5
|
+
'pre-applypatch' |
|
|
6
|
+
'post-applypatch' |
|
|
7
|
+
'pre-commit' |
|
|
8
|
+
'pre-merge-commit' |
|
|
9
|
+
'prepare-commit-msg' |
|
|
10
|
+
'commit-msg' |
|
|
11
|
+
'post-commit' |
|
|
12
|
+
'pre-rebase' |
|
|
13
|
+
'post-checkout' |
|
|
14
|
+
'post-merge' |
|
|
15
|
+
'pre-push' |
|
|
16
|
+
'pre-receive' |
|
|
17
|
+
'update' |
|
|
18
|
+
'proc-receive' |
|
|
19
|
+
'post-receive' |
|
|
20
|
+
'post-update' |
|
|
21
|
+
'reference-transaction' |
|
|
22
|
+
'push-to-checkout' |
|
|
23
|
+
'pre-auto-gc' |
|
|
24
|
+
'post-rewrite' |
|
|
25
|
+
'sendemail-validate' |
|
|
26
|
+
'fsmonitor-watchman' |
|
|
27
|
+
'p4-changelist' |
|
|
28
|
+
'p4-prepare-changelist' |
|
|
29
|
+
'p4-post-changelist' |
|
|
30
|
+
'p4-pre-submit' |
|
|
31
|
+
'post-index-change'
|
|
32
|
+
>;
|
|
33
|
+
export declare const VALID_OPTIONS: Array<'preserveUnused'>;
|
|
34
|
+
export declare const PREPEND_SCRIPT: unknown;
|
|
35
|
+
export declare function getGitProjectRoot(directory: string): string | undefined;
|
|
36
|
+
export declare function checkBunGitHooksInDependencies(projectRootPath: string): boolean;
|
|
37
|
+
declare function _getPackageJson(projectPath): void;
|
|
38
|
+
export declare function setHooksFromConfig(projectRootPath: string, options?: SetHooksFromConfigOptions): void;
|
|
39
|
+
declare function _setHook(hook: string, command: string, projectRoot: string): void;
|
|
40
|
+
export declare function removeHooks(projectRoot: string, verbose): void;
|
|
41
|
+
declare function _removeHook(hook: string, projectRoot, verbose): void;
|
|
42
|
+
declare function _validateHooks(config: Record<string, string>): void;
|
|
43
|
+
declare const gitHooks: {
|
|
44
|
+
PREPEND_SCRIPT: typeof PREPEND_SCRIPT
|
|
45
|
+
setHooksFromConfig: typeof setHooksFromConfig
|
|
46
|
+
removeHooks: typeof removeHooks
|
|
47
|
+
checkBunGitHooksInDependencies: typeof checkBunGitHooksInDependencies
|
|
48
|
+
getProjectRootDirectoryFromNodeModules: typeof getProjectRootDirectoryFromNodeModules
|
|
49
|
+
getGitProjectRoot: typeof getGitProjectRoot
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default gitHooks;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Buffer } from 'node:buffer';
|
|
2
|
+
|
|
3
|
+
export declare interface RawImageData<T> {
|
|
4
|
+
width: number
|
|
5
|
+
height: number
|
|
6
|
+
data: T
|
|
7
|
+
}
|
|
8
|
+
export declare interface BufferRet {
|
|
9
|
+
data: Buffer | Uint8ClampedArray
|
|
10
|
+
width: number
|
|
11
|
+
height: number
|
|
12
|
+
exifBuffer?: ArrayBuffer
|
|
13
|
+
comments?: string[]
|
|
14
|
+
}
|
|
15
|
+
export declare type UintArrRet = ImageData & {
|
|
16
|
+
exifBuffer?: ArrayBuffer
|
|
17
|
+
comments?: string[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ImageData {
|
|
21
|
+
width: number
|
|
22
|
+
height: number
|
|
23
|
+
data: Uint8ClampedArray | Buffer
|
|
24
|
+
colorSpace?: 'srgb'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type BufferLike = Buffer | Uint8Array | ArrayLike<number> | Iterable<number> | ArrayBuffer
|
|
28
|
+
|
|
29
|
+
export interface DecoderOptions {
|
|
30
|
+
useTArray: boolean
|
|
31
|
+
colorTransform?: boolean
|
|
32
|
+
formatAsRGBA?: boolean
|
|
33
|
+
tolerantDecoding?: boolean
|
|
34
|
+
maxResolutionInMP?: number
|
|
35
|
+
maxMemoryUsageInMB?: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type GitHooksConfig = {
|
|
39
|
+
[K in typeof VALID_GIT_HOOKS[number]]?: string
|
|
40
|
+
} & {
|
|
41
|
+
preserveUnused?: boolean | typeof VALID_GIT_HOOKS[number][]
|
|
42
|
+
verbose?: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SetHooksFromConfigOptions {
|
|
46
|
+
configFile?: GitHooksConfig
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-git-hooks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.12",
|
|
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",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"module": "./dist/index.js",
|
|
39
39
|
"types": "./dist/index.d.ts",
|
|
40
40
|
"bin": {
|
|
41
|
-
"git-hooks": "./bin/
|
|
42
|
-
"bun-git-hooks": "./bin/
|
|
41
|
+
"git-hooks": "./dist/bin/cli.js",
|
|
42
|
+
"bun-git-hooks": "./dist/bin/cli.js"
|
|
43
43
|
},
|
|
44
|
-
"files": ["README.md", "
|
|
44
|
+
"files": ["README.md", "dist"],
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "bun build.ts && bun run compile",
|
|
47
47
|
"compile": "bun build ./bin/cli.ts --compile --minify --outfile bin/git-hooks",
|
package/bin/cli.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { CAC } from 'cac'
|
|
4
|
-
import { version } from '../package.json'
|
|
5
|
-
import { removeHooks, setHooksFromConfig } from '../src/git-hooks'
|
|
6
|
-
|
|
7
|
-
const cli = new CAC('git-hooks')
|
|
8
|
-
|
|
9
|
-
// Check if installation should be skipped
|
|
10
|
-
const { SKIP_INSTALL_GIT_HOOKS } = process.env
|
|
11
|
-
if (['1', 'true'].includes(SKIP_INSTALL_GIT_HOOKS || '')) {
|
|
12
|
-
console.log(`[INFO] SKIP_INSTALL_GIT_HOOKS is set to "${SKIP_INSTALL_GIT_HOOKS}", skipping installing hooks.`)
|
|
13
|
-
process.exit(0)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
cli
|
|
17
|
-
.command('[configPath]', 'Install git hooks, optionally from specified config file')
|
|
18
|
-
.option('--verbose', 'Enable verbose logging')
|
|
19
|
-
.example('bun-git-hooks')
|
|
20
|
-
.example('bun-git-hooks ../src/config.ts')
|
|
21
|
-
.example('bun-git-hooks --verbose')
|
|
22
|
-
.action(async (configPath?: string, options?: { verbose?: boolean }) => {
|
|
23
|
-
try {
|
|
24
|
-
if (options?.verbose) {
|
|
25
|
-
console.log('[DEBUG] Config path:', configPath || 'using default')
|
|
26
|
-
console.log('[DEBUG] Working directory:', process.cwd())
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setHooksFromConfig(process.cwd(), { configFile: configPath })
|
|
30
|
-
console.log('[INFO] Successfully set all git hooks')
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
console.error('[ERROR] Was not able to set git hooks. Error:', err)
|
|
34
|
-
process.exit(1)
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
cli
|
|
39
|
-
.command('uninstall', 'Remove all git hooks')
|
|
40
|
-
.alias('remove') // Add alias for uninstall
|
|
41
|
-
.option('--verbose', 'Enable verbose logging')
|
|
42
|
-
.example('bun-git-hooks uninstall')
|
|
43
|
-
.example('bunx bun-git-hooks remove')
|
|
44
|
-
.example('bunx git-hooks uninstall --verbose')
|
|
45
|
-
.action(async (options?: { verbose?: boolean }) => {
|
|
46
|
-
try {
|
|
47
|
-
if (options?.verbose) {
|
|
48
|
-
console.log('[DEBUG] Removing hooks from:', process.cwd())
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
removeHooks(process.cwd(), options?.verbose)
|
|
52
|
-
console.log('[INFO] Successfully removed all git hooks')
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
console.error('[ERROR] Was not able to remove git hooks. Error:', err)
|
|
56
|
-
process.exit(1)
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
cli.version(version)
|
|
61
|
-
cli.help()
|
|
62
|
-
cli.parse()
|
package/bin/git-hooks
DELETED
|
Binary file
|
|
Binary file
|
package/bin/git-hooks-darwin-x64
DELETED
|
Binary file
|
|
Binary file
|
package/bin/git-hooks-linux-x64
DELETED
|
Binary file
|
|
Binary file
|