prodex 1.1.0 → 1.3.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.
Files changed (60) hide show
  1. package/README.md +234 -140
  2. package/bin/prodex.js +1 -17
  3. package/dist/cli/cli-input.js +106 -0
  4. package/dist/cli/flags.js +42 -0
  5. package/dist/cli/init.js +21 -0
  6. package/dist/cli/picker.js +82 -0
  7. package/dist/cli/summary.js +26 -0
  8. package/dist/constants/config-loader.js +95 -0
  9. package/dist/constants/config.js +26 -0
  10. package/dist/constants/default-config.js +34 -0
  11. package/dist/constants/render-constants.js +28 -0
  12. package/dist/core/combine.js +38 -0
  13. package/dist/core/dependency.js +55 -0
  14. package/dist/core/file-utils.js +41 -0
  15. package/dist/core/helpers.js +81 -0
  16. package/dist/core/output.js +48 -0
  17. package/dist/core/parsers/extract-imports.js +51 -0
  18. package/dist/core/renderers.js +42 -0
  19. package/dist/index.js +26 -0
  20. package/dist/lib/logger.js +14 -0
  21. package/dist/lib/polyfills.js +27 -0
  22. package/dist/lib/prompt.js +34 -0
  23. package/dist/lib/questions.js +28 -0
  24. package/dist/lib/utils.js +51 -0
  25. package/dist/resolvers/js/alias-loader.js +52 -0
  26. package/dist/resolvers/js/js-resolver.js +153 -0
  27. package/dist/resolvers/php/bindings.js +32 -0
  28. package/dist/resolvers/php/patterns.js +17 -0
  29. package/dist/resolvers/php/php-resolver.js +88 -0
  30. package/dist/resolvers/php/psr4.js +26 -0
  31. package/dist/resolvers/shared/excludes.js +11 -0
  32. package/dist/resolvers/shared/file-cache.js +29 -0
  33. package/dist/resolvers/shared/stats.js +17 -0
  34. package/dist/types/cli.types.js +12 -0
  35. package/dist/types/config.types.js +2 -0
  36. package/dist/types/core.types.js +2 -0
  37. package/dist/types/index.js +21 -0
  38. package/dist/types/resolver.types.js +2 -0
  39. package/dist/types/utils.types.js +2 -0
  40. package/package.json +16 -12
  41. package/dist/LICENSE +0 -21
  42. package/dist/README.md +0 -140
  43. package/dist/bin/prodex.js +0 -18
  44. package/dist/package.json +0 -45
  45. package/dist/src/cli/init.js +0 -18
  46. package/dist/src/cli/picker.js +0 -59
  47. package/dist/src/cli/summary.js +0 -6
  48. package/dist/src/constants/config-loader.js +0 -87
  49. package/dist/src/constants/config.js +0 -13
  50. package/dist/src/constants/default-config.js +0 -36
  51. package/dist/src/constants/render-constants.js +0 -22
  52. package/dist/src/core/alias-loader.js +0 -8
  53. package/dist/src/core/combine.js +0 -145
  54. package/dist/src/core/file-utils.js +0 -45
  55. package/dist/src/core/helpers.js +0 -77
  56. package/dist/src/core/renderers.js +0 -58
  57. package/dist/src/index.js +0 -15
  58. package/dist/src/resolvers/js-resolver.js +0 -180
  59. package/dist/src/resolvers/php-bindings.js +0 -31
  60. package/dist/src/resolvers/php-resolver.js +0 -155
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.prompt = prompt;
7
+ const inquirer_1 = __importDefault(require("inquirer"));
8
+ const logger_1 = require("./logger");
9
+ /**
10
+ * 🧩 prompt()
11
+ * Unified and safe wrapper for inquirer.prompt()
12
+ *
13
+ * - Requires explicit `showUi` flag (no env auto-detection).
14
+ * - Returns `null` or `fallback` on failure or disabled UI.
15
+ * - Handles TTY errors and user cancellations gracefully.
16
+ */
17
+ async function prompt(questions, fallback) {
18
+ try {
19
+ const answers = (await inquirer_1.default.prompt(questions));
20
+ return answers;
21
+ }
22
+ catch (err) {
23
+ if (err?.isTtyError) {
24
+ logger_1.logger.warn("Interactive prompts not supported (no TTY).");
25
+ }
26
+ else if (/canceled|aborted/i.test(err?.message)) {
27
+ logger_1.logger.warn("Prompt canceled by user.");
28
+ }
29
+ else {
30
+ logger_1.logger.error("Prompt failed:", err.message || err);
31
+ }
32
+ return fallback ?? null;
33
+ }
34
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PICK_ENTRIES_QUESTION = exports.OUTPUT_NAME_QUESTION = void 0;
4
+ /**
5
+ * 🧩 Centralized Inquirer question definitions.
6
+ * Each export is a named, reusable question set.
7
+ */
8
+ /** Ask for the output filename (used in produceOutput). */
9
+ exports.OUTPUT_NAME_QUESTION = [
10
+ {
11
+ type: "input",
12
+ name: "outputBase",
13
+ message: "Output file name (without extension):",
14
+ default: "combined",
15
+ filter: (v) => v.trim().replace(/[<>:\"/\\|?*]+/g, "_") || "combined",
16
+ },
17
+ ];
18
+ const PICK_ENTRIES_QUESTION = (choices, depth) => [
19
+ {
20
+ type: "checkbox",
21
+ name: "picks",
22
+ message: `Select entry files (depth ${depth})`,
23
+ choices,
24
+ loop: false,
25
+ pageSize: 20,
26
+ },
27
+ ];
28
+ exports.PICK_ENTRIES_QUESTION = PICK_ENTRIES_QUESTION;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.unique = unique;
5
+ exports.setDiff = setDiff;
6
+ exports.toArray = toArray;
7
+ exports.shortTimestamp = shortTimestamp;
8
+ exports.normalizePatterns = normalizePatterns;
9
+ const config_1 = require("../constants/config");
10
+ function unique(arr) {
11
+ return [...new Set(arr)];
12
+ }
13
+ function setDiff(A, B) {
14
+ return new Set([...A].filter((x) => !B.has(x)));
15
+ }
16
+ function toArray(v) {
17
+ return Array.isArray(v) ? v : [v];
18
+ }
19
+ /** Compact YYMMDD-HHmm timestamp for versioned filenames. */
20
+ function shortTimestamp() {
21
+ const d = new Date();
22
+ const yy = String(d.getFullYear()).slice(-2);
23
+ const MM = String(d.getMonth() + 1).padStart(2, "0");
24
+ const dd = String(d.getDate()).padStart(2, "0");
25
+ const hh = String(d.getHours()).padStart(2, "0");
26
+ const mm = String(d.getMinutes()).padStart(2, "0");
27
+ return `${yy}${MM}${dd}-${hh}${mm}`;
28
+ }
29
+ function normalizePatterns(input) {
30
+ if (!input)
31
+ return [];
32
+ let arr;
33
+ if (typeof input === "string") {
34
+ arr = input.split(",").map((s) => s.trim());
35
+ }
36
+ else if (Array.isArray(input)) {
37
+ arr = input.map((s) => (typeof s === "string" ? s.trim() : ""));
38
+ }
39
+ else {
40
+ return [];
41
+ }
42
+ return arr
43
+ .filter((s) => s.length > 0)
44
+ .map((s) => s.replace(/\\/g, "/")) // normalize slashes
45
+ .filter((s) => {
46
+ const valid = config_1.VALID_GLOB_CHARS.test(s);
47
+ if (!valid)
48
+ console.warn(`⚠️ Invalid glob pattern skipped: "${s}"`);
49
+ return valid;
50
+ });
51
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.loadProjectAliases = loadProjectAliases;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ let cacheByRoot = new Map();
11
+ function loadProjectAliases(root) {
12
+ if (cacheByRoot.has(root))
13
+ return cacheByRoot.get(root);
14
+ const aliases = {};
15
+ const tsPath = path_1.default.join(root, "tsconfig.json");
16
+ const viteJs = path_1.default.join(root, "vite.config");
17
+ const viteTs = path_1.default.join(root, "vite.config.ts");
18
+ if (fs_1.default.existsSync(tsPath)) {
19
+ try {
20
+ const ts = JSON.parse(fs_1.default.readFileSync(tsPath, "utf8"));
21
+ const paths = ts.compilerOptions?.paths || {};
22
+ for (const [key, value] of Object.entries(paths)) {
23
+ const cleanedKey = key.replace(/\/\*$/, "");
24
+ const first = Array.isArray(value) ? value[0] : value;
25
+ if (!first)
26
+ continue;
27
+ const cleanedVal = first.replace(/\/\*$/, "");
28
+ aliases[cleanedKey] = path_1.default.resolve(root, cleanedVal);
29
+ }
30
+ }
31
+ catch { }
32
+ }
33
+ for (const vitePath of [viteJs, viteTs]) {
34
+ if (!fs_1.default.existsSync(vitePath))
35
+ continue;
36
+ try {
37
+ const content = fs_1.default.readFileSync(vitePath, "utf8");
38
+ const blocks = [...content.matchAll(/alias\s*:\s*\{([^}]+)\}/g)];
39
+ for (const m of blocks) {
40
+ const inner = m[1];
41
+ const pairs = [...inner.matchAll(/['"](.+?)['"]\s*:\s*['"](.+?)['"]/g)];
42
+ for (const [, key, val] of pairs) {
43
+ const abs = path_1.default.isAbsolute(val) ? val : path_1.default.resolve(root, val);
44
+ aliases[key] = abs;
45
+ }
46
+ }
47
+ }
48
+ catch { }
49
+ }
50
+ cacheByRoot.set(root, aliases);
51
+ return aliases;
52
+ }
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.resolveJsImports = resolveJsImports;
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const micromatch_1 = __importDefault(require("micromatch"));
11
+ const extract_imports_1 = require("../../core/parsers/extract-imports");
12
+ const alias_loader_1 = require("./alias-loader");
13
+ const config_1 = require("../../constants/config");
14
+ const utils_1 = require("../../lib/utils");
15
+ const logger_1 = require("../../lib/logger");
16
+ const IMPORTS_CACHE = new Map();
17
+ const STAT_CACHE = new Map();
18
+ async function resolveJsImports(filePath, cfg, visited = new Set(), depth = 0, maxDepth = cfg?.resolve?.depth ?? 8, ctx = {}) {
19
+ if (depth >= maxDepth)
20
+ return empty(visited);
21
+ const ROOT = cfg.root;
22
+ const resolveCfg = cfg.resolve ?? {};
23
+ // Single exclude list, applied to RAW SPECIFIERS only.
24
+ const exclude = resolveCfg.exclude ?? [];
25
+ const isExcluded = micromatch_1.default.matcher(exclude);
26
+ if (visited.has(filePath))
27
+ return empty(visited);
28
+ visited.add(filePath);
29
+ const ext = path_1.default.extname(filePath).toLowerCase();
30
+ const isDts = ext === config_1.DTS_EXT;
31
+ if (!config_1.BASE_EXTS.includes(ext) && !isDts)
32
+ return empty(visited);
33
+ let code;
34
+ try {
35
+ code = await promises_1.default.readFile(filePath, "utf8");
36
+ }
37
+ catch {
38
+ return empty(visited);
39
+ }
40
+ if (!ctx.aliases) {
41
+ ctx.aliases = { ...(0, alias_loader_1.loadProjectAliases)(ROOT), ...(resolveCfg.aliases || {}) };
42
+ }
43
+ const aliases = ctx.aliases;
44
+ const matches = await getImportsCached(filePath, code);
45
+ if (!matches.size)
46
+ return empty(visited);
47
+ const filesOut = [];
48
+ const expected = new Set();
49
+ const resolvedSet = new Set();
50
+ for (const imp of matches) {
51
+ // Only consider relative, absolute, or known-alias specifiers
52
+ if (!imp.startsWith(".") && !imp.startsWith("/") && !startsWithAnyAlias(imp, aliases)) {
53
+ continue;
54
+ }
55
+ // Apply single exclude matcher to the RAW specifier
56
+ if (isExcluded(imp))
57
+ continue;
58
+ // Always count valid, non-excluded specifiers as "expected"
59
+ expected.add(imp);
60
+ const basePath = resolveBasePath(filePath, imp, aliases);
61
+ if (!basePath)
62
+ continue;
63
+ const resolvedPath = await tryResolveImport(basePath, ROOT);
64
+ if (!resolvedPath)
65
+ continue;
66
+ filesOut.push(resolvedPath);
67
+ resolvedSet.add(imp);
68
+ // Never recurse into `.d.ts`
69
+ if (resolvedPath.toLowerCase().endsWith(config_1.DTS_EXT)) {
70
+ continue;
71
+ logger_1.logger.debug("HERE HERE");
72
+ }
73
+ const sub = await resolveJsImports(resolvedPath, cfg, visited, depth + 1, maxDepth, ctx);
74
+ if (sub.files.length)
75
+ filesOut.push(...sub.files);
76
+ for (const s of sub.stats.expected)
77
+ expected.add(s);
78
+ for (const r of sub.stats.resolved)
79
+ resolvedSet.add(r);
80
+ }
81
+ const uniqueFiles = [...new Set(filesOut)];
82
+ //Stat Log
83
+ const expCount = expected.size;
84
+ const resCount = resolvedSet.size;
85
+ const diff = (0, utils_1.setDiff)(expected, resolvedSet);
86
+ logger_1.logger.debug(`🪶 [js-resolver] ${filePath} → expected: ${expCount}, resolved: ${resCount}`);
87
+ logger_1.logger.debug([...diff], "🔴THE diff");
88
+ return { files: uniqueFiles, visited, stats: { expected, resolved: resolvedSet } };
89
+ }
90
+ // ---------- helpers ----------
91
+ function startsWithAnyAlias(imp, aliases) {
92
+ return Object.keys(aliases).some((a) => imp === a || imp.startsWith(a + "/"));
93
+ }
94
+ function resolveBasePath(fromFile, specifier, aliases) {
95
+ if (specifier.startsWith("@")) {
96
+ const key = Object.keys(aliases)
97
+ .filter((a) => specifier === a || specifier.startsWith(a + "/"))
98
+ .sort((a, b) => b.length - a.length)[0];
99
+ if (!key)
100
+ return null;
101
+ const relPart = specifier.slice(key.length).replace(/^\/+/, "");
102
+ return path_1.default.resolve(aliases[key], relPart);
103
+ }
104
+ if (specifier.startsWith(".")) {
105
+ return path_1.default.resolve(path_1.default.dirname(fromFile), specifier);
106
+ }
107
+ if (specifier.startsWith("/")) {
108
+ return path_1.default.resolve(specifier);
109
+ }
110
+ return null;
111
+ }
112
+ async function tryResolveImport(basePath, ROOT) {
113
+ const candidates = [];
114
+ if (path_1.default.extname(basePath)) {
115
+ candidates.push(basePath);
116
+ }
117
+ else {
118
+ for (const ext of [...config_1.BASE_EXTS, config_1.DTS_EXT]) {
119
+ candidates.push(basePath + ext);
120
+ candidates.push(path_1.default.join(basePath, "index" + ext));
121
+ }
122
+ }
123
+ for (const c of candidates) {
124
+ const abs = path_1.default.resolve(c);
125
+ const st = await safeStat(abs);
126
+ if (st && st.isFile())
127
+ return abs;
128
+ }
129
+ return null;
130
+ }
131
+ async function safeStat(p) {
132
+ if (STAT_CACHE.has(p))
133
+ return STAT_CACHE.get(p);
134
+ try {
135
+ const st = await promises_1.default.stat(p);
136
+ STAT_CACHE.set(p, st);
137
+ return st;
138
+ }
139
+ catch {
140
+ STAT_CACHE.set(p, null);
141
+ return null;
142
+ }
143
+ }
144
+ async function getImportsCached(filePath, code) {
145
+ if (IMPORTS_CACHE.has(filePath))
146
+ return IMPORTS_CACHE.get(filePath);
147
+ const set = await (0, extract_imports_1.extractImports)(filePath, code);
148
+ IMPORTS_CACHE.set(filePath, set);
149
+ return set;
150
+ }
151
+ function empty(visited) {
152
+ return { files: [], visited, stats: { expected: new Set(), resolved: new Set() } };
153
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.loadLaravelBindings = loadLaravelBindings;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const config_1 = require("../../constants/config");
11
+ function loadLaravelBindings() {
12
+ const providersDir = path_1.default.join(config_1.ROOT, "app", "Providers");
13
+ const bindings = {};
14
+ if (!fs_1.default.existsSync(providersDir))
15
+ return bindings;
16
+ const files = fs_1.default
17
+ .readdirSync(providersDir)
18
+ .filter(f => f.endsWith(".php"))
19
+ .map(f => path_1.default.join(providersDir, f));
20
+ // Match: $this->app->bind(Interface::class, Implementation::class)
21
+ const re = /$this->app->(?:bind|singleton)\s*\(\s*([A-Za-z0-9_:\\\\]+)::class\s*,\s*([A-Za-z0-9_:\\\\]+)::class/g;
22
+ for (const file of files) {
23
+ const code = fs_1.default.readFileSync(file, "utf8");
24
+ let m;
25
+ while ((m = re.exec(code))) {
26
+ const iface = m[1].replace(/\\\\/g, "\\");
27
+ const impl = m[2].replace(/\\\\/g, "\\");
28
+ bindings[iface] = impl;
29
+ }
30
+ }
31
+ return bindings;
32
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.extractPhpImports = extractPhpImports;
5
+ function extractPhpImports(code) {
6
+ const out = new Set();
7
+ const patterns = [
8
+ /\b(?:require|include|require_once|include_once)\s*\(?['"]([^'"]+)['"]\)?/g,
9
+ /\buse\s+([A-Z][\w\\]+(?:\s*{[^}]+})?)/g
10
+ ];
11
+ for (const r of patterns) {
12
+ let m;
13
+ while ((m = r.exec(code)))
14
+ out.add(m[1]);
15
+ }
16
+ return out;
17
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.resolvePhpImports = resolvePhpImports;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const bindings_1 = require("./bindings");
10
+ const psr4_1 = require("./psr4");
11
+ const patterns_1 = require("./patterns");
12
+ const logger_1 = require("../../lib/logger");
13
+ const stats_1 = require("../shared/stats");
14
+ const file_cache_1 = require("../shared/file-cache");
15
+ const excludes_1 = require("../shared/excludes");
16
+ async function resolvePhpImports(filePath, cfg, visited = new Set(), depth = 0, maxDepth = cfg?.resolve?.depth ?? 10, ctx = {}) {
17
+ if (depth >= maxDepth)
18
+ return empty(visited);
19
+ const stats = (0, stats_1.newStats)();
20
+ const filesOut = [];
21
+ const ROOT = cfg.root || process.cwd();
22
+ if (!ctx.psr4)
23
+ ctx.psr4 = (0, psr4_1.resolvePsr4)(ROOT);
24
+ if (!ctx.nsKeys)
25
+ ctx.nsKeys = Object.keys(ctx.psr4).sort((a, b) => b.length - a.length);
26
+ if (!ctx.bindings)
27
+ ctx.bindings = (0, bindings_1.loadLaravelBindings)();
28
+ if (visited.has(filePath))
29
+ return empty(visited);
30
+ visited.add(filePath);
31
+ if (!fs_1.default.existsSync(filePath))
32
+ return empty(visited);
33
+ const code = fs_1.default.readFileSync(filePath, "utf8");
34
+ const exclude = cfg.imports?.exclude ?? [];
35
+ const raw = (0, patterns_1.extractPhpImports)(code);
36
+ const imports = expandGroupedUses(raw);
37
+ for (const imp0 of imports) {
38
+ let imp = imp0;
39
+ if (ctx.bindings[imp]) {
40
+ log("🔗 Bound:", imp0, "→", ctx.bindings[imp]);
41
+ imp = ctx.bindings[imp];
42
+ }
43
+ if (!startsWithAny(imp, ctx.nsKeys))
44
+ continue;
45
+ if ((0, excludes_1.isExcluded)(imp, exclude))
46
+ continue;
47
+ stats.expected.add(imp);
48
+ const resolvedPath = (0, file_cache_1.tryResolvePhpFile)(imp, filePath, ctx.psr4);
49
+ if (!resolvedPath)
50
+ continue;
51
+ stats.resolved.add(imp);
52
+ filesOut.push(resolvedPath);
53
+ const sub = await resolvePhpImports(resolvedPath, cfg, visited, depth + 1, maxDepth, ctx);
54
+ filesOut.push(...sub.files);
55
+ (0, stats_1.mergeStats)(stats, sub.stats);
56
+ }
57
+ log("✅ PHP resolver:", filePath, "→", filesOut.length);
58
+ return {
59
+ files: [...new Set(filesOut)],
60
+ visited,
61
+ stats
62
+ };
63
+ }
64
+ // ---------- Local helpers (resolver-scoped only) ----------
65
+ function startsWithAny(imp, nsKeys) {
66
+ return nsKeys.some(k => imp.startsWith(k));
67
+ }
68
+ function empty(visited) {
69
+ return { files: [], visited, stats: (0, stats_1.emptyStats)() };
70
+ }
71
+ const log = (...a) => logger_1.logger.debug("[php-resolver]", ...a);
72
+ function expandGroupedUses(raw) {
73
+ const out = new Set();
74
+ for (const imp of raw) {
75
+ const g = imp.match(/^(.+?)\s*{([^}]+)}/);
76
+ if (g) {
77
+ const base = g[1].trim().replace(/\\+$/, "");
78
+ g[2]
79
+ .split(",")
80
+ .map(x => x.trim())
81
+ .forEach(p => out.add(`${base}\\${p}`));
82
+ }
83
+ else {
84
+ out.add(imp.trim());
85
+ }
86
+ }
87
+ return out;
88
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.resolvePsr4 = resolvePsr4;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ function resolvePsr4(ROOT) {
11
+ const composer = path_1.default.join(ROOT, "composer.json");
12
+ if (!fs_1.default.existsSync(composer))
13
+ return {};
14
+ try {
15
+ const data = JSON.parse(fs_1.default.readFileSync(composer, "utf8"));
16
+ const src = data.autoload?.["psr-4"] || {};
17
+ const map = {};
18
+ for (const ns in src) {
19
+ map[ns.replace(/\\+$/, "")] = path_1.default.resolve(ROOT, src[ns]);
20
+ }
21
+ return map;
22
+ }
23
+ catch {
24
+ return {};
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.isExcluded = isExcluded;
8
+ const micromatch_1 = __importDefault(require("micromatch"));
9
+ function isExcluded(imp, exclude = []) {
10
+ return micromatch_1.default.isMatch(imp.replaceAll("\\", "/"), exclude);
11
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.tryResolvePhpFile = tryResolvePhpFile;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const CACHE = new Map();
11
+ function tryResolvePhpFile(imp, fromFile, psr4) {
12
+ const key = `php:${imp}:${fromFile}`;
13
+ if (CACHE.has(key))
14
+ return CACHE.get(key);
15
+ const nsKey = Object.keys(psr4).find(k => imp.startsWith(k));
16
+ if (!nsKey) {
17
+ CACHE.set(key, null);
18
+ return null;
19
+ }
20
+ const rel = imp.slice(nsKey.length).replace(/\\/g, "/");
21
+ const tries = [
22
+ path_1.default.join(psr4[nsKey], rel),
23
+ path_1.default.join(psr4[nsKey], rel + ".php"),
24
+ path_1.default.join(psr4[nsKey], rel, "index.php")
25
+ ];
26
+ const resolved = tries.find(p => fs_1.default.existsSync(p) && fs_1.default.statSync(p).isFile());
27
+ CACHE.set(key, resolved ? path_1.default.resolve(resolved) : null);
28
+ return CACHE.get(key);
29
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.newStats = newStats;
5
+ exports.mergeStats = mergeStats;
6
+ exports.emptyStats = emptyStats;
7
+ function newStats() {
8
+ return { expected: new Set(), resolved: new Set() };
9
+ }
10
+ function mergeStats(target, src) {
11
+ src.expected.forEach(i => target.expected.add(i));
12
+ src.resolved.forEach(i => target.resolved.add(i));
13
+ return target;
14
+ }
15
+ function emptyStats() {
16
+ return { expected: new Set(), resolved: new Set() };
17
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * CLI flag schema for Prodex.
4
+ * Mirrors the current CLI synopsis:
5
+ *
6
+ * prodex [entries...] [-tcdv]
7
+ * [--txt] [--ci] [--debug] [--verbose]
8
+ * [--name=<string>|-n=<string>]
9
+ * [--limit=<int>|-l=<int>]
10
+ * [--inc=<globs>] [--exc=<globs>]
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config.types"), exports);
18
+ __exportStar(require("./cli.types"), exports);
19
+ __exportStar(require("./core.types"), exports);
20
+ __exportStar(require("./resolver.types"), exports);
21
+ __exportStar(require("./utils.types"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "prodex",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Unified Project Indexer & Dependency Extractor for Laravel + React + Node stacks.",
5
- "type": "module",
5
+ "type": "commonjs",
6
6
  "bin": {
7
7
  "prodex": "./bin/prodex.js"
8
8
  },
9
- "main": "./dist/core/combine.js",
10
- "exports": {
11
- ".": "./dist/core/combine.js"
12
- },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
13
11
  "files": [
14
12
  "dist/",
15
13
  "bin/",
@@ -27,19 +25,25 @@
27
25
  "indexer"
28
26
  ],
29
27
  "scripts": {
30
- "clean": "rm -rf dist",
31
- "build": "npm run clean && node -e \"require('fs').mkdirSync('dist',{recursive:true})\" && cp -r src bin package.json README.md LICENSE dist/",
28
+ "build": "tsc",
29
+ "dev": "tsc --watch",
32
30
  "prepare": "npm run build"
33
31
  },
32
+ "engines": {
33
+ "node": ">=16"
34
+ },
34
35
  "author": "emxhive",
35
36
  "license": "MIT",
36
37
  "devDependencies": {
37
- "@types/node": "^24.9.1",
38
- "tsup": "^8.5.0",
39
- "typescript": "^5.9.3"
38
+ "@types/node": "^24.9.2",
39
+ "typescript": "^5.9.3",
40
+ "vitest": "^4.0.4"
40
41
  },
41
42
  "dependencies": {
43
+ "es-module-lexer": "^1.7.0",
44
+ "fast-glob": "^3.3.3",
42
45
  "inquirer": "^12.10.0",
43
- "micromatch": "^4.0.8"
46
+ "micromatch": "^4.0.8",
47
+ "sade": "^1.8.1"
44
48
  }
45
49
  }