Project Files
src / paths.ts
import fs from "fs";
import os from "os";
import path from "path";
export function userDocsHomePath(...segments: string[]): string {
return path.join(os.homedir(), ".user-docs", ...segments);
}
export function legacyPluginPath(...segments: string[]): string {
return path.join(process.cwd(), ...segments);
}
export function migrateLegacyPathIfMissing(targetPath: string, legacyPath: string): void {
if (fs.existsSync(targetPath) || !fs.existsSync(legacyPath)) return;
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
try {
fs.cpSync(legacyPath, targetPath, { recursive: true, force: false, errorOnExist: true });
console.log(`[paths] Migrated legacy data: ${legacyPath} -> ${targetPath}`);
} catch (error) {
console.warn(`[paths] Could not migrate legacy data from ${legacyPath} to ${targetPath}:`, error);
}
}