prodex 1.2.0 ā 1.4.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.
- package/README.md +55 -49
- package/dist/cli/cli-input.js +58 -43
- package/dist/cli/cli-input.js.map +1 -0
- package/dist/cli/flags.js +1 -0
- package/dist/cli/flags.js.map +1 -0
- package/dist/cli/init.js +5 -5
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/picker.js +43 -41
- package/dist/cli/picker.js.map +1 -0
- package/dist/cli/summary.js +28 -9
- package/dist/cli/summary.js.map +1 -0
- package/dist/constants/cache-keys.js +12 -0
- package/dist/constants/cache-keys.js.map +1 -0
- package/dist/constants/config-loader.js +12 -7
- package/dist/constants/config-loader.js.map +1 -0
- package/dist/constants/config.js +17 -6
- package/dist/constants/config.js.map +1 -0
- package/dist/constants/default-config.js +4 -17
- package/dist/constants/default-config.js.map +1 -0
- package/dist/constants/flags.js +74 -0
- package/dist/constants/flags.js.map +1 -0
- package/dist/constants/index.js +21 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/render-constants.js +11 -9
- package/dist/constants/render-constants.js.map +1 -0
- package/dist/core/cache.js +54 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/core/combine.js +42 -59
- package/dist/core/combine.js.map +1 -0
- package/dist/core/config-manager.js +104 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/dependency.js +42 -17
- package/dist/core/dependency.js.map +1 -0
- package/dist/core/file-utils.js +1 -44
- package/dist/core/file-utils.js.map +1 -0
- package/dist/core/helpers.js +43 -38
- package/dist/core/helpers.js.map +1 -0
- package/dist/core/managers/cache.js +54 -0
- package/dist/core/managers/cache.js.map +1 -0
- package/dist/core/managers/config-manager.js +104 -0
- package/dist/core/managers/config-manager.js.map +1 -0
- package/dist/core/managers/config.js +104 -0
- package/dist/core/managers/config.js.map +1 -0
- package/dist/core/output.js +49 -0
- package/dist/core/output.js.map +1 -0
- package/dist/core/parsers/extract-imports.js +2 -7
- package/dist/core/parsers/extract-imports.js.map +1 -0
- package/dist/core/renderers.js +10 -8
- package/dist/core/renderers.js.map +1 -0
- package/dist/debug.js +14 -0
- package/dist/debug.js.map +1 -0
- package/dist/index.js +49 -22
- package/dist/index.js.map +1 -0
- package/dist/lib/logger.js +38 -9
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/polyfills.js +6 -0
- package/dist/lib/polyfills.js.map +1 -0
- package/dist/lib/prompt.js +35 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/questions.js +29 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/utils.js +35 -11
- package/dist/lib/utils.js.map +1 -0
- package/dist/resolvers/js/alias-loader.js +1 -0
- package/dist/resolvers/js/alias-loader.js.map +1 -0
- package/dist/resolvers/js/extract-imports.js +46 -0
- package/dist/resolvers/js/extract-imports.js.map +1 -0
- package/dist/resolvers/js/js-resolver.js +93 -116
- package/dist/resolvers/js/js-resolver.js.map +1 -0
- package/dist/resolvers/js/resolve-alias.js +58 -0
- package/dist/resolvers/js/resolve-alias.js.map +1 -0
- package/dist/resolvers/php/bindings.js +21 -9
- package/dist/resolvers/php/bindings.js.map +1 -0
- package/dist/resolvers/php/extract-imports.js +50 -0
- package/dist/resolvers/php/extract-imports.js.map +1 -0
- package/dist/resolvers/php/patterns.js +37 -4
- package/dist/resolvers/php/patterns.js.map +1 -0
- package/dist/resolvers/php/php-resolver.js +99 -59
- package/dist/resolvers/php/php-resolver.js.map +1 -0
- package/dist/resolvers/php/psr4.js +19 -5
- package/dist/resolvers/php/psr4.js.map +1 -0
- package/dist/resolvers/shared/excludes.js +1 -0
- package/dist/resolvers/shared/excludes.js.map +1 -0
- package/dist/resolvers/shared/file-cache.js +1 -29
- package/dist/resolvers/shared/file-cache.js.map +1 -0
- package/dist/resolvers/shared/resolve-alias.js +62 -0
- package/dist/resolvers/shared/resolve-alias.js.map +1 -0
- package/dist/resolvers/shared/stats.js +3 -3
- package/dist/resolvers/shared/stats.js.map +1 -0
- package/dist/shared/collections.js +34 -0
- package/dist/shared/collections.js.map +1 -0
- package/dist/shared/index.js +20 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/io.js +52 -0
- package/dist/shared/io.js.map +1 -0
- package/dist/shared/patterns.js +30 -0
- package/dist/shared/patterns.js.map +1 -0
- package/dist/shared/stats.js +32 -0
- package/dist/shared/stats.js.map +1 -0
- package/dist/store.js +16 -0
- package/dist/store.js.map +1 -0
- package/dist/types/cli.types.js +1 -0
- package/dist/types/cli.types.js.map +1 -0
- package/dist/types/config.types.js +1 -0
- package/dist/types/config.types.js.map +1 -0
- package/dist/types/core.types.js +1 -0
- package/dist/types/core.types.js.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/resolver.types.js +1 -0
- package/dist/types/resolver.types.js.map +1 -0
- package/dist/types/utils.types.js +1 -0
- package/dist/types/utils.types.js.map +1 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
# š§© Prodex v1.2.0
|
|
3
2
|
|
|
4
|
-
> **
|
|
3
|
+
> **Build the maze, I'll write a map.**
|
|
5
4
|
|
|
6
5
|
---
|
|
7
6
|
|
|
@@ -9,20 +8,24 @@
|
|
|
9
8
|
|
|
10
9
|
- š **Full CLI support with integrated [Sade](https://github.com/lukeed/sade).**
|
|
11
10
|
Prodex now runs entirely from the terminal ā no `prodex.json` required.
|
|
12
|
-
Supports short flags and native glob patterns for flexible targeting.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
```
|
|
17
20
|
|
|
18
21
|
- š§¾ **Markdown mode added and now default.**
|
|
19
22
|
Output is fully fenced and linkable ā jump between the index and any code block.
|
|
20
|
-
Text mode remains available using `--txt` or `-t`.
|
|
23
|
+
Text mode remains available using `--txt` or `-t`.
|
|
21
24
|
|
|
22
25
|
- š **Output naming improved.**
|
|
23
26
|
Output files are now versioned by default.
|
|
24
27
|
Custom names are supported using `--name` or `-n`.
|
|
25
|
-
Naming conventions have been updated for cleaner, consistent results.
|
|
28
|
+
Naming conventions have been updated for cleaner, consistent results.
|
|
26
29
|
|
|
27
30
|
---
|
|
28
31
|
|
|
@@ -59,16 +62,16 @@ prodex -f "**/web.php,**/app.tsx" -i "**/*.d.ts" -x "node_modules/**" -n "combin
|
|
|
59
62
|
|
|
60
63
|
### Flag Reference
|
|
61
64
|
|
|
62
|
-
| Flag
|
|
63
|
-
|
|
64
|
-
| `--files`
|
|
65
|
-
| `--include` | `-i`
|
|
66
|
-
| `--exclude` | `-x`
|
|
67
|
-
| `--name`
|
|
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. |
|
|
68
71
|
|
|
69
72
|
> Globs are powered by [Fast-Glob](https://github.com/mrmlnc/fast-glob).
|
|
70
73
|
> Use **comma-separated values** for multiple entries.
|
|
71
|
-
> Wrap globs in quotes when they include special characters like `|` or `&`.
|
|
74
|
+
> Wrap globs in quotes when they include special characters like `|` or `&`.
|
|
72
75
|
|
|
73
76
|
---
|
|
74
77
|
|
|
@@ -84,28 +87,28 @@ prodex -f "**/web.php,**/app.tsx" -i "**/*.d.ts" -x "node_modules/**" -n "combin
|
|
|
84
87
|
|
|
85
88
|
- **Combined Output**
|
|
86
89
|
All code from multiple entries is merged into a single output file.
|
|
87
|
-
Thereās currently **no limit** on output size, but itās advised to avoid combining
|
|
90
|
+
Thereās currently **no limit** on output size, but itās advised to avoid combining _too many large entries_ in a single run.
|
|
88
91
|
Future versions will include **smart naming** and **automatic splitting** for oversized outputs.
|
|
89
92
|
|
|
90
93
|
- **Performance Optimizations**
|
|
91
|
-
Planned improvements to resolver speed and dependency traversal for faster processing on large projects.
|
|
94
|
+
Planned improvements to resolver speed and dependency traversal for faster processing on large projects.
|
|
92
95
|
|
|
93
96
|
---
|
|
94
97
|
|
|
95
98
|
## š§© Features
|
|
96
99
|
|
|
97
|
-
| Status | Feature
|
|
98
|
-
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
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. |
|
|
109
112
|
|
|
110
113
|
---
|
|
111
114
|
|
|
@@ -148,24 +151,27 @@ then appends any files matched by the `--include` flag.
|
|
|
148
151
|
### š§ Suggested Pattern
|
|
149
152
|
|
|
150
153
|
1. **Pick a meaningful entry file**
|
|
151
|
-
Example:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
+
```
|
|
166
172
|
|
|
167
173
|
4. **Use them together**
|
|
168
|
-
Store each output in `/prodex/`
|
|
174
|
+
Store each output in `/prodex/`
|
|
169
175
|
These maps can be shared with teammates or loaded into AI tools for structured, code-aware assistance.
|
|
170
176
|
|
|
171
177
|
> ā” Each run recursively resolves every import, applies includes, and outputs one complete dependency map for that section.
|
|
@@ -197,7 +203,7 @@ prodex -c
|
|
|
197
203
|
```
|
|
198
204
|
|
|
199
205
|
The `-c` (or `--ci`) flag skips interactive mode and uses the config values automatically.
|
|
200
|
-
Specifying `-f` ( or `--files`) from the CLI also disables the picker by default.
|
|
206
|
+
Specifying `-f` ( or `--files`) from the CLI also disables the picker by default.
|
|
201
207
|
|
|
202
208
|
You can permanently disable the picker in the config by setting:
|
|
203
209
|
|
|
@@ -222,7 +228,7 @@ You can permanently disable the picker in the config by setting:
|
|
|
222
228
|
|
|
223
229
|
Prodex is still a **work in progress**.
|
|
224
230
|
Some parts of the experience may be rough, especially around interactive mode and advanced resolvers.
|
|
225
|
-
Updates are released **multiple times per week ā sometimes daily** ā to keep improving stability and support.
|
|
231
|
+
Updates are released **multiple times per week ā sometimes daily** ā to keep improving stability and support.
|
|
226
232
|
|
|
227
233
|
Please stay up to date for the best experience.
|
|
228
|
-
Thank you for testing Prodex early. ā¤ļø
|
|
234
|
+
Thank you for testing Prodex early. ā¤ļø
|
package/dist/cli/cli-input.js
CHANGED
|
@@ -5,45 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseCliInput = parseCliInput;
|
|
7
7
|
const sade_1 = __importDefault(require("sade"));
|
|
8
|
-
const flags_1 = require("./flags");
|
|
9
|
-
const logger_1 = require("../lib/logger");
|
|
10
8
|
const path_1 = __importDefault(require("path"));
|
|
11
9
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const flags_1 = require("../constants/flags");
|
|
12
12
|
/**
|
|
13
|
-
* Unified CLI parser powered by Sade.
|
|
14
|
-
* Returns { root,
|
|
13
|
+
* Unified CLI parser powered by Sade and FLAG_MAP.
|
|
14
|
+
* Returns { root, flags, warnings, errors }.
|
|
15
15
|
*/
|
|
16
16
|
function parseCliInput(argv = process.argv) {
|
|
17
17
|
if (argv.includes("-v") || argv.includes("--version")) {
|
|
18
|
-
|
|
18
|
+
console.log(`prodex v${package_json_1.default.version}`);
|
|
19
19
|
process.exit(0);
|
|
20
20
|
}
|
|
21
21
|
const program = (0, sade_1.default)("prodex [root]");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const short = meta.short ? `-${meta.short}, ` : "";
|
|
25
|
-
const long = `--${key}`;
|
|
26
|
-
const desc = meta.description;
|
|
27
|
-
let defaultVal;
|
|
28
|
-
switch (meta.type) {
|
|
29
|
-
case "boolean":
|
|
30
|
-
defaultVal = false;
|
|
31
|
-
break;
|
|
32
|
-
default:
|
|
33
|
-
defaultVal = undefined; // defer strings/numbers/lists
|
|
34
|
-
}
|
|
35
|
-
if (defaultVal !== undefined) {
|
|
36
|
-
program.option(`${short}${long}`, desc, defaultVal);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
program.option(`${short}${long}`, desc);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let parsed = { root: undefined, flags: {} };
|
|
43
|
-
// Define default command (root optional)
|
|
22
|
+
registerFlags(program);
|
|
23
|
+
let parsed = { rootArg: "", root: undefined, flags: {} };
|
|
44
24
|
program.action((root, opts) => {
|
|
45
25
|
const cwd = process.cwd();
|
|
46
26
|
parsed = {
|
|
27
|
+
rootArg: root,
|
|
47
28
|
root: root ? path_1.default.resolve(cwd, root) : cwd,
|
|
48
29
|
flags: { ...opts },
|
|
49
30
|
};
|
|
@@ -51,36 +32,70 @@ function parseCliInput(argv = process.argv) {
|
|
|
51
32
|
program.parse(argv);
|
|
52
33
|
const warnings = [];
|
|
53
34
|
const errors = [];
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
parsed.flags = normalizeFlags(parsed.flags, warnings, errors);
|
|
36
|
+
validateArgs(parsed, warnings, errors);
|
|
37
|
+
return { ...parsed, warnings, errors };
|
|
38
|
+
}
|
|
39
|
+
function registerFlags(program) {
|
|
40
|
+
for (const [key, meta] of Object.entries(flags_1.FLAG_MAP)) {
|
|
41
|
+
const short = meta.short ? `-${meta.short}, ` : "";
|
|
42
|
+
const long = `--${key}`;
|
|
43
|
+
const desc = meta.description;
|
|
44
|
+
const defaultVal = meta.type === "boolean" ? false : undefined;
|
|
45
|
+
program.option(`${short}${long}`, desc, defaultVal);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Convert flag values to correct types based on FLAG_MAP metadata. */
|
|
49
|
+
function normalizeFlags(flags, warnings, errors) {
|
|
50
|
+
for (const [key, meta] of Object.entries(flags_1.FLAG_MAP)) {
|
|
51
|
+
const raw = flags[key];
|
|
57
52
|
if (raw === undefined)
|
|
58
53
|
continue;
|
|
59
|
-
const obj = {};
|
|
60
54
|
switch (meta.type) {
|
|
61
55
|
case "number": {
|
|
62
56
|
const num = Number(raw);
|
|
63
|
-
if (Number.isNaN(num))
|
|
57
|
+
if (Number.isNaN(num))
|
|
64
58
|
errors.push(`Flag --${key} expected a number but got "${raw}"`);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
parsed.flags[key] = num;
|
|
68
|
-
}
|
|
59
|
+
else
|
|
60
|
+
flags[key] = num;
|
|
69
61
|
break;
|
|
70
62
|
}
|
|
71
63
|
case "list": {
|
|
72
|
-
|
|
64
|
+
flags[key] = String(raw)
|
|
73
65
|
.split(",")
|
|
74
66
|
.map((v) => v.trim())
|
|
75
67
|
.filter(Boolean);
|
|
76
|
-
parsed.flags[key] = arr;
|
|
77
68
|
break;
|
|
78
69
|
}
|
|
70
|
+
default: {
|
|
71
|
+
if (meta.type === "string")
|
|
72
|
+
flags[key] = String(raw);
|
|
73
|
+
}
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
76
|
+
return flags;
|
|
77
|
+
}
|
|
78
|
+
/** Validate path argument and report unrecognized flags. */
|
|
79
|
+
function validateArgs(parsed, warnings, errors) {
|
|
80
|
+
const { rootArg } = parsed;
|
|
81
|
+
if (rootArg) {
|
|
82
|
+
if (!fs_1.default.existsSync(parsed.root)) {
|
|
83
|
+
errors.push(`Invalid path argument: "${rootArg}" does not exist.`);
|
|
84
|
+
}
|
|
85
|
+
else if (!fs_1.default.statSync(parsed.root).isDirectory()) {
|
|
86
|
+
errors.push(`Path argument "${rootArg}" is not a directory.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const unknown = parsed.flags?._ || [];
|
|
90
|
+
if (unknown.length) {
|
|
91
|
+
warnings.push(`Unrecognized arguments detected [${unknown.join(", ")}]- They were ignored.`);
|
|
92
|
+
}
|
|
93
|
+
if (warnings.length)
|
|
94
|
+
console.warn("Warnings:", warnings);
|
|
95
|
+
if (errors.length) {
|
|
96
|
+
for (const err of errors)
|
|
97
|
+
console.error(err);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
86
100
|
}
|
|
101
|
+
//# sourceMappingURL=cli-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-input.js","sourceRoot":"","sources":["../../src/cli/cli-input.ts"],"names":[],"mappings":";;;;;AAWA,sCA6BC;AAxCD,gDAAwB;AACxB,gDAAwB;AACxB,sEAAqC;AACrC,4CAAoB;AACpB,8CAA8C;AAG9C;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAAiB,OAAO,CAAC,IAAI;IAC1D,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,WAAW,sBAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,cAAI,EAAC,eAAe,CAAC,CAAC;IACtC,aAAa,CAAC,OAAO,CAAC,CAAC;IAEvB,IAAI,MAAM,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAEtE,O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AE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE3B,IAAI,OAAO,EAAE,CAAC;QACb,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,2BAA2B,OAAO,mBAAmB,CAAC,CAAC;QACpE,CAAC;aAAM,IAAI,CAAC,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,kBAAkB,OAAO,uBAAuB,CAAC,CAAC;QAC/D,CAAC;IACF,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;IACtC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,oCAAoC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC9F,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,KAAK,MAAM,GAAG,IAAI,MAAM;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC","sourcesContent":["import sade from \"sade\";\nimport path from \"path\";\nimport pkg from \"../../package.json\";\nimport fs from \"fs\";\nimport { FLAG_MAP } from \"../constants/flags\";\nimport type { ParsedInput } from \"../types\";\n\n/**\n * Unified CLI parser powered by Sade and FLAG_MAP.\n * Returns { root, flags, warnings, errors }.\n */\nexport function parseCliInput(argv: string[] = process.argv) {\n\tif (argv.includes(\"-v\") || argv.includes(\"--version\")) {\n\t\tconsole.log(`prodex v${pkg.version}`);\n\t\tprocess.exit(0);\n\t}\n\n\tconst program = sade(\"prodex [root]\");\n\tregisterFlags(program);\n\n\tlet parsed: ParsedInput = { rootArg: \"\", root: undefined, flags: {} };\n\n\tprogram.action((root: string | undefined, opts: Record<string, any>) => {\n\t\tconst cwd = process.cwd();\n\t\tparsed = {\n\t\t\trootArg: root,\n\t\t\troot: root ? path.resolve(cwd, root) : cwd,\n\t\t\tflags: { ...opts },\n\t\t};\n\t});\n\n\tprogram.parse(argv);\n\n\tconst warnings: string[] = [];\n\tconst errors: string[] = [];\n\n\tparsed.flags = normalizeFlags(parsed.flags, warnings, errors);\n\tvalidateArgs(parsed, warnings, errors);\n\n\treturn { ...parsed, warnings, errors };\n}\n\nfunction registerFlags(program: ReturnType<typeof sade>) {\n\tfor (const [key, meta] of Object.entries(FLAG_MAP)) {\n\t\tconst short = meta.short ? `-${meta.short}, ` : \"\";\n\t\tconst long = `--${key}`;\n\t\tconst desc = meta.description;\n\t\tconst defaultVal = meta.type === \"boolean\" ? false : undefined;\n\t\tprogram.option(`${short}${long}`, desc, defaultVal);\n\t}\n}\n\n/** Convert flag values to correct types based on FLAG_MAP metadata. */\nfunction normalizeFlags(flags: Record<string, any>, warnings: string[], errors: string[]) {\n\tfor (const [key, meta] of Object.entries(FLAG_MAP)) {\n\t\tconst raw = flags[key];\n\t\tif (raw === undefined) continue;\n\n\t\tswitch (meta.type) {\n\t\t\tcase \"number\": {\n\t\t\t\tconst num = Number(raw);\n\t\t\t\tif (Number.isNaN(num)) errors.push(`Flag --${key} expected a number but got \"${raw}\"`);\n\t\t\t\telse flags[key] = num;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"list\": {\n\t\t\t\tflags[key] = String(raw)\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((v) => v.trim())\n\t\t\t\t\t.filter(Boolean);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tif (meta.type === \"string\") flags[key] = String(raw);\n\t\t\t}\n\t\t}\n\t}\n\treturn flags;\n}\n\n/** Validate path argument and report unrecognized flags. */\nfunction validateArgs(parsed: ParsedInput, warnings: string[], errors: string[]) {\n\tconst { rootArg } = parsed;\n\n\tif (rootArg) {\n\t\tif (!fs.existsSync(parsed.root)) {\n\t\t\terrors.push(`Invalid path argument: \"${rootArg}\" does not exist.`);\n\t\t} else if (!fs.statSync(parsed.root).isDirectory()) {\n\t\t\terrors.push(`Path argument \"${rootArg}\" is not a directory.`);\n\t\t}\n\t}\n\n\tconst unknown = parsed.flags?._ || [];\n\tif (unknown.length) {\n\t\twarnings.push(`Unrecognized arguments detected [${unknown.join(\", \")}]- They were ignored.`);\n\t}\n\n\tif (warnings.length) console.warn(\"Warnings:\", warnings);\n\tif (errors.length) {\n\t\tfor (const err of errors) console.error(err);\n\t\tprocess.exit(1);\n\t}\n}\n"]}
|
package/dist/cli/flags.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/cli/flags.ts"],"names":[],"mappings":";;;AAMA,IAAY,OAUX;AAVD,WAAY,OAAO;IAClB,sBAAW,CAAA;IACX,oBAAS,CAAA;IACT,0BAAe,CAAA;IACf,wBAAa,CAAA;IACb,0BAAe,CAAA;IACf,0BAAe,CAAA;IACf,0BAAe,CAAA;IACf,wBAAa,CAAA;IACb,0BAAe,CAAA;AAChB,CAAC,EAVW,OAAO,uBAAP,OAAO,QAUlB;AAOY,QAAA,YAAY,GAA0B;IAClD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,8BAA8B,EAAE;IAC1F,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,gCAAgC,EAAE;IAC7F,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAA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port type FlagType = \"boolean\" | \"string\" | \"number\" | \"list\";\n\nexport enum FlagKey {\n\tTxt = \"txt\",\n\tCi = \"ci\",\n\tDebug = \"debug\",\n\tName = \"name\",\n\tLimit = \"limit\",\n\tInc = \"include\",\n\tExc = \"exclude\",\n\tHelp = \"help\",\n\tFiles = \"files\",\n}\n\ntype Spec = {\n\tshort?: string;\n\ttype: FlagType;\n\tdescription: string;\n};\nexport const PRODEX_FLAGS: Record<FlagKey, Spec> = {\n\t[FlagKey.Files]: { short: \"f\", type: \"list\", description: \"Comma-separated entry files.\" },\n\t[FlagKey.Txt]: { short: \"t\", type: \"boolean\", description: \"Output as .txt instead of .md.\" },\n\t[FlagKey.Ci]: { short: \"c\", type: \"boolean\", description: \"Headless/no-UI mode.\" },\n\t[FlagKey.Debug]: { short: \"d\", type: \"boolean\", description: \"Enable debug logs.\" },\n\t[FlagKey.Name]: { short: \"n\", type: \"string\", description: \"Custom output filename.\" },\n\t[FlagKey.Limit]: { short: \"l\", type: \"number\", description: \"Override traversal limit.\" },\n\t[FlagKey.Inc]: { type: \"list\", short: \"i\", description: \"Comma-separated include globs.\" },\n\t[FlagKey.Exc]: { type: \"list\", short: \"x\", description: \"Comma-separated exclude globs.\" },\n\t[FlagKey.Help]: { short: \"h\", type: \"boolean\", description: \"Show CLI help and exit.\" },\n};\n\n/** Reverse lookup for short aliases. */\nexport const FLAG_SHORT_MAP: Record<string, FlagKey> = Object.entries(PRODEX_FLAGS).reduce((acc, [key, meta]) => {\n\tif (meta.short) acc[meta.short] = key as FlagKey;\n\treturn acc;\n}, {} as Record<string, FlagKey>);\n\n\nexport const CLI_USAGE = `\nUsage: prodex [-fcdv]\n [--files=<globs>|-f=<globs>]\n [--include=<globs>|-i=<globs>]\n [--exclude=<globs>|-x=<globs>]\n [--txt|-t] [--ci|-c] [--debug|-d] [--version|-v]\n [--name=<string>|-n=<string>]\n [--limit=<int>|-l=<int>]\n [--help|-h]\n`;\n"]}
|
package/dist/cli/init.js
CHANGED
|
@@ -7,15 +7,15 @@ exports.initProdex = initProdex;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const default_config_1 = require("../constants/default-config");
|
|
10
|
-
const logger_1 = require("../lib/logger");
|
|
11
10
|
async function initProdex() {
|
|
12
|
-
|
|
11
|
+
console.log("šŖ Prodex Init ā Configuration Wizard (v3");
|
|
13
12
|
const dest = path_1.default.join(process.cwd(), "prodex.json");
|
|
14
13
|
if (fs_1.default.existsSync(dest)) {
|
|
15
|
-
|
|
14
|
+
console.error("prodex.json already exists. Delete or modify it manually.\n");
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
17
|
fs_1.default.writeFileSync(dest, JSON.stringify(default_config_1.DEFAULT_PRODEX_CONFIG, null, 2) + "\n", "utf8");
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
console.log(`ā
Created ${dest}`);
|
|
19
|
+
console.log("š” Globs supported everywhere (include, exclude, priority).");
|
|
21
20
|
}
|
|
21
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":";;;;;AAIA,gCAaC;AAjBD,4CAAoB;AACpB,gDAAwB;AACxB,gEAAoE;AAE7D,KAAK,UAAU,UAAU;IAC/B,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;IAEzD,MAAM,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAErD,IAAI,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;QAC7E,OAAO;IACR,CAAC;IAED,YAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,sCAAqB,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IACtF,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { DEFAULT_PRODEX_CONFIG } from \"../constants/default-config\";\n\nexport async function initProdex() {\n\tconsole.log(\"šŖ Prodex Init ā Configuration Wizard (v3\");\n\n\tconst dest = path.join(process.cwd(), \"prodex.json\");\n\n\tif (fs.existsSync(dest)) {\n\t\tconsole.error(\"prodex.json already exists. Delete or modify it manually.\\n\");\n\t\treturn;\n\t}\n\n\tfs.writeFileSync(dest, JSON.stringify(DEFAULT_PRODEX_CONFIG, null, 2) + \"\\n\", \"utf8\");\n\tconsole.log(`ā
Created ${dest}`);\n\tconsole.log(\"š” Globs supported everywhere (include, exclude, priority).\");\n}\n"]}
|
package/dist/cli/picker.js
CHANGED
|
@@ -7,76 +7,78 @@ exports.pickEntries = pickEntries;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
-
const config_1 = require("../constants/config");
|
|
11
10
|
const helpers_1 = require("../core/helpers");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const io_1 = require("../shared/io");
|
|
12
|
+
const helpers_2 = require("../core/helpers");
|
|
13
|
+
const collections_1 = require("../shared/collections");
|
|
14
14
|
const logger_1 = require("../lib/logger");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const prompt_1 = require("../lib/prompt");
|
|
16
|
+
const questions_1 = require("../lib/questions");
|
|
17
|
+
/**
|
|
18
|
+
* Interactive entry picker for Prodex.
|
|
19
|
+
* Handles depth-based scanning, caching, and priority ordering.
|
|
20
|
+
*/
|
|
21
|
+
async function pickEntries(cfg) {
|
|
22
|
+
const { root, entry: { files, ui: { roots = [], priority = [], scanDepth }, }, } = cfg;
|
|
23
|
+
let depth = scanDepth;
|
|
24
|
+
const entryPatterns = files || [];
|
|
25
|
+
const priorities = [...entryPatterns, ...priority];
|
|
26
|
+
// 1ļøā£ Resolve pre-defined entry patterns
|
|
27
|
+
const resolvedEntries = (await (0, helpers_2.globScan)(entryPatterns, { cwd: root })).files;
|
|
21
28
|
let selected = [...resolvedEntries];
|
|
22
|
-
// cache: depth
|
|
29
|
+
// cache: depth ā files[]
|
|
23
30
|
const scanCache = new Map();
|
|
24
31
|
for (;;) {
|
|
25
|
-
const files = await getFilesAtDepth(
|
|
26
|
-
baseDirs,
|
|
27
|
-
depth,
|
|
28
|
-
cfg,
|
|
29
|
-
scanCache,
|
|
30
|
-
verbose,
|
|
31
|
-
});
|
|
32
|
+
const files = await getFilesAtDepth(depth, cfg, scanCache);
|
|
32
33
|
// Merge resolved entries with current scan results
|
|
33
|
-
const combined = (0,
|
|
34
|
-
// Priority-aware ordering: entries first, then other priorities
|
|
34
|
+
const combined = (0, collections_1.unique)([...resolvedEntries, ...files]);
|
|
35
35
|
const sorted = (0, helpers_1.orderByPriority)(combined, priorities);
|
|
36
36
|
// Build UI selection list
|
|
37
|
-
const choices = sorted.map(f => ({
|
|
38
|
-
name:
|
|
37
|
+
const choices = sorted.map((f) => ({
|
|
38
|
+
name: (0, io_1.rel)(f, root),
|
|
39
39
|
value: f,
|
|
40
40
|
checked: selected.includes(f),
|
|
41
41
|
}));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
pageSize: 20,
|
|
52
|
-
}
|
|
53
|
-
]);
|
|
42
|
+
if (depth < scanDepth + 5) {
|
|
43
|
+
choices.push(new inquirer_1.default.Separator());
|
|
44
|
+
choices.push({ name: "š½ Load more (go deeper)", value: "__loadmore" });
|
|
45
|
+
}
|
|
46
|
+
// š§ Use unified prompt wrapper
|
|
47
|
+
const answers = await (0, prompt_1.prompt)((0, questions_1.PICK_ENTRIES_QUESTION)(choices, depth), { picks: [] });
|
|
48
|
+
if (!answers)
|
|
49
|
+
return (0, collections_1.unique)(selected);
|
|
50
|
+
const { picks } = answers;
|
|
54
51
|
if (picks.includes("__loadmore")) {
|
|
55
52
|
depth++;
|
|
56
|
-
selected = picks.filter(p => p !== "__loadmore");
|
|
53
|
+
selected = picks.filter((p) => p !== "__loadmore");
|
|
57
54
|
continue;
|
|
58
55
|
}
|
|
59
|
-
selected = picks.filter(p => p !== "__loadmore");
|
|
56
|
+
selected = picks.filter((p) => p !== "__loadmore");
|
|
60
57
|
break;
|
|
61
58
|
}
|
|
62
|
-
return (0,
|
|
59
|
+
return (0, collections_1.unique)(selected);
|
|
63
60
|
}
|
|
64
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Depth-based directory scanner with caching.
|
|
63
|
+
*/
|
|
64
|
+
async function getFilesAtDepth(depth, cfg, scanCache) {
|
|
65
|
+
const baseDirs = cfg.entry.ui.roots || [];
|
|
65
66
|
if (scanCache.has(depth)) {
|
|
66
|
-
logger_1.logger.debug(`[
|
|
67
|
+
logger_1.logger.debug(`[picker] cache hit ā depth=${depth}`);
|
|
67
68
|
return scanCache.get(depth);
|
|
68
69
|
}
|
|
69
|
-
logger_1.logger.debug(`[
|
|
70
|
+
logger_1.logger.debug(`[picker] scanning ā depth=${depth}`);
|
|
70
71
|
const files = [];
|
|
71
72
|
const effectiveCfg = { ...cfg, scanDepth: depth };
|
|
72
73
|
for (const base of baseDirs) {
|
|
73
|
-
const full = path_1.default.join(
|
|
74
|
+
const full = path_1.default.join(cfg.root, base);
|
|
74
75
|
if (!fs_1.default.existsSync(full))
|
|
75
76
|
continue;
|
|
76
77
|
for (const f of (0, helpers_1.walk)(full, effectiveCfg, 0))
|
|
77
78
|
files.push(f.norm());
|
|
78
79
|
}
|
|
79
80
|
scanCache.set(depth, files);
|
|
80
|
-
logger_1.logger.debug(`[
|
|
81
|
+
logger_1.logger.debug(`[picker] depth=${depth} found=${files.length}`);
|
|
81
82
|
return files;
|
|
82
83
|
}
|
|
84
|
+
//# sourceMappingURL=picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker.js","sourceRoot":"","sources":["../../src/cli/picker.ts"],"names":[],"mappings":";;;;;AAgBA,kCAwDC;AAxED,4CAAoB;AACpB,gDAAwB;AACxB,wDAAgC;AAChC,6CAAwD;AACxD,qCAAmC;AACnC,6CAA2C;AAC3C,uDAA+C;AAC/C,0CAAuC;AACvC,0CAAuC;AAEvC,gDAAyD;AAEzD;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,GAAiB;IAClD,MAAM,EACL,IAAI,EACJ,KAAK,EAAE,EACN,KAAK,EACL,EAAE,EAAE,EAAE,KAAK,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,SAAS,EAAE,GAC5C,GACD,GAAG,GAAG,CAAC;IAER,IAAI,KAAK,GAAG,SAAS,CAAC;IACtB,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,CAAC,GAAG,aAAa,EAAE,GAAG,QAAQ,CAAC,CAAC;IAEnD,yCAAyC;IACzC,MAAM,eAAe,GAAG,CAAC,MAAM,IAAA,kBAAQ,EAAC,aAAa,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7E,IAAI,QAAQ,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC;IAEpC,yBAAyB;IACzB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE9C,SAAS,CAAC;QACT,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAE3D,mDAAmD;QACnD,MAAM,QAAQ,GAAG,IA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";\nimport { walk, orderByPriority } from \"../core/helpers\";\nimport { rel } from \"../shared/io\";\nimport { globScan } from \"../core/helpers\";\nimport { unique } from \"../shared/collections\";\nimport { logger } from \"../lib/logger\";\nimport { prompt } from \"../lib/prompt\";\nimport type { QuestionSet, ProdexConfig } from \"../types\";\nimport { PICK_ENTRIES_QUESTION } from \"../lib/questions\";\n\n/**\n * Interactive entry picker for Prodex.\n * Handles depth-based scanning, caching, and priority ordering.\n */\nexport async function pickEntries(cfg: ProdexConfig) {\n\tconst {\n\t\troot,\n\t\tentry: {\n\t\t\tfiles,\n\t\t\tui: { roots = [], priority = [], scanDepth },\n\t\t},\n\t} = cfg;\n\n\tlet depth = scanDepth;\n\tconst entryPatterns = files || [];\n\tconst priorities = [...entryPatterns, ...priority];\n\n\t// 1ļøā£ Resolve pre-defined entry patterns\n\tconst resolvedEntries = (await globScan(entryPatterns, { cwd: root })).files;\n\tlet selected = [...resolvedEntries];\n\n\t// cache: depth ā files[]\n\tconst scanCache = new Map<number, string[]>();\n\n\tfor (;;) {\n\t\tconst files = await getFilesAtDepth(depth, cfg, scanCache);\n\n\t\t// Merge resolved entries with current scan results\n\t\tconst combined = unique([...resolvedEntries, ...files]);\n\t\tconst sorted = orderByPriority(combined, priorities);\n\n\t\t// Build UI selection list\n\t\tconst choices = sorted.map((f) => ({\n\t\t\tname: rel(f, root),\n\t\t\tvalue: f,\n\t\t\tchecked: selected.includes(f),\n\t\t}));\n\n\t\tif (depth < scanDepth + 5) {\n\t\t\tchoices.push(new inquirer.Separator());\n\t\t\tchoices.push({ name: \"š½ Load more (go deeper)\", value: \"__loadmore\" });\n\t\t}\n\n\t\t// š§ Use unified prompt wrapper\n\t\tconst answers = await prompt(PICK_ENTRIES_QUESTION(choices, depth), { picks: [] });\n\t\tif (!answers) return unique(selected);\n\n\t\tconst { picks } = answers;\n\n\t\tif (picks.includes(\"__loadmore\")) {\n\t\t\tdepth++;\n\t\t\tselected = picks.filter((p) => p !== \"__loadmore\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tselected = picks.filter((p) => p !== \"__loadmore\");\n\t\tbreak;\n\t}\n\n\treturn unique(selected);\n}\n\n/**\n * Depth-based directory scanner with caching.\n */\nasync function getFilesAtDepth(depth: number, cfg: ProdexConfig, scanCache: Map<number, string[]>) {\n\tconst baseDirs = cfg.entry.ui.roots || [];\n\tif (scanCache.has(depth)) {\n\t\tlogger.debug(`[picker] cache hit ā depth=${depth}`);\n\t\treturn scanCache.get(depth)!;\n\t}\n\n\tlogger.debug(`[picker] scanning ā depth=${depth}`);\n\n\tconst files: string[] = [];\n\tconst effectiveCfg = { ...cfg, scanDepth: depth };\n\n\tfor (const base of baseDirs) {\n\t\tconst full = path.join(cfg.root, base);\n\t\tif (!fs.existsSync(full)) continue;\n\t\tfor (const f of walk(full, effectiveCfg, 0)) files.push(f.norm());\n\t}\n\n\tscanCache.set(depth, files);\n\tlogger.debug(`[picker] depth=${depth} found=${files.length}`);\n\treturn files;\n}\n"]}
|
package/dist/cli/summary.js
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.endSummary = endSummary;
|
|
4
|
+
exports.introSummary = introSummary;
|
|
5
|
+
exports.entrySummary = entrySummary;
|
|
5
6
|
const logger_1 = require("../lib/logger");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
⢠Unique imports
|
|
7
|
+
const io_1 = require("../shared/io");
|
|
8
|
+
const store_1 = require("../store");
|
|
9
|
+
let CONFIG;
|
|
10
|
+
let FLAGS;
|
|
11
|
+
function endSummary(out, result) {
|
|
12
|
+
logger_1.logger.debug(`š§© Summary:
|
|
13
|
+
⢠Unique imports expected: ${result?.stats?.expected.size}
|
|
14
|
+
⢠Unique imports resolved: ${result?.stats?.resolved.size}
|
|
13
15
|
`);
|
|
16
|
+
logger_1.logger.log(`ā
${out.norm()}`);
|
|
17
|
+
}
|
|
18
|
+
function introSummary() {
|
|
19
|
+
CONFIG = (0, store_1.getConfig)();
|
|
20
|
+
FLAGS = (0, store_1.getFlags)();
|
|
21
|
+
logger_1.logger.log(`------- PRODEx RUN @ ${new Date().toLocaleTimeString()} ā Codebase decoded -------\n`);
|
|
22
|
+
// Log parse results for testing
|
|
23
|
+
logger_1.logger.debug("š§© Parsed CLI input:", _2j({ FLAGS }));
|
|
24
|
+
logger_1.logger.debug("Final merged config:", _2j(CONFIG));
|
|
25
|
+
}
|
|
26
|
+
function entrySummary(entries) {
|
|
27
|
+
let result = "š You selected:";
|
|
28
|
+
for (const e of entries)
|
|
29
|
+
result += "\n -" + (0, io_1.rel)(e);
|
|
30
|
+
if (entries?.length)
|
|
31
|
+
logger_1.logger.log(result);
|
|
14
32
|
}
|
|
33
|
+
//# sourceMappingURL=summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/cli/summary.ts"],"names":[],"mappings":";;AAMA,gCAMC;AAED,oCAQC;AAED,oCAIC;AA5BD,0CAAuC;AACvC,qCAAmC;AACnC,oCAA+C;AAE/C,IAAI,MAAM,CAAC;AACX,IAAI,KAAK,CAAC;AACV,SAAgB,UAAU,CAAC,GAAG,EAAE,MAAM;IACrC,eAAM,CAAC,KAAK,CAAC;8BACgB,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI;8BAC5B,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI;CACzD,CAAC,CAAC;IACF,eAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,YAAY;IAC3B,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IACrB,KAAK,GAAG,IAAA,gBAAQ,GAAE,CAAC;IAEnB,eAAM,CAAC,GAAG,CAAC,wBAAwB,IAAI,IAAI,EAAE,CAAC,kBAAkB,EAAE,+BAA+B,CAAC,CAAC;IACnG,gCAAgC;IAChC,eAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACrD,eAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,YAAY,CAAC,OAAiB;IAC7C,IAAI,MAAM,GAAG,kBAAkB,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,MAAM,IAAI,QAAQ,GAAG,IAAA,QAAG,EAAC,CAAC,CAAC,CAAC;IACrD,IAAI,OAAO,EAAE,MAAM;QAAE,eAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { logger } from \"../lib/logger\";\nimport { rel } from \"../shared/io\";\nimport { getConfig, getFlags } from \"../store\";\n\nlet CONFIG;\nlet FLAGS;\nexport function endSummary(out, result) {\n\tlogger.debug(`š§© Summary:\n ⢠Unique imports expected: ${result?.stats?.expected.size}\n ⢠Unique imports resolved: ${result?.stats?.resolved.size}\n`);\n\tlogger.log(`ā
${out.norm()}`);\n}\n\nexport function introSummary() {\n\tCONFIG = getConfig();\n\tFLAGS = getFlags();\n\n\tlogger.log(`------- PRODEx RUN @ ${new Date().toLocaleTimeString()} ā Codebase decoded -------\\n`);\n\t// Log parse results for testing\n\tlogger.debug(\"š§© Parsed CLI input:\", _2j({ FLAGS }));\n\tlogger.debug(\"Final merged config:\", _2j(CONFIG));\n}\n\nexport function entrySummary(entries: string[]) {\n\tlet result = \"š You selected:\";\n\tfor (const e of entries) result += \"\\n -\" + rel(e);\n\tif (entries?.length) logger.log(result);\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CACHE_KEYS = void 0;
|
|
4
|
+
exports.CACHE_KEYS = {
|
|
5
|
+
ALIASES: "aliases",
|
|
6
|
+
JS_IMPORTS: "js:imports",
|
|
7
|
+
JS_STATS: "js:stats",
|
|
8
|
+
PHP_PSR4: "php:psr4",
|
|
9
|
+
PHP_BINDINGS: "php:bindings",
|
|
10
|
+
PHP_FILECACHE: "php:fileCache",
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=cache-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-keys.js","sourceRoot":"","sources":["../../src/constants/cache-keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACzB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;CACrB,CAAC","sourcesContent":["export const CACHE_KEYS = {\r\n\tALIASES: \"aliases\",\r\n\tJS_IMPORTS: \"js:imports\",\r\n\tJS_STATS: \"js:stats\",\r\n\tPHP_PSR4: \"php:psr4\",\r\n\tPHP_BINDINGS: \"php:bindings\",\r\n\tPHP_FILECACHE: \"php:fileCache\",\r\n} as const;\r\n\r\nexport type CacheNamespace = (typeof CACHE_KEYS)[keyof typeof CACHE_KEYS];\r\n"]}
|