ccjk 12.2.0 → 12.2.2
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/chunks/auto-init.mjs +2 -76
- package/dist/chunks/cli-hook.mjs +1821 -28
- package/dist/chunks/package.mjs +1 -1
- package/dist/cli.mjs +0 -0
- package/dist/shared/ccjk.CCcQfbni.mjs +78 -0
- package/package.json +65 -62
|
@@ -1,87 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as hookRegistry } from '../shared/ccjk.CCcQfbni.mjs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { c as commonjsGlobal } from '../shared/ccjk.BAGoDD49.mjs';
|
|
4
4
|
import require$$0 from 'crypto';
|
|
5
|
+
import { l as logger } from '../shared/ccjk.DG_o24cZ.mjs';
|
|
5
6
|
import { existsSync, readFileSync } from 'fs';
|
|
6
7
|
import { homedir } from 'os';
|
|
7
8
|
import { join } from 'path';
|
|
8
9
|
import './index2.mjs';
|
|
9
10
|
|
|
10
|
-
class HookRegistry {
|
|
11
|
-
hooks = /* @__PURE__ */ new Map();
|
|
12
|
-
/**
|
|
13
|
-
* Register a hook for an event
|
|
14
|
-
*/
|
|
15
|
-
register(event, hook) {
|
|
16
|
-
const hooks = this.hooks.get(event) || [];
|
|
17
|
-
hooks.push(hook);
|
|
18
|
-
hooks.sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
|
19
|
-
this.hooks.set(event, hooks);
|
|
20
|
-
logger.debug(`Registered hook "${hook.name}" for event "${event}"`);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Unregister a hook
|
|
24
|
-
*/
|
|
25
|
-
unregister(event, hookName) {
|
|
26
|
-
const hooks = this.hooks.get(event);
|
|
27
|
-
if (!hooks) return;
|
|
28
|
-
const filtered = hooks.filter((h) => h.name !== hookName);
|
|
29
|
-
this.hooks.set(event, filtered);
|
|
30
|
-
logger.debug(`Unregistered hook "${hookName}" for event "${event}"`);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Execute all hooks for an event
|
|
34
|
-
* Returns false if any hook returns continue: false
|
|
35
|
-
*/
|
|
36
|
-
async execute(context) {
|
|
37
|
-
const hooks = this.hooks.get(context.event) || [];
|
|
38
|
-
const enabledHooks = hooks.filter((h) => h.enabled !== false);
|
|
39
|
-
if (enabledHooks.length === 0) {
|
|
40
|
-
return { continue: true };
|
|
41
|
-
}
|
|
42
|
-
let currentContext = context;
|
|
43
|
-
let aggregatedData = {};
|
|
44
|
-
for (const hook of enabledHooks) {
|
|
45
|
-
try {
|
|
46
|
-
const result = await hook.fn(currentContext);
|
|
47
|
-
if (result.data) {
|
|
48
|
-
aggregatedData = { ...aggregatedData, ...result.data };
|
|
49
|
-
}
|
|
50
|
-
if (!result.continue) {
|
|
51
|
-
return {
|
|
52
|
-
continue: false,
|
|
53
|
-
data: aggregatedData,
|
|
54
|
-
error: result.error
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
currentContext = {
|
|
58
|
-
...currentContext,
|
|
59
|
-
data: { ...currentContext.data, ...aggregatedData }
|
|
60
|
-
};
|
|
61
|
-
} catch (error) {
|
|
62
|
-
logger.error(`Hook "${hook.name}" failed:`, error);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
continue: true,
|
|
67
|
-
data: aggregatedData
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get all registered hooks for an event
|
|
72
|
-
*/
|
|
73
|
-
getHooks(event) {
|
|
74
|
-
return this.hooks.get(event) || [];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Clear all hooks
|
|
78
|
-
*/
|
|
79
|
-
clear() {
|
|
80
|
-
this.hooks.clear();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const hookRegistry = new HookRegistry();
|
|
84
|
-
|
|
85
11
|
var cuid2 = {};
|
|
86
12
|
|
|
87
13
|
var src = {};
|