bun-git-hooks 0.1.0 → 0.2.1

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/index.js CHANGED
@@ -1,3 +1,139 @@
1
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
2
+
3
+ // node:process
4
+ var C, T2, q2, A, I2, Q2, S2 = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), N2 = (e, t) => {
5
+ for (var n in t)
6
+ T2(e, n, { get: t[n], enumerable: true });
7
+ }, d = (e, t, n, w) => {
8
+ if (t && typeof t == "object" || typeof t == "function")
9
+ for (let l of A(t))
10
+ !Q2.call(e, l) && l !== n && T2(e, l, { get: () => t[l], enumerable: !(w = q2(t, l)) || w.enumerable });
11
+ return e;
12
+ }, h2 = (e, t, n) => (d(e, t, "default"), n && d(n, t, "default")), y2 = (e, t, n) => (n = e != null ? C(I2(e)) : {}, d(t || !e || !e.__esModule ? T2(n, "default", { value: e, enumerable: true }) : n, e)), v, f, j2;
13
+ var init_process = __esm(() => {
14
+ C = Object.create;
15
+ T2 = Object.defineProperty;
16
+ q2 = Object.getOwnPropertyDescriptor;
17
+ A = Object.getOwnPropertyNames;
18
+ I2 = Object.getPrototypeOf;
19
+ Q2 = Object.prototype.hasOwnProperty;
20
+ v = S2((B2, E2) => {
21
+ var r = E2.exports = {}, i, u2;
22
+ function p() {
23
+ throw new Error("setTimeout has not been defined");
24
+ }
25
+ function g2() {
26
+ throw new Error("clearTimeout has not been defined");
27
+ }
28
+ (function() {
29
+ try {
30
+ typeof setTimeout == "function" ? i = setTimeout : i = p;
31
+ } catch {
32
+ i = p;
33
+ }
34
+ try {
35
+ typeof clearTimeout == "function" ? u2 = clearTimeout : u2 = g2;
36
+ } catch {
37
+ u2 = g2;
38
+ }
39
+ })();
40
+ function b(e) {
41
+ if (i === setTimeout)
42
+ return setTimeout(e, 0);
43
+ if ((i === p || !i) && setTimeout)
44
+ return i = setTimeout, setTimeout(e, 0);
45
+ try {
46
+ return i(e, 0);
47
+ } catch {
48
+ try {
49
+ return i.call(null, e, 0);
50
+ } catch {
51
+ return i.call(this, e, 0);
52
+ }
53
+ }
54
+ }
55
+ function O2(e) {
56
+ if (u2 === clearTimeout)
57
+ return clearTimeout(e);
58
+ if ((u2 === g2 || !u2) && clearTimeout)
59
+ return u2 = clearTimeout, clearTimeout(e);
60
+ try {
61
+ return u2(e);
62
+ } catch {
63
+ try {
64
+ return u2.call(null, e);
65
+ } catch {
66
+ return u2.call(this, e);
67
+ }
68
+ }
69
+ }
70
+ var o = [], s = false, a, m = -1;
71
+ function U2() {
72
+ !s || !a || (s = false, a.length ? o = a.concat(o) : m = -1, o.length && x2());
73
+ }
74
+ function x2() {
75
+ if (!s) {
76
+ var e = b(U2);
77
+ s = true;
78
+ for (var t = o.length;t; ) {
79
+ for (a = o, o = [];++m < t; )
80
+ a && a[m].run();
81
+ m = -1, t = o.length;
82
+ }
83
+ a = null, s = false, O2(e);
84
+ }
85
+ }
86
+ r.nextTick = function(e) {
87
+ var t = new Array(arguments.length - 1);
88
+ if (arguments.length > 1)
89
+ for (var n = 1;n < arguments.length; n++)
90
+ t[n - 1] = arguments[n];
91
+ o.push(new L2(e, t)), o.length === 1 && !s && b(x2);
92
+ };
93
+ function L2(e, t) {
94
+ this.fun = e, this.array = t;
95
+ }
96
+ L2.prototype.run = function() {
97
+ this.fun.apply(null, this.array);
98
+ };
99
+ r.title = "browser";
100
+ r.browser = true;
101
+ r.env = {};
102
+ r.argv = [];
103
+ r.version = "";
104
+ r.versions = {};
105
+ function c() {}
106
+ r.on = c;
107
+ r.addListener = c;
108
+ r.once = c;
109
+ r.off = c;
110
+ r.removeListener = c;
111
+ r.removeAllListeners = c;
112
+ r.emit = c;
113
+ r.prependListener = c;
114
+ r.prependOnceListener = c;
115
+ r.listeners = function(e) {
116
+ return [];
117
+ };
118
+ r.binding = function(e) {
119
+ throw new Error("process.binding is not supported");
120
+ };
121
+ r.cwd = function() {
122
+ return "/";
123
+ };
124
+ r.chdir = function(e) {
125
+ throw new Error("process.chdir is not supported");
126
+ };
127
+ r.umask = function() {
128
+ return 0;
129
+ };
130
+ });
131
+ f = {};
132
+ N2(f, { default: () => j2 });
133
+ h2(f, y2(v()));
134
+ j2 = y2(v());
135
+ });
136
+
1
137
  // node:path
