entkapp 5.3.1 → 5.5.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/README.md +1 -1
- package/package.json +1 -1
- package/src/resolution/FrameworkConfigParser.js +119 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"name": "entkapp",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.5.0",
|
|
5
5
|
"description": "The Ultimate Enterprise Codebase Janitor. High-speed OXC integration, type-aware analysis, and automated structural healing. Fully standalone architectural orchestrator.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "index.js",
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight Static Analysis Parser for Vite / Vitest / Framework Configurations.
|
|
6
|
+
* Extracts 'resolve.alias' and 'build.lib.entry' without executing the file.
|
|
7
|
+
* Version 5.4.0: Added poly-extension path resolution.
|
|
8
|
+
*/
|
|
9
|
+
export class FrameworkConfigParser {
|
|
10
|
+
constructor(context) {
|
|
11
|
+
this.context = context;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parses a Framework configuration file and extracts structural metadata.
|
|
16
|
+
* @param {string} content - Raw source code of the config file
|
|
17
|
+
* @param {string} filePath - Absolute path to the config file
|
|
18
|
+
* @returns {Object} { aliases: Map<string, string>, entries: Set<string> }
|
|
19
|
+
*/
|
|
20
|
+
parse(content, filePath) {
|
|
21
|
+
const results = {
|
|
22
|
+
aliases: new Map(),
|
|
23
|
+
entries: new Set()
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (!content) return results;
|
|
27
|
+
|
|
28
|
+
const configDir = path.dirname(filePath);
|
|
29
|
+
|
|
30
|
+
// 1. Extract Aliases from resolve: { alias: { ... } } or alias: [ ... ]
|
|
31
|
+
this._extractAliases(content, configDir, results.aliases);
|
|
32
|
+
|
|
33
|
+
// 2. Extract Entry Points from build: { lib: { entry: '...' } } or rollupOptions: { input: '...' }
|
|
34
|
+
this._extractEntries(content, configDir, results.entries);
|
|
35
|
+
|
|
36
|
+
return results;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_extractAliases(content, configDir, aliasMap) {
|
|
40
|
+
const objAliasPatterns = [
|
|
41
|
+
/alias\s*:\s*\{([\s\S]*?)\}/g,
|
|
42
|
+
/resolve\s*:\s*\{[\s\S]*?alias\s*:\s*\{([\s\S]*?)\}/g
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
for (const pattern of objAliasPatterns) {
|
|
46
|
+
let match;
|
|
47
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
48
|
+
const inner = match[1];
|
|
49
|
+
const pairPattern = /(?:['"]?)(@?[a-zA-Z0-9_\-\/*]+)(?:['"]?)\s*:\s*(?:['"]([^'"]+)['"]|(path\.(?:resolve|join)\([\s\S]*?\)))/g;
|
|
50
|
+
let pair;
|
|
51
|
+
while ((pair = pairPattern.exec(inner)) !== null) {
|
|
52
|
+
const [_, key, stringVal, callVal] = pair;
|
|
53
|
+
aliasMap.set(key, this._resolveValue(stringVal || callVal, configDir));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const arrAliasPattern = /alias\s*:\s*\[([\s\S]*?)\]/;
|
|
59
|
+
const arrMatch = arrAliasPattern.exec(content);
|
|
60
|
+
if (arrMatch) {
|
|
61
|
+
const inner = arrMatch[1];
|
|
62
|
+
const findPattern = /\{\s*find\s*:\s*['"]([^'"]+)['"]\s*,\s*replacement\s*:\s*['"]([^'"]+)['"]\s*\}/g;
|
|
63
|
+
let findMatch;
|
|
64
|
+
while ((findMatch = findPattern.exec(inner)) !== null) {
|
|
65
|
+
const [_, key, value] = findMatch;
|
|
66
|
+
aliasMap.set(key, this._resolveValue(value, configDir));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_extractEntries(content, configDir, entrySet) {
|
|
72
|
+
const libEntryPattern = /entry\s*:\s*['"]([^'"]+)['"]/;
|
|
73
|
+
const libMatch = libEntryPattern.exec(content);
|
|
74
|
+
if (libMatch) {
|
|
75
|
+
entrySet.add(this._resolveValue(libMatch[1], configDir));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const inputPattern = /input\s*:\s*(?:['"]([^'"]+)['"]|\[([\s\S]*?)\])/;
|
|
79
|
+
const inputMatch = inputPattern.exec(content);
|
|
80
|
+
if (inputMatch) {
|
|
81
|
+
if (inputMatch[1]) {
|
|
82
|
+
entrySet.add(this._resolveValue(inputMatch[1], configDir));
|
|
83
|
+
} else if (inputMatch[2]) {
|
|
84
|
+
const paths = inputMatch[2].match(/['"]([^'"]+)['"]/g);
|
|
85
|
+
if (paths) {
|
|
86
|
+
paths.forEach(p => entrySet.add(this._resolveValue(p.replace(/['"]/g, ''), configDir)));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Resolves a path value and applies poly-extension fallback if the file doesn't exist.
|
|
94
|
+
*/
|
|
95
|
+
_resolveValue(val, configDir) {
|
|
96
|
+
const pathCallPattern = /path\.(?:resolve|join)\s*\(\s*(?:__dirname\s*,\s*)?['"]([^'"]+)['"]\s*\)/;
|
|
97
|
+
const pathMatch = pathCallPattern.exec(val);
|
|
98
|
+
if (pathMatch) {
|
|
99
|
+
val = pathMatch[1];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (val.startsWith('.') || val.startsWith('/') || /^[a-zA-Z]:/.test(val)) {
|
|
103
|
+
let resolved = path.resolve(configDir, val).replace(/\\/g, '/');
|
|
104
|
+
|
|
105
|
+
// UPGRADE: Poly-extension fallback
|
|
106
|
+
if (!fs.existsSync(resolved)) {
|
|
107
|
+
const base = resolved.replace(/\.[a-zA-Z0-9]+$/, '');
|
|
108
|
+
const extensions = ['.ts', '.js', '.tsx', '.jsx', '.mjs', '.cjs'];
|
|
109
|
+
for (const ext of extensions) {
|
|
110
|
+
if (fs.existsSync(base + ext)) {
|
|
111
|
+
return (base + ext).replace(/\\/g, '/');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return resolved;
|
|
116
|
+
}
|
|
117
|
+
return val;
|
|
118
|
+
}
|
|
119
|
+
}
|