prodex 1.4.6 → 1.4.7

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.
@@ -21,7 +21,7 @@ class CacheManager {
21
21
  /** Set or update a cached entry */
22
22
  static set(ns, key, val) {
23
23
  this.ns(ns).set(key, val);
24
- logger_1.logger.debug(`🧩 [cache:${ns}] set ${key} → ${String(val)}`);
24
+ logger_1.logger.debug(`🧩 [cache:${ns}] set ${key} \n→ ${_2j(val)}`);
25
25
  }
26
26
  /** Retrieve a cached entry */
27
27
  static get(ns, key) {
@@ -8,9 +8,14 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const cache_1 = require("../../core/managers/cache");
10
10
  const cache_keys_1 = require("../../constants/cache-keys");
11
+ const extract_imports_1 = require("./extract-imports");
12
+ const logger_1 = require("../../lib/logger");
11
13
  /**
12
- * Scans app/Providers/*.php for `$this->app->bind()` / `singleton()` calls
13
- * and returns a map of Interface::classImplementation::class (FQCN strings).
14
+ * Scans app/Providers/*.php for $this->app->bind() / singleton() calls
15
+ * and returns a map of InterfaceFQCNImplementationFQCN.
16
+ *
17
+ * Uses existing extractPhpImports + expandGroupedUses to correctly
18
+ * resolve namespaces and short class names.
14
19
  */
15
20
  function loadLaravelBindings(root) {
16
21
  const cached = cache_1.CacheManager.get(cache_keys_1.CACHE_KEYS.PHP_BINDINGS, root);
@@ -26,16 +31,27 @@ function loadLaravelBindings(root) {
26
31
  .readdirSync(providersDir)
27
32
  .filter((f) => f.endsWith(".php"))
28
33
  .map((f) => path_1.default.join(providersDir, f));
29
- // $this->app->bind(Interface::class, Implementation::class)
30
- // $this->app->singleton(Interface::class, Implementation::class)
31
- const re = /\$this->app->(?:bind|singleton)\s*\(\s*([A-Za-z0-9_:\\\\]+)::class\s*,\s*([A-Za-z0-9_:\\\\]+)::class/g;
32
34
  for (const file of files) {
33
35
  const code = fs_1.default.readFileSync(file, "utf8");
36
+ // 1️⃣ Extract all imports in the provider
37
+ const rawImports = (0, extract_imports_1.extractPhpImports)(code);
38
+ const expanded = (0, extract_imports_1.expandGroupedUses)(rawImports);
39
+ // Build ShortName → FQCN map
40
+ const importMap = {};
41
+ for (const fqcn of expanded) {
42
+ const short = fqcn.split("\\").pop();
43
+ importMap[short] = fqcn;
44
+ }
45
+ // 2️⃣ Extract bindings (short class names only)
46
+ const bindRe = /\$this->app->(?:bind|singleton)\s*\(\s*([A-Za-z0-9_]+)::class\s*,\s*([A-Za-z0-9_]+)::class/g;
34
47
  let m;
35
- while ((m = re.exec(code))) {
36
- const iface = m[1].replace(/\\\\/g, "\\");
37
- const impl = m[2].replace(/\\\\/g, "\\");
38
- bindings[iface] = impl;
48
+ while ((m = bindRe.exec(code))) {
49
+ const ifaceShort = m[1];
50
+ const implShort = m[2];
51
+ const ifaceFull = importMap[ifaceShort] || ifaceShort;
52
+ const implFull = importMap[implShort] || implShort;
53
+ logger_1.logger.debug(`[laravel-bindings] ${file} => ${ifaceFull} → ${implFull}`);
54
+ bindings[ifaceFull] = implFull;
39
55
  }
40
56
  }
41
57
  cache_1.CacheManager.set(cache_keys_1.CACHE_KEYS.PHP_BINDINGS, root, bindings);
@@ -64,7 +64,7 @@ async function resolvePhpImports({ filePath, visited = new Set(), depth = 0, max
64
64
  let imp = imp0;
65
65
  // Respect Laravel container bindings (Interface → Implementation)
66
66
  if (phpCtx.bindings[imp]) {
67
- logger_1.logger.debug("[php-resolver] binding:", imp, "→", phpCtx.bindings[imp]);
67
+ // logger.debug("[php-resolver] binding:", imp, "→", _2j(phpCtx.bindings[imp]));
68
68
  imp = phpCtx.bindings[imp];
69
69
  }
70
70
  // Only resolve PSR-4 mapped namespaces
@@ -109,7 +109,7 @@ async function tryResolvePhpFile(imp, fromFile, psr4) {
109
109
  cache_1.CacheManager.set(constants_1.CACHE_KEYS.PHP_FILECACHE, key, null);
110
110
  return null;
111
111
  }
112
- const rel = imp.slice(nsKey.length).norm();
112
+ const rel = imp.replace(nsKey, "").norm();
113
113
  const tries = [path_1.default.join(psr4[nsKey], rel), path_1.default.join(psr4[nsKey], rel + ".php"), path_1.default.join(psr4[nsKey], rel, "index.php")];
114
114
  // 🔹 Run all stats concurrently
115
115
  const results = await Promise.allSettled(tries.map(async (p) => {
@@ -4,21 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isExcluded = isExcluded;
7
- exports.makeExcludeMatcher = makeExcludeMatcher;
8
7
  // File: src/shared/patterns.ts
9
8
  const micromatch_1 = __importDefault(require("micromatch"));
10
9
  const path_1 = __importDefault(require("path"));
11
10
  const _1 = require(".");
12
- /**
13
- * Returns true if a given path matches any of the provided glob patterns.
14
- * Equivalent to core/helpers.isExcluded().
15
- */
16
- // export function isExcluded(p: string = "", patterns: string[] = [], root = process.cwd()): boolean {
17
- // if (!patterns?.length) return false;
18
- // if (!p) return false;
19
- // const relPath = p.replaceAll("\\", "/");
20
- // return micromatch.isMatch(relPath, patterns);
21
- // }
22
11
  /**
23
12
  * Centralized exclusion logic.
24
13
  * Accepts namespaces, absolute paths, or relative paths
@@ -36,13 +25,3 @@ function isExcluded(p, patterns = [], root = process.cwd()) {
36
25
  norm = (0, _1.rel)(norm, root).norm();
37
26
  return micromatch_1.default.isMatch(norm, patterns);
38
27
  }
39
- /**
40
- * Builds a reusable micromatch matcher for efficiency.
41
- * Equivalent to php-resolver.makeExcludeMatcher().
42
- */
43
- function makeExcludeMatcher(patterns = []) {
44
- if (!patterns?.length)
45
- return () => false;
46
- const mm = micromatch_1.default.matcher(patterns);
47
- return (s) => mm(String(s).replace(/\\/g, "/"));
48
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prodex",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "Unified Project Indexer & Dependency Extractor for Laravel + React + Node stacks.",
5
5
  "type": "commonjs",
6
6
  "bin": {