entkapp 5.2.1 → 5.2.2

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/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.2.1",
4
+ "version": "5.2.2",
5
5
  "description": "The Ultimate Enterprise Codebase Janitor. Faster than Knip with OXC integration, type-aware analysis, and automated structural healing. Fully standalone - solving what Knip cannot.",
6
6
  "type": "module",
7
7
  "main": "index.js",
@@ -604,8 +604,14 @@ export class ASTAnalyzer {
604
604
  if (this.context.verbose) console.log(`[AST-DEBUG] Found require() call in ${fileNode.filePath}`);
605
605
  const arg = node.arguments[0];
606
606
  if (arg && ts.isStringLiteral(arg)) {
607
- if (this.context.verbose) console.log(`[AST-DEBUG] Added import: ${arg.text}`);
608
- fileNode.explicitImports.add(arg.text);
607
+ const specifier = arg.text;
608
+ if (this.context.verbose) console.log(`[AST-DEBUG] Added import: ${specifier}`);
609
+ fileNode.explicitImports.add(specifier);
610
+
611
+ // UPGRADE: Also track package usage for unlisted dependency detection
612
+ if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
613
+ fileNode.externalPackageUsage.add(this._extractPackageName(specifier));
614
+ }
609
615
  }
610
616
  }
611
617
  }
package/src/index.js CHANGED
@@ -498,40 +498,63 @@ export class RefactoringEngine {
498
498
  }
499
499
  }
500
500
 
501
+ // UPGRADE: Unlisted Dependency Audit (Unified Root & Workspace)
502
+ const auditManifests = [];
503
+ // 1. Collect Root Manifest
504
+ const rootPkgPath = path.join(this.context.cwd, 'package.json');
505
+ if (existsSync(rootPkgPath)) {
506
+ auditManifests.push({
507
+ rootDirectory: this.context.cwd,
508
+ manifestPath: rootPkgPath
509
+ });
510
+ }
511
+ // 2. Collect Workspace Manifests
501
512
  if (this.workspaceGraph && this.workspaceGraph.packageManifests) {
502
513
  for (const [_, metadata] of this.workspaceGraph.packageManifests.entries()) {
503
- if (this.context.projectGraph) {
504
- for (const [filePath, fileNode] of this.context.projectGraph.entries()) {
505
- const cleanRelative = path.relative(metadata.rootDirectory, filePath).replace(/\\/g, '/');
506
-
507
- if (!cleanRelative.startsWith('..') && !cleanRelative.startsWith('/') && fileNode.explicitImports) {
508
- try {
509
- const localManifest = JSON.parse(readFileSync(metadata.manifestPath, 'utf8'));
510
- const localDeps = new Set([
511
- ...Object.keys(localManifest.dependencies || {}),
512
- ...Object.keys(localManifest.devDependencies || {}),
513
- ...Object.keys(localManifest.peerDependencies || {})
514
- ]);
515
-
516
- fileNode.explicitImports.forEach(specifier => {
517
- if (specifier.startsWith('.') || specifier.startsWith('/')) return;
518
- const basePkg = specifier.startsWith('@') ? specifier.split('/').slice(0, 2).join('/') : specifier.split('/')[0];
519
-
520
- if (!localDeps.has(basePkg)) {
521
- const alreadyFlagged = this.context.unlistedDependencies.some(u => u.package === basePkg && u.file === filePath);
522
- if (!alreadyFlagged) {
523
- this.context.unlistedDependencies.push({
524
- package: basePkg,
525
- file: path.relative(this.context.cwd, filePath),
526
- manifest: path.relative(this.context.cwd, metadata.manifestPath)
527
- });
528
- }
514
+ auditManifests.push(metadata);
515
+ }
516
+ }
517
+
518
+ for (const metadata of auditManifests) {
519
+ if (this.context.projectGraph) {
520
+ for (const [filePath, fileNode] of this.context.projectGraph.entries()) {
521
+ const cleanRelative = path.relative(metadata.rootDirectory, filePath).replace(/\\/g, '/');
522
+
523
+ // Check if file belongs to this manifest's directory scope
524
+ if (!cleanRelative.startsWith('..') && !cleanRelative.startsWith('/') && fileNode.explicitImports) {
525
+ try {
526
+ const localManifest = JSON.parse(readFileSync(metadata.manifestPath, 'utf8'));
527
+ const localDeps = new Set([
528
+ ...Object.keys(localManifest.dependencies || {}),
529
+ ...Object.keys(localManifest.devDependencies || {}),
530
+ ...Object.keys(localManifest.peerDependencies || {}),
531
+ ...Object.keys(localManifest.optionalDependencies || {})
532
+ ]);
533
+
534
+ fileNode.explicitImports.forEach(specifier => {
535
+ if (specifier.startsWith('.') || specifier.startsWith('/')) return;
536
+
537
+ // Extract base package name (handle scoped packages)
538
+ const basePkg = specifier.startsWith('@') ? specifier.split('/').slice(0, 2).join('/') : specifier.split('/')[0];
539
+
540
+ // Ignore Node.js built-ins
541
+ const nodeBuiltins = ['assert', 'async_hooks', 'buffer', 'child_process', 'cluster', 'console', 'constants', 'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'http2', 'https', 'inspector', 'module', 'net', 'os', 'path', 'perf_hooks', 'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'timers', 'tls', 'trace_events', 'tty', 'url', 'util', 'v8', 'vm', 'worker_threads', 'zlib'];
542
+ if (nodeBuiltins.includes(basePkg) || nodeBuiltins.includes(basePkg.replace('node:', ''))) return;
543
+
544
+ if (!localDeps.has(basePkg)) {
545
+ const alreadyFlagged = this.context.unlistedDependencies.some(u => u.package === basePkg && u.file === filePath);
546
+ if (!alreadyFlagged) {
547
+ this.context.unlistedDependencies.push({
548
+ package: basePkg,
549
+ file: path.relative(this.context.cwd, filePath),
550
+ manifest: path.relative(this.context.cwd, metadata.manifestPath)
551
+ });
529
552
  }
530
- });
531
- } catch (error) {
532
- if (this.context.options.verbose) {
533
- console.error(ansis.red(` ❌ Manifest Parsing Exception: ${error.message}`));
534
553
  }
554
+ });
555
+ } catch (error) {
556
+ if (this.context.options.verbose) {
557
+ console.error(ansis.red(` ❌ Manifest Parsing Exception: ${error.message}`));
535
558
  }
536
559
  }
537
560
  }