UNPKG

route-claudecode

Version:

Advanced routing and transformation system for Claude Code outputs to multiple AI providers

83 lines 3.06 kB
"use strict"; /** * Configuration Path Management * Handles priority-based configuration path resolution * Project owner: Jason Zhang */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getConfigPaths = getConfigPaths; exports.needsMigration = needsMigration; exports.getLegacyConfigPaths = getLegacyConfigPaths; exports.getNewConfigPaths = getNewConfigPaths; const fs_1 = require("fs"); const path_1 = require("path"); const os_1 = require("os"); /** * Get configuration paths with priority order: * 1. ~/.route-claude-code/ (new preferred path) * 2. ~/.claude-code-router/ (legacy path) */ function getConfigPaths() { const homeDir = (0, os_1.homedir)(); // New preferred path const newConfigDir = (0, path_1.join)(homeDir, '.route-claude-code'); const newConfigExists = (0, fs_1.existsSync)(newConfigDir); // Legacy path const legacyConfigDir = (0, path_1.join)(homeDir, '.claude-code-router'); const legacyConfigExists = (0, fs_1.existsSync)(legacyConfigDir); // Priority: new path if exists, otherwise legacy, otherwise create new const configDir = newConfigExists ? newConfigDir : legacyConfigExists ? legacyConfigDir : newConfigDir; // Ensure config directory exists if (!(0, fs_1.existsSync)(configDir)) { (0, fs_1.mkdirSync)(configDir, { recursive: true }); } // Ensure logs directory exists const logsDir = (0, path_1.join)(configDir, 'logs'); if (!(0, fs_1.existsSync)(logsDir)) { (0, fs_1.mkdirSync)(logsDir, { recursive: true }); } return { configDir, configFile: (0, path_1.join)(configDir, 'config.json'), logsDir, releaseConfigFile: (0, path_1.join)(configDir, 'config.release.json') }; } /** * Check if migration is needed from legacy to new path */ function needsMigration() { const homeDir = (0, os_1.homedir)(); const newConfigDir = (0, path_1.join)(homeDir, '.route-claude-code'); const legacyConfigDir = (0, path_1.join)(homeDir, '.claude-code-router'); return (0, fs_1.existsSync)(legacyConfigDir) && !(0, fs_1.existsSync)(newConfigDir); } /** * Get legacy configuration paths for migration */ function getLegacyConfigPaths() { const homeDir = (0, os_1.homedir)(); const configDir = (0, path_1.join)(homeDir, '.claude-code-router'); return { configDir, configFile: (0, path_1.join)(configDir, 'config.json'), logsDir: (0, path_1.join)(configDir, 'logs'), releaseConfigFile: (0, path_1.join)(configDir, 'config.release.json') }; } /** * Get new configuration paths for migration */ function getNewConfigPaths() { const homeDir = (0, os_1.homedir)(); const configDir = (0, path_1.join)(homeDir, '.route-claude-code'); return { configDir, configFile: (0, path_1.join)(configDir, 'config.json'), logsDir: (0, path_1.join)(configDir, 'logs'), releaseConfigFile: (0, path_1.join)(configDir, 'config.release.json') }; } //# sourceMappingURL=config-paths.js.map