chkit 0.1.0-beta.21 → 0.1.0-beta.23
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/README.md +1 -1
- package/dist/bin/chkit.js +162 -102
- package/dist/bin/chkit.js.map +1 -1
- package/dist/bin/command-dispatch.d.ts +0 -5
- package/dist/bin/command-dispatch.d.ts.map +1 -1
- package/dist/bin/command-dispatch.js +1 -1
- package/dist/bin/command-dispatch.js.map +1 -1
- package/dist/bin/commands/drift.d.ts +2 -1
- package/dist/bin/commands/drift.d.ts.map +1 -1
- package/dist/bin/internal-plugins/skill-hint.d.ts +1 -6
- package/dist/bin/internal-plugins/skill-hint.d.ts.map +1 -1
- package/dist/bin/internal-plugins/skill-hint.js +1 -1
- package/dist/bin/internal-plugins/skill-hint.js.map +1 -1
- package/dist/bin/journal-store.d.ts +2 -6
- package/dist/bin/journal-store.d.ts.map +1 -1
- package/dist/bin/journal-store.js +1 -5
- package/dist/bin/journal-store.js.map +1 -1
- package/dist/bin/json-output.d.ts +2 -5
- package/dist/bin/json-output.d.ts.map +1 -1
- package/dist/bin/json-output.js +1 -1
- package/dist/bin/json-output.js.map +1 -1
- package/dist/bin/lib.d.ts +2 -5
- package/dist/bin/lib.d.ts.map +1 -1
- package/dist/bin/lib.js +2 -5
- package/dist/bin/lib.js.map +1 -1
- package/dist/bin/migration-store.d.ts +2 -2
- package/dist/bin/migration-store.d.ts.map +1 -1
- package/dist/bin/migration-store.js +1 -1
- package/dist/bin/migration-store.js.map +1 -1
- package/dist/bin/safety-markers.d.ts +1 -3
- package/dist/bin/safety-markers.d.ts.map +1 -1
- package/dist/bin/safety-markers.js +2 -2
- package/dist/bin/safety-markers.js.map +1 -1
- package/dist/bin/table-scope.d.ts +1 -2
- package/dist/bin/table-scope.d.ts.map +1 -1
- package/dist/bin/table-scope.js +1 -1
- package/dist/bin/table-scope.js.map +1 -1
- package/dist/commands/check/command.d.ts +3 -0
- package/dist/commands/check/command.d.ts.map +1 -0
- package/dist/commands/check/command.js +106 -0
- package/dist/commands/check/command.js.map +1 -0
- package/dist/commands/check/output.d.ts +35 -0
- package/dist/commands/check/output.d.ts.map +1 -0
- package/dist/commands/check/output.js +105 -0
- package/dist/commands/check/output.js.map +1 -0
- package/dist/commands/drift/command.d.ts +3 -0
- package/dist/commands/drift/command.d.ts.map +1 -0
- package/dist/commands/drift/command.js +128 -0
- package/dist/commands/drift/command.js.map +1 -0
- package/dist/commands/drift/compare.d.ts +66 -0
- package/dist/commands/drift/compare.d.ts.map +1 -0
- package/dist/commands/drift/compare.js +220 -0
- package/dist/commands/drift/compare.js.map +1 -0
- package/dist/commands/drift/diff.d.ts +8 -0
- package/dist/commands/drift/diff.d.ts.map +1 -0
- package/dist/commands/drift/diff.js +46 -0
- package/dist/commands/drift/diff.js.map +1 -0
- package/dist/commands/drift/payload.d.ts +24 -0
- package/dist/commands/drift/payload.d.ts.map +1 -0
- package/dist/commands/drift/payload.js +96 -0
- package/dist/commands/drift/payload.js.map +1 -0
- package/dist/commands/generate/command.d.ts +3 -0
- package/dist/commands/generate/command.d.ts.map +1 -0
- package/dist/commands/generate/command.js +163 -0
- package/dist/commands/generate/command.js.map +1 -0
- package/dist/commands/generate/output.d.ts +8 -0
- package/dist/commands/generate/output.d.ts.map +1 -0
- package/dist/commands/generate/output.js +59 -0
- package/dist/commands/generate/output.js.map +1 -0
- package/dist/commands/generate/plan-pipeline.d.ts +7 -0
- package/dist/commands/generate/plan-pipeline.d.ts.map +1 -0
- package/dist/commands/generate/plan-pipeline.js +143 -0
- package/dist/commands/generate/plan-pipeline.js.map +1 -0
- package/dist/commands/generate/rename-mappings.d.ts +29 -0
- package/dist/commands/generate/rename-mappings.d.ts.map +1 -0
- package/dist/commands/generate/rename-mappings.js +195 -0
- package/dist/commands/generate/rename-mappings.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +24 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/migrate/apply.d.ts +18 -0
- package/dist/commands/migrate/apply.d.ts.map +1 -0
- package/dist/commands/migrate/apply.js +48 -0
- package/dist/commands/migrate/apply.js.map +1 -0
- package/dist/commands/migrate/command.d.ts +3 -0
- package/dist/commands/migrate/command.d.ts.map +1 -0
- package/dist/commands/migrate/command.js +174 -0
- package/dist/commands/migrate/command.js.map +1 -0
- package/dist/commands/migrate/destructive.d.ts +7 -0
- package/dist/commands/migrate/destructive.d.ts.map +1 -0
- package/dist/commands/migrate/destructive.js +16 -0
- package/dist/commands/migrate/destructive.js.map +1 -0
- package/dist/commands/migrate/prompts.d.ts +6 -0
- package/dist/commands/migrate/prompts.d.ts.map +1 -0
- package/dist/commands/migrate/prompts.js +40 -0
- package/dist/commands/migrate/prompts.js.map +1 -0
- package/dist/commands/migrate/scope.d.ts +2 -0
- package/dist/commands/migrate/scope.d.ts.map +1 -0
- package/dist/commands/migrate/scope.js +25 -0
- package/dist/commands/migrate/scope.js.map +1 -0
- package/dist/commands/plugin.d.ts +3 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +129 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/query.d.ts +8 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +114 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +64 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/drift.d.ts +7 -6
- package/dist/drift.d.ts.map +1 -1
- package/dist/internal-plugins/core/plugin.d.ts +2 -0
- package/dist/internal-plugins/core/plugin.d.ts.map +1 -0
- package/dist/internal-plugins/core/plugin.js +21 -0
- package/dist/internal-plugins/core/plugin.js.map +1 -0
- package/dist/internal-plugins/index.d.ts +3 -0
- package/dist/internal-plugins/index.d.ts.map +1 -0
- package/dist/internal-plugins/index.js +6 -0
- package/dist/internal-plugins/index.js.map +1 -0
- package/dist/internal-plugins/skill-hint/agent-detect.d.ts +20 -0
- package/dist/internal-plugins/skill-hint/agent-detect.d.ts.map +1 -0
- package/dist/internal-plugins/skill-hint/agent-detect.js +68 -0
- package/dist/internal-plugins/skill-hint/agent-detect.js.map +1 -0
- package/dist/internal-plugins/skill-hint/plugin.d.ts +16 -0
- package/dist/internal-plugins/skill-hint/plugin.d.ts.map +1 -0
- package/dist/internal-plugins/skill-hint/plugin.js +60 -0
- package/dist/internal-plugins/skill-hint/plugin.js.map +1 -0
- package/dist/internal-plugins/skill-hint/prompt.d.ts +5 -0
- package/dist/internal-plugins/skill-hint/prompt.d.ts.map +1 -0
- package/dist/internal-plugins/skill-hint/prompt.js +37 -0
- package/dist/internal-plugins/skill-hint/prompt.js.map +1 -0
- package/dist/internal-plugins/skill-hint/state.d.ts +7 -0
- package/dist/internal-plugins/skill-hint/state.d.ts.map +1 -0
- package/dist/internal-plugins/skill-hint/state.js +23 -0
- package/dist/internal-plugins/skill-hint/state.js.map +1 -0
- package/dist/plugins.d.ts +56 -32
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +0 -6
- package/dist/plugins.js.map +1 -1
- package/dist/runtime/command-dispatch.d.ts +18 -0
- package/dist/runtime/command-dispatch.d.ts.map +1 -0
- package/dist/runtime/command-dispatch.js +221 -0
- package/dist/runtime/command-dispatch.js.map +1 -0
- package/dist/runtime/command-registry.d.ts +31 -0
- package/dist/runtime/command-registry.d.ts.map +1 -0
- package/dist/runtime/command-registry.js +74 -0
- package/dist/runtime/command-registry.js.map +1 -0
- package/dist/runtime/config-merge.d.ts +4 -0
- package/dist/runtime/config-merge.d.ts.map +1 -0
- package/dist/runtime/config-merge.js +72 -0
- package/dist/runtime/config-merge.js.map +1 -0
- package/dist/runtime/config.d.ts +22 -0
- package/dist/runtime/config.d.ts.map +1 -0
- package/dist/runtime/config.js +126 -0
- package/dist/runtime/config.js.map +1 -0
- package/dist/runtime/debug.d.ts +3 -0
- package/dist/runtime/debug.d.ts.map +1 -0
- package/dist/runtime/debug.js +14 -0
- package/dist/runtime/debug.js.map +1 -0
- package/dist/runtime/extract-config-path.d.ts +2 -0
- package/dist/runtime/extract-config-path.d.ts.map +1 -0
- package/dist/runtime/extract-config-path.js +13 -0
- package/dist/runtime/extract-config-path.js.map +1 -0
- package/dist/runtime/global-flags.d.ts +16 -0
- package/dist/runtime/global-flags.d.ts.map +1 -0
- package/dist/runtime/global-flags.js +7 -0
- package/dist/runtime/global-flags.js.map +1 -0
- package/dist/runtime/help.d.ts +5 -0
- package/dist/runtime/help.d.ts.map +1 -0
- package/dist/runtime/help.js +84 -0
- package/dist/runtime/help.js.map +1 -0
- package/dist/runtime/journal-store.d.ts +10 -0
- package/dist/runtime/journal-store.d.ts.map +1 -0
- package/dist/runtime/journal-store.js +137 -0
- package/dist/runtime/journal-store.js.map +1 -0
- package/dist/runtime/json-output.d.ts +5 -0
- package/dist/runtime/json-output.d.ts.map +1 -0
- package/dist/runtime/json-output.js +21 -0
- package/dist/runtime/json-output.js.map +1 -0
- package/dist/runtime/logging.d.ts +3 -0
- package/dist/runtime/logging.d.ts.map +1 -0
- package/dist/runtime/logging.js +31 -0
- package/dist/runtime/logging.js.map +1 -0
- package/dist/runtime/migration-store.d.ts +22 -0
- package/dist/runtime/migration-store.d.ts.map +1 -0
- package/dist/runtime/migration-store.js +60 -0
- package/dist/runtime/migration-store.js.map +1 -0
- package/dist/runtime/plugin-runtime/errors.d.ts +3 -0
- package/dist/runtime/plugin-runtime/errors.d.ts.map +1 -0
- package/dist/runtime/plugin-runtime/errors.js +13 -0
- package/dist/runtime/plugin-runtime/errors.js.map +1 -0
- package/dist/runtime/plugin-runtime/executor-debug.d.ts +3 -0
- package/dist/runtime/plugin-runtime/executor-debug.d.ts.map +1 -0
- package/dist/runtime/plugin-runtime/executor-debug.js +65 -0
- package/dist/runtime/plugin-runtime/executor-debug.js.map +1 -0
- package/dist/runtime/plugin-runtime/hooks.d.ts +23 -0
- package/dist/runtime/plugin-runtime/hooks.d.ts.map +1 -0
- package/dist/runtime/plugin-runtime/hooks.js +148 -0
- package/dist/runtime/plugin-runtime/hooks.js.map +1 -0
- package/dist/runtime/plugin-runtime/index.d.ts +9 -0
- package/dist/runtime/plugin-runtime/index.d.ts.map +1 -0
- package/dist/runtime/plugin-runtime/index.js +178 -0
- package/dist/runtime/plugin-runtime/index.js.map +1 -0
- package/dist/runtime/plugin-runtime/loader.d.ts +11 -0
- package/dist/runtime/plugin-runtime/loader.d.ts.map +1 -0
- package/dist/runtime/plugin-runtime/loader.js +37 -0
- package/dist/runtime/plugin-runtime/loader.js.map +1 -0
- package/dist/runtime/plugin-runtime/null-executor.d.ts +3 -0
- package/dist/runtime/plugin-runtime/null-executor.d.ts.map +1 -0
- package/dist/runtime/plugin-runtime/null-executor.js +17 -0
- package/dist/runtime/plugin-runtime/null-executor.js.map +1 -0
- package/dist/runtime/safety-markers.d.ts +23 -0
- package/dist/runtime/safety-markers.d.ts.map +1 -0
- package/dist/runtime/safety-markers.js +85 -0
- package/dist/runtime/safety-markers.js.map +1 -0
- package/dist/runtime/schema-loader.d.ts +3 -0
- package/dist/runtime/schema-loader.d.ts.map +1 -0
- package/dist/runtime/schema-loader.js +11 -0
- package/dist/runtime/schema-loader.js.map +1 -0
- package/dist/runtime/table-scope.d.ts +33 -0
- package/dist/runtime/table-scope.d.ts.map +1 -0
- package/dist/runtime/table-scope.js +167 -0
- package/dist/runtime/table-scope.js.map +1 -0
- package/dist/runtime/user-config.d.ts +4 -0
- package/dist/runtime/user-config.d.ts.map +1 -0
- package/dist/runtime/user-config.js +11 -0
- package/dist/runtime/user-config.js.map +1 -0
- package/dist/runtime/version.d.ts +2 -0
- package/dist/runtime/version.d.ts.map +1 -0
- package/dist/runtime/version.js +5 -0
- package/dist/runtime/version.js.map +1 -0
- package/package.json +9 -7
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ChxPluginCommand, CommandExtension, FlagDef } from '../plugins.js';
|
|
2
|
+
export interface RegisteredCommand {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
flags: readonly FlagDef[];
|
|
6
|
+
pluginFlags: Array<{
|
|
7
|
+
pluginName: string;
|
|
8
|
+
flags: readonly FlagDef[];
|
|
9
|
+
}>;
|
|
10
|
+
pluginName?: string;
|
|
11
|
+
subcommands?: RegisteredCommand[];
|
|
12
|
+
}
|
|
13
|
+
export interface CommandRegistry {
|
|
14
|
+
commands: RegisteredCommand[];
|
|
15
|
+
globalFlags: readonly FlagDef[];
|
|
16
|
+
get(name: string): RegisteredCommand | undefined;
|
|
17
|
+
resolveFlags(name: string, subcommand?: string): FlagDef[];
|
|
18
|
+
}
|
|
19
|
+
export declare function createCommandRegistry(input: {
|
|
20
|
+
globalFlags: readonly FlagDef[];
|
|
21
|
+
pluginExtensions: Array<{
|
|
22
|
+
pluginName: string;
|
|
23
|
+
extensions: CommandExtension[];
|
|
24
|
+
}>;
|
|
25
|
+
pluginCommands: Array<{
|
|
26
|
+
pluginName: string;
|
|
27
|
+
commands: ChxPluginCommand[];
|
|
28
|
+
manifestName: string;
|
|
29
|
+
}>;
|
|
30
|
+
}): CommandRegistry;
|
|
31
|
+
//# sourceMappingURL=command-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/command-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEhF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;IACzB,WAAW,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;KAAE,CAAC,CAAA;IACrE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,iBAAiB,EAAE,CAAA;IAC7B,WAAW,EAAE,SAAS,OAAO,EAAE,CAAA;IAC/B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAA;IAChD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAAA;CAC3D;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,WAAW,EAAE,SAAS,OAAO,EAAE,CAAA;IAC/B,gBAAgB,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC,CAAA;IAC/E,cAAc,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,gBAAgB,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAClG,GAAG,eAAe,CA6ElB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const FLATTEN_PLUGIN_NAMES = new Set(['core']);
|
|
2
|
+
export function createCommandRegistry(input) {
|
|
3
|
+
const commands = [];
|
|
4
|
+
const byName = new Map();
|
|
5
|
+
for (const { pluginName, commands: pluginCmds, manifestName } of input.pluginCommands) {
|
|
6
|
+
if (pluginCmds.length === 0)
|
|
7
|
+
continue;
|
|
8
|
+
const flatten = FLATTEN_PLUGIN_NAMES.has(manifestName) ||
|
|
9
|
+
(pluginCmds.length === 1 && pluginCmds[0]?.name === manifestName);
|
|
10
|
+
if (flatten) {
|
|
11
|
+
for (const cmd of pluginCmds) {
|
|
12
|
+
const registered = {
|
|
13
|
+
name: cmd.name,
|
|
14
|
+
description: cmd.description ?? '',
|
|
15
|
+
flags: cmd.flags ?? [],
|
|
16
|
+
pluginFlags: [],
|
|
17
|
+
pluginName,
|
|
18
|
+
};
|
|
19
|
+
commands.push(registered);
|
|
20
|
+
byName.set(cmd.name, registered);
|
|
21
|
+
}
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const subcommands = pluginCmds.map((cmd) => ({
|
|
25
|
+
name: cmd.name,
|
|
26
|
+
description: cmd.description ?? '',
|
|
27
|
+
flags: cmd.flags ?? [],
|
|
28
|
+
pluginFlags: [],
|
|
29
|
+
pluginName,
|
|
30
|
+
}));
|
|
31
|
+
const registered = {
|
|
32
|
+
name: pluginName,
|
|
33
|
+
description: `Plugin: ${pluginName}`,
|
|
34
|
+
flags: [],
|
|
35
|
+
pluginFlags: [],
|
|
36
|
+
pluginName,
|
|
37
|
+
subcommands,
|
|
38
|
+
};
|
|
39
|
+
commands.push(registered);
|
|
40
|
+
byName.set(pluginName, registered);
|
|
41
|
+
}
|
|
42
|
+
for (const { pluginName, extensions } of input.pluginExtensions) {
|
|
43
|
+
for (const ext of extensions) {
|
|
44
|
+
const targets = Array.isArray(ext.command) ? ext.command : [ext.command];
|
|
45
|
+
for (const target of targets) {
|
|
46
|
+
const cmd = byName.get(target);
|
|
47
|
+
if (cmd) {
|
|
48
|
+
cmd.pluginFlags.push({ pluginName, flags: ext.flags });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
commands,
|
|
55
|
+
globalFlags: input.globalFlags,
|
|
56
|
+
get(name) {
|
|
57
|
+
return byName.get(name);
|
|
58
|
+
},
|
|
59
|
+
resolveFlags(name, subcommand) {
|
|
60
|
+
const cmd = byName.get(name);
|
|
61
|
+
if (!cmd)
|
|
62
|
+
return [...input.globalFlags];
|
|
63
|
+
let commandFlags = cmd.flags;
|
|
64
|
+
if (subcommand && cmd.subcommands) {
|
|
65
|
+
const sub = cmd.subcommands.find((s) => s.name === subcommand);
|
|
66
|
+
if (sub)
|
|
67
|
+
commandFlags = sub.flags;
|
|
68
|
+
}
|
|
69
|
+
const pluginFlagDefs = cmd.pluginFlags.flatMap((pf) => pf.flags);
|
|
70
|
+
return [...input.globalFlags, ...commandFlags, ...pluginFlagDefs];
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=command-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-registry.js","sourceRoot":"","sources":["../../src/runtime/command-registry.ts"],"names":[],"mappings":"AAkBA,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAE9C,MAAM,UAAU,qBAAqB,CAAC,KAIrC;IACC,MAAM,QAAQ,GAAwB,EAAE,CAAA;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAA;IAEnD,KAAK,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACtF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,SAAQ;QAErC,MAAM,OAAO,GACX,oBAAoB,CAAC,GAAG,CAAC,YAAY,CAAC;YACtC,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,YAAY,CAAC,CAAA;QAEnE,IAAI,OAAO,EAAE,CAAC;YACZ,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;gBAC7B,MAAM,UAAU,GAAsB;oBACpC,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE;oBAClC,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE;oBACtB,WAAW,EAAE,EAAE;oBACf,UAAU;iBACX,CAAA;gBACD,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACzB,MAAM,CAAC,GAAG,CAA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CAAC;IAED,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,GAAG,CAAC,IAAY;YACd,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;QACD,YAAY,CAAC,IAAY,EAAE,UAAmB;YAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAC5B,IAAI,CAAC,GAAG;gBAAE,OAAO,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAA;YAEvC,IAAI,YAAY,GAAG,GAAG,CAAC,KAAK,CAAA;YAC5B,IAAI,UAAU,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBAClC,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA;gBAC9D,IAAI,GAAG;oBAAE,YAAY,GAAG,GAAG,CAAC,KAAK,CAAA;YACnC,CAAC;YAED,MAAM,cAAc,GAAG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;YAChE,OAAO,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,YAAY,EAAE,GAAG,cAAc,CAAC,CAAA;QACnE,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ChxPluginRegistration, ChxUserConfig } from '@chkit/core';
|
|
2
|
+
export declare function pluginNameOf(reg: ChxPluginRegistration): string | undefined;
|
|
3
|
+
export declare function mergeUserConfig(base: ChxUserConfig, overlay: ChxUserConfig): ChxUserConfig;
|
|
4
|
+
//# sourceMappingURL=config-merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-merge.d.ts","sourceRoot":"","sources":["../../src/runtime/config-merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAErB,aAAa,EACd,MAAM,aAAa,CAAA;AAMpB,wBAAgB,YAAY,CAAC,GAAG,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAW3E;AA8CD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,aAAa,GACrB,aAAa,CAWf"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
function isObject(value) {
|
|
2
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
export function pluginNameOf(reg) {
|
|
5
|
+
if (!isObject(reg))
|
|
6
|
+
return undefined;
|
|
7
|
+
if (typeof reg.name === 'string' && reg.name.length > 0)
|
|
8
|
+
return reg.name;
|
|
9
|
+
const plugin = reg.plugin;
|
|
10
|
+
if (isObject(plugin)) {
|
|
11
|
+
const manifest = plugin.manifest;
|
|
12
|
+
if (isObject(manifest) && typeof manifest.name === 'string' && manifest.name.length > 0) {
|
|
13
|
+
return manifest.name;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
function mergePlugins(base, overlay) {
|
|
19
|
+
if (!base && !overlay)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (!base)
|
|
22
|
+
return overlay;
|
|
23
|
+
if (!overlay)
|
|
24
|
+
return base;
|
|
25
|
+
const overlayNames = new Set();
|
|
26
|
+
for (const reg of overlay) {
|
|
27
|
+
const name = pluginNameOf(reg);
|
|
28
|
+
if (name)
|
|
29
|
+
overlayNames.add(name);
|
|
30
|
+
}
|
|
31
|
+
const result = [];
|
|
32
|
+
for (const reg of base) {
|
|
33
|
+
const name = pluginNameOf(reg);
|
|
34
|
+
if (name && overlayNames.has(name))
|
|
35
|
+
continue;
|
|
36
|
+
result.push(reg);
|
|
37
|
+
}
|
|
38
|
+
for (const reg of overlay)
|
|
39
|
+
result.push(reg);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function mergeClickhouse(base, overlay) {
|
|
43
|
+
if (!base && !overlay)
|
|
44
|
+
return undefined;
|
|
45
|
+
if (!base)
|
|
46
|
+
return overlay;
|
|
47
|
+
if (!overlay)
|
|
48
|
+
return base;
|
|
49
|
+
return { ...base, ...overlay };
|
|
50
|
+
}
|
|
51
|
+
function mergeShallow(base, overlay) {
|
|
52
|
+
if (!base && !overlay)
|
|
53
|
+
return undefined;
|
|
54
|
+
if (!base)
|
|
55
|
+
return overlay;
|
|
56
|
+
if (!overlay)
|
|
57
|
+
return base;
|
|
58
|
+
return { ...base, ...overlay };
|
|
59
|
+
}
|
|
60
|
+
export function mergeUserConfig(base, overlay) {
|
|
61
|
+
return {
|
|
62
|
+
schema: overlay.schema ?? base.schema,
|
|
63
|
+
outDir: overlay.outDir ?? base.outDir,
|
|
64
|
+
migrationsDir: overlay.migrationsDir ?? base.migrationsDir,
|
|
65
|
+
metaDir: overlay.metaDir ?? base.metaDir,
|
|
66
|
+
plugins: mergePlugins(base.plugins, overlay.plugins),
|
|
67
|
+
check: mergeShallow(base.check, overlay.check),
|
|
68
|
+
safety: mergeShallow(base.safety, overlay.safety),
|
|
69
|
+
clickhouse: mergeClickhouse(base.clickhouse, overlay.clickhouse),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=config-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-merge.js","sourceRoot":"","sources":["../../src/runtime/config-merge.ts"],"names":[],"mappings":"AAMA,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAA0B;IACrD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IAC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U,EAAE,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;KACjE,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ChxConfigEnv, type ResolvedChxConfig } from '@chkit/core';
|
|
2
|
+
export declare const DEFAULT_CONFIG_FILE = "clickhouse.config.ts";
|
|
3
|
+
export type ConfigSource = 'project' | 'profile';
|
|
4
|
+
export interface LoadedConfig {
|
|
5
|
+
config: ResolvedChxConfig;
|
|
6
|
+
path: string;
|
|
7
|
+
source: ConfigSource;
|
|
8
|
+
profileLayered: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function loadConfig(configPathArg?: string, env?: ChxConfigEnv, options?: {
|
|
11
|
+
command?: string;
|
|
12
|
+
cwd?: string;
|
|
13
|
+
userConfigDir?: string;
|
|
14
|
+
allowSynthesizedProfileConfig?: boolean;
|
|
15
|
+
}): Promise<LoadedConfig>;
|
|
16
|
+
export declare function writeIfMissing(filePath: string, content: string): Promise<boolean>;
|
|
17
|
+
export declare function resolveDirs(config: ResolvedChxConfig): {
|
|
18
|
+
outDir: string;
|
|
19
|
+
migrationsDir: string;
|
|
20
|
+
metaDir: string;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/runtime/config.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,YAAY,EAKjB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAA;AAUpB,eAAO,MAAM,mBAAmB,yBAAyB,CAAA;AAEzD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,CAAA;AAGhD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,iBAAiB,CAAA;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,YAAY,CAAA;IACpB,cAAc,EAAE,OAAO,CAAA;CACxB;AAgBD,wBAAsB,UAAU,CAC9B,aAAa,CAAC,EAAE,MAAM,EACtB,GAAG,GAAE,YAAiB,EACtB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACnC,GACL,OAAO,CAAC,YAAY,CAAC,CA8CvB;AAuFD,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKxF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAKjH"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, resolve } from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { resolveConfig, SYNTHESIZED_CONFIG_PATH, } from '@chkit/core';
|
|
7
|
+
import { mergeUserConfig } from './config-merge.js';
|
|
8
|
+
import { debug } from './debug.js';
|
|
9
|
+
import { getUserConfigDir, USER_CREDENTIALS_FILE, USER_PROFILE_CONFIG_FILE, } from './user-config.js';
|
|
10
|
+
export const DEFAULT_CONFIG_FILE = 'clickhouse.config.ts';
|
|
11
|
+
function isConfigFunction(candidate) {
|
|
12
|
+
return typeof candidate === 'function';
|
|
13
|
+
}
|
|
14
|
+
export async function loadConfig(configPathArg, env = {}, options = {}) {
|
|
15
|
+
const cwd = options.cwd ?? process.cwd();
|
|
16
|
+
const userDir = options.userConfigDir ?? getUserConfigDir();
|
|
17
|
+
const projectPath = configPathArg
|
|
18
|
+
? resolve(cwd, configPathArg)
|
|
19
|
+
: resolve(cwd, DEFAULT_CONFIG_FILE);
|
|
20
|
+
if (configPathArg) {
|
|
21
|
+
debug('config', `resolving explicit config at ${projectPath}`);
|
|
22
|
+
if (!existsSync(projectPath)) {
|
|
23
|
+
throw new Error(`Config not found at ${projectPath}.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
debug('config', `looking for project config at ${projectPath}`);
|
|
28
|
+
}
|
|
29
|
+
const projectExists = existsSync(projectPath);
|
|
30
|
+
if (projectExists) {
|
|
31
|
+
const project = await readRawConfig(projectPath, env);
|
|
32
|
+
const layer = await readProfileLayer(userDir, env, options.allowSynthesizedProfileConfig);
|
|
33
|
+
if (layer) {
|
|
34
|
+
debug('config', `layering profile (${layer.source}, path=${layer.path}) under project`);
|
|
35
|
+
const merged = mergeUserConfig(layer.raw, project.raw);
|
|
36
|
+
return finalize(merged, project.path, 'project', true);
|
|
37
|
+
}
|
|
38
|
+
return finalize(project.raw, project.path, 'project', false);
|
|
39
|
+
}
|
|
40
|
+
const layer = await readProfileLayer(userDir, env, options.allowSynthesizedProfileConfig);
|
|
41
|
+
if (layer) {
|
|
42
|
+
return finalize(layer.raw, layer.path, layer.source, false);
|
|
43
|
+
}
|
|
44
|
+
if (options.command === 'query') {
|
|
45
|
+
throw new Error(`No project config found at ${projectPath}, and no ObsessionDB profile is available.\n` +
|
|
46
|
+
`Run 'chkit obsessiondb login' to query ObsessionDB from any directory, or run 'chkit init' in a project.`);
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Config not found at ${projectPath}.\n` +
|
|
49
|
+
`Either run 'chkit init' in your project, or run 'chkit obsessiondb login' to use chkit from any directory.`);
|
|
50
|
+
}
|
|
51
|
+
async function readRawConfig(configPath, env) {
|
|
52
|
+
const mod = await import(pathToFileURL(configPath).href);
|
|
53
|
+
const candidate = (mod.default ?? mod.config);
|
|
54
|
+
if (!candidate) {
|
|
55
|
+
throw new Error(`Config file ${configPath} must export a default/config object or a function via defineConfig.`);
|
|
56
|
+
}
|
|
57
|
+
const isFn = isConfigFunction(candidate);
|
|
58
|
+
debug('config', `config export is ${isFn ? 'function' : 'object'} (path=${configPath})`);
|
|
59
|
+
const raw = isFn ? await candidate(env) : candidate;
|
|
60
|
+
return { raw, path: configPath };
|
|
61
|
+
}
|
|
62
|
+
async function readProfileLayer(userDir, env, allowSynthesized) {
|
|
63
|
+
const profilePath = resolve(userDir, USER_PROFILE_CONFIG_FILE);
|
|
64
|
+
if (existsSync(profilePath)) {
|
|
65
|
+
debug('config', `found profile config at ${profilePath}`);
|
|
66
|
+
const { raw } = await readRawConfig(profilePath, env);
|
|
67
|
+
return { raw, path: profilePath, source: 'profile', origin: 'file' };
|
|
68
|
+
}
|
|
69
|
+
const credentialsPath = resolve(userDir, USER_CREDENTIALS_FILE);
|
|
70
|
+
if (existsSync(credentialsPath)) {
|
|
71
|
+
debug('config', `synthesizing profile layer from credentials at ${credentialsPath}`);
|
|
72
|
+
return synthesizedProfileLayer('credentials');
|
|
73
|
+
}
|
|
74
|
+
if (allowSynthesized) {
|
|
75
|
+
debug('config', 'synthesizing profile layer without existing credentials');
|
|
76
|
+
return synthesizedProfileLayer('synthetic');
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function finalize(raw, path, source, profileLayered) {
|
|
81
|
+
const config = resolveConfig(raw);
|
|
82
|
+
debug('config', `loaded (source=${source}, profileLayered=${profileLayered})`, {
|
|
83
|
+
schema: config.schema,
|
|
84
|
+
outDir: config.outDir,
|
|
85
|
+
migrationsDir: config.migrationsDir,
|
|
86
|
+
clickhouse: config.clickhouse
|
|
87
|
+
? `${config.clickhouse.url} (db: ${config.clickhouse.database ?? 'default'})`
|
|
88
|
+
: 'not configured',
|
|
89
|
+
plugins: (config.plugins ?? []).length,
|
|
90
|
+
});
|
|
91
|
+
return { config, path, source, profileLayered };
|
|
92
|
+
}
|
|
93
|
+
async function loadObsessionDBRegistration() {
|
|
94
|
+
try {
|
|
95
|
+
const mod = (await import('@chkit/plugin-obsessiondb'));
|
|
96
|
+
if (typeof mod.obsessiondb !== 'function') {
|
|
97
|
+
throw new Error('missing obsessiondb export');
|
|
98
|
+
}
|
|
99
|
+
return mod.obsessiondb();
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
103
|
+
throw new Error(`ObsessionDB profile fallback requires @chkit/plugin-obsessiondb, but it could not be loaded: ${message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function synthesizedProfileLayer(origin) {
|
|
107
|
+
const raw = {
|
|
108
|
+
schema: [],
|
|
109
|
+
plugins: [await loadObsessionDBRegistration()],
|
|
110
|
+
};
|
|
111
|
+
return { raw, path: SYNTHESIZED_CONFIG_PATH, source: 'profile', origin };
|
|
112
|
+
}
|
|
113
|
+
export async function writeIfMissing(filePath, content) {
|
|
114
|
+
if (existsSync(filePath))
|
|
115
|
+
return false;
|
|
116
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
117
|
+
await writeFile(filePath, content, 'utf8');
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
export function resolveDirs(config) {
|
|
121
|
+
const outDir = resolve(process.cwd(), config.outDir);
|
|
122
|
+
const migrationsDir = resolve(process.cwd(), config.migrationsDir);
|
|
123
|
+
const metaDir = resolve(process.cwd(), config.metaDir);
|
|
124
|
+
return { outDir, migrationsDir, metaDir };
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/runtime/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WA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ts","sourceRoot":"","sources":["../../src/runtime/debug.ts"],"names":[],"mappings":"AAIA,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAQ/E;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getLogger } from '@logtape/logtape';
|
|
2
|
+
import { isDebugEnabled } from './logging.js';
|
|
3
|
+
export function debug(category, message, detail) {
|
|
4
|
+
if (!isDebugEnabled())
|
|
5
|
+
return;
|
|
6
|
+
const logger = getLogger(['chkit', category]);
|
|
7
|
+
if (detail !== undefined) {
|
|
8
|
+
logger.debug(message, { detail });
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
logger.debug(message);
|
|
12
|
+
}
|
|
13
|
+
export { isDebugEnabled } from './logging.js';
|
|
14
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/runtime/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,OAAe,EAAE,MAAgB;IACvE,IAAI,CAAC,cAAc,EAAE;QAAE,OAAM;IAC7B,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC7C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QACjC,OAAM;IACR,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-config-path.d.ts","sourceRoot":"","sources":["../../src/runtime/extract-config-path.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAQpE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function extractConfigPath(argv) {
|
|
2
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
3
|
+
const token = argv[i];
|
|
4
|
+
if (token === '--')
|
|
5
|
+
return undefined;
|
|
6
|
+
if (token === '--config')
|
|
7
|
+
return argv[i + 1];
|
|
8
|
+
if (token?.startsWith('--config='))
|
|
9
|
+
return token.slice('--config='.length);
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=extract-config-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-config-path.js","sourceRoot":"","sources":["../../src/runtime/extract-config-path.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,IAAc;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACrB,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,SAAS,CAAA;QACpC,IAAI,KAAK,KAAK,UAAU;YAAE,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QAC5C,IAAI,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const GLOBAL_FLAGS: readonly [{
|
|
2
|
+
readonly name: "--config";
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly description: "Path to config file";
|
|
5
|
+
readonly placeholder: "<path>";
|
|
6
|
+
}, {
|
|
7
|
+
readonly name: "--json";
|
|
8
|
+
readonly type: "boolean";
|
|
9
|
+
readonly description: "Emit machine-readable JSON output";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "--table";
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly description: "Limit command scope to tables by exact name or trailing wildcard prefix";
|
|
14
|
+
readonly placeholder: "<selector>";
|
|
15
|
+
}];
|
|
16
|
+
//# sourceMappingURL=global-flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-flags.d.ts","sourceRoot":"","sources":["../../src/runtime/global-flags.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;EAId,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { defineFlags } from '@chkit/core';
|
|
2
|
+
export const GLOBAL_FLAGS = defineFlags([
|
|
3
|
+
{ name: '--config', type: 'string', description: 'Path to config file', placeholder: '<path>' },
|
|
4
|
+
{ name: '--json', type: 'boolean', description: 'Emit machine-readable JSON output' },
|
|
5
|
+
{ name: '--table', type: 'string', description: 'Limit command scope to tables by exact name or trailing wildcard prefix', placeholder: '<selector>' },
|
|
6
|
+
]);
|
|
7
|
+
//# sourceMappingURL=global-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-flags.js","sourceRoot":"","sources":["../../src/runtime/global-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;IACtC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE,WAAW,EAAE,QAAQ,EAAE;IAC/F,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,mCAAmC,EAAE;IACrF,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yEAAyE,EAAE,WAAW,EAAE,YAAY,EAAE;CAC9I,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FlagDef } from '../plugins.js';
|
|
2
|
+
import type { CommandRegistry, RegisteredCommand } from './command-registry.js';
|
|
3
|
+
export declare function formatGlobalHelp(registry: CommandRegistry, version: string): string;
|
|
4
|
+
export declare function formatCommandHelp(command: RegisteredCommand, globalFlags: readonly FlagDef[]): string;
|
|
5
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/runtime/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAE/E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CA0CnF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAuCrG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export function formatGlobalHelp(registry, version) {
|
|
2
|
+
const lines = [];
|
|
3
|
+
lines.push(`chkit v${version} - ClickHouse toolkit`);
|
|
4
|
+
lines.push('');
|
|
5
|
+
lines.push('Usage:');
|
|
6
|
+
lines.push(' chkit <command> [options]');
|
|
7
|
+
lines.push('');
|
|
8
|
+
lines.push('Commands:');
|
|
9
|
+
lines.push(` ${'init'.padEnd(14)} Scaffold a new project with config and example schema`);
|
|
10
|
+
const coreCommands = registry.commands.filter((c) => c.pluginName === 'core');
|
|
11
|
+
const pluginCommands = registry.commands.filter((c) => c.pluginName !== 'core');
|
|
12
|
+
for (const cmd of coreCommands) {
|
|
13
|
+
lines.push(` ${cmd.name.padEnd(14)} ${cmd.description}`);
|
|
14
|
+
}
|
|
15
|
+
if (pluginCommands.length > 0) {
|
|
16
|
+
lines.push('');
|
|
17
|
+
lines.push('Plugin commands:');
|
|
18
|
+
for (const cmd of pluginCommands) {
|
|
19
|
+
if (cmd.subcommands) {
|
|
20
|
+
lines.push(` ${cmd.name.padEnd(14)} ${cmd.description}`);
|
|
21
|
+
for (const sub of cmd.subcommands) {
|
|
22
|
+
lines.push(` ${sub.name.padEnd(12)} ${sub.description}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
lines.push(` ${cmd.name.padEnd(14)} ${cmd.description}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
lines.push('');
|
|
31
|
+
lines.push('Global options:');
|
|
32
|
+
for (const flag of registry.globalFlags) {
|
|
33
|
+
lines.push(formatFlagLine(flag));
|
|
34
|
+
}
|
|
35
|
+
lines.push(formatFlagLine({ name: '-h, --help', type: 'boolean', description: 'Show help' }));
|
|
36
|
+
lines.push(formatFlagLine({ name: '-v, --version', type: 'boolean', description: 'Show version' }));
|
|
37
|
+
return lines.join('\n');
|
|
38
|
+
}
|
|
39
|
+
export function formatCommandHelp(command, globalFlags) {
|
|
40
|
+
const lines = [];
|
|
41
|
+
if (command.subcommands) {
|
|
42
|
+
lines.push(`chkit ${command.name} <command> [options]`);
|
|
43
|
+
lines.push(` ${command.description}`);
|
|
44
|
+
lines.push('');
|
|
45
|
+
lines.push('Commands:');
|
|
46
|
+
for (const sub of command.subcommands) {
|
|
47
|
+
lines.push(` ${sub.name.padEnd(14)} ${sub.description}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
lines.push(`chkit ${command.name} [options]`);
|
|
52
|
+
lines.push(` ${command.description}`);
|
|
53
|
+
}
|
|
54
|
+
if (command.flags.length > 0) {
|
|
55
|
+
lines.push('');
|
|
56
|
+
lines.push('Options:');
|
|
57
|
+
for (const flag of command.flags) {
|
|
58
|
+
lines.push(formatFlagLine(flag));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const pf of command.pluginFlags) {
|
|
62
|
+
lines.push('');
|
|
63
|
+
lines.push(`Plugin: ${pf.pluginName}`);
|
|
64
|
+
for (const flag of pf.flags) {
|
|
65
|
+
lines.push(formatFlagLine(flag));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
lines.push('');
|
|
69
|
+
lines.push('Global options:');
|
|
70
|
+
for (const flag of globalFlags) {
|
|
71
|
+
lines.push(formatFlagLine(flag));
|
|
72
|
+
}
|
|
73
|
+
return lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
function formatFlagLine(flag) {
|
|
76
|
+
const nameStr = flag.name ?? '';
|
|
77
|
+
const placeholder = flag.placeholder ? ` ${flag.placeholder}` : '';
|
|
78
|
+
const label = `${nameStr}${placeholder}`;
|
|
79
|
+
if (label.length >= 22) {
|
|
80
|
+
return ` ${label}\n${''.padEnd(24)}${flag.description}`;
|
|
81
|
+
}
|
|
82
|
+
return ` ${label.padEnd(22)} ${flag.description}`;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/runtime/help.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,OAAe;IACzE,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,CAAC,IAAI,CAAC,UAAU,OAAO,uBAAuB,CAAC,CAAA;IACpD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACd,KAAK,CAAC,IAAI,CAAC,QAAQ,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AI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED,SAAS,cAAc,CAAC,IAAiC;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAA;IAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAClE,MAAM,KAAK,GAAG,GAAG,OAAO,GAAG,WAAW,EAAE,CAAA;IACxC,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QACvB,OAAO,KAAK,KAAK,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IAC1D,CAAC;IACD,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ClickHouseExecutor } from '@chkit/clickhouse';
|
|
2
|
+
import type { MigrationJournal, MigrationJournalEntry } from './migration-store.js';
|
|
3
|
+
interface JournalStore {
|
|
4
|
+
readJournal(): Promise<MigrationJournal>;
|
|
5
|
+
appendEntry(entry: MigrationJournalEntry): Promise<void>;
|
|
6
|
+
readonly databaseMissing: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createJournalStore(db: ClickHouseExecutor): JournalStore;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=journal-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal-store.d.ts","sourceRoot":"","sources":["../../src/runtime/journal-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAInF,UAAU,YAAY;IACpB,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACxC,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AA4BD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,GAAG,YAAY,CAkHvE"}
|