Skip to content

Commit b486a4e

Browse files
author
Dataflow Dev
committed
fix: break 3-file import cycle in cli/project-files
project-files.ts -> auth.ts -> logger.ts -> project-files.ts Import getConfigDir directly from config-dir instead of auth to break the circular dependency. config-dir.ts exports the identical function (auth.ts just wraps it). anonymous-id.ts already imports from config-dir directly. Add getProjectDataDir tests to exercise the fixed import path.
1 parent 1c6346c commit b486a4e

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

cli/src/__tests__/project-files-chat-id.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
getCurrentChatId,
99
setCurrentChatId,
1010
startNewChat,
11+
setProjectRoot,
12+
getProjectDataDir,
1113
} from '../project-files'
1214

1315
describe('chat id lifecycle', () => {
@@ -32,3 +34,19 @@ describe('chat id lifecycle', () => {
3234
expect(rotated).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.\d{3}Z$/)
3335
})
3436
})
37+
38+
describe('getProjectDataDir', () => {
39+
test('returns a path containing the project basename', () => {
40+
setProjectRoot('/tmp/my-project')
41+
const dataDir = getProjectDataDir()
42+
expect(dataDir).toContain('my-project')
43+
expect(dataDir).toContain('projects')
44+
})
45+
46+
test('uses config-dir getConfigDir (not auth re-export)', () => {
47+
setProjectRoot('/tmp/test-repo')
48+
const dataDir = getProjectDataDir()
49+
// Should resolve via ~/.config/manicode* without pulling in auth.ts
50+
expect(dataDir).toMatch(/\.config\/manicode/)
51+
})
52+
})

cli/src/project-files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mkdirSync, readdirSync, statSync } from 'fs'
22
import path from 'path'
33

4-
import { getConfigDir } from './utils/auth'
4+
import { getConfigDir } from './utils/config-dir'
55

66
let projectRoot: string | undefined
77
let currentChatId: string | undefined

0 commit comments

Comments
 (0)