Skip to content

Commit f2084d7

Browse files
committed
walk nested fallback dependencies
1 parent 7644c5f commit f2084d7

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

packages/intent/src/discovery/walk.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ export function createDependencyWalker(opts: CreateDependencyWalkerOptions) {
123123
nodeModulesDir,
124124
opts.getFsIdentity,
125125
)) {
126-
opts.tryRegister(dirPath, 'unknown')
126+
if (!opts.tryRegister(dirPath, 'unknown')) continue
127+
128+
const pkgJson = opts.readPkgJson(dirPath)
129+
const pkgName = typeof pkgJson?.name === 'string' ? pkgJson.name : 'unknown'
130+
walkDeps(dirPath, pkgName)
127131
}
128132
}
129133

packages/intent/tests/scanner.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,12 +1288,30 @@ describe('scanForIntents', () => {
12881288
writeJson(join(skillPkgDir, 'package.json'), {
12891289
name: '@tanstack/query',
12901290
version: '5.0.0',
1291+
dependencies: {
1292+
'@tanstack/store': '1.0.0',
1293+
},
12911294
intent: { version: 1, repo: 'TanStack/query', docs: 'docs/' },
12921295
})
12931296
writeSkillMd(createDir(skillPkgDir, 'skills', 'fetching'), {
12941297
name: 'fetching',
12951298
description: 'Query fetching skill',
12961299
})
1300+
const transitiveSkillPkgDir = createDir(
1301+
skillPkgDir,
1302+
'node_modules',
1303+
'@tanstack',
1304+
'store',
1305+
)
1306+
writeJson(join(transitiveSkillPkgDir, 'package.json'), {
1307+
name: '@tanstack/store',
1308+
version: '1.0.0',
1309+
intent: { version: 1, repo: 'TanStack/store', docs: 'docs/' },
1310+
})
1311+
writeSkillMd(createDir(transitiveSkillPkgDir, 'skills', 'store'), {
1312+
name: 'store',
1313+
description: 'Store skill',
1314+
})
12971315

12981316
createDir(wrapperDir, 'node_modules', '@tanstack')
12991317
symlinkSync(
@@ -1309,8 +1327,10 @@ describe('scanForIntents', () => {
13091327

13101328
const result = scanForIntents(root)
13111329

1312-
expect(result.packages).toHaveLength(1)
1313-
expect(result.packages[0]!.name).toBe('@tanstack/query')
1330+
expect(result.packages.map((pkg) => pkg.name).sort()).toEqual([
1331+
'@tanstack/query',
1332+
'@tanstack/store',
1333+
])
13141334
expect(result.stats!.packageJsonReadCount).toBeLessThan(10)
13151335
})
13161336

0 commit comments

Comments
 (0)