prodex 1.1.0 → 1.2.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 (57) hide show
  1. package/README.md +174 -86
  2. package/bin/prodex.js +1 -17
  3. package/dist/cli/cli-input.js +86 -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 +14 -0
  8. package/dist/constants/config-loader.js +90 -0
  9. package/dist/constants/config.js +17 -0
  10. package/dist/constants/default-config.js +48 -0
  11. package/dist/constants/render-constants.js +23 -0
  12. package/dist/core/combine.js +74 -0
  13. package/dist/core/dependency.js +51 -0
  14. package/dist/core/file-utils.js +44 -0
  15. package/dist/core/helpers.js +81 -0
  16. package/dist/core/parsers/extract-imports.js +51 -0
  17. package/dist/core/renderers.js +42 -0
  18. package/dist/index.js +29 -0
  19. package/dist/lib/logger.js +14 -0
  20. package/dist/lib/polyfills.js +12 -0
  21. package/dist/lib/utils.js +15 -0
  22. package/dist/resolvers/js/alias-loader.js +52 -0
  23. package/dist/resolvers/js/js-resolver.js +153 -0
  24. package/dist/resolvers/php/bindings.js +32 -0
  25. package/dist/resolvers/php/patterns.js +17 -0
  26. package/dist/resolvers/php/php-resolver.js +88 -0
  27. package/dist/resolvers/php/psr4.js +26 -0
  28. package/dist/resolvers/shared/excludes.js +11 -0
  29. package/dist/resolvers/shared/file-cache.js +29 -0
  30. package/dist/resolvers/shared/stats.js +17 -0
  31. package/dist/types/cli.types.js +12 -0
  32. package/dist/types/config.types.js +2 -0
  33. package/dist/types/core.types.js +2 -0
  34. package/dist/types/index.js +21 -0
  35. package/dist/types/resolver.types.js +2 -0
  36. package/dist/types/utils.types.js +2 -0
  37. package/package.json +16 -12
  38. package/dist/LICENSE +0 -21
  39. package/dist/README.md +0 -140
  40. package/dist/bin/prodex.js +0 -18
  41. package/dist/package.json +0 -45
  42. package/dist/src/cli/init.js +0 -18
  43. package/dist/src/cli/picker.js +0 -59
  44. package/dist/src/cli/summary.js +0 -6
  45. package/dist/src/constants/config-loader.js +0 -87
  46. package/dist/src/constants/config.js +0 -13
  47. package/dist/src/constants/default-config.js +0 -36
  48. package/dist/src/constants/render-constants.js +0 -22
  49. package/dist/src/core/alias-loader.js +0 -8
  50. package/dist/src/core/combine.js +0 -145
  51. package/dist/src/core/file-utils.js +0 -45
  52. package/dist/src/core/helpers.js +0 -77
  53. package/dist/src/core/renderers.js +0 -58
  54. package/dist/src/index.js +0 -15
  55. package/dist/src/resolvers/js-resolver.js +0 -180
  56. package/dist/src/resolvers/php-bindings.js +0 -31
  57. package/dist/src/resolvers/php-resolver.js +0 -155
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DTS_EXT = exports.BASE_EXTS = exports.GLOBAL_IGNORE = exports.RESOLVERS = exports.CODE_EXTS = exports.ROOT = void 0;
4
+ exports.ROOT = process.cwd();
5
+ exports.CODE_EXTS = [".js", ".mjs", ".ts", ".tsx", ".d.ts", ".php"];
6
+ const js_resolver_1 = require("../resolvers/js/js-resolver");
7
+ const php_resolver_1 = require("../resolvers/php/php-resolver");
8
+ exports.RESOLVERS = {
9
+ ".php": php_resolver_1.resolvePhpImports,
10
+ ".ts": js_resolver_1.resolveJsImports,
11
+ ".tsx": js_resolver_1.resolveJsImports,
12
+ ".d.ts": js_resolver_1.resolveJsImports,
13
+ ".js": js_resolver_1.resolveJsImports
14
+ };
15
+ exports.GLOBAL_IGNORE = ["**/node_modules/**", "**/vendor/**", "**/dist/**"];
16
+ exports.BASE_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".types"];
17
+ exports.DTS_EXT = ".d.ts";
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_PRODEX_CONFIG = void 0;
4
+ /**
5
+ * Default configuration for Prodex.
6
+ * Conforms strictly to ProdexConfig for full type safety.
7
+ */
8
+ exports.DEFAULT_PRODEX_CONFIG = {
9
+ version: 3.1,
10
+ output: {
11
+ dir: "prodex",
12
+ versioned: false,
13
+ prefix: "combined",
14
+ format: "md",
15
+ },
16
+ entry: {
17
+ files: [],
18
+ ui: {
19
+ roots: ["app", "routes", "resources/js/**"],
20
+ scanDepth: 2,
21
+ priority: [
22
+ "**/routes/web.php",
23
+ "**/routes/api.php",
24
+ "**/*index.*",
25
+ "**/*main.*",
26
+ "**/app.*"
27
+ ],
28
+ },
29
+ },
30
+ resolve: {
31
+ include: ["**/*.d.ts", "**/*.interface.ts"],
32
+ aliases: {
33
+ "@hooks": "resources/js/hooks",
34
+ "@data": "resources/js/data",
35
+ },
36
+ exclude: [
37
+ "node_modules/**",
38
+ "@shadcn/**",
39
+ "**/components/ui/**"
40
+ ],
41
+ depth: 10,
42
+ limit: 200,
43
+ },
44
+ debug: {
45
+ verbose: false,
46
+ showSummary: true,
47
+ },
48
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // ================================================================
3
+ // 🧩 Prodex — Render Constants
4
+ // Defines shared constants for renderer outDir formats.
5
+ // ================================================================
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TEXT_HEADERS = exports.LANG_MAP = void 0;
8
+ exports.LANG_MAP = {
9
+ "": "js",
10
+ ".mjs": "js",
11
+ ".jsx": "jsx",
12
+ ".ts": "ts",
13
+ ".tsx": "tsx",
14
+ ".php": "php",
15
+ ".json": "json",
16
+ ".d.ts": "ts"
17
+ };
18
+ exports.TEXT_HEADERS = {
19
+ toc: "##==== Combined Scope ====",
20
+ path: p => `##==== path: ${p} ====`,
21
+ regionStart: p => `##region ${p}`,
22
+ regionEnd: "##endregion"
23
+ };
@@ -0,0 +1,74 @@
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.runCombine = runCombine;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const picker_1 = require("../cli/picker");
11
+ const summary_1 = require("../cli/summary");
12
+ const dependency_1 = require("./dependency");
13
+ const file_utils_1 = require("./file-utils");
14
+ const renderers_1 = require("./renderers");
15
+ const logger_1 = require("../lib/logger");
16
+ const package_json_1 = __importDefault(require("../../package.json"));
17
+ async function runCombine(cfg, showUi) {
18
+ const { output, entry, resolve } = cfg;
19
+ const toMd = cfg.output.format == "md";
20
+ const ROOT = cfg.root;
21
+ const { ui } = entry;
22
+ const entryFiles = entry.files ?? [];
23
+ let entries = [];
24
+ if (!showUi) {
25
+ logger_1.logger.info("CI Mode");
26
+ if (!entryFiles.length) {
27
+ logger_1.logger.warn("No entry files defined and UI mode is disabled.");
28
+ return;
29
+ }
30
+ entries = (await (0, file_utils_1.globScan)(entryFiles, { cwd: ROOT })).files;
31
+ }
32
+ else {
33
+ entries = await (0, picker_1.pickEntries)(ui.roots, ui.scanDepth, cfg);
34
+ }
35
+ if (!entries.length) {
36
+ logger_1.logger.error("No entries selected.");
37
+ return;
38
+ }
39
+ logger_1.logger.log("\n📋 You selected:");
40
+ for (const e of entries)
41
+ logger_1.logger.log(" -", e.replace(ROOT + "/", ""));
42
+ const autoName = (0, file_utils_1.generateOutputName)(entries);
43
+ const outDir = output.dir;
44
+ const limit = resolve.limit;
45
+ let outputBase = autoName;
46
+ if (showUi) {
47
+ const { outputBase: answer } = await inquirer_1.default.prompt([
48
+ {
49
+ type: "input",
50
+ name: "outputBase",
51
+ message: "Output file name (without extension):",
52
+ default: autoName,
53
+ filter: (v) => (v.trim() || autoName).replace(/[<>:"/\\|?*]+/g, "_"),
54
+ },
55
+ ]);
56
+ outputBase = answer;
57
+ }
58
+ try {
59
+ fs_1.default.mkdirSync(outDir, { recursive: true });
60
+ }
61
+ catch {
62
+ logger_1.logger.warn("Could not create outDir directory:", outDir);
63
+ }
64
+ const outputPath = (0, file_utils_1.resolveOutDirPath)(outDir, outputBase, toMd);
65
+ (0, summary_1.showSummary)({ outDir, fileName: path_1.default.basename(outputPath), entries });
66
+ const result = await (0, dependency_1.followChain)(entries, cfg, limit);
67
+ const withinclude = await (0, dependency_1.applyincludes)(cfg, result.files);
68
+ const sorted = [...withinclude].sort((a, b) => a.localeCompare(b));
69
+ const footer = ["\n---", "*Generated with [Prodex](https://github.com/emxhive/prodex) — Codebase decoded.*", `<!-- PRODEx v${package_json_1.default.version} | ${new Date().toISOString()} -->`].join("\n");
70
+ const content = toMd ? [(0, renderers_1.tocTxt)(sorted), ...sorted.map(renderers_1.renderTxt)].join("") : [(0, renderers_1.tocMd)(sorted), ...sorted.map((f, i) => (0, renderers_1.renderMd)(f, i)), footer].join("\n");
71
+ fs_1.default.writeFileSync(outputPath, content, "utf8");
72
+ logger_1.logger.log(`\n✅ ${outputPath.norm()}`);
73
+ (0, summary_1.importSummary)(result);
74
+ }
@@ -0,0 +1,51 @@
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.followChain = followChain;
7
+ exports.applyincludes = applyincludes;
8
+ const path_1 = __importDefault(require("path"));
9
+ const config_1 = require("../constants/config");
10
+ const file_utils_1 = require("./file-utils");
11
+ const logger_1 = require("../lib/logger");
12
+ async function followChain(entryFiles, cfg, limit = 200) {
13
+ logger_1.logger.debug("🧩 Following dependency chain...");
14
+ const visited = new Set();
15
+ const all = [];
16
+ const expected = new Set();
17
+ const resolved = new Set();
18
+ const resolverDepth = cfg.resolve.depth;
19
+ for (const f of entryFiles) {
20
+ if (visited.has(f))
21
+ continue;
22
+ all.push(f);
23
+ const ext = path_1.default.extname(f);
24
+ if (!config_1.CODE_EXTS.includes(ext))
25
+ continue;
26
+ const resolver = config_1.RESOLVERS[ext];
27
+ if (resolver) {
28
+ const result = await resolver(f, cfg, visited, 0, resolverDepth);
29
+ const { files, stats } = result;
30
+ all.push(...files);
31
+ stats?.expected?.forEach((x) => expected.add(x));
32
+ stats?.resolved?.forEach((x) => resolved.add(x));
33
+ }
34
+ if (limit && all.length >= limit) {
35
+ logger_1.logger.warn("⚠️ Limit reached:", limit);
36
+ break;
37
+ }
38
+ }
39
+ return {
40
+ files: [...new Set(all)],
41
+ stats: { expected, resolved },
42
+ };
43
+ }
44
+ async function applyincludes(cfg, files) {
45
+ const { resolve } = cfg;
46
+ const ROOT = cfg.root;
47
+ const scan = await (0, file_utils_1.globScan)(resolve.include, { cwd: ROOT });
48
+ logger_1.logger.debug("APPLY_include", _2j(scan));
49
+ const combined = [...new Set([...files, ...scan.files])];
50
+ return combined;
51
+ }
@@ -0,0 +1,44 @@
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.globScan = globScan;
7
+ exports.generateOutputName = generateOutputName;
8
+ exports.resolveOutDirPath = resolveOutDirPath;
9
+ const path_1 = __importDefault(require("path"));
10
+ const fast_glob_1 = __importDefault(require("fast-glob"));
11
+ const config_1 = require("../constants/config");
12
+ const logger_1 = require("../lib/logger");
13
+ /**
14
+ * Safe micromatch.scan wrapper (compatible with micromatch v4 & v5)
15
+ */
16
+ async function globScan(pattern, opts) {
17
+ logger_1.logger.debug("PATTERN", pattern);
18
+ const { absolute = true, cwd = process.cwd() } = opts;
19
+ if (!pattern?.length)
20
+ return { files: [] };
21
+ const files = await (0, fast_glob_1.default)(pattern, {
22
+ cwd,
23
+ dot: true,
24
+ onlyFiles: true,
25
+ ignore: config_1.GLOBAL_IGNORE,
26
+ absolute,
27
+ });
28
+ logger_1.logger.debug("GLOB-SCAN_FILES ", _2j(files));
29
+ return { files };
30
+ }
31
+ function generateOutputName(entries) {
32
+ const names = entries.map((f) => path_1.default.basename(f, path_1.default.extname(f)));
33
+ if (names.length === 1)
34
+ return names[0];
35
+ if (names.length === 2)
36
+ return `${names[0]}-${names[1]}`;
37
+ if (names.length > 2)
38
+ return `${names[0]}-and-${names.length - 1}more`;
39
+ return "unknown";
40
+ }
41
+ function resolveOutDirPath(outDir, base, asTxt = false) {
42
+ const ext = asTxt ? "txt" : "md";
43
+ return path_1.default.join(outDir, `${base}-combined.${ext}`);
44
+ }
@@ -0,0 +1,81 @@
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.rel = rel;
7
+ exports.read = read;
8
+ exports.isExcluded = isExcluded;
9
+ exports.walk = walk;
10
+ exports.orderByPriority = orderByPriority;
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const micromatch_1 = __importDefault(require("micromatch"));
14
+ /**
15
+ * Get a root-relative version of a path.
16
+ */
17
+ function rel(p, root = process.cwd()) {
18
+ return path_1.default.relative(root, p).replaceAll("\\", "/");
19
+ }
20
+ /**
21
+ * Safe text read.
22
+ */
23
+ function read(p) {
24
+ try {
25
+ return fs_1.default.readFileSync(p, "utf8");
26
+ }
27
+ catch {
28
+ return "";
29
+ }
30
+ }
31
+ /**
32
+ * Check if a path/file matches any of the provided glob patterns.
33
+ */
34
+ function isExcluded(p, patterns, root = process.cwd()) {
35
+ if (!patterns?.length)
36
+ return false;
37
+ const relPath = rel(p, root);
38
+ return micromatch_1.default.isMatch(relPath, patterns);
39
+ }
40
+ /**
41
+ * Recursive walker that respects glob exclude.
42
+ * Returns all files under the given directory tree.
43
+ */
44
+ function* walk(dir, cfg, depth = 0) {
45
+ const { scanDepth, entry } = cfg;
46
+ const root = process.cwd();
47
+ if (depth > scanDepth)
48
+ return;
49
+ const entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
50
+ for (const e of entries) {
51
+ const full = path_1.default.join(dir, e.name);
52
+ if (e.isDirectory()) {
53
+ // Skip excluded directories entirely
54
+ const relPath = rel(full, root);
55
+ if (isExcluded(relPath, entry.exclude))
56
+ continue;
57
+ yield* walk(full, cfg, depth + 1);
58
+ continue;
59
+ }
60
+ if (e.isFile()) {
61
+ const relPath = rel(full, root);
62
+ if (isExcluded(relPath, entry.exclude))
63
+ continue;
64
+ yield full;
65
+ }
66
+ }
67
+ }
68
+ function orderByPriority(files, priorityList = []) {
69
+ if (!priorityList.length)
70
+ return files;
71
+ const prioritized = [];
72
+ const normal = [];
73
+ for (const f of files) {
74
+ const normalized = f.norm().toLowerCase();
75
+ if (priorityList.some(p => micromatch_1.default.isMatch(normalized, p.toLowerCase())))
76
+ prioritized.push(f);
77
+ else
78
+ normal.push(f);
79
+ }
80
+ return [...new Set([...prioritized, ...normal])];
81
+ }
@@ -0,0 +1,51 @@
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.extractImports = extractImports;
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const es_module_lexer_1 = require("es-module-lexer");
10
+ let initialized = false;
11
+ async function extractImports(filePath, code) {
12
+ if (!initialized) {
13
+ await es_module_lexer_1.init;
14
+ initialized = true;
15
+ }
16
+ let src = code;
17
+ if (src == null) {
18
+ try {
19
+ src = await promises_1.default.readFile(filePath, "utf8");
20
+ }
21
+ catch {
22
+ return new Set();
23
+ }
24
+ }
25
+ try {
26
+ const [imports] = (0, es_module_lexer_1.parse)(src);
27
+ const out = new Set();
28
+ for (const i of imports)
29
+ if (i.n)
30
+ out.add(i.n);
31
+ return out;
32
+ }
33
+ catch {
34
+ return fallbackRegex(src);
35
+ }
36
+ }
37
+ function fallbackRegex(code) {
38
+ const patterns = [
39
+ /import\s+[^'"]*['"]([^'"]+)['"]/g,
40
+ /import\(\s*['"]([^'"]+)['"]\s*\)/g,
41
+ /require\(\s*['"]([^'"]+)['"]\s*\)/g,
42
+ /export\s+\*\s+from\s+['"]([^'"]+)['"]/g,
43
+ ];
44
+ const matches = new Set();
45
+ for (const r of patterns) {
46
+ let m;
47
+ while ((m = r.exec(code)))
48
+ matches.add(m[1]);
49
+ }
50
+ return matches;
51
+ }
@@ -0,0 +1,42 @@
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.tocMd = tocMd;
7
+ exports.renderMd = renderMd;
8
+ exports.tocTxt = tocTxt;
9
+ exports.renderTxt = renderTxt;
10
+ const path_1 = __importDefault(require("path"));
11
+ const helpers_1 = require("./helpers");
12
+ const render_constants_1 = require("../constants/render-constants");
13
+ /**
14
+ * Generate Markdown Table of Contents with anchors
15
+ */
16
+ function tocMd(files) {
17
+ const count = files.length;
18
+ const items = files.map((f, i) => `- [${(0, helpers_1.rel)(f)}](#${i + 1})`).join("\n");
19
+ return [`# Index `, `\nIncluded Source Files (${count})`, "", items, "", "---"].join("\n");
20
+ }
21
+ /**
22
+ * Render each file section with invisible anchors
23
+ */
24
+ function renderMd(p, i) {
25
+ const rp = (0, helpers_1.rel)(p);
26
+ const ext = path_1.default.extname(p).toLowerCase();
27
+ const lang = render_constants_1.LANG_MAP[ext] || "txt";
28
+ const code = (0, helpers_1.read)(p).trimEnd();
29
+ return [`---\n#### ${i + 1}`, "\n", "` File: " + rp + "` [↑ Back to top](#index)", "", "```" + lang, code, "```", ""].join("\n");
30
+ }
31
+ /**
32
+ * TXT version (unchanged)
33
+ */
34
+ function tocTxt(files) {
35
+ const sorted = [...files].sort((a, b) => a.localeCompare(b));
36
+ return ["##==== Combined Scope ====", ...sorted.map((f) => "## - " + (0, helpers_1.rel)(f))].join("\n") + "\n\n";
37
+ }
38
+ function renderTxt(p) {
39
+ const relPath = (0, helpers_1.rel)(p);
40
+ const code = (0, helpers_1.read)(p);
41
+ return ["##==== path: " + relPath + " ====", "##region " + relPath, code, "##endregion", ""].join("\n");
42
+ }
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = startProdex;
4
+ const combine_1 = require("./core/combine");
5
+ const init_1 = require("./cli/init");
6
+ const logger_1 = require("./lib/logger");
7
+ const cli_input_1 = require("./cli/cli-input");
8
+ const config_loader_1 = require("./constants/config-loader");
9
+ require("./lib/polyfills");
10
+ async function startProdex() {
11
+ const args = process.argv;
12
+ // Handle init mode
13
+ if (args.includes("init")) {
14
+ return (0, init_1.initProdex)();
15
+ }
16
+ // Parse CLI input
17
+ const { root, flags, warnings, errors } = (0, cli_input_1.parseCliInput)(args);
18
+ if (warnings.length)
19
+ logger_1.logger.warn("Warnings:", warnings);
20
+ if (errors.length)
21
+ logger_1.logger.error("Errors:", errors);
22
+ // Load and merge configuration (with flag overrides)
23
+ const config = await (0, config_loader_1.loadProdexConfig)(flags, root);
24
+ logger_1.logger.log(`------- PRODEx RUN @ ${new Date().toLocaleTimeString()} — Codebase decoded -------`);
25
+ // Log parse results for testing
26
+ logger_1.logger.debug("🧩 Parsed CLI input:", _2j({ flags }));
27
+ logger_1.logger.debug("Final merged config:", _2j(config));
28
+ await (0, combine_1.runCombine)(config, !flags.ci && !flags?.files?.length);
29
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ const env = () => {
5
+ const obj = { debug: process.env.PRODEX_DEBUG === "1", silent: process.env.PRODEX_SILENT === "1" };
6
+ return obj;
7
+ };
8
+ exports.logger = {
9
+ debug: (...args) => !env().silent && env().debug && console.log("\n🪶 [debug]", ...args),
10
+ info: (...args) => !env().silent && console.log("\n📌 [info]", ...args),
11
+ warn: (...args) => !env().silent && console.warn("\n⚠️ [warn]", ...args),
12
+ error: (...args) => !env().silent && console.error("\n💥 [error]", ...args),
13
+ log: (...args) => !env().silent && console.log("\n", ...args),
14
+ };
@@ -0,0 +1,12 @@
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
+ const util_1 = __importDefault(require("util"));
7
+ if (!String.prototype.norm) {
8
+ String.prototype.norm = function () {
9
+ return this.replace(/\\/g, "/");
10
+ };
11
+ }
12
+ globalThis._2j = (obj) => util_1.default.inspect(obj, { colors: true, depth: null, breakLength: 150, compact: 3 });
@@ -0,0 +1,15 @@
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
+ function unique(arr) {
8
+ return [...new Set(arr)];
9
+ }
10
+ function setDiff(A, B) {
11
+ return new Set([...A].filter(x => !B.has(x)));
12
+ }
13
+ function toArray(v) {
14
+ return Array.isArray(v) ? v : [v];
15
+ }
@@ -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
+ }