bun-git-hooks 0.2.9 → 0.2.11

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/bin/cli.ts ADDED
@@ -0,0 +1,62 @@
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 ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/cli.js CHANGED
@@ -604,7 +604,7 @@ class CAC extends EventEmitter {
604
604
  }
605
605
  }
606
606
  // package.json
607
- var version = "0.2.9";
607
+ var version = "0.2.11";
608
608
 
609
609
  // src/git-hooks.ts
610
610
  import fs from "fs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-git-hooks",
3
3
  "type": "module",
4
- "version": "0.2.9",
4
+ "version": "0.2.11",
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": "./dist/cli.js",
42
- "bun-git-hooks": "./dist/cli.js"
41
+ "git-hooks": "./bin/git-hooks",
42
+ "bun-git-hooks": "./bin/git-hooks"
43
43
  },
44
- "files": ["README.md", "dist"],
44
+ "files": ["README.md", "bin", "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",