ucn 3.1.6 → 3.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ucn might be problematic. Click here for more details.
- package/core/discovery.js +1 -1
- package/core/project.js +9 -0
- package/package.json +1 -1
- package/test/parser.test.js +24 -0
package/core/discovery.js
CHANGED
|
@@ -371,7 +371,7 @@ function detectProjectPattern(projectRoot) {
|
|
|
371
371
|
const entries = fs.readdirSync(projectRoot, { withFileTypes: true });
|
|
372
372
|
for (const entry of entries) {
|
|
373
373
|
if (entry.isDirectory() && !entry.name.startsWith('.') &&
|
|
374
|
-
!
|
|
374
|
+
!shouldIgnore(entry.name, DEFAULT_IGNORES)) {
|
|
375
375
|
checkDir(path.join(projectRoot, entry.name));
|
|
376
376
|
}
|
|
377
377
|
}
|
package/core/project.js
CHANGED
|
@@ -14,6 +14,9 @@ const { parseFile } = require('./parser');
|
|
|
14
14
|
const { detectLanguage, getParser, getLanguageModule, PARSE_OPTIONS } = require('../languages');
|
|
15
15
|
const { getTokenTypeAtPosition } = require('../languages/utils');
|
|
16
16
|
|
|
17
|
+
// Read UCN version for cache invalidation
|
|
18
|
+
const UCN_VERSION = require('../package.json').version;
|
|
19
|
+
|
|
17
20
|
/**
|
|
18
21
|
* Escape special regex characters
|
|
19
22
|
*/
|
|
@@ -3317,6 +3320,7 @@ class ProjectIndex {
|
|
|
3317
3320
|
|
|
3318
3321
|
const cacheData = {
|
|
3319
3322
|
version: 4, // v4: className, memberType, isMethod for all languages
|
|
3323
|
+
ucnVersion: UCN_VERSION, // Invalidate cache when UCN is updated
|
|
3320
3324
|
root: this.root,
|
|
3321
3325
|
buildTime: this.buildTime,
|
|
3322
3326
|
timestamp: Date.now(),
|
|
@@ -3356,6 +3360,11 @@ class ProjectIndex {
|
|
|
3356
3360
|
return false;
|
|
3357
3361
|
}
|
|
3358
3362
|
|
|
3363
|
+
// Invalidate cache when UCN version changes (logic may have changed)
|
|
3364
|
+
if (cacheData.ucnVersion !== UCN_VERSION) {
|
|
3365
|
+
return false;
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3359
3368
|
// Validate cache structure has required fields
|
|
3360
3369
|
if (!Array.isArray(cacheData.files) ||
|
|
3361
3370
|
!Array.isArray(cacheData.symbols) ||
|
package/package.json
CHANGED
package/test/parser.test.js
CHANGED
|
@@ -2881,6 +2881,30 @@ describe('Regression: Project detection with language markers', () => {
|
|
|
2881
2881
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
2882
2882
|
}
|
|
2883
2883
|
});
|
|
2884
|
+
|
|
2885
|
+
it('should detect multi-language project (Go root + TS subdirectory)', () => {
|
|
2886
|
+
const tmpDir = path.join(require('os').tmpdir(), `ucn-test-multilang-${Date.now()}`);
|
|
2887
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
2888
|
+
fs.mkdirSync(path.join(tmpDir, 'web'), { recursive: true });
|
|
2889
|
+
|
|
2890
|
+
try {
|
|
2891
|
+
// Go at root
|
|
2892
|
+
fs.writeFileSync(path.join(tmpDir, 'go.mod'), 'module test\ngo 1.21');
|
|
2893
|
+
fs.writeFileSync(path.join(tmpDir, 'main.go'), 'package main\nfunc main() {}');
|
|
2894
|
+
// TypeScript in web/ subdirectory
|
|
2895
|
+
fs.writeFileSync(path.join(tmpDir, 'web', 'package.json'), '{"name": "web"}');
|
|
2896
|
+
fs.writeFileSync(path.join(tmpDir, 'web', 'App.tsx'), 'export function App() {}');
|
|
2897
|
+
|
|
2898
|
+
const { detectProjectPattern } = require('../core/discovery');
|
|
2899
|
+
const pattern = detectProjectPattern(tmpDir);
|
|
2900
|
+
|
|
2901
|
+
// Should detect BOTH Go and TypeScript
|
|
2902
|
+
assert.ok(pattern.includes('go'), 'Should detect Go files from root');
|
|
2903
|
+
assert.ok(pattern.includes('tsx'), 'Should detect TypeScript files from subdirectory');
|
|
2904
|
+
} finally {
|
|
2905
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2884
2908
|
});
|
|
2885
2909
|
|
|
2886
2910
|
// ============================================================================
|