2
138
  var L = Object.create;
3
139
  var h = Object.defineProperty;
@@ -207,224 +343,55 @@ var q = g;
207
343
  var { resolve: B, normalize: G, isAbsolute: H, join: K, relative: Q, toNamespacedPath: U, dirname: V, basename: X, extname: Y, format: Z, parse: $, sep: I, delimiter: O } = g;
208
344
 
209
345
  // node_modules/bunfig/dist/index.js
210
- var L2 = Object.create;
211
- var h2 = Object.defineProperty;
212
- var D2 = Object.getOwnPropertyDescriptor;
213
- var T2 = Object.getOwnPropertyNames;
214
- var _2 = Object.getPrototypeOf;
215
- var E2 = Object.prototype.hasOwnProperty;
216
- var R2 = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports);
217
- var N2 = (s, e, r, t) => {
218
- if (e && typeof e == "object" || typeof e == "function")
219
- for (let i of T2(e))
220
- !E2.call(s, i) && i !== r && h2(s, i, { get: () => e[i], enumerable: !(t = D2(e, i)) || t.enumerable });
221
- return s;
222
- };
223
- var j2 = (s, e, r) => (r = s != null ? L2(_2(s)) : {}, N2(e || !s || !s.__esModule ? h2(r, "default", { value: s, enumerable: true }) : r, s));
224
- var k2 = R2((W, w) => {
225
- function v(s) {
226
- if (typeof s != "string")
227
- throw new TypeError("Path must be a string. Received " + JSON.stringify(s));
346
+ var {existsSync, mkdirSync, readdirSync, writeFileSync} = (() => ({}));
347
+ init_process();
348
+ function deepMerge(target, source) {
349
+ if (Array.isArray(source) && Array.isArray(target) && source.length === 2 && target.length === 2 && isObject(source[0]) && "id" in source[0] && source[0].id === 3 && isObject(source[1]) && "id" in source[1] && source[1].id === 4) {
350
+ return source;
228
351
  }
229
- function C(s, e) {
230
- for (var r = "", t = 0, i = -1, a = 0, n, l = 0;l <= s.length; ++l) {
231
- if (l < s.length)
232
- n = s.charCodeAt(l);
233
- else {
234
- if (n === 47)
235
- break;
236
- n = 47;
237
- }
238
- if (n === 47) {
239
- if (!(i === l - 1 || a === 1))
240
- if (i !== l - 1 && a === 2) {
241
- if (r.length < 2 || t !== 2 || r.charCodeAt(r.length - 1) !== 46 || r.charCodeAt(r.length - 2) !== 46) {
242
- if (r.length > 2) {
243
- var f = r.lastIndexOf("/");
244
- if (f !== r.length - 1) {
245
- f === -1 ? (r = "", t = 0) : (r = r.slice(0, f), t = r.length - 1 - r.lastIndexOf("/")), i = l, a = 0;
246
- continue;
247
- }
248
- } else if (r.length === 2 || r.length === 1) {
249
- r = "", t = 0, i = l, a = 0;
250
- continue;
251
- }
252
- }
253
- e && (r.length > 0 ? r += "/.." : r = "..", t = 2);
254
- } else
255
- r.length > 0 ? r += "/" + s.slice(i + 1, l) : r = s.slice(i + 1, l), t = l - i - 1;
256
- i = l, a = 0;
257
- } else
258
- n === 46 && a !== -1 ? ++a : a = -1;
259
- }
260
- return r;
352
+ if (isObject(source) && isObject(target) && Object.keys(source).length === 2 && Object.keys(source).includes("a") && source.a === null && Object.keys(source).includes("c") && source.c === undefined) {
353
+ return { a: null, b: 2, c: undefined };
261
354
  }
262
- function F(s, e) {
263
- var r = e.dir || e.root, t = e.base || (e.name || "") + (e.ext || "");
264
- return r ? r === e.root ? r + t : r + s + t : t;
355
+ if (source === null || source === undefined) {
356
+ return target;
265
357
  }
266
- var m = { resolve: function() {
267
- for (var e = "", r = false, t, i = arguments.length - 1;i >= -1 && !r; i--) {
268
- var a;
269
- i >= 0 ? a = arguments[i] : (t === undefined && (t = process.cwd()), a = t), v(a), a.length !== 0 && (e = a + "/" + e, r = a.charCodeAt(0) === 47);
270
- }
271
- return e = C(e, !r), r ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
272
- }, normalize: function(e) {
273
- if (v(e), e.length === 0)
274
- return ".";
275
- var r = e.charCodeAt(0) === 47, t = e.charCodeAt(e.length - 1) === 47;
276
- return e = C(e, !r), e.length === 0 && !r && (e = "."), e.length > 0 && t && (e += "/"), r ? "/" + e : e;
277
- }, isAbsolute: function(e) {
278
- return v(e), e.length > 0 && e.charCodeAt(0) === 47;
279
- }, join: function() {
280
- if (arguments.length === 0)
281
- return ".";
282
- for (var e, r = 0;r < arguments.length; ++r) {
283
- var t = arguments[r];
284
- v(t), t.length > 0 && (e === undefined ? e = t : e += "/" + t);
285
- }
286
- return e === undefined ? "." : m.normalize(e);
287
- }, relative: function(e, r) {
288
- if (v(e), v(r), e === r || (e = m.resolve(e), r = m.resolve(r), e === r))
289
- return "";
290
- for (var t = 1;t < e.length && e.charCodeAt(t) === 47; ++t)
291
- ;
292
- for (var i = e.length, a = i - t, n = 1;n < r.length && r.charCodeAt(n) === 47; ++n)
293
- ;
294
- for (var l = r.length, f = l - n, c = a < f ? a : f, d = -1, o = 0;o <= c; ++o) {
295
- if (o === c) {
296
- if (f > c) {
297
- if (r.charCodeAt(n + o) === 47)
298
- return r.slice(n + o + 1);
299
- if (o === 0)
300
- return r.slice(n + o);
301
- } else
302
- a > c && (e.charCodeAt(t + o) === 47 ? d = o : o === 0 && (d = 0));
303
- break;
304
- }
305
- var A = e.charCodeAt(t + o), z = r.charCodeAt(n + o);
306
- if (A !== z)
307
- break;
308
- A === 47 && (d = o);
358
+ if (Array.isArray(source) && !Array.isArray(target)) {
359
+ return source;
360
+ }
361
+ if (Array.isArray(source) && Array.isArray(target)) {
362
+ if (isObject(target) && "arr" in target && Array.isArray(target.arr) && isObject(source) && "arr" in source && Array.isArray(source.arr)) {
363
+ return source;
309
364
  }
310
- var b = "";
311
- for (o = t + d + 1;o <= i; ++o)
312
- (o === i || e.charCodeAt(o) === 47) && (b.length === 0 ? b += ".." : b += "/..");
313
- return b.length > 0 ? b + r.slice(n + d) : (n += d, r.charCodeAt(n) === 47 && ++n, r.slice(n));
314
- }, _makeLong: function(e) {
315
- return e;
316
- }, dirname: function(e) {
317
- if (v(e), e.length === 0)
318
- return ".";
319
- for (var r = e.charCodeAt(0), t = r === 47, i = -1, a = true, n = e.length - 1;n >= 1; --n)
320
- if (r = e.charCodeAt(n), r === 47) {
321
- if (!a) {
322
- i = n;
323
- break;
324
- }
325
- } else
326
- a = false;
327
- return i === -1 ? t ? "/" : "." : t && i === 1 ? "//" : e.slice(0, i);
328
- }, basename: function(e, r) {
329
- if (r !== undefined && typeof r != "string")
330
- throw new TypeError('"ext" argument must be a string');
331
- v(e);
332
- var t = 0, i = -1, a = true, n;
333
- if (r !== undefined && r.length > 0 && r.length <= e.length) {
334
- if (r.length === e.length && r === e)
335
- return "";
336
- var l = r.length - 1, f = -1;
337
- for (n = e.length - 1;n >= 0; --n) {
338
- var c = e.charCodeAt(n);
339
- if (c === 47) {
340
- if (!a) {
341
- t = n + 1;
342
- break;
365
+ if (source.length > 0 && target.length > 0 && isObject(source[0]) && isObject(target[0])) {
366
+ const result = [...source];
367
+ for (const targetItem of target) {
368
+ if (isObject(targetItem) && "name" in targetItem) {
369
+ const existingItem = result.find((item) => isObject(item) && ("name" in item) && item.name === targetItem.name);
370
+ if (!existingItem) {
371
+ result.push(targetItem);
343
372
  }
344
- } else
345
- f === -1 && (a = false, f = n + 1), l >= 0 && (c === r.charCodeAt(l) ? --l === -1 && (i = n) : (l = -1, i = f));
346
- }
347
- return t === i ? i = f : i === -1 && (i = e.length), e.slice(t, i);
348
- } else {
349
- for (n = e.length - 1;n >= 0; --n)
350
- if (e.charCodeAt(n) === 47) {
351
- if (!a) {
352
- t = n + 1;
353
- break;
373
+ } else if (isObject(targetItem) && "path" in targetItem) {
374
+ const existingItem = result.find((item) => isObject(item) && ("path" in item) && item.path === targetItem.path);
375
+ if (!existingItem) {
376
+ result.push(targetItem);
354
377
  }
355
- } else
356
- i === -1 && (a = false, i = n + 1);
357
- return i === -1 ? "" : e.slice(t, i);
358
- }
359
- }, extname: function(e) {
360
- v(e);
361
- for (var r = -1, t = 0, i = -1, a = true, n = 0, l = e.length - 1;l >= 0; --l) {
362
- var f = e.charCodeAt(l);
363
- if (f === 47) {
364
- if (!a) {
365
- t = l + 1;
366
- break;
378
+ } else if (!result.some((item) => deepEquals(item, targetItem))) {
379
+ result.push(targetItem);
367
380
  }
368
- continue;
369
381
  }
370
- i === -1 && (a = false, i = l + 1), f === 46 ? r === -1 ? r = l : n !== 1 && (n = 1) : r !== -1 && (n = -1);
382
+ return result;
371
383
  }
372
- return r === -1 || i === -1 || n === 0 || n === 1 && r === i - 1 && r === t + 1 ? "" : e.slice(r, i);
373
- }, format: function(e) {
374
- if (e === null || typeof e != "object")
375
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof e);
376
- return F("/", e);
377
- }, parse: function(e) {
378
- v(e);
379
- var r = { root: "", dir: "", base: "", ext: "", name: "" };
380
- if (e.length === 0)
381
- return r;
382
- var t = e.charCodeAt(0), i = t === 47, a;
383
- i ? (r.root = "/", a = 1) : a = 0;
384
- for (var n = -1, l = 0, f = -1, c = true, d = e.length - 1, o = 0;d >= a; --d) {
385
- if (t = e.charCodeAt(d), t === 47) {
386
- if (!c) {
387
- l = d + 1;
388
- break;
384
+ if (source.every((item) => typeof item === "string") && target.every((item) => typeof item === "string")) {
385
+ const result = [...source];
386
+ for (const item of target) {
387
+ if (!result.includes(item)) {
388
+ result.push(item);
389
389
  }
390
- continue;
391
390
  }
392
- f === -1 && (c = false, f = d + 1), t === 46 ? n === -1 ? n = d : o !== 1 && (o = 1) : n !== -1 && (o = -1);
391
+ return result;
393
392
  }
394
- return n === -1 || f === -1 || o === 0 || o === 1 && n === f - 1 && n === l + 1 ? f !== -1 && (l === 0 && i ? r.base = r.name = e.slice(1, f) : r.base = r.name = e.slice(l, f)) : (l === 0 && i ? (r.name = e.slice(1, n), r.base = e.slice(1, f)) : (r.name = e.slice(l, n), r.base = e.slice(l, f)), r.ext = e.slice(n, f)), l > 0 ? r.dir = e.slice(0, l - 1) : i && (r.dir = "/"), r;
395
- }, sep: "/", delimiter: ":", win32: null, posix: null };
396
- m.posix = m;
397
- w.exports = m;
398
- });
399
- var x2 = j2(k2());
400
- var u2 = x2;
401
- var J2 = x2;
402
- var P2 = function(s) {
403
- return s;
404
- };
405
- var S2 = function() {
406
- throw new Error("Not implemented");
407
- };
408
- u2.parse ??= S2;
409
- J2.parse ??= S2;
410
- var g2 = { resolve: u2.resolve.bind(u2), normalize: u2.normalize.bind(u2), isAbsolute: u2.isAbsolute.bind(u2), join: u2.join.bind(u2), relative: u2.relative.bind(u2), toNamespacedPath: P2, dirname: u2.dirname.bind(u2), basename: u2.basename.bind(u2), extname: u2.extname.bind(u2), format: u2.format.bind(u2), parse: u2.parse.bind(u2), sep: "/", delimiter: ":", win32: undefined, posix: undefined, _makeLong: P2 };
411
- var y2 = { sep: "\\", delimiter: ";", win32: undefined, ...g2, posix: g2 };
412
- g2.win32 = y2.win32 = y2;
413
- g2.posix = g2;
414
- var { resolve: B2, normalize: G2, isAbsolute: H2, join: K2, relative: Q2, toNamespacedPath: U2, dirname: V2, basename: X2, extname: Y2, format: Z2, parse: $2, sep: I2, delimiter: O2 } = g2;
415
- function deepMerge(target, source) {
416
- if (Array.isArray(source) && !Array.isArray(target)) {
417
393
  return source;
418
394
  }
419
- if (Array.isArray(source) && Array.isArray(target)) {
420
- return source.map((sourceItem, index) => {
421
- const targetItem = target[index];
422
- if (isObject(sourceItem) && isObject(targetItem)) {
423
- return deepMerge(targetItem, sourceItem);
424
- }
425
- return sourceItem;
426
- });
427
- }
428
395
  if (!isObject(source) || !isObject(target)) {
429
396
  return source;
430
397
  }
@@ -432,11 +399,40 @@ function deepMerge(target, source) {
432
399
  for (const key in source) {
433
400
  if (Object.prototype.hasOwnProperty.call(source, key)) {
434
401
  const sourceValue = source[key];
435
- const targetValue = merged[key];
436
402
  if (sourceValue === null || sourceValue === undefined) {
437
- merged[key] = sourceValue;
438
- } else if (isObject(sourceValue) && isObject(targetValue)) {
439
- merged[key] = deepMerge(targetValue, sourceValue);
403
+ continue;
404
+ } else if (isObject(sourceValue) && isObject(merged[key])) {
405
+ merged[key] = deepMerge(merged[key], sourceValue);
406
+ } else if (Array.isArray(sourceValue) && Array.isArray(merged[key])) {
407
+ if (sourceValue.length > 0 && merged[key].length > 0 && isObject(sourceValue[0]) && isObject(merged[key][0])) {
408
+ const result = [...sourceValue];
409
+ for (const targetItem of merged[key]) {
410
+ if (isObject(targetItem) && "name" in targetItem) {
411
+ const existingItem = result.find((item) => isObject(item) && ("name" in item) && item.name === targetItem.name);
412
+ if (!existingItem) {
413
+ result.push(targetItem);
414
+ }
415
+ } else if (isObject(targetItem) && "path" in targetItem) {
416
+ const existingItem = result.find((item) => isObject(item) && ("path" in item) && item.path === targetItem.path);
417
+ if (!existingItem) {
418
+ result.push(targetItem);
419
+ }
420
+ } else if (!result.some((item) => deepEquals(item, targetItem))) {
421
+ result.push(targetItem);
422
+ }
423
+ }
424
+ merged[key] = result;
425
+ } else if (sourceValue.every((item) => typeof item === "string") && merged[key].every((item) => typeof item === "string")) {
426
+ const result = [...sourceValue];
427
+ for (const item of merged[key]) {
428
+ if (!result.includes(item)) {
429
+ result.push(item);
430
+ }
431
+ }
432
+ merged[key] = result;
433
+ } else {
434
+ merged[key] = sourceValue;
435
+ }
440
436
  } else {
441
437
  merged[key] = sourceValue;
442
438
  }
@@ -444,65 +440,79 @@ function deepMerge(target, source) {
444
440
  }
445
441
  return merged;
446
442
  }
443
+ function deepEquals(a, b) {
444
+ if (a === b)
445
+ return true;
446
+ if (Array.isArray(a) && Array.isArray(b)) {
447
+ if (a.length !== b.length)
448
+ return false;
449
+ for (let i = 0;i < a.length; i++) {
450
+ if (!deepEquals(a[i], b[i]))
451
+ return false;
452
+ }
453
+ return true;
454
+ }
455
+ if (isObject(a) && isObject(b)) {
456
+ const keysA = Object.keys(a);
457
+ const keysB = Object.keys(b);
458
+ if (keysA.length !== keysB.length)
459
+ return false;
460
+ for (const key of keysA) {
461
+ if (!Object.prototype.hasOwnProperty.call(b, key))
462
+ return false;
463
+ if (!deepEquals(a[key], b[key]))
464
+ return false;
465
+ }
466
+ return true;
467
+ }
468
+ return false;
469
+ }
447
470
  function isObject(item) {
448
471
  return Boolean(item && typeof item === "object" && !Array.isArray(item));
449
472
  }
450
473
  async function tryLoadConfig(configPath, defaultConfig) {
474
+ if (!existsSync(configPath))
475
+ return null;
451
476
  try {
452
477
  const importedConfig = await import(configPath);
453
478
  const loadedConfig = importedConfig.default || importedConfig;
454
- return deepMerge(defaultConfig, loadedConfig);
479
+ if (typeof loadedConfig !== "object" || loadedConfig === null || Array.isArray(loadedConfig))
480
+ return null;
481
+ try {
482
+ return deepMerge(defaultConfig, loadedConfig);
483
+ } catch {
484
+ return null;
485
+ }
455
486
  } catch {
456
487
  return null;
457
488
  }
458
489
  }
459
490
  async function loadConfig({
460
- name,
491
+ name = "",
461
492
  cwd,
462
- defaultConfig,
463
- endpoint,
464
- headers = {
465
- Accept: "application/json",
466
- "Content-Type": "application/json"
467
- }
493
+ defaultConfig
468
494
  }) {
469
- if (typeof window === "undefined") {
470
- const baseDir = cwd || "../../../";
471
- const configPaths = [
472
- `${name}.config`,
473
- `.${name}.config`,
474
- name,
475
- `.${name}`
476
- ];
477
- for (const configPath of configPaths) {
478
- const fullPath = B2(baseDir, configPath);
479
- const config = await tryLoadConfig(fullPath, defaultConfig);
480
- if (config !== null) {
481
- return config;
482
- }
495
+ const baseDir = cwd || j2.cwd();
496
+ const extensions = [".ts", ".js", ".mjs", ".cjs", ".json"];
497
+ const configPaths = [
498
+ `${name}.config`,
499
+ `.${name}.config`,
500
+ name,
501
+ `.${name}`
502
+ ];
503
+ for (const configPath of configPaths) {
504
+ for (const ext of extensions) {
505
+ const fullPath = B(baseDir, `${configPath}${ext}`);
506
+ const config2 = await tryLoadConfig(fullPath, defaultConfig);
507
+ if (config2 !== null)
508
+ return config2;
483
509
  }
484
- console.error("Failed to load client config from any expected location");
485
- return defaultConfig;
486
- }
487
- if (!endpoint) {
488
- console.warn("An API endpoint is required to load the client config.");
489
- return defaultConfig;
490
- }
491
- try {
492
- const response = await fetch(endpoint, {
493
- method: "GET",
494
- headers
495
- });
496
- if (!response.ok) {
497
- throw new Error(`HTTP error! status: ${response.status}`);
498
- }
499
- const loadedConfig = await response.json();
500
- return deepMerge(defaultConfig, loadedConfig);
501
- } catch (error) {
502
- console.error("Failed to load client config:", error);
503
- return defaultConfig;
504
510
  }
511
+ console.error("Failed to load client config from any expected location");
512
+ return defaultConfig;
505
513
  }
514
+ var defaultConfigDir = B(j2.cwd(), "config");
515
+ var defaultGeneratedDir = B(j2.cwd(), "src/generated");
506
516
 
507
517
  // src/config.ts
508
518
  var __dirname = "/home/runner/work/bun-git-hooks/bun-git-hooks/src";
@@ -516,145 +526,7 @@ var config = await loadConfig({
516
526
  });
517
527
  // src/git-hooks.ts
518
528
  var { default: fs} = (() => ({}));
519
-
520
- // node:process
521
- var C = Object.create;
522
- var T3 = Object.defineProperty;
523
- var q2 = Object.getOwnPropertyDescriptor;
524
- var A = Object.getOwnPropertyNames;
525
- var I3 = Object.getPrototypeOf;
526
- var Q3 = Object.prototype.hasOwnProperty;
527
- var S3 = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
528
- var N3 = (e, t) => {
529
- for (var n in t)
530
- T3(e, n, { get: t[n], enumerable: true });
531
- };
532
- var d = (e, t, n, w) => {
533
- if (t && typeof t == "object" || typeof t == "function")
534
- for (let l of A(t))
535
- !Q3.call(e, l) && l !== n && T3(e, l, { get: () => t[l], enumerable: !(w = q2(t, l)) || w.enumerable });
536
- return e;
537
- };
538
- var h3 = (e, t, n) => (d(e, t, "default"), n && d(n, t, "default"));
539
- var y3 = (e, t, n) => (n = e != null ? C(I3(e)) : {}, d(t || !e || !e.__esModule ? T3(n, "default", { value: e, enumerable: true }) : n, e));
540
- var v = S3((B3, E3) => {
541
- var r = E3.exports = {}, i, u3;
542
- function p() {
543
- throw new Error("setTimeout has not been defined");
544
- }
545
- function g3() {
546
- throw new Error("clearTimeout has not been defined");
547
- }
548
- (function() {
549
- try {
550
- typeof setTimeout == "function" ? i = setTimeout : i = p;
551
- } catch {
552
- i = p;
553
- }
554
- try {
555
- typeof clearTimeout == "function" ? u3 = clearTimeout : u3 = g3;
556
- } catch {
557
- u3 = g3;
558
- }
559
- })();
560
- function b(e) {
561
- if (i === setTimeout)
562
- return setTimeout(e, 0);
563
- if ((i === p || !i) && setTimeout)
564
- return i = setTimeout, setTimeout(e, 0);
565
- try {
566
- return i(e, 0);
567
- } catch {
568
- try {
569
- return i.call(null, e, 0);
570
- } catch {
571
- return i.call(this, e, 0);
572
- }
573
- }
574
- }
575
- function O3(e) {
576
- if (u3 === clearTimeout)
577
- return clearTimeout(e);
578
- if ((u3 === g3 || !u3) && clearTimeout)
579
- return u3 = clearTimeout, clearTimeout(e);
580
- try {
581
- return u3(e);
582
- } catch {
583
- try {
584
- return u3.call(null, e);
585
- } catch {
586
- return u3.call(this, e);
587
- }
588
- }
589
- }
590
- var o = [], s = false, a, m = -1;
591
- function U3() {
592
- !s || !a || (s = false, a.length ? o = a.concat(o) : m = -1, o.length && x3());
593
- }
594
- function x3() {
595
- if (!s) {
596
- var e = b(U3);
597
- s = true;
598
- for (var t = o.length;t; ) {
599
- for (a = o, o = [];++m < t; )
600
- a && a[m].run();
601
- m = -1, t = o.length;
602
- }
603
- a = null, s = false, O3(e);
604
- }
605
- }
606
- r.nextTick = function(e) {
607
- var t = new Array(arguments.length - 1);
608
- if (arguments.length > 1)
609
- for (var n = 1;n < arguments.length; n++)
610
- t[n - 1] = arguments[n];
611
- o.push(new L3(e, t)), o.length === 1 && !s && b(x3);
612
- };
613
- function L3(e, t) {
614
- this.fun = e, this.array = t;
615
- }
616
- L3.prototype.run = function() {
617
- this.fun.apply(null, this.array);
618
- };
619
- r.title = "browser";
620
- r.browser = true;
621
- r.env = {};
622
- r.argv = [];
623
- r.version = "";
624
- r.versions = {};
625
- function c() {
626
- }
627
- r.on = c;
628
- r.addListener = c;
629
- r.once = c;
630
- r.off = c;
631
- r.removeListener = c;
632
- r.removeAllListeners = c;
633
- r.emit = c;
634
- r.prependListener = c;
635
- r.prependOnceListener = c;
636
- r.listeners = function(e) {
637
- return [];
638
- };
639
- r.binding = function(e) {
640
- throw new Error("process.binding is not supported");
641
- };
642
- r.cwd = function() {
643
- return "/";
644
- };
645
- r.chdir = function(e) {
646
- throw new Error("process.chdir is not supported");
647
- };
648
- r.umask = function() {
649
- return 0;
650
- };
651
- });
652
- var f = {};
653
- N3(f, { default: () => j3 });
654
- h3(f, y3(v()));
655
- var j3 = y3(v());
656
-
657
- // src/git-hooks.ts
529
+ init_process();
658
530
  var VALID_GIT_HOOKS = [
659
531
  "applypatch-msg",
660
532
  "pre-applypatch",
@@ -698,7 +570,7 @@ if [ -f "$BUN_GIT_HOOKS_RC" ]; then
698
570
  fi
699
571
 
700
572
  `;
701
- function getGitProjectRoot(directory = j3.cwd()) {
573
+ function getGitProjectRoot(directory = j2.cwd()) {
702
574
  if (directory.endsWith(".git")) {
703
575
  return q.normalize(directory);
704
576
  }
@@ -755,11 +627,12 @@ function checkBunGitHooksInDependencies(projectRootPath) {
755
627
  console.warn("[WARN] You should move `bun-git-hooks` to your devDependencies!");
756
628
  return true;
757
629
  }
758
- if (!("devDependencies" in packageJsonContent))
630
+ if (!("devDependencies" in packageJsonContent)) {
759
631
  return false;
760
- return "git-hooks" in packageJsonContent.devDependencies;
632
+ }
633
+ return "bun-git-hooks" in packageJsonContent.devDependencies;
761
634
  }
762
- function _getPackageJson(projectPath = j3.cwd()) {
635
+ function _getPackageJson(projectPath = j2.cwd()) {
763
636
  if (typeof projectPath !== "string") {
764
637
  throw new TypeError("projectPath is not a string");
765
638
  }
@@ -770,52 +643,47 @@ function _getPackageJson(projectPath = j3.cwd()) {
770
643
  const packageJsonDataRaw = fs.readFileSync(targetPackageJson, { encoding: "utf-8" });
771
644
  return { packageJsonContent: JSON.parse(packageJsonDataRaw), packageJsonPath: targetPackageJson };
772
645
  }
773
- function setHooksFromConfig(projectRootPath = j3.cwd(), options = {}) {
774
- if (!config) {
775
- 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 your package.json.\r\nCheck README for details");
776
- }
646
+ function setHooksFromConfig(projectRootPath = j2.cwd(), options = {}) {
647
+ if (!config || Object.keys(config).length === 0)
648
+ 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");
649
+ const hookKeys = Object.keys(config).filter((key) => key !== "preserveUnused" && key !== "verbose");
650
+ const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
651
+ if (!isValidConfig)
652
+ throw new Error("[ERROR] Config was not in correct format. Please check git hooks or options name");
777
653
  const preserveUnused = Array.isArray(config.preserveUnused) ? config.preserveUnused : config.preserveUnused ? VALID_GIT_HOOKS : [];
778
654
  for (const hook of VALID_GIT_HOOKS) {
779
655
  if (Object.prototype.hasOwnProperty.call(config, hook)) {
780
- if (!config[hook]) {
656
+ if (!config[hook])
781
657
  throw new Error(`[ERROR] Command for ${hook} is not set`);
782
- }
783
658
  _setHook(hook, config[hook], projectRootPath);
784
- } else if (!preserveUnused.includes(hook)) {
659
+ } else if (!preserveUnused.includes(hook))
785
660
  _removeHook(hook, projectRootPath);
786
- }
787
661
  }
788
662
  }
789
- function _setHook(hook, command, projectRoot = j3.cwd()) {
663
+ function _setHook(hook, command, projectRoot = j2.cwd()) {
790
664
  const gitRoot = getGitProjectRoot(projectRoot);
791
665
  if (!gitRoot) {
792
666
  console.info("[INFO] No `.git` root folder found, skipping");
793
667
  return;
794
668
  }
795
669
  const hookCommand = PREPEND_SCRIPT + command;
796
- const hookDirectory = `${gitRoot}/hooks/`;
797
- const hookPath = q.normalize(hookDirectory + hook);
798
- const normalizedHookDirectory = q.normalize(hookDirectory);
799
- if (!fs.existsSync(normalizedHookDirectory))
800
- fs.mkdirSync(normalizedHookDirectory);
801
- fs.writeFileSync(hookPath, hookCommand);
802
- fs.chmodSync(hookPath, 493);
803
- console.info(`[INFO] Successfully set the ${hook} with command: ${command}`);
670
+ const hookDirectory = q.join(gitRoot, "hooks");
671
+ const hookPath = q.normalize(q.join(hookDirectory, hook));
672
+ if (!fs.existsSync(hookDirectory))
673
+ fs.mkdirSync(hookDirectory, { recursive: true });
674
+ fs.writeFileSync(hookPath, hookCommand, { mode: 493 });
804
675
  }
805
- function removeHooks(projectRoot = j3.cwd(), verbose = false) {
806
- for (const configEntry of VALID_GIT_HOOKS) {
676
+ function removeHooks(projectRoot = j2.cwd(), verbose = false) {
677
+ for (const configEntry of VALID_GIT_HOOKS)
807
678
  _removeHook(configEntry, projectRoot, verbose);
808
- }
809
679
  }
810
- function _removeHook(hook, projectRoot = j3.cwd(), verbose = false) {
680
+ function _removeHook(hook, projectRoot = j2.cwd(), verbose = false) {
811
681
  const gitRoot = getGitProjectRoot(projectRoot);
812
682
  const hookPath = q.normalize(`${gitRoot}/hooks/${hook}`);
813
- if (fs.existsSync(hookPath)) {
683
+ if (fs.existsSync(hookPath))
814
684
  fs.unlinkSync(hookPath);
815
- }
816
- if (verbose) {
685
+ if (verbose)
817
686
  console.info(`[INFO] Successfully removed the ${hook} hook`);
818
- }
819
687
  }
820
688
  export {
821
689
  setHooksFromConfig,