bun-git-hooks 0.2.1 → 0.2.4
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} +8 -3
- package/dist/bin/config.d.ts +4 -0
- package/dist/bin/git-hooks.d.ts +50 -0
- package/dist/bin/index.d.ts +3 -0
- package/dist/bin/types.d.ts +43 -0
- package/dist/config.d.ts +1 -1
- package/dist/index.js +6 -1
- package/package.json +1 -1
|
@@ -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.4";
|
|
608
608
|
|
|
609
609
|
// src/git-hooks.ts
|
|
610
610
|
import fs from "fs";
|
|
@@ -884,6 +884,7 @@ function setHooksFromConfig(projectRootPath = process3.cwd(), options = {}) {
|
|
|
884
884
|
if (Object.prototype.hasOwnProperty.call(config, hook)) {
|
|
885
885
|
if (!config[hook])
|
|
886
886
|
throw new Error(`[ERROR] Command for ${hook} is not set`);
|
|
887
|
+
console.log(`Hook ${hook}: `, config[hook]);
|
|
887
888
|
_setHook(hook, config[hook], projectRootPath);
|
|
888
889
|
} else if (!preserveUnused.includes(hook))
|
|
889
890
|
_removeHook(hook, projectRootPath);
|
|
@@ -898,8 +899,12 @@ function _setHook(hook, command, projectRoot = process3.cwd()) {
|
|
|
898
899
|
const hookCommand = PREPEND_SCRIPT + command;
|
|
899
900
|
const hookDirectory = path.join(gitRoot, "hooks");
|
|
900
901
|
const hookPath = path.normalize(path.join(hookDirectory, hook));
|
|
901
|
-
|
|
902
|
+
console.log("hook", { hookPath, hookCommand, hookDirectory });
|
|
903
|
+
if (!fs.existsSync(hookDirectory)) {
|
|
904
|
+
console.log("hook folder not exists");
|
|
902
905
|
fs.mkdirSync(hookDirectory, { recursive: true });
|
|
906
|
+
}
|
|
907
|
+
console.log("Create/Write hook");
|
|
903
908
|
fs.writeFileSync(hookPath, hookCommand, { mode: 493 });
|
|
904
909
|
}
|
|
905
910
|
function removeHooks(projectRoot = process3.cwd(), verbose = false) {
|
|
@@ -922,7 +927,7 @@ if (["1", "true"].includes(SKIP_INSTALL_GIT_HOOKS || "")) {
|
|
|
922
927
|
console.log(`[INFO] SKIP_INSTALL_GIT_HOOKS is set to "${SKIP_INSTALL_GIT_HOOKS}", skipping installing hooks.`);
|
|
923
928
|
process4.exit(0);
|
|
924
929
|
}
|
|
925
|
-
cli.command("[configPath]", "Install git hooks, optionally from specified config file").option("--verbose", "Enable verbose logging").example("bun-git-hooks").example("bun-git-hooks
|
|
930
|
+
cli.command("[configPath]", "Install git hooks, optionally from specified config file").option("--verbose", "Enable verbose logging").example("bun-git-hooks").example("bun-git-hooks ../src/config.ts").example("bun-git-hooks --verbose").action(async (configPath, options) => {
|
|
926
931
|
try {
|
|
927
932
|
if (options?.verbose) {
|
|
928
933
|
console.log("[DEBUG] Config path:", configPath || "using default");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const VALID_GIT_HOOKS: Array<
|
|
2
|
+
'applypatch-msg' |
|
|
3
|
+
'pre-applypatch' |
|
|
4
|
+
'post-applypatch' |
|
|
5
|
+
'pre-commit' |
|
|
6
|
+
'pre-merge-commit' |
|
|
7
|
+
'prepare-commit-msg' |
|
|
8
|
+
'commit-msg' |
|
|
9
|
+
'post-commit' |
|
|
10
|
+
'pre-rebase' |
|
|
11
|
+
'post-checkout' |
|
|
12
|
+
'post-merge' |
|
|
13
|
+
'pre-push' |
|
|
14
|
+
'pre-receive' |
|
|
15
|
+
'update' |
|
|
16
|
+
'proc-receive' |
|
|
17
|
+
'post-receive' |
|
|
18
|
+
'post-update' |
|
|
19
|
+
'reference-transaction' |
|
|
20
|
+
'push-to-checkout' |
|
|
21
|
+
'pre-auto-gc' |
|
|
22
|
+
'post-rewrite' |
|
|
23
|
+
'sendemail-validate' |
|
|
24
|
+
'fsmonitor-watchman' |
|
|
25
|
+
'p4-changelist' |
|
|
26
|
+
'p4-prepare-changelist' |
|
|
27
|
+
'p4-post-changelist' |
|
|
28
|
+
'p4-pre-submit' |
|
|
29
|
+
'post-index-change'
|
|
30
|
+
>;
|
|
31
|
+
export declare const VALID_OPTIONS: Array<'preserveUnused'>;
|
|
32
|
+
export declare const PREPEND_SCRIPT: unknown;
|
|
33
|
+
export declare function getGitProjectRoot(directory: string): string | undefined;
|
|
34
|
+
export declare function checkBunGitHooksInDependencies(projectRootPath: string): boolean;
|
|
35
|
+
declare function _getPackageJson(projectPath): void;
|
|
36
|
+
export declare function setHooksFromConfig(projectRootPath: string, options?: { configFile?: , string }): void;
|
|
37
|
+
declare function _setHook(hook: string, command: string, projectRoot: string): void;
|
|
38
|
+
export declare function removeHooks(projectRoot: string, verbose): void;
|
|
39
|
+
declare function _removeHook(hook: string, projectRoot, verbose): void;
|
|
40
|
+
declare function _validateHooks(config: Record<string, string>): void;
|
|
41
|
+
declare const gitHooks: {
|
|
42
|
+
PREPEND_SCRIPT: typeof PREPEND_SCRIPT
|
|
43
|
+
setHooksFromConfig: typeof setHooksFromConfig
|
|
44
|
+
removeHooks: typeof removeHooks
|
|
45
|
+
checkBunGitHooksInDependencies: typeof checkBunGitHooksInDependencies
|
|
46
|
+
getProjectRootDirectoryFromNodeModules: typeof getProjectRootDirectoryFromNodeModules
|
|
47
|
+
getGitProjectRoot: typeof getGitProjectRoot
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default gitHooks;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
package/dist/config.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -655,6 +655,7 @@ function setHooksFromConfig(projectRootPath = j2.cwd(), options = {}) {
|
|
|
655
655
|
if (Object.prototype.hasOwnProperty.call(config, hook)) {
|
|
656
656
|
if (!config[hook])
|
|
657
657
|
throw new Error(`[ERROR] Command for ${hook} is not set`);
|
|
658
|
+
console.log(`Hook ${hook}: `, config[hook]);
|
|
658
659
|
_setHook(hook, config[hook], projectRootPath);
|
|
659
660
|
} else if (!preserveUnused.includes(hook))
|
|
660
661
|
_removeHook(hook, projectRootPath);
|
|
@@ -669,8 +670,12 @@ function _setHook(hook, command, projectRoot = j2.cwd()) {
|
|
|
669
670
|
const hookCommand = PREPEND_SCRIPT + command;
|
|
670
671
|
const hookDirectory = q.join(gitRoot, "hooks");
|
|
671
672
|
const hookPath = q.normalize(q.join(hookDirectory, hook));
|
|
672
|
-
|
|
673
|
+
console.log("hook", { hookPath, hookCommand, hookDirectory });
|
|
674
|
+
if (!fs.existsSync(hookDirectory)) {
|
|
675
|
+
console.log("hook folder not exists");
|
|
673
676
|
fs.mkdirSync(hookDirectory, { recursive: true });
|
|
677
|
+
}
|
|
678
|
+
console.log("Create/Write hook");
|
|
674
679
|
fs.writeFileSync(hookPath, hookCommand, { mode: 493 });
|
|
675
680
|
}
|
|
676
681
|
function removeHooks(projectRoot = j2.cwd(), verbose = false) {
|
package/package.json
CHANGED