refactor: split config module

This commit is contained in:
Peter Steinberger
2026-01-04 07:05:04 +01:00
parent 5e36e2c3f3
commit c9504a6f20
16 changed files with 2236 additions and 2082 deletions

View File

@@ -0,0 +1,19 @@
import { applyLegacyMigrations } from "./legacy.js";
import type { ClawdisConfig } from "./types.js";
import { validateConfigObject } from "./validation.js";
export function migrateLegacyConfig(raw: unknown): {
config: ClawdisConfig | null;
changes: string[];
} {
const { next, changes } = applyLegacyMigrations(raw);
if (!next) return { config: null, changes: [] };
const validated = validateConfigObject(next);
if (!validated.ok) {
changes.push(
"Migration applied, but config still invalid; fix remaining issues manually.",
);
return { config: null, changes };
}
return { config: validated.config, changes };
}