bun-git-hooks 0.2.7 → 0.2.8
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 → cli.js} +1 -13
- package/dist/index.js +0 -11
- package/package.json +7 -7
- package/dist/bin/config.d.ts +0 -4
- package/dist/bin/git-hooks.d.ts +0 -50
- package/dist/bin/index.d.ts +0 -3
- package/dist/bin/types.d.ts +0 -43
|
@@ -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.8";
|
|
608
608
|
|
|
609
609
|
// src/git-hooks.ts
|
|
610
610
|
import fs from "fs";
|
|
@@ -796,7 +796,6 @@ var config = await loadConfig({
|
|
|
796
796
|
cwd: process3.cwd(),
|
|
797
797
|
defaultConfig
|
|
798
798
|
});
|
|
799
|
-
console.log("config", process3.cwd());
|
|
800
799
|
|
|
801
800
|
// src/git-hooks.ts
|
|
802
801
|
var VALID_GIT_HOOKS = [
|
|
@@ -875,24 +874,17 @@ function getGitProjectRoot(directory = process4.cwd()) {
|
|
|
875
874
|
function setHooksFromConfig(projectRootPath = process4.cwd(), options = {}) {
|
|
876
875
|
if (!config || Object.keys(config).length === 0)
|
|
877
876
|
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");
|
|
878
|
-
console.log("setHooksFromConfig config", config);
|
|
879
877
|
const hookKeys = Object.keys(config).filter((key) => key !== "preserveUnused" && key !== "verbose");
|
|
880
|
-
console.log("hookKeys", hookKeys);
|
|
881
878
|
const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
|
|
882
|
-
console.log("isValidConfig", isValidConfig);
|
|
883
879
|
if (!isValidConfig)
|
|
884
880
|
throw new Error("[ERROR] Config was not in correct format. Please check git hooks or options name");
|
|
885
881
|
const preserveUnused = Array.isArray(config.preserveUnused) ? config.preserveUnused : config.preserveUnused ? VALID_GIT_HOOKS : [];
|
|
886
882
|
for (const hook of VALID_GIT_HOOKS) {
|
|
887
|
-
console.log("hook", hook);
|
|
888
883
|
if (Object.prototype.hasOwnProperty.call(config, hook)) {
|
|
889
|
-
console.log("hook in config");
|
|
890
884
|
if (!config[hook])
|
|
891
885
|
throw new Error(`[ERROR] Command for ${hook} is not set`);
|
|
892
|
-
console.log(`Hook ${hook}: `, config[hook]);
|
|
893
886
|
_setHook(hook, config[hook], projectRootPath);
|
|
894
887
|
} else if (!preserveUnused.includes(hook)) {
|
|
895
|
-
console.log("Remove hook", hook);
|
|
896
888
|
_removeHook(hook, projectRootPath);
|
|
897
889
|
}
|
|
898
890
|
}
|
|
@@ -906,12 +898,9 @@ function _setHook(hook, command, projectRoot = process4.cwd()) {
|
|
|
906
898
|
const hookCommand = PREPEND_SCRIPT + command;
|
|
907
899
|
const hookDirectory = path.join(gitRoot, "hooks");
|
|
908
900
|
const hookPath = path.normalize(path.join(hookDirectory, hook));
|
|
909
|
-
console.log("hook", { hookPath, hookCommand, hookDirectory });
|
|
910
901
|
if (!fs.existsSync(hookDirectory)) {
|
|
911
|
-
console.log("hook folder not exists");
|
|
912
902
|
fs.mkdirSync(hookDirectory, { recursive: true });
|
|
913
903
|
}
|
|
914
|
-
console.log("Create/Write hook");
|
|
915
904
|
fs.writeFileSync(hookPath, hookCommand, { mode: 493 });
|
|
916
905
|
}
|
|
917
906
|
function removeHooks(projectRoot = process4.cwd(), verbose = false) {
|
|
@@ -940,7 +929,6 @@ cli.command("[configPath]", "Install git hooks, optionally from specified config
|
|
|
940
929
|
console.log("[DEBUG] Config path:", configPath || "using default");
|
|
941
930
|
console.log("[DEBUG] Working directory:", process5.cwd());
|
|
942
931
|
}
|
|
943
|
-
console.log("setHooksFromConfig", { configFile: configPath });
|
|
944
932
|
setHooksFromConfig(process5.cwd(), { configFile: configPath });
|
|
945
933
|
console.log("[INFO] Successfully set all git hooks");
|
|
946
934
|
} catch (err) {
|
package/dist/index.js
CHANGED
|
@@ -528,7 +528,6 @@ var config = await loadConfig({
|
|
|
528
528
|
cwd: j.cwd(),
|
|
529
529
|
defaultConfig
|
|
530
530
|
});
|
|
531
|
-
console.log("config", j.cwd());
|
|
532
531
|
// src/git-hooks.ts
|
|
533
532
|
var { default: fs} = (() => ({}));
|
|
534
533
|
init_process();
|
|
@@ -651,24 +650,17 @@ function _getPackageJson(projectPath = j.cwd()) {
|
|
|
651
650
|
function setHooksFromConfig(projectRootPath = j.cwd(), options = {}) {
|
|
652
651
|
if (!config || Object.keys(config).length === 0)
|
|
653
652
|
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");
|
|
654
|
-
console.log("setHooksFromConfig config", config);
|
|
655
653
|
const hookKeys = Object.keys(config).filter((key) => key !== "preserveUnused" && key !== "verbose");
|
|
656
|
-
console.log("hookKeys", hookKeys);
|
|
657
654
|
const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
|
|
658
|
-
console.log("isValidConfig", isValidConfig);
|
|
659
655
|
if (!isValidConfig)
|
|
660
656
|
throw new Error("[ERROR] Config was not in correct format. Please check git hooks or options name");
|
|
661
657
|
const preserveUnused = Array.isArray(config.preserveUnused) ? config.preserveUnused : config.preserveUnused ? VALID_GIT_HOOKS : [];
|
|
662
658
|
for (const hook of VALID_GIT_HOOKS) {
|
|
663
|
-
console.log("hook", hook);
|
|
664
659
|
if (Object.prototype.hasOwnProperty.call(config, hook)) {
|
|
665
|
-
console.log("hook in config");
|
|
666
660
|
if (!config[hook])
|
|
667
661
|
throw new Error(`[ERROR] Command for ${hook} is not set`);
|
|
668
|
-
console.log(`Hook ${hook}: `, config[hook]);
|
|
669
662
|
_setHook(hook, config[hook], projectRootPath);
|
|
670
663
|
} else if (!preserveUnused.includes(hook)) {
|
|
671
|
-
console.log("Remove hook", hook);
|
|
672
664
|
_removeHook(hook, projectRootPath);
|
|
673
665
|
}
|
|
674
666
|
}
|
|
@@ -682,12 +674,9 @@ function _setHook(hook, command, projectRoot = j.cwd()) {
|
|
|
682
674
|
const hookCommand = PREPEND_SCRIPT + command;
|
|
683
675
|
const hookDirectory = q2.join(gitRoot, "hooks");
|
|
684
676
|
const hookPath = q2.normalize(q2.join(hookDirectory, hook));
|
|
685
|
-
console.log("hook", { hookPath, hookCommand, hookDirectory });
|
|
686
677
|
if (!fs.existsSync(hookDirectory)) {
|
|
687
|
-
console.log("hook folder not exists");
|
|
688
678
|
fs.mkdirSync(hookDirectory, { recursive: true });
|
|
689
679
|
}
|
|
690
|
-
console.log("Create/Write hook");
|
|
691
680
|
fs.writeFileSync(hookPath, hookCommand, { mode: 493 });
|
|
692
681
|
}
|
|
693
682
|
function removeHooks(projectRoot = j.cwd(), verbose = false) {
|
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.8",
|
|
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,8 +38,8 @@
|
|
|
38
38
|
"module": "./dist/index.js",
|
|
39
39
|
"types": "./dist/index.d.ts",
|
|
40
40
|
"bin": {
|
|
41
|
-
"git-hooks": "./dist/
|
|
42
|
-
"bun-git-hooks": "./dist/
|
|
41
|
+
"git-hooks": "./dist/cli.js",
|
|
42
|
+
"bun-git-hooks": "./dist/cli.js"
|
|
43
43
|
},
|
|
44
44
|
"files": ["README.md", "dist"],
|
|
45
45
|
"scripts": {
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@iconify-json/carbon": "^1.2.8",
|
|
77
|
-
"@shikijs/vitepress-twoslash": "^3.2.
|
|
77
|
+
"@shikijs/vitepress-twoslash": "^3.2.2",
|
|
78
78
|
"@stacksjs/eslint-config": "^4.10.2-beta.3",
|
|
79
|
-
"@types/bun": "^1.2.
|
|
80
|
-
"@types/node": "^22.
|
|
79
|
+
"@types/bun": "^1.2.9",
|
|
80
|
+
"@types/node": "^22.14.0",
|
|
81
81
|
"@vite-pwa/vitepress": "^1.0.0",
|
|
82
82
|
"bumpp": "^10.1.0",
|
|
83
83
|
"bun-plugin-dtsx": "^0.21.9",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"cac": "^6.7.14",
|
|
86
86
|
"changelogen": "^0.6.1",
|
|
87
87
|
"lint-staged": "^15.5.0",
|
|
88
|
-
"typescript": "^5.8.
|
|
88
|
+
"typescript": "^5.8.3",
|
|
89
89
|
"unocss": "^66.0.0",
|
|
90
90
|
"unplugin-icons": "^22.1.0",
|
|
91
91
|
"unplugin-vue-components": "^28.4.1",
|
package/dist/bin/config.d.ts
DELETED
package/dist/bin/git-hooks.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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;
|
package/dist/bin/index.d.ts
DELETED
package/dist/bin/types.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}
|