Skip to content

Commit fc81d4e

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 fc81d4e

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
getCurrentChatId,
99
setCurrentChatId,
1010
startNewChat,
11+
setProjectRoot,
12+
getProjectDataDir,
1113
} from '../project-files'
14+
import { getConfigDir } from '../utils/config-dir'
1215

1316
describe('chat id lifecycle', () => {
1417
test('getCurrentChatId is stable across calls', () => {
@@ -32,3 +35,20 @@ describe('chat id lifecycle', () => {
3235
expect(rotated).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.\d{3}Z$/)
3336
})
3437
})
38+
39+
describe('getProjectDataDir', () => {
40+
test('returns a path containing the project basename', () => {
41+
setProjectRoot('/tmp/my-project')
42+
const dataDir = getProjectDataDir()
43+
expect(dataDir).toContain('my-project')
44+
expect(dataDir).toContain('projects')
45+
})
46+
47+
test('uses config-dir getConfigDir (not auth re-export)', () => {
48+
setProjectRoot('/tmp/test-repo')
49+
const dataDir = getProjectDataDir()
50+
// Should resolve via config-dir's getConfigDir without pulling in auth.ts
51+
const configDir = getConfigDir()
52+
expect(dataDir).toContain(configDir)
53+
})
54+
})

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)