prodex 1.2.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.
- package/README.md +234 -228
- package/dist/cli/cli-input.js +55 -35
- package/dist/cli/picker.js +37 -37
- package/dist/cli/summary.js +19 -7
- package/dist/constants/config-loader.js +10 -5
- package/dist/constants/config.js +12 -3
- package/dist/constants/default-config.js +3 -17
- package/dist/constants/render-constants.js +11 -6
- package/dist/core/combine.js +22 -58
- package/dist/core/dependency.js +7 -3
- package/dist/core/file-utils.js +10 -13
- package/dist/core/output.js +48 -0
- package/dist/index.js +8 -11
- package/dist/lib/logger.js +1 -1
- package/dist/lib/polyfills.js +15 -0
- package/dist/lib/prompt.js +34 -0
- package/dist/lib/questions.js +28 -0
- package/dist/lib/utils.js +37 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,228 +1,234 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
| `--
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
- **
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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/dist/cli/cli-input.js
CHANGED
|
@@ -9,6 +9,7 @@ const flags_1 = require("./flags");
|
|
|
9
9
|
const logger_1 = require("../lib/logger");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
13
|
/**
|
|
13
14
|
* Unified CLI parser powered by Sade.
|
|
14
15
|
* Returns { root, entries (from --files), flags, warnings, errors }.
|
|
@@ -19,31 +20,13 @@ function parseCliInput(argv = process.argv) {
|
|
|
19
20
|
process.exit(0);
|
|
20
21
|
}
|
|
21
22
|
const program = (0, sade_1.default)("prodex [root]");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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)
|
|
23
|
+
registerFlags(program);
|
|
24
|
+
let parsed = { rootArg: "", root: undefined, flags: {} };
|
|
25
|
+
// Define action
|
|
44
26
|
program.action((root, opts) => {
|
|
45
27
|
const cwd = process.cwd();
|
|
46
28
|
parsed = {
|
|
29
|
+
rootArg: root,
|
|
47
30
|
root: root ? path_1.default.resolve(cwd, root) : cwd,
|
|
48
31
|
flags: { ...opts },
|
|
49
32
|
};
|
|
@@ -52,20 +35,40 @@ function parseCliInput(argv = process.argv) {
|
|
|
52
35
|
const warnings = [];
|
|
53
36
|
const errors = [];
|
|
54
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) {
|
|
55
47
|
for (const [key, meta] of Object.entries(flags_1.PRODEX_FLAGS)) {
|
|
56
|
-
const
|
|
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];
|
|
57
63
|
if (raw === undefined)
|
|
58
64
|
continue;
|
|
59
|
-
const obj = {};
|
|
60
65
|
switch (meta.type) {
|
|
61
66
|
case "number": {
|
|
62
67
|
const num = Number(raw);
|
|
63
|
-
if (Number.isNaN(num))
|
|
68
|
+
if (Number.isNaN(num))
|
|
64
69
|
errors.push(`Flag --${key} expected a number but got "${raw}"`);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
parsed.flags[key] = num;
|
|
68
|
-
}
|
|
70
|
+
else
|
|
71
|
+
flags[key] = num;
|
|
69
72
|
break;
|
|
70
73
|
}
|
|
71
74
|
case "list": {
|
|
@@ -73,14 +76,31 @@ function parseCliInput(argv = process.argv) {
|
|
|
73
76
|
.split(",")
|
|
74
77
|
.map((v) => v.trim())
|
|
75
78
|
.filter(Boolean);
|
|
76
|
-
|
|
79
|
+
flags[key] = arr;
|
|
77
80
|
break;
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
+
}
|
|
86
106
|
}
|