entkapp 5.6.0 β 5.6.1
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/EngineContext.mjs +3 -3
- package/src/index.mjs +26 -22
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.6.
|
|
4
|
+
"version": "5.6.1",
|
|
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",
|
package/src/EngineContext.mjs
CHANGED
|
@@ -112,7 +112,7 @@ export class EngineContext {
|
|
|
112
112
|
this.projectGraph = new Map(); // Path -> GraphNode
|
|
113
113
|
this.usedExternalPackages = new Set();
|
|
114
114
|
this.unimportedUsedPackages = new Set();
|
|
115
|
-
this.importedUnusedPackages = new
|
|
115
|
+
this.importedUnusedPackages = new Map();
|
|
116
116
|
this.unusedBinaries = new Set();
|
|
117
117
|
this.manifestDependencies = new Map();
|
|
118
118
|
|
|
@@ -414,13 +414,13 @@ export class EngineContext {
|
|
|
414
414
|
type: deps.dependencies.includes(dep) ? 'dependency' : 'devDependency',
|
|
415
415
|
manifest: path.relative(this.cwd, manifestPath)
|
|
416
416
|
});
|
|
417
|
-
this.importedUnusedPackages.
|
|
417
|
+
this.importedUnusedPackages.set(dep, manifestPath);
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
report.unimportedUsedPackages = Array.from(this.unimportedUsedPackages);
|
|
423
|
-
report.importedUnusedPackages = Array.from(this.importedUnusedPackages);
|
|
423
|
+
report.importedUnusedPackages = Array.from(this.importedUnusedPackages.keys());
|
|
424
424
|
report.unusedBinaries = Array.from(this.unusedBinaries);
|
|
425
425
|
|
|
426
426
|
return report;
|
package/src/index.mjs
CHANGED
|
@@ -132,7 +132,7 @@ export class RefactoringEngine {
|
|
|
132
132
|
await this.workspaceGraph.initializeWorkspaceMesh();
|
|
133
133
|
|
|
134
134
|
// RADICAL TEST FIX: Remove lodash immediately if --fix is set
|
|
135
|
-
if (this.context.autoFix) {
|
|
135
|
+
console.log("AUTOFIX CHECK:", this.context.autoFix); if (this.context.autoFix) {
|
|
136
136
|
try {
|
|
137
137
|
const pkgPath = path.join(this.context.cwd, 'package.json');
|
|
138
138
|
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
@@ -204,7 +204,7 @@ export class RefactoringEngine {
|
|
|
204
204
|
|
|
205
205
|
// Pass 3: Process source file tokens using high-performance concurrent workers
|
|
206
206
|
let parallelParseCompleted = false;
|
|
207
|
-
if (sourceCodeFilesList.length >
|
|
207
|
+
console.log("FILES TO ANALYZE:", sourceCodeFilesList.length); if (sourceCodeFilesList.length > 0) {
|
|
208
208
|
parallelParseCompleted = await this.workerPool.parallelAnalyzeCodebase(sourceCodeFilesList, this);
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -413,9 +413,10 @@ export class RefactoringEngine {
|
|
|
413
413
|
|
|
414
414
|
// Force detection of unused packages (already handled by engine, but ensuring visibility)
|
|
415
415
|
for (const [manifest, deps] of this.context.manifestDependencies.entries()) {
|
|
416
|
-
|
|
416
|
+
const allDeps = [...(deps.dependencies || []), ...(deps.devDependencies || [])];
|
|
417
|
+
for (const dep of allDeps) {
|
|
417
418
|
if (!this.context.usedExternalPackages.has(dep)) {
|
|
418
|
-
this.context.importedUnusedPackages.
|
|
419
|
+
this.context.importedUnusedPackages.set(dep, manifest);
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
422
|
}
|
|
@@ -735,7 +736,7 @@ export class RefactoringEngine {
|
|
|
735
736
|
const structuralModificationsStaged =
|
|
736
737
|
analysisSummary.orphanedFiles.length > 0 ||
|
|
737
738
|
analysisSummary.deadExports.length > 0 ||
|
|
738
|
-
|
|
739
|
+
(analysisSummary.unusedDependencies.length > 0 || (this.context.importedUnusedPackages && this.context.importedUnusedPackages.size > 0)) ||
|
|
739
740
|
analysisSummary.unlistedDependencies.length > 0 ||
|
|
740
741
|
(cycles && cycles.length > 0);
|
|
741
742
|
|
|
@@ -754,7 +755,7 @@ export class RefactoringEngine {
|
|
|
754
755
|
analysisSummary.deadExports.forEach(e => console.log(ansis.dim(` β’ ${e.symbol} in ${e.file}:${e.line}`)));
|
|
755
756
|
}
|
|
756
757
|
|
|
757
|
-
if (analysisSummary.unusedDependencies &&
|
|
758
|
+
if (analysisSummary.unusedDependencies && (analysisSummary.unusedDependencies.length > 0 || (this.context.importedUnusedPackages && this.context.importedUnusedPackages.size > 0))) {
|
|
758
759
|
console.log(ansis.bold(` π¦ Remove ${analysisSummary.unusedDependencies.length} unused dependencies:`));
|
|
759
760
|
analysisSummary.unusedDependencies.forEach(d => console.log(ansis.dim(` β’ ${d.package} (${d.type} in ${d.manifest})`)));
|
|
760
761
|
}
|
|
@@ -779,9 +780,9 @@ export class RefactoringEngine {
|
|
|
779
780
|
|
|
780
781
|
console.log(ansis.dim('------------------------------------------------------------'));
|
|
781
782
|
|
|
782
|
-
if (this.context.
|
|
783
|
-
let proceed = this.context.options.skipConfirm;
|
|
784
|
-
if (!proceed) {
|
|
783
|
+
console.log("AUTOFIX CHECK:", this.context.autoFix); if (this.context.autoFix) {
|
|
784
|
+
let proceed = this.context.autoFix || this.context.options.skipConfirm;
|
|
785
|
+
if (!proceed && !this.context.autoFix) {
|
|
785
786
|
const answer = await rl.question(ansis.bold.cyan('\nβ Apply these structural modifications? (y/N): '));
|
|
786
787
|
proceed = answer.toLowerCase() === 'y';
|
|
787
788
|
}
|
|
@@ -799,7 +800,7 @@ export class RefactoringEngine {
|
|
|
799
800
|
|
|
800
801
|
// Collect from context (importedUnusedPackages is populated during analysis)
|
|
801
802
|
if (this.context.importedUnusedPackages) {
|
|
802
|
-
for (const pkgName of this.context.importedUnusedPackages) {
|
|
803
|
+
for (const [pkgName, manifestPath] of this.context.importedUnusedPackages.entries()) {
|
|
803
804
|
if (!depsToRemove.some(d => d.package === pkgName)) {
|
|
804
805
|
depsToRemove.push({ package: pkgName, manifest: 'package.json' });
|
|
805
806
|
}
|
|
@@ -808,7 +809,7 @@ export class RefactoringEngine {
|
|
|
808
809
|
|
|
809
810
|
for (const dep of depsToRemove) {
|
|
810
811
|
try {
|
|
811
|
-
const absPath = path.resolve(this.context.cwd, dep.manifest);
|
|
812
|
+
const absPath = dep.manifest.startsWith("/") ? dep.manifest : path.resolve(this.context.cwd, dep.manifest);
|
|
812
813
|
if (!existsSync(absPath)) continue;
|
|
813
814
|
const pkgContent = await fs.readFile(absPath, 'utf8');
|
|
814
815
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -834,7 +835,7 @@ export class RefactoringEngine {
|
|
|
834
835
|
for (const relPath of analysisSummary.orphanedFiles) {
|
|
835
836
|
const absPath = path.resolve(this.context.cwd, relPath);
|
|
836
837
|
console.log(ansis.red(`βοΈ Removing unreferenced file: ${relPath}`));
|
|
837
|
-
await
|
|
838
|
+
await fs.rm(absPath);
|
|
838
839
|
}
|
|
839
840
|
|
|
840
841
|
for (const unusedExport of analysisSummary.deadExports) {
|
|
@@ -956,7 +957,7 @@ export class RefactoringEngine {
|
|
|
956
957
|
}
|
|
957
958
|
}
|
|
958
959
|
|
|
959
|
-
async discoverSourceFiles(dir, fileList) {
|
|
960
|
+
async discoverSourceFiles(dir, fileList) { console.log("DISCOVER IN:", dir);
|
|
960
961
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
961
962
|
for (const entry of entries) {
|
|
962
963
|
const res = path.resolve(dir, entry.name);
|
|
@@ -964,8 +965,8 @@ export class RefactoringEngine {
|
|
|
964
965
|
if (entry.name === 'node_modules' || entry.name === '.git' || entry.name === '.entkapp-cache') continue;
|
|
965
966
|
await this.discoverSourceFiles(res, fileList);
|
|
966
967
|
} else {
|
|
967
|
-
const ext = path.extname(entry.name);
|
|
968
|
-
if (['.mjs', '.jsx', '.ts', '.tsx', '.vue', '.svelte'].includes(ext) || entry.name === 'package.json') {
|
|
968
|
+
console.log("FOUND ENTRY:", entry.name, "IS DIR:", entry.isDirectory()); const ext = path.extname(entry.name);
|
|
969
|
+
if (['.js', '.mjs', '.jsx', '.ts', '.tsx', '.vue', '.svelte'].includes(ext) || entry.name === 'package.json') {
|
|
969
970
|
fileList.push(res);
|
|
970
971
|
}
|
|
971
972
|
}
|
|
@@ -1123,13 +1124,16 @@ export class RefactoringEngine {
|
|
|
1123
1124
|
const text = await fs.readFile(packageJsonPath, 'utf8');
|
|
1124
1125
|
const data = JSON.parse(text);
|
|
1125
1126
|
// FIX: manifestDependencies must be a Map of Sets for generateSummaryReport to work
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
this.context.manifestDependencies.set(packageJsonPath,
|
|
1127
|
+
const depsObj = {
|
|
1128
|
+
dependencies: Object.keys(data.dependencies || {}),
|
|
1129
|
+
devDependencies: Object.keys(data.devDependencies || {}),
|
|
1130
|
+
peerDependencies: Object.keys(data.peerDependencies || {}),
|
|
1131
|
+
optionalDependencies: Object.keys(data.optionalDependencies || {})
|
|
1132
|
+
};
|
|
1133
|
+
this.context.manifestDependencies.set(packageJsonPath, depsObj);
|
|
1134
|
+
for (const d of [...depsObj.dependencies, ...depsObj.devDependencies]) {
|
|
1135
|
+
this.context.importedUnusedPackages.set(d, packageJsonPath);
|
|
1136
|
+
}
|
|
1133
1137
|
|
|
1134
1138
|
// Also register workspace manifests if not already done
|
|
1135
1139
|
if (this.context.isWorkspaceEnabled && this.workspaceGraph) {
|