Project Files
src / paths.ts
import fs from "fs";
import os from "os";
import path from "path";
export function drawThingsIndexDataPath(...segments: string[]): string {
return path.join(os.homedir(), ".draw-things-index", ...segments);
}
export function legacyPluginDataPath(...segments: string[]): string {
return path.join(process.cwd(), "data", ...segments);
}
export function migrateLegacyFileIfMissing(targetPath: string, legacyPath: string): void {
if (fs.existsSync(targetPath) || !fs.existsSync(legacyPath)) return;
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
try {
fs.copyFileSync(legacyPath, targetPath, fs.constants.COPYFILE_EXCL);
console.log(`[paths] Migrated legacy data file: ${legacyPath} -> ${targetPath}`);
} catch (error) {
console.warn(`[paths] Could not migrate legacy data file from ${legacyPath} to ${targetPath}:`, error);
}
}