driftdetect-core 0.1.0
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.
- package/dist/analyzers/ast-analyzer.d.ts +251 -0
- package/dist/analyzers/ast-analyzer.d.ts.map +1 -0
- package/dist/analyzers/ast-analyzer.js +548 -0
- package/dist/analyzers/ast-analyzer.js.map +1 -0
- package/dist/analyzers/flow-analyzer.d.ts +241 -0
- package/dist/analyzers/flow-analyzer.d.ts.map +1 -0
- package/dist/analyzers/flow-analyzer.js +1219 -0
- package/dist/analyzers/flow-analyzer.js.map +1 -0
- package/dist/analyzers/index.d.ts +18 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +19 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/semantic-analyzer.d.ts +252 -0
- package/dist/analyzers/semantic-analyzer.d.ts.map +1 -0
- package/dist/analyzers/semantic-analyzer.js +1182 -0
- package/dist/analyzers/semantic-analyzer.js.map +1 -0
- package/dist/analyzers/type-analyzer.d.ts +289 -0
- package/dist/analyzers/type-analyzer.d.ts.map +1 -0
- package/dist/analyzers/type-analyzer.js +1269 -0
- package/dist/analyzers/type-analyzer.js.map +1 -0
- package/dist/analyzers/types.d.ts +537 -0
- package/dist/analyzers/types.d.ts.map +1 -0
- package/dist/analyzers/types.js +11 -0
- package/dist/analyzers/types.js.map +1 -0
- package/dist/config/config-loader.d.ts +166 -0
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/config/config-loader.js +429 -0
- package/dist/config/config-loader.js.map +1 -0
- package/dist/config/config-validator.d.ts +204 -0
- package/dist/config/config-validator.d.ts.map +1 -0
- package/dist/config/config-validator.js +632 -0
- package/dist/config/config-validator.js.map +1 -0
- package/dist/config/defaults.d.ts +8 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +26 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +10 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +47 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest/exporter.d.ts +21 -0
- package/dist/manifest/exporter.d.ts.map +1 -0
- package/dist/manifest/exporter.js +339 -0
- package/dist/manifest/exporter.js.map +1 -0
- package/dist/manifest/index.d.ts +14 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +15 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/manifest-store.d.ts +111 -0
- package/dist/manifest/manifest-store.d.ts.map +1 -0
- package/dist/manifest/manifest-store.js +418 -0
- package/dist/manifest/manifest-store.js.map +1 -0
- package/dist/manifest/types.d.ts +238 -0
- package/dist/manifest/types.d.ts.map +1 -0
- package/dist/manifest/types.js +11 -0
- package/dist/manifest/types.js.map +1 -0
- package/dist/matcher/confidence-scorer.d.ts +188 -0
- package/dist/matcher/confidence-scorer.d.ts.map +1 -0
- package/dist/matcher/confidence-scorer.js +302 -0
- package/dist/matcher/confidence-scorer.js.map +1 -0
- package/dist/matcher/index.d.ts +24 -0
- package/dist/matcher/index.d.ts.map +1 -0
- package/dist/matcher/index.js +26 -0
- package/dist/matcher/index.js.map +1 -0
- package/dist/matcher/outlier-detector.d.ts +252 -0
- package/dist/matcher/outlier-detector.d.ts.map +1 -0
- package/dist/matcher/outlier-detector.js +544 -0
- package/dist/matcher/outlier-detector.js.map +1 -0
- package/dist/matcher/pattern-matcher.d.ts +169 -0
- package/dist/matcher/pattern-matcher.d.ts.map +1 -0
- package/dist/matcher/pattern-matcher.js +692 -0
- package/dist/matcher/pattern-matcher.js.map +1 -0
- package/dist/matcher/types.d.ts +476 -0
- package/dist/matcher/types.d.ts.map +1 -0
- package/dist/matcher/types.js +36 -0
- package/dist/matcher/types.js.map +1 -0
- package/dist/parsers/base-parser.d.ts +282 -0
- package/dist/parsers/base-parser.d.ts.map +1 -0
- package/dist/parsers/base-parser.js +421 -0
- package/dist/parsers/base-parser.js.map +1 -0
- package/dist/parsers/css-parser.d.ts +225 -0
- package/dist/parsers/css-parser.d.ts.map +1 -0
- package/dist/parsers/css-parser.js +477 -0
- package/dist/parsers/css-parser.js.map +1 -0
- package/dist/parsers/index.d.ts +15 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +15 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/json-parser.d.ts +219 -0
- package/dist/parsers/json-parser.d.ts.map +1 -0
- package/dist/parsers/json-parser.js +602 -0
- package/dist/parsers/json-parser.js.map +1 -0
- package/dist/parsers/markdown-parser.d.ts +276 -0
- package/dist/parsers/markdown-parser.d.ts.map +1 -0
- package/dist/parsers/markdown-parser.js +731 -0
- package/dist/parsers/markdown-parser.js.map +1 -0
- package/dist/parsers/parser-manager.d.ts +294 -0
- package/dist/parsers/parser-manager.d.ts.map +1 -0
- package/dist/parsers/parser-manager.js +738 -0
- package/dist/parsers/parser-manager.js.map +1 -0
- package/dist/parsers/python-parser.d.ts +204 -0
- package/dist/parsers/python-parser.d.ts.map +1 -0
- package/dist/parsers/python-parser.js +517 -0
- package/dist/parsers/python-parser.js.map +1 -0
- package/dist/parsers/types.d.ts +43 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/types.js +7 -0
- package/dist/parsers/types.js.map +1 -0
- package/dist/parsers/typescript-parser.d.ts +264 -0
- package/dist/parsers/typescript-parser.d.ts.map +1 -0
- package/dist/parsers/typescript-parser.js +658 -0
- package/dist/parsers/typescript-parser.js.map +1 -0
- package/dist/rules/evaluator.d.ts +305 -0
- package/dist/rules/evaluator.d.ts.map +1 -0
- package/dist/rules/evaluator.js +579 -0
- package/dist/rules/evaluator.js.map +1 -0
- package/dist/rules/index.d.ts +13 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +13 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/quick-fix-generator.d.ts +334 -0
- package/dist/rules/quick-fix-generator.d.ts.map +1 -0
- package/dist/rules/quick-fix-generator.js +1075 -0
- package/dist/rules/quick-fix-generator.js.map +1 -0
- package/dist/rules/rule-engine.d.ts +241 -0
- package/dist/rules/rule-engine.d.ts.map +1 -0
- package/dist/rules/rule-engine.js +585 -0
- package/dist/rules/rule-engine.js.map +1 -0
- package/dist/rules/severity-manager.d.ts +394 -0
- package/dist/rules/severity-manager.d.ts.map +1 -0
- package/dist/rules/severity-manager.js +619 -0
- package/dist/rules/severity-manager.js.map +1 -0
- package/dist/rules/types.d.ts +370 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +133 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/variant-manager.d.ts +388 -0
- package/dist/rules/variant-manager.d.ts.map +1 -0
- package/dist/rules/variant-manager.js +777 -0
- package/dist/rules/variant-manager.js.map +1 -0
- package/dist/scanner/change-detector.d.ts +164 -0
- package/dist/scanner/change-detector.d.ts.map +1 -0
- package/dist/scanner/change-detector.js +263 -0
- package/dist/scanner/change-detector.js.map +1 -0
- package/dist/scanner/dependency-graph.d.ts +270 -0
- package/dist/scanner/dependency-graph.d.ts.map +1 -0
- package/dist/scanner/dependency-graph.js +436 -0
- package/dist/scanner/dependency-graph.js.map +1 -0
- package/dist/scanner/file-walker.d.ts +127 -0
- package/dist/scanner/file-walker.d.ts.map +1 -0
- package/dist/scanner/file-walker.js +526 -0
- package/dist/scanner/file-walker.js.map +1 -0
- package/dist/scanner/index.d.ts +12 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +12 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/types.d.ts +218 -0
- package/dist/scanner/types.d.ts.map +1 -0
- package/dist/scanner/types.js +10 -0
- package/dist/scanner/types.js.map +1 -0
- package/dist/scanner/worker-pool.d.ts +317 -0
- package/dist/scanner/worker-pool.d.ts.map +1 -0
- package/dist/scanner/worker-pool.js +571 -0
- package/dist/scanner/worker-pool.js.map +1 -0
- package/dist/store/cache-manager.d.ts +179 -0
- package/dist/store/cache-manager.d.ts.map +1 -0
- package/dist/store/cache-manager.js +391 -0
- package/dist/store/cache-manager.js.map +1 -0
- package/dist/store/history-store.d.ts +314 -0
- package/dist/store/history-store.d.ts.map +1 -0
- package/dist/store/history-store.js +707 -0
- package/dist/store/history-store.js.map +1 -0
- package/dist/store/index.d.ts +20 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +26 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/lock-file-manager.d.ts +202 -0
- package/dist/store/lock-file-manager.d.ts.map +1 -0
- package/dist/store/lock-file-manager.js +475 -0
- package/dist/store/lock-file-manager.js.map +1 -0
- package/dist/store/pattern-store.d.ts +289 -0
- package/dist/store/pattern-store.d.ts.map +1 -0
- package/dist/store/pattern-store.js +936 -0
- package/dist/store/pattern-store.js.map +1 -0
- package/dist/store/schema-validator.d.ts +159 -0
- package/dist/store/schema-validator.d.ts.map +1 -0
- package/dist/store/schema-validator.js +1096 -0
- package/dist/store/schema-validator.js.map +1 -0
- package/dist/store/types.d.ts +585 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +82 -0
- package/dist/store/types.js.map +1 -0
- package/dist/types/analysis.d.ts +19 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +5 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/common.d.ts +7 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +5 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/patterns.d.ts +40 -0
- package/dist/types/patterns.d.ts.map +1 -0
- package/dist/types/patterns.js +7 -0
- package/dist/types/patterns.js.map +1 -0
- package/dist/types/violations.d.ts +7 -0
- package/dist/types/violations.d.ts.map +1 -0
- package/dist/types/violations.js +7 -0
- package/dist/types/violations.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency-graph.js","sourceRoot":"","sources":["../../src/scanner/dependency-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqJH;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAC1B,wCAAwC;IAChC,OAAO,GAA4B,IAAI,GAAG,EAAE,CAAC;IAErD,6BAA6B;IACrB,KAAK,GAAqB,EAAE,CAAC;IAErC,4BAA4B;IACpB,OAAO,CAAyB;IAExC,YAAY,UAAkC,EAAE;QAC9C,IAAI,CAAC,OAAO,GAAG;YACb,gBAAgB,EAAE,IAAI;YACtB,kBAAkB,EAAE,KAAK;YACzB,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,IAAY,EAAE,OAAqB,EAAE,OAAqB;QAClE,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAEhD,kCAAkC;QAClC,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC/D,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtE,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,mCAAmC;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,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E,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EACvD,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,IAAY;QAChC,wDAAwD;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,MAAc;QACjC,uCAAuC;QACvC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Walker - Directory traversal with ignore pattern support
|
|
3
|
+
*
|
|
4
|
+
* Implements recursive directory traversal that respects .gitignore
|
|
5
|
+
* and .driftignore patterns.
|
|
6
|
+
*
|
|
7
|
+
* @requirements 2.1, 2.8
|
|
8
|
+
*/
|
|
9
|
+
import type { Language } from '../parsers/types.js';
|
|
10
|
+
import type { ScanOptions, ScanResult, FileInfo, ScanProgressCallback } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* FileWalker class for recursive directory traversal
|
|
13
|
+
*
|
|
14
|
+
* Traverses directories respecting .gitignore and .driftignore patterns,
|
|
15
|
+
* with support for symlink handling and progress callbacks.
|
|
16
|
+
*
|
|
17
|
+
* @requirements 2.1 - Traverse directory structures respecting .gitignore and .driftignore patterns
|
|
18
|
+
* @requirements 2.8 - Files outside the workspace SHALL be ignored
|
|
19
|
+
*/
|
|
20
|
+
export declare class FileWalker {
|
|
21
|
+
private options;
|
|
22
|
+
private rootDir;
|
|
23
|
+
private ignoreInstance;
|
|
24
|
+
private visitedPaths;
|
|
25
|
+
private files;
|
|
26
|
+
private directories;
|
|
27
|
+
private errors;
|
|
28
|
+
private stats;
|
|
29
|
+
private progressCallback;
|
|
30
|
+
private startTime;
|
|
31
|
+
constructor();
|
|
32
|
+
/**
|
|
33
|
+
* Main entry point for directory traversal
|
|
34
|
+
*
|
|
35
|
+
* @param options - Scan configuration options
|
|
36
|
+
* @param progressCallback - Optional callback for progress updates
|
|
37
|
+
* @returns Promise resolving to scan results
|
|
38
|
+
*/
|
|
39
|
+
walk(options: ScanOptions, progressCallback?: ScanProgressCallback): Promise<ScanResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Load .gitignore and .driftignore patterns from a directory
|
|
42
|
+
*
|
|
43
|
+
* @param dir - Directory to load patterns from
|
|
44
|
+
* @returns Promise resolving to array of patterns
|
|
45
|
+
*/
|
|
46
|
+
loadIgnorePatterns(dir: string): Promise<string[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Read patterns from an ignore file
|
|
49
|
+
*
|
|
50
|
+
* @param filePath - Path to the ignore file
|
|
51
|
+
* @returns Promise resolving to array of patterns
|
|
52
|
+
*/
|
|
53
|
+
private readIgnoreFile;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a path should be ignored based on patterns
|
|
56
|
+
*
|
|
57
|
+
* @param relativePath - Path relative to root directory
|
|
58
|
+
* @param isDirectory - Whether the path is a directory
|
|
59
|
+
* @returns True if the path should be ignored
|
|
60
|
+
*/
|
|
61
|
+
shouldIgnore(relativePath: string, isDirectory?: boolean): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get file information including metadata
|
|
64
|
+
*
|
|
65
|
+
* @param filePath - Absolute path to the file
|
|
66
|
+
* @returns Promise resolving to FileInfo
|
|
67
|
+
*/
|
|
68
|
+
getFileInfo(filePath: string): Promise<FileInfo>;
|
|
69
|
+
/**
|
|
70
|
+
* Detect programming language from file extension
|
|
71
|
+
*
|
|
72
|
+
* @param extension - File extension including the dot
|
|
73
|
+
* @returns Detected language or undefined
|
|
74
|
+
*/
|
|
75
|
+
detectLanguage(extension: string): Language | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Recursively traverse a directory
|
|
78
|
+
*
|
|
79
|
+
* @param dirPath - Absolute path to the directory
|
|
80
|
+
* @param depth - Current depth from root
|
|
81
|
+
*/
|
|
82
|
+
private traverseDirectory;
|
|
83
|
+
/**
|
|
84
|
+
* Check if a file should be included based on filters
|
|
85
|
+
*
|
|
86
|
+
* @param filePath - Absolute path to the file
|
|
87
|
+
* @param stat - File stats
|
|
88
|
+
* @returns True if the file should be included
|
|
89
|
+
*/
|
|
90
|
+
private shouldIncludeFile;
|
|
91
|
+
/**
|
|
92
|
+
* Check if a path is within the workspace root
|
|
93
|
+
*
|
|
94
|
+
* @requirements 2.8 - Files outside the workspace SHALL be ignored
|
|
95
|
+
* @param realPath - Real (resolved) path to check
|
|
96
|
+
* @returns True if the path is within the workspace
|
|
97
|
+
*/
|
|
98
|
+
private isWithinWorkspace;
|
|
99
|
+
/**
|
|
100
|
+
* Compute SHA-256 hash of a file
|
|
101
|
+
*
|
|
102
|
+
* @param filePath - Path to the file
|
|
103
|
+
* @returns Promise resolving to hex-encoded hash
|
|
104
|
+
*/
|
|
105
|
+
private computeFileHash;
|
|
106
|
+
/**
|
|
107
|
+
* Add an error to the error list
|
|
108
|
+
*
|
|
109
|
+
* @param filePath - Path that caused the error
|
|
110
|
+
* @param type - Type of error
|
|
111
|
+
* @param error - The error object
|
|
112
|
+
*/
|
|
113
|
+
private addError;
|
|
114
|
+
/**
|
|
115
|
+
* Create initial stats object
|
|
116
|
+
*/
|
|
117
|
+
private createInitialStats;
|
|
118
|
+
/**
|
|
119
|
+
* Create an error result for early failures
|
|
120
|
+
*/
|
|
121
|
+
private createErrorResult;
|
|
122
|
+
/**
|
|
123
|
+
* Report progress to the callback
|
|
124
|
+
*/
|
|
125
|
+
private reportProgress;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=file-walker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-walker.d.ts","sourceR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;IACH,OAAO,CAAC,QAAQ;IAqBhB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiB1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA6BzB;;OAEG;IACH,OAAO,CAAC,cAAc;CA4BvB"}
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Walker - Directory traversal with ignore pattern support
|
|
3
|
+
*
|
|
4
|
+
* Implements recursive directory traversal that respects .gitignore
|
|
5
|
+
* and .driftignore patterns.
|
|
6
|
+
*
|
|
7
|
+
* @requirements 2.1, 2.8
|
|
8
|
+
*/
|
|
9
|
+
import * as fs from 'node:fs/promises';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import { createHash } from 'node:crypto';
|
|
12
|
+
import { createRequire } from 'node:module';
|
|
13
|
+
import { minimatch } from 'minimatch';
|
|
14
|
+
// Import ignore using require for proper CJS interop
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const ignore = require('ignore');
|
|
17
|
+
/**
|
|
18
|
+
* Extension to language mapping
|
|
19
|
+
*/
|
|
20
|
+
const EXTENSION_LANGUAGE_MAP = {
|
|
21
|
+
'.ts': 'typescript',
|
|
22
|
+
'.tsx': 'typescript',
|
|
23
|
+
'.mts': 'typescript',
|
|
24
|
+
'.cts': 'typescript',
|
|
25
|
+
'.js': 'javascript',
|
|
26
|
+
'.jsx': 'javascript',
|
|
27
|
+
'.mjs': 'javascript',
|
|
28
|
+
'.cjs': 'javascript',
|
|
29
|
+
'.py': 'python',
|
|
30
|
+
'.pyw': 'python',
|
|
31
|
+
'.css': 'css',
|
|
32
|
+
'.scss': 'scss',
|
|
33
|
+
'.sass': 'scss',
|
|
34
|
+
'.json': 'json',
|
|
35
|
+
'.jsonc': 'json',
|
|
36
|
+
'.yaml': 'yaml',
|
|
37
|
+
'.yml': 'yaml',
|
|
38
|
+
'.md': 'markdown',
|
|
39
|
+
'.mdx': 'markdown',
|
|
40
|
+
'.markdown': 'markdown',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Default scan options
|
|
44
|
+
*/
|
|
45
|
+
const DEFAULT_OPTIONS = {
|
|
46
|
+
respectGitignore: true,
|
|
47
|
+
respectDriftignore: true,
|
|
48
|
+
followSymlinks: false,
|
|
49
|
+
computeHashes: false,
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* FileWalker class for recursive directory traversal
|
|
53
|
+
*
|
|
54
|
+
* Traverses directories respecting .gitignore and .driftignore patterns,
|
|
55
|
+
* with support for symlink handling and progress callbacks.
|
|
56
|
+
*
|
|
57
|
+
* @requirements 2.1 - Traverse directory structures respecting .gitignore and .driftignore patterns
|
|
58
|
+
* @requirements 2.8 - Files outside the workspace SHALL be ignored
|
|
59
|
+
*/
|
|
60
|
+
export class FileWalker {
|
|
61
|
+
options;
|
|
62
|
+
rootDir;
|
|
63
|
+
ignoreInstance;
|
|
64
|
+
visitedPaths;
|
|
65
|
+
files;
|
|
66
|
+
directories;
|
|
67
|
+
errors;
|
|
68
|
+
stats;
|
|
69
|
+
progressCallback;
|
|
70
|
+
startTime;
|
|
71
|
+
constructor() {
|
|
72
|
+
this.options = {};
|
|
73
|
+
this.rootDir = '';
|
|
74
|
+
this.ignoreInstance = ignore();
|
|
75
|
+
this.visitedPaths = new Set();
|
|
76
|
+
this.files = [];
|
|
77
|
+
this.directories = [];
|
|
78
|
+
this.errors = [];
|
|
79
|
+
this.stats = this.createInitialStats();
|
|
80
|
+
this.startTime = new Date();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Main entry point for directory traversal
|
|
84
|
+
*
|
|
85
|
+
* @param options - Scan configuration options
|
|
86
|
+
* @param progressCallback - Optional callback for progress updates
|
|
87
|
+
* @returns Promise resolving to scan results
|
|
88
|
+
*/
|
|
89
|
+
async walk(options, progressCallback) {
|
|
90
|
+
// Initialize state
|
|
91
|
+
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
92
|
+
this.rootDir = path.resolve(options.rootDir);
|
|
93
|
+
this.ignoreInstance = ignore();
|
|
94
|
+
this.visitedPaths = new Set();
|
|
95
|
+
this.files = [];
|
|
96
|
+
this.directories = [];
|
|
97
|
+
this.errors = [];
|
|
98
|
+
this.startTime = new Date();
|
|
99
|
+
this.stats = this.createInitialStats();
|
|
100
|
+
this.progressCallback = progressCallback;
|
|
101
|
+
// Verify root directory exists and is accessible
|
|
102
|
+
try {
|
|
103
|
+
const rootStat = await fs.stat(this.rootDir);
|
|
104
|
+
if (!rootStat.isDirectory()) {
|
|
105
|
+
throw new Error(`Root path is not a directory: ${this.rootDir}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return this.createErrorResult(`Cannot access root directory: ${this.rootDir}`, error);
|
|
110
|
+
}
|
|
111
|
+
// Load ignore patterns from root directory
|
|
112
|
+
await this.loadIgnorePatterns(this.rootDir);
|
|
113
|
+
// Add custom ignore patterns from options
|
|
114
|
+
if (this.options.ignorePatterns && this.options.ignorePatterns.length > 0) {
|
|
115
|
+
this.ignoreInstance.add(this.options.ignorePatterns);
|
|
116
|
+
}
|
|
117
|
+
// Report discovery phase
|
|
118
|
+
this.reportProgress('discovering', 0, 0);
|
|
119
|
+
// Start recursive traversal
|
|
120
|
+
await this.traverseDirectory(this.rootDir, 0);
|
|
121
|
+
// Finalize stats
|
|
122
|
+
this.stats.endTime = new Date();
|
|
123
|
+
this.stats.duration = this.stats.endTime.getTime() - this.startTime.getTime();
|
|
124
|
+
this.stats.totalFiles = this.files.length;
|
|
125
|
+
this.stats.totalDirectories = this.directories.length;
|
|
126
|
+
this.stats.errorCount = this.errors.length;
|
|
127
|
+
// Report completion
|
|
128
|
+
this.reportProgress('complete', this.files.length, this.files.length);
|
|
129
|
+
return {
|
|
130
|
+
files: this.files,
|
|
131
|
+
directories: this.directories,
|
|
132
|
+
stats: this.stats,
|
|
133
|
+
errors: this.errors,
|
|
134
|
+
rootDir: this.rootDir,
|
|
135
|
+
options: this.options,
|
|
136
|
+
success: this.errors.length === 0,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Load .gitignore and .driftignore patterns from a directory
|
|
141
|
+
*
|
|
142
|
+
* @param dir - Directory to load patterns from
|
|
143
|
+
* @returns Promise resolving to array of patterns
|
|
144
|
+
*/
|
|
145
|
+
async loadIgnorePatterns(dir) {
|
|
146
|
+
const patterns = [];
|
|
147
|
+
// Load .gitignore if enabled
|
|
148
|
+
if (this.options.respectGitignore) {
|
|
149
|
+
const gitignorePath = path.join(dir, '.gitignore');
|
|
150
|
+
const gitignorePatterns = await this.readIgnoreFile(gitignorePath);
|
|
151
|
+
patterns.push(...gitignorePatterns);
|
|
152
|
+
}
|
|
153
|
+
// Load .driftignore if enabled
|
|
154
|
+
if (this.options.respectDriftignore) {
|
|
155
|
+
const driftignorePath = path.join(dir, '.driftignore');
|
|
156
|
+
const driftignorePatterns = await this.readIgnoreFile(driftignorePath);
|
|
157
|
+
patterns.push(...driftignorePatterns);
|
|
158
|
+
}
|
|
159
|
+
// Add patterns to ignore instance
|
|
160
|
+
if (patterns.length > 0) {
|
|
161
|
+
this.ignoreInstance.add(patterns);
|
|
162
|
+
}
|
|
163
|
+
return patterns;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Read patterns from an ignore file
|
|
167
|
+
*
|
|
168
|
+
* @param filePath - Path to the ignore file
|
|
169
|
+
* @returns Promise resolving to array of patterns
|
|
170
|
+
*/
|
|
171
|
+
async readIgnoreFile(filePath) {
|
|
172
|
+
try {
|
|
173
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
174
|
+
return content
|
|
175
|
+
.split('\n')
|
|
176
|
+
.map((line) => line.trim())
|
|
177
|
+
.filter((line) => line && !line.startsWith('#'));
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
// File doesn't exist or can't be read - that's fine
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Check if a path should be ignored based on patterns
|
|
186
|
+
*
|
|
187
|
+
* @param relativePath - Path relative to root directory
|
|
188
|
+
* @param isDirectory - Whether the path is a directory
|
|
189
|
+
* @returns True if the path should be ignored
|
|
190
|
+
*/
|
|
191
|
+
shouldIgnore(relativePath, isDirectory = false) {
|
|
192
|
+
// Normalize path separators for cross-platform compatibility
|
|
193
|
+
const normalizedPath = relativePath.replace(/\\/g, '/');
|
|
194
|
+
// For directories, append trailing slash for proper matching
|
|
195
|
+
const pathToCheck = isDirectory ? `${normalizedPath}/` : normalizedPath;
|
|
196
|
+
// Check against ignore patterns
|
|
197
|
+
if (this.ignoreInstance.ignores(pathToCheck)) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
// Also check without trailing slash for directories
|
|
201
|
+
if (isDirectory && this.ignoreInstance.ignores(normalizedPath)) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get file information including metadata
|
|
208
|
+
*
|
|
209
|
+
* @param filePath - Absolute path to the file
|
|
210
|
+
* @returns Promise resolving to FileInfo
|
|
211
|
+
*/
|
|
212
|
+
async getFileInfo(filePath) {
|
|
213
|
+
const stat = await fs.lstat(filePath);
|
|
214
|
+
const relativePath = path.relative(this.rootDir, filePath);
|
|
215
|
+
const extension = path.extname(filePath);
|
|
216
|
+
const name = path.basename(filePath);
|
|
217
|
+
const language = this.detectLanguage(extension);
|
|
218
|
+
const fileInfo = {
|
|
219
|
+
path: filePath,
|
|
220
|
+
relativePath,
|
|
221
|
+
name,
|
|
222
|
+
extension,
|
|
223
|
+
size: stat.size,
|
|
224
|
+
mtime: stat.mtime,
|
|
225
|
+
ctime: stat.ctime,
|
|
226
|
+
isSymlink: stat.isSymbolicLink(),
|
|
227
|
+
};
|
|
228
|
+
// Only add language if detected
|
|
229
|
+
if (language !== undefined) {
|
|
230
|
+
fileInfo.language = language;
|
|
231
|
+
}
|
|
232
|
+
// Compute hash if requested
|
|
233
|
+
if (this.options.computeHashes) {
|
|
234
|
+
try {
|
|
235
|
+
fileInfo.hash = await this.computeFileHash(filePath);
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
this.addError(filePath, 'hash_error', error);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return fileInfo;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Detect programming language from file extension
|
|
245
|
+
*
|
|
246
|
+
* @param extension - File extension including the dot
|
|
247
|
+
* @returns Detected language or undefined
|
|
248
|
+
*/
|
|
249
|
+
detectLanguage(extension) {
|
|
250
|
+
return EXTENSION_LANGUAGE_MAP[extension.toLowerCase()];
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Recursively traverse a directory
|
|
254
|
+
*
|
|
255
|
+
* @param dirPath - Absolute path to the directory
|
|
256
|
+
* @param depth - Current depth from root
|
|
257
|
+
*/
|
|
258
|
+
async traverseDirectory(dirPath, depth) {
|
|
259
|
+
// Check max depth
|
|
260
|
+
if (this.options.maxDepth !== undefined && depth > this.options.maxDepth) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
// Get real path to handle symlinks and detect loops
|
|
264
|
+
let realPath;
|
|
265
|
+
try {
|
|
266
|
+
realPath = await fs.realpath(dirPath);
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
this.addError(dirPath, 'read_error', error);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
// Check for symlink loops
|
|
273
|
+
if (this.visitedPaths.has(realPath)) {
|
|
274
|
+
this.addError(dirPath, 'symlink_loop', new Error('Circular symlink detected'));
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.visitedPaths.add(realPath);
|
|
278
|
+
// Check if path is outside workspace (requirement 2.8)
|
|
279
|
+
if (!this.isWithinWorkspace(realPath)) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
// Read directory entries
|
|
283
|
+
let entries;
|
|
284
|
+
try {
|
|
285
|
+
entries = await fs.readdir(dirPath);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
this.addError(dirPath, 'permission_denied', error);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
// Load ignore patterns from this directory (for nested .gitignore/.driftignore)
|
|
292
|
+
await this.loadIgnorePatterns(dirPath);
|
|
293
|
+
// Track directory info
|
|
294
|
+
const relativePath = path.relative(this.rootDir, dirPath);
|
|
295
|
+
let fileCount = 0;
|
|
296
|
+
let subdirectoryCount = 0;
|
|
297
|
+
// Process entries
|
|
298
|
+
for (const entry of entries) {
|
|
299
|
+
const entryPath = path.join(dirPath, entry);
|
|
300
|
+
const entryRelativePath = path.relative(this.rootDir, entryPath);
|
|
301
|
+
// Get entry stats
|
|
302
|
+
let entryStat;
|
|
303
|
+
try {
|
|
304
|
+
entryStat = await fs.lstat(entryPath);
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
this.addError(entryPath, 'read_error', error);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
const isSymlink = entryStat.isSymbolicLink();
|
|
311
|
+
// Handle symlinks
|
|
312
|
+
if (isSymlink) {
|
|
313
|
+
if (!this.options.followSymlinks) {
|
|
314
|
+
// Skip symlinks if not following them
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
// Get the target stats
|
|
318
|
+
try {
|
|
319
|
+
entryStat = await fs.stat(entryPath);
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
this.addError(entryPath, 'read_error', error);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// Check if should be ignored
|
|
327
|
+
if (this.shouldIgnore(entryRelativePath, entryStat.isDirectory())) {
|
|
328
|
+
this.stats.skippedByIgnore++;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (entryStat.isDirectory()) {
|
|
332
|
+
subdirectoryCount++;
|
|
333
|
+
// Recurse into subdirectory
|
|
334
|
+
await this.traverseDirectory(entryPath, depth + 1);
|
|
335
|
+
}
|
|
336
|
+
else if (entryStat.isFile()) {
|
|
337
|
+
// Check file filters
|
|
338
|
+
if (!this.shouldIncludeFile(entryPath, entryStat)) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
fileCount++;
|
|
342
|
+
// Get file info
|
|
343
|
+
try {
|
|
344
|
+
const fileInfo = await this.getFileInfo(entryPath);
|
|
345
|
+
this.files.push(fileInfo);
|
|
346
|
+
// Update stats
|
|
347
|
+
this.stats.totalSize += fileInfo.size;
|
|
348
|
+
if (fileInfo.extension) {
|
|
349
|
+
this.stats.filesByExtension[fileInfo.extension] =
|
|
350
|
+
(this.stats.filesByExtension[fileInfo.extension] || 0) + 1;
|
|
351
|
+
}
|
|
352
|
+
if (fileInfo.language) {
|
|
353
|
+
this.stats.filesByLanguage[fileInfo.language] =
|
|
354
|
+
(this.stats.filesByLanguage[fileInfo.language] || 0) + 1;
|
|
355
|
+
}
|
|
356
|
+
// Report progress
|
|
357
|
+
this.reportProgress('scanning', this.files.length, this.files.length);
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
this.addError(entryPath, 'read_error', error);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// Add directory info
|
|
365
|
+
const dirStat = await fs.lstat(dirPath);
|
|
366
|
+
this.directories.push({
|
|
367
|
+
path: dirPath,
|
|
368
|
+
relativePath: relativePath || '.',
|
|
369
|
+
name: path.basename(dirPath),
|
|
370
|
+
fileCount,
|
|
371
|
+
subdirectoryCount,
|
|
372
|
+
depth,
|
|
373
|
+
isSymlink: dirStat.isSymbolicLink(),
|
|
374
|
+
});
|
|
375
|
+
// Update max depth
|
|
376
|
+
if (depth > this.stats.maxDepthReached) {
|
|
377
|
+
this.stats.maxDepthReached = depth;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Check if a file should be included based on filters
|
|
382
|
+
*
|
|
383
|
+
* @param filePath - Absolute path to the file
|
|
384
|
+
* @param stat - File stats
|
|
385
|
+
* @returns True if the file should be included
|
|
386
|
+
*/
|
|
387
|
+
shouldIncludeFile(filePath, stat) {
|
|
388
|
+
const extension = path.extname(filePath);
|
|
389
|
+
const relativePath = path.relative(this.rootDir, filePath);
|
|
390
|
+
// Check extension filter
|
|
391
|
+
if (this.options.extensions && this.options.extensions.length > 0) {
|
|
392
|
+
if (!this.options.extensions.includes(extension)) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// Check size limit
|
|
397
|
+
if (this.options.maxFileSize !== undefined && stat.size > this.options.maxFileSize) {
|
|
398
|
+
this.stats.skippedBySize++;
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
// Check include patterns
|
|
402
|
+
if (this.options.includePatterns && this.options.includePatterns.length > 0) {
|
|
403
|
+
const matches = this.options.includePatterns.some((pattern) => minimatch(relativePath, pattern, { dot: true }));
|
|
404
|
+
if (!matches) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Check if a path is within the workspace root
|
|
412
|
+
*
|
|
413
|
+
* @requirements 2.8 - Files outside the workspace SHALL be ignored
|
|
414
|
+
* @param realPath - Real (resolved) path to check
|
|
415
|
+
* @returns True if the path is within the workspace
|
|
416
|
+
*/
|
|
417
|
+
isWithinWorkspace(realPath) {
|
|
418
|
+
const normalizedRoot = path.normalize(this.rootDir);
|
|
419
|
+
const normalizedPath = path.normalize(realPath);
|
|
420
|
+
// Check if the path starts with the root directory
|
|
421
|
+
return normalizedPath.startsWith(normalizedRoot);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Compute SHA-256 hash of a file
|
|
425
|
+
*
|
|
426
|
+
* @param filePath - Path to the file
|
|
427
|
+
* @returns Promise resolving to hex-encoded hash
|
|
428
|
+
*/
|
|
429
|
+
async computeFileHash(filePath) {
|
|
430
|
+
const content = await fs.readFile(filePath);
|
|
431
|
+
return createHash('sha256').update(content).digest('hex');
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Add an error to the error list
|
|
435
|
+
*
|
|
436
|
+
* @param filePath - Path that caused the error
|
|
437
|
+
* @param type - Type of error
|
|
438
|
+
* @param error - The error object
|
|
439
|
+
*/
|
|
440
|
+
addError(filePath, type, error) {
|
|
441
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
442
|
+
const code = error?.code;
|
|
443
|
+
const scanError = {
|
|
444
|
+
path: filePath,
|
|
445
|
+
message: errorObj.message,
|
|
446
|
+
type,
|
|
447
|
+
};
|
|
448
|
+
if (code !== undefined) {
|
|
449
|
+
scanError.code = code;
|
|
450
|
+
}
|
|
451
|
+
if (errorObj.stack !== undefined) {
|
|
452
|
+
scanError.stack = errorObj.stack;
|
|
453
|
+
}
|
|
454
|
+
this.errors.push(scanError);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Create initial stats object
|
|
458
|
+
*/
|
|
459
|
+
createInitialStats() {
|
|
460
|
+
return {
|
|
461
|
+
totalFiles: 0,
|
|
462
|
+
totalDirectories: 0,
|
|
463
|
+
totalSize: 0,
|
|
464
|
+
duration: 0,
|
|
465
|
+
skippedByIgnore: 0,
|
|
466
|
+
skippedBySize: 0,
|
|
467
|
+
errorCount: 0,
|
|
468
|
+
filesByExtension: {},
|
|
469
|
+
filesByLanguage: {},
|
|
470
|
+
maxDepthReached: 0,
|
|
471
|
+
startTime: new Date(),
|
|
472
|
+
endTime: new Date(),
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Create an error result for early failures
|
|
477
|
+
*/
|
|
478
|
+
createErrorResult(message, error) {
|
|
479
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
480
|
+
const scanError = {
|
|
481
|
+
path: this.rootDir,
|
|
482
|
+
message,
|
|
483
|
+
type: 'read_error',
|
|
484
|
+
};
|
|
485
|
+
if (errorObj.stack !== undefined) {
|
|
486
|
+
scanError.stack = errorObj.stack;
|
|
487
|
+
}
|
|
488
|
+
return {
|
|
489
|
+
files: [],
|
|
490
|
+
directories: [],
|
|
491
|
+
stats: {
|
|
492
|
+
...this.createInitialStats(),
|
|
493
|
+
errorCount: 1,
|
|
494
|
+
endTime: new Date(),
|
|
495
|
+
duration: Date.now() - this.startTime.getTime(),
|
|
496
|
+
},
|
|
497
|
+
errors: [scanError],
|
|
498
|
+
rootDir: this.rootDir,
|
|
499
|
+
options: this.options,
|
|
500
|
+
success: false,
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Report progress to the callback
|
|
505
|
+
*/
|
|
506
|
+
reportProgress(phase, filesProcessed, totalFiles) {
|
|
507
|
+
if (!this.progressCallback) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const elapsedMs = Date.now() - this.startTime.getTime();
|
|
511
|
+
const percentComplete = totalFiles > 0 ? Math.round((filesProcessed / totalFiles) * 100) : 0;
|
|
512
|
+
const progress = {
|
|
513
|
+
phase,
|
|
514
|
+
filesProcessed,
|
|
515
|
+
totalFiles,
|
|
516
|
+
percentComplete,
|
|
517
|
+
elapsedMs,
|
|
518
|
+
};
|
|
519
|
+
const currentFile = this.files[this.files.length - 1]?.relativePath;
|
|
520
|
+
if (currentFile !== undefined) {
|
|
521
|
+
progress.currentFile = currentFile;
|
|
522
|
+
}
|
|
523
|
+
this.progressCallback(progress);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
//# sourceMappingURL=file-walker.js.map
|