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
package/README.md CHANGED
@@ -1,140 +1,234 @@
1
- # 🧩 Prodex — Unified Project Indexer & Dependency Extractor
2
-
3
- > **Prodex** *(short for “Project Index”)* a cross-language dependency combiner for modern full-stack applications.
4
- > Traverses **Laravel + React + TypeScript** projects to generate a single, organized view of your project’s true dependency scope.
5
-
6
- ---
7
-
8
- ## 🧠 Recent Fixes & Updates — v1.0.8
9
- - **Priority Files Support** — priority files will now appear **first** on the entry selection list.
10
-
11
- - 🪟 **Windows path resolution fixed** now uses proper `file://` URLs for full ESM compatibility.
12
- - 🧾 **Improved output naming** — automatic, context-aware filenames (e.g. `prodex-[entries]-combined.txt`).
13
- - ⚙️ **“Yes to all” confirmation added** — skip repetitive prompts during CLI runs.
14
-
15
- ---
16
-
17
- ---
18
-
19
- ## 📦 Installation
20
-
21
- ### Global install (recommended)
22
- ```bash
23
- npm install -g prodex
24
- ```
25
-
26
-
27
- ## 🚀 Features
28
-
29
- | Feature | Description |
30
- |----------|-------------|
31
- | ⚙️ **Cross-language resolver** | Parses JS/TS (`import`, `export`) and PHP (`use`, `require`, `include`) dependency trees. |
32
- | 🧭 **Alias detection** | Reads `tsconfig.json` and `vite.config.*` for alias paths (`@/components/...`). |
33
- | 🧩 **Laravel-aware** | Maps PSR-4 namespaces and detects providers under `app/Providers`. |
34
- | 🔄 **Recursive chain following** | Resolves dependency graphs up to a configurable depth and file limit. |
35
- | 🪶 **Clean unified output** | Merges all resolved files into a single `.txt` file with region markers for readability. |
36
- | 🧠 **Static & safe** | Fully static parsing — no runtime execution or file modification. |
37
- | 💬 **Interactive CLI** | Select files, confirm settings, or use “Yes to all” for streamlined automation. |
38
-
39
- ---
40
-
41
- ## ⚙️ Configuration
42
-
43
- Optional `.prodex.json` (in project root):
44
-
45
- ```json
46
- {
47
- "$schema": "https://raw.githubusercontent.com/emxhive/prodex/main/schema/prodex.schema.json",
48
- "output": "prodex",
49
- "scanDepth": 2,
50
- "limit": 200,
51
- "baseDirs": ["app", "routes", "resources/js"],
52
- "aliasOverrides": {
53
- "@hooks": "resources/js/hooks",
54
- "@data": "resources/js/data"
55
- },
56
- "entryExcludes": [
57
- "resources/js/components/ui/",
58
- "app/DTOs/"
59
- ],
60
- "importExcludes": [
61
- "node_modules",
62
- "@shadcn/"
63
- ],
64
- "priorityFiles": [
65
- "routes/web.php",
66
- "routes/api.php",
67
- "index.",
68
- "main.",
69
- "app."
70
- ]
71
- }
72
- ```
73
-
74
- ```
75
-
76
-
77
-
78
- ```
79
-
80
-
81
-
82
- Files are matched using `.includes()` (case-insensitive), so `"index."` will match `src/index.js`, `app/index.tsx`, etc.
83
- Popular entries appear at the top of the picker.
84
-
85
-
86
-
87
-
88
-
89
- ---
90
-
91
- ## 🧱 Example: Laravel + React
92
-
93
- ```bash
94
- prodex
95
- ```
96
-
97
- ```
98
- 🧩 Following dependency chain...
99
- ✅ prodex-app-routes-combined.txt written (24 file(s)).
100
- ```
101
-
102
- Included files:
103
- ```
104
- resources/js/pages/accounts.tsx
105
- app/Http/Controllers/Shots/AccountsController.php
106
- app/Repositories/Shots/FireflyApiRepository.php
107
- app/Enums/Shots/Granularity.php
108
- app/Support/Shots/CacheKeys.php
109
- ...
110
- ```
111
-
112
- ---
113
-
114
- ## 🧠 Ideal Use Cases
115
-
116
- - 📦 Generate single-file **project snapshots**
117
- - 🤖 Provide structured context for **AI assistants**
118
- - 🧩 Perform **dependency audits** or code reviews
119
- - 📄 Simplify documentation and onboarding
120
-
121
- ---
122
-
123
- ## 🔮 Upcoming Features
124
-
125
- - 📝 **Markdown export** (`.md`) with automatic code fences
126
- - 📦 **Configurable output formats** (txt / md)
127
- - **Alias auto-discovery for Laravel Mix and Next.js**
128
-
129
- ---
130
-
131
- ## 🧾 License
132
-
133
- **MIT © 2025 [emxhive](https://github.com/emxhive)**
134
- Issues and contributions welcome:
135
- 👉 [github.com/emxhive/prodex/issues](https://github.com/emxhive/prodex/issues)
136
-
137
- ---
138
-
139
- **Prodex** *Codebase, decoded*
140
-
1
+ # 🧩 Prodex v1.2.0
2
+
3
+ > **Build the maze, I'll write a map.**
4
+
5
+ ---
6
+
7
+ ## 🧠 What’s New — v1.2.0
8
+
9
+ - 🆕 **Full CLI support with integrated [Sade](https://github.com/lukeed/sade).**
10
+ Prodex now runs entirely from the terminal — no `prodex.json` required.
11
+ Supports short flags and native glob patterns for flexible targeting.
12
+
13
+ ```bash
14
+ prodex -f "**/web.php,**/app.tsx" -i "**/*.d.ts" -x "node_modules/**"
15
+ ```
16
+
17
+ ```bash
18
+ prodex --files "**/web.php,**/app.tsx" --include **/*types.ts --exclude "@shadcn/**"
19
+ ```
20
+
21
+ - 🧾 **Markdown mode added and now default.**
22
+ Output is fully fenced and linkable — jump between the index and any code block.
23
+ Text mode remains available using `--txt` or `-t`.
24
+
25
+ - 🗂 **Output naming improved.**
26
+ Output files are now versioned by default.
27
+ Custom names are supported using `--name` or `-n`.
28
+ Naming conventions have been updated for cleaner, consistent results.
29
+
30
+ ---
31
+
32
+ ## ⚙️ Usage
33
+
34
+ Prodex v1.2.0 runs entirely from the command line.
35
+ Interactive mode is currently unstable use CLI flags instead.
36
+
37
+ ### Installation
38
+
39
+ ```bash
40
+ npm install -g prodex
41
+ ```
42
+
43
+ Or run without installing:
44
+
45
+ ```bash
46
+ npx prodex
47
+ ```
48
+
49
+ ---
50
+
51
+ ### Basic Run
52
+
53
+ ```bash
54
+ prodex -f "**/web.php,**/app.tsx"
55
+ ```
56
+
57
+ ### With Includes, exclude, and Custom Name
58
+
59
+ ```bash
60
+ prodex -f "**/web.php,**/app.tsx" -i "**/*.d.ts" -x "node_modules/**" -n "combined-output"
61
+ ```
62
+
63
+ ### Flag Reference
64
+
65
+ | Flag | Short | Description |
66
+ | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
+ | `--files` | `-f` | Entry files — starting points for dependency resolution. Accepts multiple names or globs. |
68
+ | `--include` | `-i` | Adds extra files or patterns to include (e.g. `.d.ts`, interface, or type files). These files are **not dependency-resolved** — they’re appended as-is. |
69
+ | `--exclude` | `-x` | Patterns or folders to skip during the scan. |
70
+ | `--name` | `-n` | Custom output filename (without extension). Versioning still applies automatically. |
71
+
72
+ > Globs are powered by [Fast-Glob](https://github.com/mrmlnc/fast-glob).
73
+ > Use **comma-separated values** for multiple entries.
74
+ > Wrap globs in quotes when they include special characters like `|` or `&`.
75
+
76
+ ---
77
+
78
+ ## 🧭 Plans
79
+
80
+ - **Alias Resolution Improvements**
81
+ Planned overhaul of alias handling to support deeper nested paths, wildcard matching, and auto-mapped imports across mixed stacks.
82
+
83
+ - **Language Support**
84
+ Currently supports **JavaScript**, **React**, and **Laravel + React** stacks.
85
+ May work with other frameworks but remains untested.
86
+ Broader multi-language support is planned for future versions.
87
+
88
+ - **Combined Output**
89
+ All code from multiple entries is merged into a single output file.
90
+ There’s currently **no limit** on output size, but it’s advised to avoid combining _too many large entries_ in a single run.
91
+ Future versions will include **smart naming** and **automatic splitting** for oversized outputs.
92
+
93
+ - **Performance Optimizations**
94
+ Planned improvements to resolver speed and dependency traversal for faster processing on large projects.
95
+
96
+ ---
97
+
98
+ ## 🧩 Features
99
+
100
+ | Status | Feature | Description |
101
+ | :----: | --------------------------- | ---------------------------------------------------------------------------------------------- |
102
+ | ✅ | **Cross-language indexing** | Resolves imports across JS, TS, React, and PHP (Laravel) projects. |
103
+ | ✅ | **Markdown output** | Generates clean `.md` files with anchors, back-to-top links, and fenced code blocks. |
104
+ | ✅ | **Text output** | Optional `.txt` mode using `--txt` or `-t`. |
105
+ | ✅ | **Glob support** | Works with flexible glob patterns powered by [Fast-Glob](https://github.com/mrmlnc/fast-glob). |
106
+ | ✅ | **Custom output names** | Define your own output prefix using `--name` or `-n`. |
107
+ | ⚠️ | **Interactive picker (UI)** | Still unstable — not recommended for production use. |
108
+ | ⚠️ | **Alias resolution** | Basic alias mapping supported; advanced cases in progress. |
109
+ | 🚧 | **Smart file splitting** | Planned for large combined outputs. |
110
+ | 🚧 | **PSR-4 deep scan** | Planned to improve PHP dependency resolution. |
111
+ | 🚧 | **Speed optimization** | Further resolver and I/O improvements under development. |
112
+
113
+ ---
114
+
115
+ ## 🧱 Use Cases
116
+
117
+ Prodex can technically combine your entire codebase into one file —
118
+ but it’s **best used in parts**, focusing on specific sections or features.
119
+ Each run produces a clean, self-contained map showing all related files and dependencies.
120
+
121
+ ### 🧩 Common Scenarios
122
+
123
+ - **🤖 Project Awareness for AI Assistants**
124
+ Generate compact `.md` summaries of key parts of your project.
125
+ These can be shared with AI tools (like ChatGPT, Claude, or Copilot) to give them structured context about your codebase — without exposing unnecessary files.
126
+
127
+ - **📦 Feature or Module Mapping**
128
+ Combine everything connected to a specific feature (e.g., `Checkout`, `Dashboard`, or `Payments`).
129
+ Prodex gathers all linked imports, helpers, and files into one readable document.
130
+
131
+ - **🔍 Dependency Insight**
132
+ Trace how a particular entry file connects through your stack — whether it’s `app.tsx` on the frontend or `routes/web.php` on the backend.
133
+ Great for debugging, refactoring, or understanding cross-stack dependencies.
134
+
135
+ - **📖 Documentation Bundles**
136
+ Create readable Markdown maps per module or domain instead of one large export.
137
+ Each output acts as a focused, navigable view of your code relationships.
138
+
139
+ - **🧠 Team Handoffs**
140
+ Share isolated code scopes (like `Auth`, `Payments`, or `User Management`) with full dependency context.
141
+ Makes onboarding and code reviews significantly faster.
142
+
143
+ ---
144
+
145
+ ## 🧩 Recommended Workflow
146
+
147
+ Prodex works best when used to **map and export projects in logical parts** rather than all at once.
148
+ Each run focuses on one or more entry points, and Prodex automatically **loads all imports recursively** for those files —
149
+ then appends any files matched by the `--include` flag.
150
+
151
+ ### 🧠 Suggested Pattern
152
+
153
+ 1. **Pick a meaningful entry file**
154
+ Example:
155
+
156
+ - Frontend: `resources/js/**/dashboard.tsx`
157
+ - Backend: `routes/**/(web|api).php`
158
+ - Shared logic: `app/Services/**/PaymentService.php`
159
+
160
+ 2. **Run Prodex with includes for type or interface files**
161
+
162
+ ```bash
163
+ prodex -f "**/dashboard.tsx" -i "**/*.d.ts,**/*.interface.ts"
164
+ ```
165
+
166
+ 3. **Export separate maps for each major area**
167
+
168
+ ```bash
169
+ prodex -f "**/dashboard.tsx" -n "dashboard-map"
170
+ prodex -f "**/(web|api).php" -n "backend-map"
171
+ ```
172
+
173
+ 4. **Use them together**
174
+ Store each output in `/prodex/`
175
+ These maps can be shared with teammates or loaded into AI tools for structured, code-aware assistance.
176
+
177
+ > ⚡ Each run recursively resolves every import, applies includes, and outputs one complete dependency map for that section.
178
+
179
+ ---
180
+
181
+ ## ⚙️ Optional — `prodex.json`
182
+
183
+ `prodex.json` is **fully optional** in v1.2.0.
184
+ You can run Prodex entirely from the command line, but the config file can be useful for saved defaults.
185
+
186
+ ### 🪄 Quick Setup
187
+
188
+ You can generate a ready-to-use config file with:
189
+
190
+ ```bash
191
+ prodex init
192
+ ```
193
+
194
+ This creates a `prodex.json` file in your project root with sensible defaults — including base directories, globs, and priority files.
195
+
196
+ ### 🧩 Running with a Config File
197
+
198
+ If you’ve defined your entry files in the config under `entry.files`,
199
+ you can run Prodex directly without specifying `--files`:
200
+
201
+ ```bash
202
+ prodex -c
203
+ ```
204
+
205
+ The `-c` (or `--ci`) flag skips interactive mode and uses the config values automatically.
206
+ Specifying `-f` ( or `--files`) from the CLI also disables the picker by default.
207
+
208
+ You can permanently disable the picker in the config by setting:
209
+
210
+ ```json
211
+ "entry": {
212
+ "ui": {
213
+ "enablePicker": false
214
+ }
215
+ }
216
+ ```
217
+
218
+ ---
219
+
220
+ ## 📜 License
221
+
222
+ **MIT License**
223
+ © 2025 [emxhive](https://github.com/emxhive)
224
+
225
+ ---
226
+
227
+ ## ⚠️ Note from the Author
228
+
229
+ Prodex is still a **work in progress**.
230
+ Some parts of the experience may be rough, especially around interactive mode and advanced resolvers.
231
+ Updates are released **multiple times per week — sometimes daily** — to keep improving stability and support.
232
+
233
+ Please stay up to date for the best experience.
234
+ Thank you for testing Prodex early. ❤️
package/bin/prodex.js CHANGED
@@ -1,18 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import fs from "fs";
3
- import path from "path";
4
- import { pathToFileURL, fileURLToPath } from "url";
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
-
9
- const devPath = path.resolve(__dirname, "../src/index.js");
10
- const distPath = path.resolve(__dirname, "../dist/src/index.js");
11
-
12
- // prefer dist in published package
13
- const entry = fs.existsSync(distPath) ? distPath : devPath;
14
-
15
- // convert to file:// URL for cross-platform ESM loading
16
- const entryUrl = pathToFileURL(entry).href;
17
-
18
- import(entryUrl).then(({ default: startProdex }) => startProdex());
2
+ require("../dist/index.js").default();
@@ -0,0 +1,106 @@
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.parseCliInput = parseCliInput;
7
+ const sade_1 = __importDefault(require("sade"));
8
+ const flags_1 = require("./flags");
9
+ const logger_1 = require("../lib/logger");
10
+ const path_1 = __importDefault(require("path"));
11
+ const package_json_1 = __importDefault(require("../../package.json"));
12
+ const fs_1 = __importDefault(require("fs"));
13
+ /**
14
+ * Unified CLI parser powered by Sade.
15
+ * Returns { root, entries (from --files), flags, warnings, errors }.
16
+ */
17
+ function parseCliInput(argv = process.argv) {
18
+ if (argv.includes("-v") || argv.includes("--version")) {
19
+ logger_1.logger.log(`prodex v${package_json_1.default.version}`);
20
+ process.exit(0);
21
+ }
22
+ const program = (0, sade_1.default)("prodex [root]");
23
+ registerFlags(program);
24
+ let parsed = { rootArg: "", root: undefined, flags: {} };
25
+ // Define action
26
+ program.action((root, opts) => {
27
+ const cwd = process.cwd();
28
+ parsed = {
29
+ rootArg: root,
30
+ root: root ? path_1.default.resolve(cwd, root) : cwd,
31
+ flags: { ...opts },
32
+ };
33
+ });
34
+ program.parse(argv);
35
+ const warnings = [];
36
+ const errors = [];
37
+ // Post-parse casting + normalization
38
+ parsed.flags = normalizeFlags(parsed.flags, warnings, errors);
39
+ validateArgs(parsed, warnings, errors);
40
+ return {
41
+ ...parsed,
42
+ warnings,
43
+ errors,
44
+ };
45
+ }
46
+ function registerFlags(program) {
47
+ for (const [key, meta] of Object.entries(flags_1.PRODEX_FLAGS)) {
48
+ const short = meta.short ? `-${meta.short}, ` : "";
49
+ const long = `--${key}`;
50
+ const desc = meta.description;
51
+ let defaultVal;
52
+ if (meta.type === "boolean")
53
+ defaultVal = false;
54
+ if (defaultVal !== undefined)
55
+ program.option(`${short}${long}`, desc, defaultVal);
56
+ else
57
+ program.option(`${short}${long}`, desc);
58
+ }
59
+ }
60
+ function normalizeFlags(flags, warnings, errors) {
61
+ for (const [key, meta] of Object.entries(flags_1.PRODEX_FLAGS)) {
62
+ const raw = flags[key];
63
+ if (raw === undefined)
64
+ continue;
65
+ switch (meta.type) {
66
+ case "number": {
67
+ const num = Number(raw);
68
+ if (Number.isNaN(num))
69
+ errors.push(`Flag --${key} expected a number but got "${raw}"`);
70
+ else
71
+ flags[key] = num;
72
+ break;
73
+ }
74
+ case "list": {
75
+ const arr = String(raw)
76
+ .split(",")
77
+ .map((v) => v.trim())
78
+ .filter(Boolean);
79
+ flags[key] = arr;
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ return flags;
85
+ }
86
+ function validateArgs(parsed, warnings, errors) {
87
+ const { rootArg, flags: { _: unknown }, } = parsed;
88
+ if (rootArg) {
89
+ if (!fs_1.default.existsSync(parsed.root)) {
90
+ errors.push(`Invalid path argument: "${rootArg}" does not exist.`);
91
+ }
92
+ else if (!fs_1.default.statSync(parsed.root).isDirectory()) {
93
+ errors.push(`Path argument "${rootArg}" is not a directory.`);
94
+ }
95
+ }
96
+ if (unknown.length) {
97
+ warnings.push(`Unrecognized arguments detected [${unknown.join(", ")}]- They were ignored.`);
98
+ }
99
+ if (warnings.length)
100
+ logger_1.logger.warn("Warnings:", warnings);
101
+ if (errors.length) {
102
+ for (const err of errors)
103
+ logger_1.logger.error(err);
104
+ process.exit(1);
105
+ }
106
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLI_USAGE = exports.FLAG_SHORT_MAP = exports.PRODEX_FLAGS = exports.FlagKey = void 0;
4
+ var FlagKey;
5
+ (function (FlagKey) {
6
+ FlagKey["Txt"] = "txt";
7
+ FlagKey["Ci"] = "ci";
8
+ FlagKey["Debug"] = "debug";
9
+ FlagKey["Name"] = "name";
10
+ FlagKey["Limit"] = "limit";
11
+ FlagKey["Inc"] = "include";
12
+ FlagKey["Exc"] = "exclude";
13
+ FlagKey["Help"] = "help";
14
+ FlagKey["Files"] = "files";
15
+ })(FlagKey || (exports.FlagKey = FlagKey = {}));
16
+ exports.PRODEX_FLAGS = {
17
+ [FlagKey.Files]: { short: "f", type: "list", description: "Comma-separated entry files." },
18
+ [FlagKey.Txt]: { short: "t", type: "boolean", description: "Output as .txt instead of .md." },
19
+ [FlagKey.Ci]: { short: "c", type: "boolean", description: "Headless/no-UI mode." },
20
+ [FlagKey.Debug]: { short: "d", type: "boolean", description: "Enable debug logs." },
21
+ [FlagKey.Name]: { short: "n", type: "string", description: "Custom output filename." },
22
+ [FlagKey.Limit]: { short: "l", type: "number", description: "Override traversal limit." },
23
+ [FlagKey.Inc]: { type: "list", short: "i", description: "Comma-separated include globs." },
24
+ [FlagKey.Exc]: { type: "list", short: "x", description: "Comma-separated exclude globs." },
25
+ [FlagKey.Help]: { short: "h", type: "boolean", description: "Show CLI help and exit." },
26
+ };
27
+ /** Reverse lookup for short aliases. */
28
+ exports.FLAG_SHORT_MAP = Object.entries(exports.PRODEX_FLAGS).reduce((acc, [key, meta]) => {
29
+ if (meta.short)
30
+ acc[meta.short] = key;
31
+ return acc;
32
+ }, {});
33
+ exports.CLI_USAGE = `
34
+ Usage: prodex [-fcdv]
35
+ [--files=<globs>|-f=<globs>]
36
+ [--include=<globs>|-i=<globs>]
37
+ [--exclude=<globs>|-x=<globs>]
38
+ [--txt|-t] [--ci|-c] [--debug|-d] [--version|-v]
39
+ [--name=<string>|-n=<string>]
40
+ [--limit=<int>|-l=<int>]
41
+ [--help|-h]
42
+ `;
@@ -0,0 +1,21 @@
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.initProdex = initProdex;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const default_config_1 = require("../constants/default-config");
10
+ const logger_1 = require("../lib/logger");
11
+ async function initProdex() {
12
+ logger_1.logger.log("🪄 Prodex Init — Configuration Wizard (v2)");
13
+ const dest = path_1.default.join(process.cwd(), "prodex.json");
14
+ if (fs_1.default.existsSync(dest)) {
15
+ logger_1.logger.error("prodex.json already exists. Delete or modify it manually.\n");
16
+ return;
17
+ }
18
+ fs_1.default.writeFileSync(dest, JSON.stringify(default_config_1.DEFAULT_PRODEX_CONFIG, null, 2) + "\n", "utf8");
19
+ logger_1.logger.log(`✅ Created ${dest}`);
20
+ logger_1.logger.log("💡 Globs supported everywhere (include, exclude, priority).");
21
+ }
@@ -0,0 +1,82 @@
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.pickEntries = pickEntries;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const inquirer_1 = __importDefault(require("inquirer"));
10
+ const helpers_1 = require("../core/helpers");
11
+ const file_utils_1 = require("../core/file-utils");
12
+ const utils_1 = require("../lib/utils");
13
+ const logger_1 = require("../lib/logger");
14
+ const prompt_1 = require("../lib/prompt");
15
+ const questions_1 = require("../lib/questions");
16
+ /**
17
+ * Interactive entry picker for Prodex.
18
+ * Handles depth-based scanning, caching, and priority ordering.
19
+ */
20
+ async function pickEntries(cfg) {
21
+ const { root, entry: { files, ui: { roots = [], priority = [], scanDepth }, }, } = cfg;
22
+ let depth = scanDepth;
23
+ const entryPatterns = files || [];
24
+ const priorities = [...entryPatterns, ...priority];
25
+ // 1️⃣ Resolve pre-defined entry patterns
26
+ const resolvedEntries = (await (0, file_utils_1.globScan)(entryPatterns, { cwd: root })).files;
27
+ let selected = [...resolvedEntries];
28
+ // cache: depth → files[]
29
+ const scanCache = new Map();
30
+ for (;;) {
31
+ const files = await getFilesAtDepth(depth, cfg, scanCache);
32
+ // Merge resolved entries with current scan results
33
+ const combined = (0, utils_1.unique)([...resolvedEntries, ...files]);
34
+ const sorted = (0, helpers_1.orderByPriority)(combined, priorities);
35
+ // Build UI selection list
36
+ const choices = sorted.map((f) => ({
37
+ name: (0, helpers_1.rel)(f, root),
38
+ value: f,
39
+ checked: selected.includes(f),
40
+ }));
41
+ if (depth < scanDepth + 5) {
42
+ choices.push(new inquirer_1.default.Separator());
43
+ choices.push({ name: "🔽 Load more (go deeper)", value: "__loadmore" });
44
+ }
45
+ // 🧠 Use unified prompt wrapper
46
+ const answers = await (0, prompt_1.prompt)((0, questions_1.PICK_ENTRIES_QUESTION)(choices, depth), { picks: [] });
47
+ if (!answers)
48
+ return (0, utils_1.unique)(selected);
49
+ const { picks } = answers;
50
+ if (picks.includes("__loadmore")) {
51
+ depth++;
52
+ selected = picks.filter((p) => p !== "__loadmore");
53
+ continue;
54
+ }
55
+ selected = picks.filter((p) => p !== "__loadmore");
56
+ break;
57
+ }
58
+ return (0, utils_1.unique)(selected);
59
+ }
60
+ /**
61
+ * Depth-based directory scanner with caching.
62
+ */
63
+ async function getFilesAtDepth(depth, cfg, scanCache) {
64
+ const baseDirs = cfg.entry.ui.roots || [];
65
+ if (scanCache.has(depth)) {
66
+ logger_1.logger.debug(`[picker] cache hit → depth=${depth}`);
67
+ return scanCache.get(depth);
68
+ }
69
+ logger_1.logger.debug(`[picker] scanning → depth=${depth}`);
70
+ const files = [];
71
+ const effectiveCfg = { ...cfg, scanDepth: depth };
72
+ for (const base of baseDirs) {
73
+ const full = path_1.default.join(cfg.root, base);
74
+ if (!fs_1.default.existsSync(full))
75
+ continue;
76
+ for (const f of (0, helpers_1.walk)(full, effectiveCfg, 0))
77
+ files.push(f.norm());
78
+ }
79
+ scanCache.set(depth, files);
80
+ logger_1.logger.debug(`[picker] depth=${depth} found=${files.length}`);
81
+ return files;
82
+ }