@liendev/parser 0.39.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/ast/chunker.d.ts +30 -0
- package/dist/ast/chunker.d.ts.map +1 -0
- package/dist/ast/chunker.js +310 -0
- package/dist/ast/chunker.js.map +1 -0
- package/dist/ast/complexity/cognitive.d.ts +16 -0
- package/dist/ast/complexity/cognitive.d.ts.map +1 -0
- package/dist/ast/complexity/cognitive.js +137 -0
- package/dist/ast/complexity/cognitive.js.map +1 -0
- package/dist/ast/complexity/cyclomatic.d.ts +12 -0
- package/dist/ast/complexity/cyclomatic.d.ts.map +1 -0
- package/dist/ast/complexity/cyclomatic.js +54 -0
- package/dist/ast/complexity/cyclomatic.js.map +1 -0
- package/dist/ast/complexity/halstead.d.ts +56 -0
- package/dist/ast/complexity/halstead.d.ts.map +1 -0
- package/dist/ast/complexity/halstead.js +196 -0
- package/dist/ast/complexity/halstead.js.map +1 -0
- package/dist/ast/complexity/index.d.ts +13 -0
- package/dist/ast/complexity/index.d.ts.map +1 -0
- package/dist/ast/complexity/index.js +12 -0
- package/dist/ast/complexity/index.js.map +1 -0
- package/dist/ast/extractors/index.d.ts +35 -0
- package/dist/ast/extractors/index.d.ts.map +1 -0
- package/dist/ast/extractors/index.js +41 -0
- package/dist/ast/extractors/index.js.map +1 -0
- package/dist/ast/extractors/symbol-helpers.d.ts +20 -0
- package/dist/ast/extractors/symbol-helpers.d.ts.map +1 -0
- package/dist/ast/extractors/symbol-helpers.js +58 -0
- package/dist/ast/extractors/symbol-helpers.js.map +1 -0
- package/dist/ast/extractors/types.d.ts +108 -0
- package/dist/ast/extractors/types.d.ts.map +1 -0
- package/dist/ast/extractors/types.js +2 -0
- package/dist/ast/extractors/types.js.map +1 -0
- package/dist/ast/languages/javascript.d.ts +134 -0
- package/dist/ast/languages/javascript.d.ts.map +1 -0
- package/dist/ast/languages/javascript.js +787 -0
- package/dist/ast/languages/javascript.js.map +1 -0
- package/dist/ast/languages/php.d.ts +84 -0
- package/dist/ast/languages/php.d.ts.map +1 -0
- package/dist/ast/languages/php.js +452 -0
- package/dist/ast/languages/php.js.map +1 -0
- package/dist/ast/languages/python.d.ts +96 -0
- package/dist/ast/languages/python.d.ts.map +1 -0
- package/dist/ast/languages/python.js +448 -0
- package/dist/ast/languages/python.js.map +1 -0
- package/dist/ast/languages/registry.d.ts +30 -0
- package/dist/ast/languages/registry.d.ts.map +1 -0
- package/dist/ast/languages/registry.js +95 -0
- package/dist/ast/languages/registry.js.map +1 -0
- package/dist/ast/languages/rust.d.ts +113 -0
- package/dist/ast/languages/rust.d.ts.map +1 -0
- package/dist/ast/languages/rust.js +614 -0
- package/dist/ast/languages/rust.js.map +1 -0
- package/dist/ast/languages/types.d.ts +52 -0
- package/dist/ast/languages/types.d.ts.map +1 -0
- package/dist/ast/languages/types.js +2 -0
- package/dist/ast/languages/types.js.map +1 -0
- package/dist/ast/languages/typescript.d.ts +3 -0
- package/dist/ast/languages/typescript.d.ts.map +1 -0
- package/dist/ast/languages/typescript.js +134 -0
- package/dist/ast/languages/typescript.js.map +1 -0
- package/dist/ast/parser.d.ts +29 -0
- package/dist/ast/parser.d.ts.map +1 -0
- package/dist/ast/parser.js +67 -0
- package/dist/ast/parser.js.map +1 -0
- package/dist/ast/symbols.d.ts +74 -0
- package/dist/ast/symbols.d.ts.map +1 -0
- package/dist/ast/symbols.js +171 -0
- package/dist/ast/symbols.js.map +1 -0
- package/dist/ast/traversers/index.d.ts +19 -0
- package/dist/ast/traversers/index.d.ts.map +1 -0
- package/dist/ast/traversers/index.js +21 -0
- package/dist/ast/traversers/index.js.map +1 -0
- package/dist/ast/traversers/types.d.ts +98 -0
- package/dist/ast/traversers/types.d.ts.map +1 -0
- package/dist/ast/traversers/types.js +2 -0
- package/dist/ast/traversers/types.js.map +1 -0
- package/dist/ast/types.d.ts +54 -0
- package/dist/ast/types.d.ts.map +1 -0
- package/dist/ast/types.js +2 -0
- package/dist/ast/types.js.map +1 -0
- package/dist/chunk-only-index.d.ts +25 -0
- package/dist/chunk-only-index.d.ts.map +1 -0
- package/dist/chunk-only-index.js +107 -0
- package/dist/chunk-only-index.js.map +1 -0
- package/dist/chunker.d.ts +12 -0
- package/dist/chunker.d.ts.map +1 -0
- package/dist/chunker.js +98 -0
- package/dist/chunker.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +11 -0
- package/dist/constants.js.map +1 -0
- package/dist/content-hash.d.ts +20 -0
- package/dist/content-hash.d.ts.map +1 -0
- package/dist/content-hash.js +91 -0
- package/dist/content-hash.js.map +1 -0
- package/dist/dependency-analyzer.d.ts +79 -0
- package/dist/dependency-analyzer.d.ts.map +1 -0
- package/dist/dependency-analyzer.js +408 -0
- package/dist/dependency-analyzer.js.map +1 -0
- package/dist/ecosystem-presets.d.ts +32 -0
- package/dist/ecosystem-presets.d.ts.map +1 -0
- package/dist/ecosystem-presets.js +325 -0
- package/dist/ecosystem-presets.js.map +1 -0
- package/dist/gitignore.d.ts +22 -0
- package/dist/gitignore.d.ts.map +1 -0
- package/dist/gitignore.js +128 -0
- package/dist/gitignore.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/insights/chunk-complexity.d.ts +89 -0
- package/dist/insights/chunk-complexity.d.ts.map +1 -0
- package/dist/insights/chunk-complexity.js +332 -0
- package/dist/insights/chunk-complexity.js.map +1 -0
- package/dist/insights/types.d.ts +73 -0
- package/dist/insights/types.d.ts.map +1 -0
- package/dist/insights/types.js +9 -0
- package/dist/insights/types.js.map +1 -0
- package/dist/json-template-chunker.d.ts +12 -0
- package/dist/json-template-chunker.d.ts.map +1 -0
- package/dist/json-template-chunker.js +87 -0
- package/dist/json-template-chunker.js.map +1 -0
- package/dist/liquid-chunker.d.ts +16 -0
- package/dist/liquid-chunker.d.ts.map +1 -0
- package/dist/liquid-chunker.js +274 -0
- package/dist/liquid-chunker.js.map +1 -0
- package/dist/scanner.d.ts +16 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +95 -0
- package/dist/scanner.js.map +1 -0
- package/dist/symbol-extractor.d.ts +18 -0
- package/dist/symbol-extractor.d.ts.map +1 -0
- package/dist/symbol-extractor.js +343 -0
- package/dist/symbol-extractor.js.map +1 -0
- package/dist/test-associations.d.ts +16 -0
- package/dist/test-associations.d.ts.map +1 -0
- package/dist/test-associations.js +43 -0
- package/dist/test-associations.js.map +1 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/path-matching.d.ts +71 -0
- package/dist/utils/path-matching.d.ts.map +1 -0
- package/dist/utils/path-matching.js +258 -0
- package/dist/utils/path-matching.js.map +1 -0
- package/dist/utils/repo-id.d.ts +6 -0
- package/dist/utils/repo-id.d.ts.map +1 -0
- package/dist/utils/repo-id.js +12 -0
- package/dist/utils/repo-id.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Predefined ecosystem presets.
|
|
5
|
+
* Each preset checks for marker files and provides exclude patterns
|
|
6
|
+
* for common build artifacts, caches, and generated files.
|
|
7
|
+
*/
|
|
8
|
+
export const ECOSYSTEM_PRESETS = [
|
|
9
|
+
{
|
|
10
|
+
name: 'nodejs',
|
|
11
|
+
markerFiles: ['package.json'],
|
|
12
|
+
excludePatterns: [
|
|
13
|
+
'.next/**',
|
|
14
|
+
'**/.next/**',
|
|
15
|
+
'.nuxt/**',
|
|
16
|
+
'**/.nuxt/**',
|
|
17
|
+
'.vite/**',
|
|
18
|
+
'**/.vite/**',
|
|
19
|
+
'.turbo/**',
|
|
20
|
+
'**/.turbo/**',
|
|
21
|
+
'.vercel/**',
|
|
22
|
+
'**/.vercel/**',
|
|
23
|
+
'.netlify/**',
|
|
24
|
+
'**/.netlify/**',
|
|
25
|
+
'coverage/**',
|
|
26
|
+
'**/coverage/**',
|
|
27
|
+
'playwright-report/**',
|
|
28
|
+
'**/playwright-report/**',
|
|
29
|
+
'test-results/**',
|
|
30
|
+
'**/test-results/**',
|
|
31
|
+
'__generated__/**',
|
|
32
|
+
'**/__generated__/**',
|
|
33
|
+
'.cache/**',
|
|
34
|
+
'**/.cache/**',
|
|
35
|
+
'out/**',
|
|
36
|
+
'**/out/**',
|
|
37
|
+
'public/build/**',
|
|
38
|
+
'**/public/build/**',
|
|
39
|
+
'*.bundle.js',
|
|
40
|
+
'**/*.bundle.js',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'python',
|
|
45
|
+
markerFiles: ['requirements.txt', 'setup.py', 'pyproject.toml', 'Pipfile'],
|
|
46
|
+
excludePatterns: [
|
|
47
|
+
'venv/**',
|
|
48
|
+
'**/venv/**',
|
|
49
|
+
'.venv/**',
|
|
50
|
+
'**/.venv/**',
|
|
51
|
+
'__pycache__/**',
|
|
52
|
+
'**/__pycache__/**',
|
|
53
|
+
'*.pyc',
|
|
54
|
+
'**/*.pyc',
|
|
55
|
+
'*.pyo',
|
|
56
|
+
'**/*.pyo',
|
|
57
|
+
'*.pyd',
|
|
58
|
+
'**/*.pyd',
|
|
59
|
+
'*.egg-info/**',
|
|
60
|
+
'**/*.egg-info/**',
|
|
61
|
+
'.tox/**',
|
|
62
|
+
'**/.tox/**',
|
|
63
|
+
'.pytest_cache/**',
|
|
64
|
+
'**/.pytest_cache/**',
|
|
65
|
+
'.coverage',
|
|
66
|
+
'htmlcov/**',
|
|
67
|
+
'**/htmlcov/**',
|
|
68
|
+
'.mypy_cache/**',
|
|
69
|
+
'**/.mypy_cache/**',
|
|
70
|
+
'docs/_build/**',
|
|
71
|
+
'migrations/**',
|
|
72
|
+
'**/migrations/**',
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'php',
|
|
77
|
+
markerFiles: ['composer.json'],
|
|
78
|
+
excludePatterns: [
|
|
79
|
+
'storage/**',
|
|
80
|
+
'**/storage/**',
|
|
81
|
+
'cache/**',
|
|
82
|
+
'**/cache/**',
|
|
83
|
+
'bootstrap/cache/**',
|
|
84
|
+
'**/bootstrap/cache/**',
|
|
85
|
+
'.phpunit.cache/**',
|
|
86
|
+
'**/.phpunit.cache/**',
|
|
87
|
+
'public/build/**',
|
|
88
|
+
'**/public/build/**',
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'laravel',
|
|
93
|
+
markerFiles: ['artisan'],
|
|
94
|
+
excludePatterns: [
|
|
95
|
+
'database/migrations/**',
|
|
96
|
+
'database/seeders/**',
|
|
97
|
+
'database/factories/**',
|
|
98
|
+
'public/**/*.js',
|
|
99
|
+
'public/**/*.css',
|
|
100
|
+
'public/hot',
|
|
101
|
+
'public/build/**',
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'ruby',
|
|
106
|
+
markerFiles: ['Gemfile'],
|
|
107
|
+
excludePatterns: [
|
|
108
|
+
'tmp/**',
|
|
109
|
+
'**/tmp/**',
|
|
110
|
+
'.bundle/**',
|
|
111
|
+
'**/.bundle/**',
|
|
112
|
+
'log/**',
|
|
113
|
+
'**/log/**',
|
|
114
|
+
'coverage/**',
|
|
115
|
+
'**/coverage/**',
|
|
116
|
+
'public/assets/**',
|
|
117
|
+
'**/public/assets/**',
|
|
118
|
+
'public/packs/**',
|
|
119
|
+
'**/public/packs/**',
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'rails',
|
|
124
|
+
markerFiles: ['bin/rails'],
|
|
125
|
+
excludePatterns: [
|
|
126
|
+
'db/migrate/**',
|
|
127
|
+
'**/db/migrate/**',
|
|
128
|
+
'db/seeds/**',
|
|
129
|
+
'**/db/seeds/**',
|
|
130
|
+
'storage/**',
|
|
131
|
+
'**/storage/**',
|
|
132
|
+
'tmp/**',
|
|
133
|
+
'**/tmp/**',
|
|
134
|
+
'log/**',
|
|
135
|
+
'**/log/**',
|
|
136
|
+
'public/assets/**',
|
|
137
|
+
'**/public/assets/**',
|
|
138
|
+
'public/packs/**',
|
|
139
|
+
'**/public/packs/**',
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'rust',
|
|
144
|
+
markerFiles: ['Cargo.toml'],
|
|
145
|
+
excludePatterns: ['target/**', '**/target/**'],
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'jvm',
|
|
149
|
+
markerFiles: ['pom.xml', 'build.gradle', 'build.gradle.kts'],
|
|
150
|
+
excludePatterns: [
|
|
151
|
+
'.gradle/**',
|
|
152
|
+
'**/.gradle/**',
|
|
153
|
+
'target/**',
|
|
154
|
+
'**/target/**',
|
|
155
|
+
'out/**',
|
|
156
|
+
'**/out/**',
|
|
157
|
+
'.idea/**',
|
|
158
|
+
'**/.idea/**',
|
|
159
|
+
'*.class',
|
|
160
|
+
'**/*.class',
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'swift',
|
|
165
|
+
markerFiles: ['Package.swift', '*.xcodeproj', '*.xcworkspace'],
|
|
166
|
+
excludePatterns: [
|
|
167
|
+
'.build/**',
|
|
168
|
+
'**/.build/**',
|
|
169
|
+
'DerivedData/**',
|
|
170
|
+
'**/DerivedData/**',
|
|
171
|
+
'*.xcodeproj/**',
|
|
172
|
+
'**/*.xcodeproj/**',
|
|
173
|
+
'Pods/**',
|
|
174
|
+
'**/Pods/**',
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'dotnet',
|
|
179
|
+
markerFiles: ['*.csproj', '*.sln'],
|
|
180
|
+
excludePatterns: [
|
|
181
|
+
'bin/**',
|
|
182
|
+
'**/bin/**',
|
|
183
|
+
'obj/**',
|
|
184
|
+
'**/obj/**',
|
|
185
|
+
'packages/**',
|
|
186
|
+
'**/packages/**',
|
|
187
|
+
'.vs/**',
|
|
188
|
+
'**/.vs/**',
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'django',
|
|
193
|
+
markerFiles: ['manage.py'],
|
|
194
|
+
excludePatterns: [
|
|
195
|
+
'staticfiles/**',
|
|
196
|
+
'**/staticfiles/**',
|
|
197
|
+
'media/**',
|
|
198
|
+
'**/media/**',
|
|
199
|
+
'*.sqlite3',
|
|
200
|
+
'**/*.sqlite3',
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'astro',
|
|
205
|
+
markerFiles: ['astro.config.*'],
|
|
206
|
+
excludePatterns: ['.astro/**', '**/.astro/**'],
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
/** Directories to skip when scanning for marker files in subdirectories */
|
|
210
|
+
const SKIP_DIRS = new Set([
|
|
211
|
+
'node_modules',
|
|
212
|
+
'vendor',
|
|
213
|
+
'.git',
|
|
214
|
+
'.lien',
|
|
215
|
+
'dist',
|
|
216
|
+
'build',
|
|
217
|
+
'.next',
|
|
218
|
+
'.nuxt',
|
|
219
|
+
'.vite',
|
|
220
|
+
'.turbo',
|
|
221
|
+
'venv',
|
|
222
|
+
'.venv',
|
|
223
|
+
'__pycache__',
|
|
224
|
+
'.tox',
|
|
225
|
+
'coverage',
|
|
226
|
+
'.cache',
|
|
227
|
+
'target',
|
|
228
|
+
'.gradle',
|
|
229
|
+
'.idea',
|
|
230
|
+
'out',
|
|
231
|
+
'DerivedData',
|
|
232
|
+
'Pods',
|
|
233
|
+
'.build',
|
|
234
|
+
'obj',
|
|
235
|
+
'.vs',
|
|
236
|
+
'tmp',
|
|
237
|
+
'log',
|
|
238
|
+
'.bundle',
|
|
239
|
+
'.astro',
|
|
240
|
+
]);
|
|
241
|
+
/** Convert a simple glob pattern (e.g. `*.csproj`) to a RegExp */
|
|
242
|
+
function simpleGlobToRegExp(pattern) {
|
|
243
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
244
|
+
return new RegExp(`^${escaped}$`);
|
|
245
|
+
}
|
|
246
|
+
/** Check if a marker file exists in a directory, using cached readdir for glob markers */
|
|
247
|
+
async function hasMarkerFile(dir, marker, dirEntryCache) {
|
|
248
|
+
try {
|
|
249
|
+
if (marker.includes('*')) {
|
|
250
|
+
let entries = dirEntryCache.get(dir);
|
|
251
|
+
if (!entries) {
|
|
252
|
+
entries = await fs.readdir(dir);
|
|
253
|
+
dirEntryCache.set(dir, entries);
|
|
254
|
+
}
|
|
255
|
+
const re = simpleGlobToRegExp(marker);
|
|
256
|
+
return entries.some(entry => re.test(entry));
|
|
257
|
+
}
|
|
258
|
+
await fs.access(path.join(dir, marker));
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/** Get rootDir + immediate subdirectories, skipping known artifact dirs */
|
|
266
|
+
async function getSearchDirs(rootDir) {
|
|
267
|
+
const dirs = [rootDir];
|
|
268
|
+
try {
|
|
269
|
+
const entries = await fs.readdir(rootDir, { withFileTypes: true });
|
|
270
|
+
for (const entry of entries) {
|
|
271
|
+
if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
|
|
272
|
+
dirs.push(path.join(rootDir, entry.name));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
// Can't read subdirs, just check root
|
|
278
|
+
}
|
|
279
|
+
return dirs;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Detect which ecosystems are present in a project by checking for marker files.
|
|
283
|
+
* Checks rootDir and immediate subdirectories (depth 1) for monorepo support.
|
|
284
|
+
*
|
|
285
|
+
* @param rootDir - Project root directory
|
|
286
|
+
* @returns Array of matched ecosystem names
|
|
287
|
+
*/
|
|
288
|
+
export async function detectEcosystems(rootDir) {
|
|
289
|
+
const matched = new Set();
|
|
290
|
+
const searchDirs = await getSearchDirs(rootDir);
|
|
291
|
+
const dirEntryCache = new Map();
|
|
292
|
+
for (const dir of searchDirs) {
|
|
293
|
+
for (const preset of ECOSYSTEM_PRESETS) {
|
|
294
|
+
if (matched.has(preset.name))
|
|
295
|
+
continue;
|
|
296
|
+
for (const marker of preset.markerFiles) {
|
|
297
|
+
if (await hasMarkerFile(dir, marker, dirEntryCache)) {
|
|
298
|
+
matched.add(preset.name);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return [...matched];
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Get merged exclude patterns for the given ecosystem names.
|
|
308
|
+
* Returns a deduplicated array of exclude patterns.
|
|
309
|
+
*
|
|
310
|
+
* @param ecosystemNames - Array of ecosystem names (e.g. ['nodejs', 'python'])
|
|
311
|
+
* @returns Deduplicated exclude patterns
|
|
312
|
+
*/
|
|
313
|
+
export function getEcosystemExcludePatterns(ecosystemNames) {
|
|
314
|
+
const patterns = new Set();
|
|
315
|
+
for (const name of ecosystemNames) {
|
|
316
|
+
const preset = ECOSYSTEM_PRESETS.find(p => p.name === name);
|
|
317
|
+
if (preset) {
|
|
318
|
+
for (const pattern of preset.excludePatterns) {
|
|
319
|
+
patterns.add(pattern);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return [...patterns];
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=ecosystem-presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecosystem-presets.js","sourceRoot":"","sources":["../src/ecosystem-presets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAYxB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
|
|
|
1
|
+
/**
|
|
2
|
+
* Patterns that should always be ignored regardless of user configuration.
|
|
3
|
+
* Single source of truth — imported by scanner.ts and used by createGitignoreFilter.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ALWAYS_IGNORE_PATTERNS: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Create a filter function that checks if a file path is gitignored.
|
|
8
|
+
* Discovers .gitignore files throughout the directory tree and applies
|
|
9
|
+
* each at its appropriate scope, plus built-in exclusions (node_modules,
|
|
10
|
+
* vendor, .git, .lien, dist, build, minified assets) to match the full scan
|
|
11
|
+
* behavior in scanner.ts.
|
|
12
|
+
*
|
|
13
|
+
* Limitation: scoped evaluation is OR across .gitignore files, so a nested
|
|
14
|
+
* .gitignore cannot un-ignore a pattern from a parent. Cross-scope negation
|
|
15
|
+
* (e.g., root ignores `*.log`, child un-ignores `!important.log`) is not
|
|
16
|
+
* supported. Nested .gitignore files in practice almost always ADD patterns.
|
|
17
|
+
*
|
|
18
|
+
* @param rootDir - Project root directory
|
|
19
|
+
* @returns Function that returns true if a relative path is ignored
|
|
20
|
+
*/
|
|
21
|
+
export declare function createGitignoreFilter(rootDir: string): Promise<(relativePath: string) => boolean>;
|
|
22
|
+
//# sourceMappingURL=gitignore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.d.ts","sourceRoot":"","sources":["../src/gitignore.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,UAgBlC,CAAC;AAuEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,CAuB5C"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import ignore from 'ignore';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
/**
|
|
5
|
+
* Patterns that should always be ignored regardless of user configuration.
|
|
6
|
+
* Single source of truth — imported by scanner.ts and used by createGitignoreFilter.
|
|
7
|
+
*/
|
|
8
|
+
export const ALWAYS_IGNORE_PATTERNS = [
|
|
9
|
+
'node_modules/**',
|
|
10
|
+
'**/node_modules/**',
|
|
11
|
+
'vendor/**',
|
|
12
|
+
'**/vendor/**',
|
|
13
|
+
'.git/**',
|
|
14
|
+
'**/.git/**',
|
|
15
|
+
'.lien/**',
|
|
16
|
+
'dist/**',
|
|
17
|
+
'**/dist/**',
|
|
18
|
+
'build/**',
|
|
19
|
+
'**/build/**',
|
|
20
|
+
'*.min.js',
|
|
21
|
+
'**/*.min.js',
|
|
22
|
+
'*.min.css',
|
|
23
|
+
'**/*.min.css',
|
|
24
|
+
];
|
|
25
|
+
/** Directories to skip during .gitignore discovery (no useful .gitignore inside) */
|
|
26
|
+
const SKIP_DIRS = new Set(['node_modules', 'vendor', '.git', '.lien', 'dist', 'build']);
|
|
27
|
+
/** Whether a directory entry should be traversed during .gitignore discovery */
|
|
28
|
+
function shouldTraverseDir(entry) {
|
|
29
|
+
if (!entry.isDirectory() || entry.isSymbolicLink())
|
|
30
|
+
return false;
|
|
31
|
+
if (SKIP_DIRS.has(entry.name))
|
|
32
|
+
return false;
|
|
33
|
+
// Skip hidden dirs except .github
|
|
34
|
+
if (entry.name.startsWith('.') && entry.name !== '.github')
|
|
35
|
+
return false;
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
/** Read .gitignore content from a directory, or null if not present */
|
|
39
|
+
async function readGitignore(absDir, entries) {
|
|
40
|
+
if (!entries.some(e => e.name === '.gitignore' && e.isFile()))
|
|
41
|
+
return null;
|
|
42
|
+
try {
|
|
43
|
+
return await fs.readFile(path.join(absDir, '.gitignore'), 'utf-8');
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null; // Race condition or permission issue
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Walk the directory tree from rootDir, collecting .gitignore contents.
|
|
51
|
+
* Skips SKIP_DIRS and symlinked directories to avoid cycles.
|
|
52
|
+
*
|
|
53
|
+
* @returns Map of relative dir path ('' for root, 'packages/app' etc.) to .gitignore content
|
|
54
|
+
*/
|
|
55
|
+
async function discoverGitignoreFiles(rootDir) {
|
|
56
|
+
const result = new Map();
|
|
57
|
+
const queue = [''];
|
|
58
|
+
let head = 0;
|
|
59
|
+
while (head < queue.length) {
|
|
60
|
+
const relDir = queue[head++];
|
|
61
|
+
const absDir = relDir ? path.join(rootDir, relDir) : rootDir;
|
|
62
|
+
let entries;
|
|
63
|
+
try {
|
|
64
|
+
entries = await fs.readdir(absDir, { withFileTypes: true });
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const content = await readGitignore(absDir, entries);
|
|
70
|
+
if (content !== null) {
|
|
71
|
+
result.set(relDir, content);
|
|
72
|
+
}
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (!shouldTraverseDir(entry))
|
|
75
|
+
continue;
|
|
76
|
+
const childRel = relDir ? `${relDir}/${entry.name}` : entry.name;
|
|
77
|
+
queue.push(childRel);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
/** Check if a path matches a scoped .gitignore (root or nested) */
|
|
83
|
+
function matchesScopedIgnore(normalized, prefix, ig) {
|
|
84
|
+
if (prefix === '')
|
|
85
|
+
return ig.ignores(normalized);
|
|
86
|
+
const prefixWithSlash = prefix + '/';
|
|
87
|
+
if (!normalized.startsWith(prefixWithSlash))
|
|
88
|
+
return false;
|
|
89
|
+
const scopedPath = normalized.slice(prefixWithSlash.length);
|
|
90
|
+
return scopedPath !== '' && ig.ignores(scopedPath);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a filter function that checks if a file path is gitignored.
|
|
94
|
+
* Discovers .gitignore files throughout the directory tree and applies
|
|
95
|
+
* each at its appropriate scope, plus built-in exclusions (node_modules,
|
|
96
|
+
* vendor, .git, .lien, dist, build, minified assets) to match the full scan
|
|
97
|
+
* behavior in scanner.ts.
|
|
98
|
+
*
|
|
99
|
+
* Limitation: scoped evaluation is OR across .gitignore files, so a nested
|
|
100
|
+
* .gitignore cannot un-ignore a pattern from a parent. Cross-scope negation
|
|
101
|
+
* (e.g., root ignores `*.log`, child un-ignores `!important.log`) is not
|
|
102
|
+
* supported. Nested .gitignore files in practice almost always ADD patterns.
|
|
103
|
+
*
|
|
104
|
+
* @param rootDir - Project root directory
|
|
105
|
+
* @returns Function that returns true if a relative path is ignored
|
|
106
|
+
*/
|
|
107
|
+
export async function createGitignoreFilter(rootDir) {
|
|
108
|
+
// Always-ignore patterns in a separate instance (cannot be negated)
|
|
109
|
+
const alwaysIg = ignore();
|
|
110
|
+
alwaysIg.add(ALWAYS_IGNORE_PATTERNS);
|
|
111
|
+
// Discover all .gitignore files and build scoped ignore instances
|
|
112
|
+
const gitignoreMap = await discoverGitignoreFiles(rootDir);
|
|
113
|
+
const scopedIgnores = [];
|
|
114
|
+
for (const [relDir, content] of gitignoreMap) {
|
|
115
|
+
const ig = ignore();
|
|
116
|
+
ig.add(content);
|
|
117
|
+
scopedIgnores.push({ prefix: relDir, ig });
|
|
118
|
+
}
|
|
119
|
+
// Sort by prefix length (root first) for consistent evaluation
|
|
120
|
+
scopedIgnores.sort((a, b) => a.prefix.length - b.prefix.length);
|
|
121
|
+
return (relativePath) => {
|
|
122
|
+
const normalized = relativePath.replace(/\\/g, '/');
|
|
123
|
+
if (alwaysIg.ignores(normalized))
|
|
124
|
+
return true;
|
|
125
|
+
return scopedIgnores.some(({ prefix, ig }) => matchesScopedIgnore(normalized, prefix, ig));
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=gitignore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.js","sourceRoot":"","sources":["../src/gitignore.ts"],"names":[],"mappings":"A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O,CAAC,YAAoB,EAAE,EAAE;QAC9B,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACpD,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type { CodeChunk, ChunkMetadata, ScanOptions } from './types.js';
|
|
2
|
+
export type { RiskLevel, ComplexityMetricType, HalsteadDetails, ComplexityViolation, FileComplexityData, ComplexityReport, } from './insights/types.js';
|
|
3
|
+
export { RISK_ORDER } from './insights/types.js';
|
|
4
|
+
export { DEFAULT_CHUNK_SIZE, DEFAULT_CHUNK_OVERLAP, MAX_CHUNKS_PER_FILE } from './constants.js';
|
|
5
|
+
export { normalizePath, matchesFile, getCanonicalPath, isTestFile } from './utils/path-matching.js';
|
|
6
|
+
export { extractRepoId } from './utils/repo-id.js';
|
|
7
|
+
export { chunkByAST, shouldUseAST } from './ast/chunker.js';
|
|
8
|
+
export type { ASTChunkOptions } from './ast/chunker.js';
|
|
9
|
+
export { parseAST, detectLanguage, isASTSupported } from './ast/parser.js';
|
|
10
|
+
export { extractSymbolInfo, extractImports, extractImportedSymbols, extractExports, extractCallSites, } from './ast/symbols.js';
|
|
11
|
+
export type { SupportedLanguage, ASTChunk, SymbolInfo } from './ast/types.js';
|
|
12
|
+
export { getTraverser } from './ast/traversers/index.js';
|
|
13
|
+
export { getExtractor, getImportExtractor, getSymbolExtractor } from './ast/extractors/index.js';
|
|
14
|
+
export { calculateCognitiveComplexity, calculateHalstead } from './ast/complexity/index.js';
|
|
15
|
+
export { getSupportedExtensions, getLanguage, getAllLanguages, languageExists, } from './ast/languages/registry.js';
|
|
16
|
+
export { chunkFile, chunkText } from './chunker.js';
|
|
17
|
+
export type { ChunkOptions } from './chunker.js';
|
|
18
|
+
export { scanCodebase, detectFileType } from './scanner.js';
|
|
19
|
+
export { extractSymbols } from './symbol-extractor.js';
|
|
20
|
+
export { chunkLiquidFile } from './liquid-chunker.js';
|
|
21
|
+
export { chunkJSONTemplate } from './json-template-chunker.js';
|
|
22
|
+
export { createGitignoreFilter, ALWAYS_IGNORE_PATTERNS } from './gitignore.js';
|
|
23
|
+
export { detectEcosystems, getEcosystemExcludePatterns, ECOSYSTEM_PRESETS, } from './ecosystem-presets.js';
|
|
24
|
+
export type { EcosystemPreset } from './ecosystem-presets.js';
|
|
25
|
+
export { computeContentHash, isHashAlgorithmCompatible } from './content-hash.js';
|
|
26
|
+
export { findTestAssociationsFromChunks } from './test-associations.js';
|
|
27
|
+
export { analyzeDependencies, findTransitiveDependents, groupChunksByNormalizedPath, chunkImportsFrom, fileIsReExporter, DEPENDENT_COUNT_THRESHOLDS, COMPLEXITY_THRESHOLDS, } from './dependency-analyzer.js';
|
|
28
|
+
export type { FileComplexityInfo, DependencyAnalysisResult } from './dependency-analyzer.js';
|
|
29
|
+
export { analyzeComplexityFromChunks } from './insights/chunk-complexity.js';
|
|
30
|
+
export { performChunkOnlyIndex } from './chunk-only-index.js';
|
|
31
|
+
export type { ChunkOnlyOptions, ChunkOnlyResult } from './chunk-only-index.js';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGxE,YAAY,EACV,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,q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O,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAM/D,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAM/E,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAMlF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAMxE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAM7F,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAM7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// @liendev/parser - AST parsing, complexity analysis, and semantic chunking
|
|
2
|
+
export { RISK_ORDER } from './insights/types.js';
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// CONSTANTS
|
|
5
|
+
// =============================================================================
|
|
6
|
+
export { DEFAULT_CHUNK_SIZE, DEFAULT_CHUNK_OVERLAP, MAX_CHUNKS_PER_FILE } from './constants.js';
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// UTILITIES
|
|
9
|
+
// =============================================================================
|
|
10
|
+
export { normalizePath, matchesFile, getCanonicalPath, isTestFile } from './utils/path-matching.js';
|
|
11
|
+
export { extractRepoId } from './utils/repo-id.js';
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// AST
|
|
14
|
+
// =============================================================================
|
|
15
|
+
export { chunkByAST, shouldUseAST } from './ast/chunker.js';
|
|
16
|
+
export { parseAST, detectLanguage, isASTSupported } from './ast/parser.js';
|
|
17
|
+
export { extractSymbolInfo, extractImports, extractImportedSymbols, extractExports, extractCallSites, } from './ast/symbols.js';
|
|
18
|
+
export { getTraverser } from './ast/traversers/index.js';
|
|
19
|
+
export { getExtractor, getImportExtractor, getSymbolExtractor } from './ast/extractors/index.js';
|
|
20
|
+
export { calculateCognitiveComplexity, calculateHalstead } from './ast/complexity/index.js';
|
|
21
|
+
// AST Language Registry
|
|
22
|
+
export { getSupportedExtensions, getLanguage, getAllLanguages, languageExists, } from './ast/languages/registry.js';
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// CHUNKING
|
|
25
|
+
// =============================================================================
|
|
26
|
+
export { chunkFile, chunkText } from './chunker.js';
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// SCANNING
|
|
29
|
+
// =============================================================================
|
|
30
|
+
export { scanCodebase, detectFileType } from './scanner.js';
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// SYMBOL EXTRACTION (line-based)
|
|
33
|
+
// =============================================================================
|
|
34
|
+
export { extractSymbols } from './symbol-extractor.js';
|
|
35
|
+
// =============================================================================
|
|
36
|
+
// LIQUID & JSON TEMPLATE CHUNKING
|
|
37
|
+
// =============================================================================
|
|
38
|
+
export { chunkLiquidFile } from './liquid-chunker.js';
|
|
39
|
+
export { chunkJSONTemplate } from './json-template-chunker.js';
|
|
40
|
+
// =============================================================================
|
|
41
|
+
// GITIGNORE
|
|
42
|
+
// =============================================================================
|
|
43
|
+
export { createGitignoreFilter, ALWAYS_IGNORE_PATTERNS } from './gitignore.js';
|
|
44
|
+
// =============================================================================
|
|
45
|
+
// ECOSYSTEM PRESETS
|
|
46
|
+
// =============================================================================
|
|
47
|
+
export { detectEcosystems, getEcosystemExcludePatterns, ECOSYSTEM_PRESETS, } from './ecosystem-presets.js';
|
|
48
|
+
// =============================================================================
|
|
49
|
+
// CONTENT HASH
|
|
50
|
+
// =============================================================================
|
|
51
|
+
export { computeContentHash, isHashAlgorithmCompatible } from './content-hash.js';
|
|
52
|
+
// =============================================================================
|
|
53
|
+
// TEST ASSOCIATIONS
|
|
54
|
+
// =============================================================================
|
|
55
|
+
export { findTestAssociationsFromChunks } from './test-associations.js';
|
|
56
|
+
// =============================================================================
|
|
57
|
+
// DEPENDENCY ANALYSIS
|
|
58
|
+
// =============================================================================
|
|
59
|
+
export { analyzeDependencies, findTransitiveDependents, groupChunksByNormalizedPath, chunkImportsFrom, fileIsReExporter, DEPENDENT_COUNT_THRESHOLDS, COMPLEXITY_THRESHOLDS, } from './dependency-analyzer.js';
|
|
60
|
+
// =============================================================================
|
|
61
|
+
// COMPLEXITY ANALYSIS (chunk-based, no VectorDB)
|
|
62
|
+
// =============================================================================
|
|
63
|
+
export { analyzeComplexityFromChunks } from './insights/chunk-complexity.js';
|
|
64
|
+
// =============================================================================
|
|
65
|
+
// CHUNK-ONLY INDEXING (no embeddings or VectorDB)
|
|
66
|
+
// =============================================================================
|
|
67
|
+
export { performChunkOnlyIndex } from './chunk-only-index.js';
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAkB5E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEhG,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC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