fix(standalone): respect CLAUDE_ROOT for config path
This commit is contained in:
parent
92dbae84ec
commit
f97d9c6e2c
3 changed files with 44 additions and 6 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
* - Handle JSON parse errors gracefully
|
* - Handle JSON parse errors gracefully
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getHomeDir, setClaudeBasePathOverride } from '@main/utils/pathDecoder';
|
import { getClaudeBasePath, setClaudeBasePathOverride } from '@main/utils/pathDecoder';
|
||||||
import { validateRegexPattern } from '@main/utils/regexValidation';
|
import { validateRegexPattern } from '@main/utils/regexValidation';
|
||||||
import { createLogger } from '@shared/utils/logger';
|
import { createLogger } from '@shared/utils/logger';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
@ -23,9 +23,11 @@ import type { SshConnectionProfile } from '@shared/types/api';
|
||||||
|
|
||||||
const logger = createLogger('Service:ConfigManager');
|
const logger = createLogger('Service:ConfigManager');
|
||||||
|
|
||||||
const CONFIG_DIR = path.join(getHomeDir(), '.claude');
|
|
||||||
const CONFIG_FILENAME = 'claude-devtools-config.json';
|
const CONFIG_FILENAME = 'claude-devtools-config.json';
|
||||||
const DEFAULT_CONFIG_PATH = path.join(CONFIG_DIR, CONFIG_FILENAME);
|
|
||||||
|
function getDefaultConfigPath(): string {
|
||||||
|
return path.join(getClaudeBasePath(), CONFIG_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// Types
|
// Types
|
||||||
|
|
@ -377,7 +379,7 @@ export class ConfigManager {
|
||||||
private triggerManager: TriggerManager;
|
private triggerManager: TriggerManager;
|
||||||
|
|
||||||
constructor(configPath?: string) {
|
constructor(configPath?: string) {
|
||||||
this.configPath = configPath ?? DEFAULT_CONFIG_PATH;
|
this.configPath = configPath ?? getDefaultConfigPath();
|
||||||
this.config = this.loadConfig();
|
this.config = this.loadConfig();
|
||||||
setClaudeBasePathOverride(this.config.general.claudeRootPath);
|
setClaudeBasePathOverride(this.config.general.claudeRootPath);
|
||||||
this.triggerManager = new TriggerManager(this.config.notifications.triggers, () =>
|
this.triggerManager = new TriggerManager(this.config.notifications.triggers, () =>
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,17 @@
|
||||||
|
|
||||||
import { createLogger } from '@shared/utils/logger';
|
import { createLogger } from '@shared/utils/logger';
|
||||||
|
|
||||||
import { HttpServer } from './services/infrastructure/HttpServer';
|
|
||||||
import {
|
import {
|
||||||
getProjectsBasePath,
|
getProjectsBasePath,
|
||||||
getTodosBasePath,
|
getTodosBasePath,
|
||||||
setClaudeBasePathOverride,
|
setClaudeBasePathOverride,
|
||||||
} from './utils/pathDecoder';
|
} from './utils/pathDecoder';
|
||||||
import { LocalFileSystemProvider, NotificationManager, ServiceContext } from './services';
|
import { LocalFileSystemProvider } from './services/infrastructure/LocalFileSystemProvider';
|
||||||
|
|
||||||
import type { HttpServices } from './http';
|
import type { HttpServices } from './http';
|
||||||
|
import type { HttpServer } from './services/infrastructure/HttpServer';
|
||||||
|
import type { NotificationManager } from './services/infrastructure/NotificationManager';
|
||||||
|
import type { ServiceContext } from './services/infrastructure/ServiceContext';
|
||||||
import type { SshConnectionManager } from './services/infrastructure/SshConnectionManager';
|
import type { SshConnectionManager } from './services/infrastructure/SshConnectionManager';
|
||||||
import type { UpdaterService } from './services/infrastructure/UpdaterService';
|
import type { UpdaterService } from './services/infrastructure/UpdaterService';
|
||||||
|
|
||||||
|
|
@ -99,6 +101,13 @@ async function start(): Promise<void> {
|
||||||
logger.info(`Using CLAUDE_ROOT: ${CLAUDE_ROOT}`);
|
logger.info(`Using CLAUDE_ROOT: ${CLAUDE_ROOT}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Import services after applying CLAUDE_ROOT so ConfigManager picks up the correct base path.
|
||||||
|
const [{ HttpServer }, { NotificationManager }, { ServiceContext }] = await Promise.all([
|
||||||
|
import('./services/infrastructure/HttpServer'),
|
||||||
|
import('./services/infrastructure/NotificationManager'),
|
||||||
|
import('./services/infrastructure/ServiceContext'),
|
||||||
|
]);
|
||||||
|
|
||||||
const projectsDir = getProjectsBasePath();
|
const projectsDir = getProjectsBasePath();
|
||||||
const todosDir = getTodosBasePath();
|
const todosDir = getTodosBasePath();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import * as os from 'os';
|
||||||
|
import * as path from 'path';
|
||||||
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
describe('ConfigManager CLAUDE_ROOT support', () => {
|
||||||
|
afterEach(async () => {
|
||||||
|
vi.resetModules();
|
||||||
|
const pathDecoder = await import('../../../../src/main/utils/pathDecoder');
|
||||||
|
pathDecoder.setClaudeBasePathOverride(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('resolves the default config path from the current Claude base path override', async () => {
|
||||||
|
vi.resetModules();
|
||||||
|
|
||||||
|
const overrideRoot = path.join(os.tmpdir(), 'claude-root-test');
|
||||||
|
const pathDecoder = await import('../../../../src/main/utils/pathDecoder');
|
||||||
|
pathDecoder.setClaudeBasePathOverride(overrideRoot);
|
||||||
|
|
||||||
|
const { configManager } = await import(
|
||||||
|
'../../../../src/main/services/infrastructure/ConfigManager'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(configManager.getConfigPath()).toBe(
|
||||||
|
path.join(overrideRoot, 'claude-devtools-config.json')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue