@deplens/cli 0.1.4 → 0.1.6
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 +32 -1
- package/bin/deplens.js +0 -0
- package/package.json +2 -2
- package/src/cli.mjs +323 -71
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ npx deplens --help
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
deplens <package-or-import-path> [filter]
|
|
17
|
+
deplens inspect <package-or-import-path> [filter]
|
|
18
|
+
deplens diff <package> [options]
|
|
17
19
|
```
|
|
18
20
|
|
|
19
21
|
## Examples
|
|
@@ -37,15 +39,44 @@ deplens ai --types \
|
|
|
37
39
|
--jsdoc-tags param,returns \
|
|
38
40
|
--jsdoc-truncate sentence \
|
|
39
41
|
--jsdoc-max-len 220
|
|
42
|
+
|
|
43
|
+
# Diff package versions
|
|
44
|
+
|
|
45
|
+
deplens diff express --from 4.18.0 --to 4.19.0 --verbose
|
|
40
46
|
```
|
|
41
47
|
|
|
42
|
-
## Flags
|
|
48
|
+
## Flags (inspect)
|
|
43
49
|
|
|
44
50
|
- `--types` — include type signatures from `.d.ts`
|
|
45
51
|
- `--filter <text>` — substring filter for exports
|
|
52
|
+
- `--search <query>` — semantic search (token match + JSDoc)
|
|
46
53
|
- `--kind <k1,k2>` — `function`, `class`, `object`, `constant`
|
|
47
54
|
- `--depth <0-5>` — object inspection depth
|
|
48
55
|
- `--resolve-from <dir>` — base directory for module resolution
|
|
56
|
+
- `--docs` — include README preview
|
|
57
|
+
- `--examples` — include code examples
|
|
58
|
+
- `--list-sections` — list README sections
|
|
59
|
+
- `--docs-sections <s1,s2>` — extract README sections
|
|
60
|
+
- `--remote` — download package to cache
|
|
61
|
+
- `--remote-version <v>` — remote version override
|
|
62
|
+
- `--max-exports <n>` — limit exports shown
|
|
63
|
+
- `--max-props <n>` — limit object props shown
|
|
64
|
+
- `--max-examples <n>` — limit examples shown
|
|
65
|
+
- `--analyze-source` — analyze source complexity
|
|
66
|
+
- `--source-max-files <n>` — max source files to analyze
|
|
67
|
+
- `--source-include-body` — include function body snippets
|
|
68
|
+
|
|
69
|
+
## Flags (diff)
|
|
70
|
+
|
|
71
|
+
- `--from <version>` — base version (default: installed)
|
|
72
|
+
- `--to <version>` — target version (default: latest)
|
|
73
|
+
- `--filter <text>` — filter exports by name
|
|
74
|
+
- `--format text|json` — output format
|
|
75
|
+
- `--include-source` — compare source complexity
|
|
76
|
+
- `--no-changelog` — skip changelog parsing
|
|
77
|
+
- `--verbose` — show detailed changes
|
|
78
|
+
- `--no-color` — disable ANSI colors
|
|
79
|
+
- `--project-dir <dir>` — base directory for installed version
|
|
49
80
|
|
|
50
81
|
JSDoc:
|
|
51
82
|
|
package/bin/deplens.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deplens/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Inspect exports and types of installed npm packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bin"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@deplens/core": "0.1.
|
|
14
|
+
"@deplens/core": "0.1.6"
|
|
15
15
|
},
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
package/src/cli.mjs
CHANGED
|
@@ -1,87 +1,152 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { runInspect } from "@deplens/core"
|
|
2
|
+
import { runInspect, runDiff } from "@deplens/core";
|
|
3
3
|
|
|
4
|
-
function
|
|
5
|
-
const target = argv[0]
|
|
6
|
-
let filter =
|
|
7
|
-
|
|
4
|
+
function parseInspectArgs(argv) {
|
|
5
|
+
const target = argv[0];
|
|
6
|
+
let filter =
|
|
7
|
+
argv[1] && !argv[1].startsWith("--") ? argv[1].toLowerCase() : null;
|
|
8
|
+
const showTypes = argv.includes("--types");
|
|
9
|
+
const includeDocs =
|
|
10
|
+
argv.includes("--docs") || argv.includes("--include-docs");
|
|
11
|
+
const includeExamples =
|
|
12
|
+
argv.includes("--examples") || argv.includes("--include-examples");
|
|
13
|
+
const remote = argv.includes("--remote");
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
const
|
|
15
|
+
// New options
|
|
16
|
+
const listSections = argv.includes("--list-sections");
|
|
17
|
+
|
|
18
|
+
let format = "text";
|
|
19
|
+
const formatIndex = argv.indexOf("--format");
|
|
20
|
+
if (formatIndex !== -1 && argv[formatIndex + 1]) {
|
|
21
|
+
format = argv[formatIndex + 1].toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let search = null;
|
|
25
|
+
const searchIndex = argv.indexOf("--search");
|
|
26
|
+
if (searchIndex !== -1 && argv[searchIndex + 1]) {
|
|
27
|
+
search = argv[searchIndex + 1];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let docsSections = null;
|
|
31
|
+
const docsSectionsIndex = argv.indexOf("--docs-sections");
|
|
32
|
+
if (docsSectionsIndex !== -1 && argv[docsSectionsIndex + 1]) {
|
|
33
|
+
docsSections = argv[docsSectionsIndex + 1].split(",").map((s) => s.trim());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let maxExports = null;
|
|
37
|
+
const maxExportsIndex = argv.indexOf("--max-exports");
|
|
38
|
+
if (maxExportsIndex !== -1 && argv[maxExportsIndex + 1]) {
|
|
39
|
+
const parsed = parseInt(argv[maxExportsIndex + 1], 10);
|
|
40
|
+
if (!isNaN(parsed) && parsed > 0) maxExports = parsed;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let maxProps = null;
|
|
44
|
+
const maxPropsIndex = argv.indexOf("--max-props");
|
|
45
|
+
if (maxPropsIndex !== -1 && argv[maxPropsIndex + 1]) {
|
|
46
|
+
const parsed = parseInt(argv[maxPropsIndex + 1], 10);
|
|
47
|
+
if (!isNaN(parsed) && parsed > 0) maxProps = parsed;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let maxExamples = null;
|
|
51
|
+
const maxExamplesIndex = argv.indexOf("--max-examples");
|
|
52
|
+
if (maxExamplesIndex !== -1 && argv[maxExamplesIndex + 1]) {
|
|
53
|
+
const parsed = parseInt(argv[maxExamplesIndex + 1], 10);
|
|
54
|
+
if (!isNaN(parsed) && parsed > 0) maxExamples = parsed;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const analyzeSource = argv.includes("--analyze-source");
|
|
58
|
+
let sourceMaxFiles = null;
|
|
59
|
+
const sourceMaxFilesIndex = argv.indexOf("--source-max-files");
|
|
60
|
+
if (sourceMaxFilesIndex !== -1 && argv[sourceMaxFilesIndex + 1]) {
|
|
61
|
+
const parsed = parseInt(argv[sourceMaxFilesIndex + 1], 10);
|
|
62
|
+
if (!isNaN(parsed) && parsed > 0) sourceMaxFiles = parsed;
|
|
63
|
+
}
|
|
64
|
+
const sourceIncludeBody = argv.includes("--source-include-body");
|
|
65
|
+
|
|
66
|
+
let jsdoc = null;
|
|
67
|
+
const jsdocIndex = argv.indexOf("--jsdoc");
|
|
11
68
|
if (jsdocIndex !== -1 && argv[jsdocIndex + 1]) {
|
|
12
|
-
jsdoc = argv[jsdocIndex + 1].toLowerCase()
|
|
69
|
+
jsdoc = argv[jsdocIndex + 1].toLowerCase();
|
|
13
70
|
}
|
|
14
71
|
|
|
15
|
-
let jsdocOutput = null
|
|
16
|
-
const jsdocOutputIndex = argv.indexOf("--jsdoc-output")
|
|
72
|
+
let jsdocOutput = null;
|
|
73
|
+
const jsdocOutputIndex = argv.indexOf("--jsdoc-output");
|
|
17
74
|
if (jsdocOutputIndex !== -1 && argv[jsdocOutputIndex + 1]) {
|
|
18
|
-
jsdocOutput = argv[jsdocOutputIndex + 1].toLowerCase()
|
|
75
|
+
jsdocOutput = argv[jsdocOutputIndex + 1].toLowerCase();
|
|
19
76
|
}
|
|
20
77
|
|
|
21
|
-
let jsdocSymbols = null
|
|
22
|
-
const jsdocSymbolIndex = argv.indexOf("--jsdoc-symbol")
|
|
78
|
+
let jsdocSymbols = null;
|
|
79
|
+
const jsdocSymbolIndex = argv.indexOf("--jsdoc-symbol");
|
|
23
80
|
if (jsdocSymbolIndex !== -1 && argv[jsdocSymbolIndex + 1]) {
|
|
24
|
-
jsdocSymbols = argv[jsdocSymbolIndex + 1]
|
|
81
|
+
jsdocSymbols = argv[jsdocSymbolIndex + 1];
|
|
25
82
|
}
|
|
26
83
|
|
|
27
|
-
let jsdocSections = null
|
|
28
|
-
const jsdocSectionsIndex = argv.indexOf("--jsdoc-sections")
|
|
84
|
+
let jsdocSections = null;
|
|
85
|
+
const jsdocSectionsIndex = argv.indexOf("--jsdoc-sections");
|
|
29
86
|
if (jsdocSectionsIndex !== -1 && argv[jsdocSectionsIndex + 1]) {
|
|
30
|
-
jsdocSections = argv[jsdocSectionsIndex + 1]
|
|
87
|
+
jsdocSections = argv[jsdocSectionsIndex + 1];
|
|
31
88
|
}
|
|
32
89
|
|
|
33
|
-
let jsdocTagsInclude = null
|
|
34
|
-
const jsdocTagsIndex = argv.indexOf("--jsdoc-tags")
|
|
90
|
+
let jsdocTagsInclude = null;
|
|
91
|
+
const jsdocTagsIndex = argv.indexOf("--jsdoc-tags");
|
|
35
92
|
if (jsdocTagsIndex !== -1 && argv[jsdocTagsIndex + 1]) {
|
|
36
|
-
jsdocTagsInclude = argv[jsdocTagsIndex + 1]
|
|
93
|
+
jsdocTagsInclude = argv[jsdocTagsIndex + 1];
|
|
37
94
|
}
|
|
38
95
|
|
|
39
|
-
let jsdocTagsExclude = null
|
|
40
|
-
const jsdocTagsExcludeIndex = argv.indexOf("--jsdoc-tags-exclude")
|
|
96
|
+
let jsdocTagsExclude = null;
|
|
97
|
+
const jsdocTagsExcludeIndex = argv.indexOf("--jsdoc-tags-exclude");
|
|
41
98
|
if (jsdocTagsExcludeIndex !== -1 && argv[jsdocTagsExcludeIndex + 1]) {
|
|
42
|
-
jsdocTagsExclude = argv[jsdocTagsExcludeIndex + 1]
|
|
99
|
+
jsdocTagsExclude = argv[jsdocTagsExcludeIndex + 1];
|
|
43
100
|
}
|
|
44
101
|
|
|
45
|
-
let jsdocTruncate = null
|
|
46
|
-
const jsdocTruncateIndex = argv.indexOf("--jsdoc-truncate")
|
|
102
|
+
let jsdocTruncate = null;
|
|
103
|
+
const jsdocTruncateIndex = argv.indexOf("--jsdoc-truncate");
|
|
47
104
|
if (jsdocTruncateIndex !== -1 && argv[jsdocTruncateIndex + 1]) {
|
|
48
|
-
jsdocTruncate = argv[jsdocTruncateIndex + 1].toLowerCase()
|
|
105
|
+
jsdocTruncate = argv[jsdocTruncateIndex + 1].toLowerCase();
|
|
49
106
|
}
|
|
50
107
|
|
|
51
|
-
let jsdocMaxLen = null
|
|
52
|
-
const jsdocMaxLenIndex = argv.indexOf("--jsdoc-max-len")
|
|
108
|
+
let jsdocMaxLen = null;
|
|
109
|
+
const jsdocMaxLenIndex = argv.indexOf("--jsdoc-max-len");
|
|
53
110
|
if (jsdocMaxLenIndex !== -1 && argv[jsdocMaxLenIndex + 1]) {
|
|
54
|
-
const parsed = parseInt(argv[jsdocMaxLenIndex + 1], 10)
|
|
55
|
-
if (!isNaN(parsed) && parsed >= 0) jsdocMaxLen = parsed
|
|
111
|
+
const parsed = parseInt(argv[jsdocMaxLenIndex + 1], 10);
|
|
112
|
+
if (!isNaN(parsed) && parsed >= 0) jsdocMaxLen = parsed;
|
|
56
113
|
}
|
|
57
114
|
|
|
58
|
-
const filterIndex = argv.indexOf("--filter")
|
|
115
|
+
const filterIndex = argv.indexOf("--filter");
|
|
59
116
|
if (filterIndex !== -1 && argv[filterIndex + 1]) {
|
|
60
|
-
filter = argv[filterIndex + 1].toLowerCase()
|
|
117
|
+
filter = argv[filterIndex + 1].toLowerCase();
|
|
61
118
|
}
|
|
62
119
|
|
|
63
|
-
let resolveFrom = null
|
|
64
|
-
const resolveFromIndex = argv.indexOf("--resolve-from")
|
|
120
|
+
let resolveFrom = null;
|
|
121
|
+
const resolveFromIndex = argv.indexOf("--resolve-from");
|
|
65
122
|
if (resolveFromIndex !== -1 && argv[resolveFromIndex + 1]) {
|
|
66
|
-
resolveFrom = argv[resolveFromIndex + 1]
|
|
123
|
+
resolveFrom = argv[resolveFromIndex + 1];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let remoteVersion = null;
|
|
127
|
+
const remoteVersionIndex = argv.indexOf("--remote-version");
|
|
128
|
+
if (remoteVersionIndex !== -1 && argv[remoteVersionIndex + 1]) {
|
|
129
|
+
remoteVersion = argv[remoteVersionIndex + 1];
|
|
67
130
|
}
|
|
68
131
|
|
|
69
|
-
let kindFilter = null
|
|
70
|
-
const kindIndex = argv.indexOf("--kind")
|
|
132
|
+
let kindFilter = null;
|
|
133
|
+
const kindIndex = argv.indexOf("--kind");
|
|
71
134
|
if (kindIndex !== -1 && argv[kindIndex + 1]) {
|
|
72
|
-
kindFilter = argv[kindIndex + 1]
|
|
135
|
+
kindFilter = argv[kindIndex + 1]
|
|
136
|
+
.split(",")
|
|
137
|
+
.map((k) => k.trim().toLowerCase());
|
|
73
138
|
}
|
|
74
139
|
|
|
75
|
-
let depth = 1
|
|
76
|
-
const depthIndex = argv.indexOf("--depth")
|
|
140
|
+
let depth = 1;
|
|
141
|
+
const depthIndex = argv.indexOf("--depth");
|
|
77
142
|
if (depthIndex !== -1 && argv[depthIndex + 1]) {
|
|
78
|
-
depth = parseInt(argv[depthIndex + 1], 10)
|
|
143
|
+
depth = parseInt(argv[depthIndex + 1], 10);
|
|
79
144
|
if (isNaN(depth) || depth < 0 || depth > 5) {
|
|
80
|
-
depth = 1
|
|
145
|
+
depth = 1;
|
|
81
146
|
}
|
|
82
147
|
}
|
|
83
148
|
|
|
84
|
-
let jsdocQuery = null
|
|
149
|
+
let jsdocQuery = null;
|
|
85
150
|
if (
|
|
86
151
|
jsdocSymbols ||
|
|
87
152
|
jsdocSections ||
|
|
@@ -90,46 +155,233 @@ function parseCliArgs(argv) {
|
|
|
90
155
|
jsdocTruncate ||
|
|
91
156
|
jsdocMaxLen !== null
|
|
92
157
|
) {
|
|
93
|
-
const symbols = jsdocSymbols
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
158
|
+
const symbols = jsdocSymbols
|
|
159
|
+
? jsdocSymbols
|
|
160
|
+
.split(",")
|
|
161
|
+
.map((s) => s.trim())
|
|
162
|
+
.filter(Boolean)
|
|
163
|
+
: undefined;
|
|
164
|
+
const sections = jsdocSections
|
|
165
|
+
? jsdocSections
|
|
166
|
+
.split(",")
|
|
167
|
+
.map((s) => s.trim())
|
|
168
|
+
.filter(Boolean)
|
|
169
|
+
: undefined;
|
|
170
|
+
const tagsInclude = jsdocTagsInclude
|
|
171
|
+
? jsdocTagsInclude
|
|
172
|
+
.split(",")
|
|
173
|
+
.map((s) => s.trim())
|
|
174
|
+
.filter(Boolean)
|
|
175
|
+
: undefined;
|
|
176
|
+
const tagsExclude = jsdocTagsExclude
|
|
177
|
+
? jsdocTagsExclude
|
|
178
|
+
.split(",")
|
|
179
|
+
.map((s) => s.trim())
|
|
180
|
+
.filter(Boolean)
|
|
181
|
+
: undefined;
|
|
97
182
|
jsdocQuery = {
|
|
98
183
|
symbols: symbols && symbols.length === 1 ? symbols[0] : symbols,
|
|
99
184
|
sections,
|
|
100
|
-
tags:
|
|
185
|
+
tags:
|
|
186
|
+
tagsInclude || tagsExclude
|
|
187
|
+
? { include: tagsInclude, exclude: tagsExclude }
|
|
188
|
+
: undefined,
|
|
101
189
|
mode: jsdoc === "compact" || jsdoc === "full" ? jsdoc : undefined,
|
|
102
190
|
maxLen: jsdocMaxLen ?? undefined,
|
|
103
191
|
truncate: jsdocTruncate ?? undefined,
|
|
104
|
-
}
|
|
192
|
+
};
|
|
105
193
|
}
|
|
106
194
|
|
|
107
|
-
return {
|
|
195
|
+
return {
|
|
196
|
+
target,
|
|
197
|
+
filter,
|
|
198
|
+
showTypes,
|
|
199
|
+
includeDocs,
|
|
200
|
+
includeExamples,
|
|
201
|
+
remote,
|
|
202
|
+
remoteVersion,
|
|
203
|
+
kindFilter,
|
|
204
|
+
depth,
|
|
205
|
+
resolveFrom,
|
|
206
|
+
jsdoc,
|
|
207
|
+
jsdocOutput,
|
|
208
|
+
jsdocQuery,
|
|
209
|
+
// New options
|
|
210
|
+
format,
|
|
211
|
+
listSections,
|
|
212
|
+
docsSections,
|
|
213
|
+
search,
|
|
214
|
+
maxExports,
|
|
215
|
+
maxProps,
|
|
216
|
+
maxExamples,
|
|
217
|
+
analyzeSource,
|
|
218
|
+
sourceMaxFiles,
|
|
219
|
+
sourceIncludeBody,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function parseDiffArgs(argv) {
|
|
224
|
+
const packageName = argv[0];
|
|
225
|
+
|
|
226
|
+
let from = "installed";
|
|
227
|
+
const fromIndex = argv.indexOf("--from");
|
|
228
|
+
if (fromIndex !== -1 && argv[fromIndex + 1]) {
|
|
229
|
+
from = argv[fromIndex + 1];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let to = "latest";
|
|
233
|
+
const toIndex = argv.indexOf("--to");
|
|
234
|
+
if (toIndex !== -1 && argv[toIndex + 1]) {
|
|
235
|
+
to = argv[toIndex + 1];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let filter = null;
|
|
239
|
+
const filterIndex = argv.indexOf("--filter");
|
|
240
|
+
if (filterIndex !== -1 && argv[filterIndex + 1]) {
|
|
241
|
+
filter = argv[filterIndex + 1];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let format = "text";
|
|
245
|
+
const formatIndex = argv.indexOf("--format");
|
|
246
|
+
if (formatIndex !== -1 && argv[formatIndex + 1]) {
|
|
247
|
+
format = argv[formatIndex + 1].toLowerCase();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const includeSource = argv.includes("--include-source");
|
|
251
|
+
const includeChangelog = !argv.includes("--no-changelog");
|
|
252
|
+
const verbose = argv.includes("--verbose");
|
|
253
|
+
const noColor = argv.includes("--no-color");
|
|
254
|
+
|
|
255
|
+
let projectDir = null;
|
|
256
|
+
const projectDirIndex = argv.indexOf("--project-dir");
|
|
257
|
+
if (projectDirIndex !== -1 && argv[projectDirIndex + 1]) {
|
|
258
|
+
projectDir = argv[projectDirIndex + 1];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
packageName,
|
|
263
|
+
from,
|
|
264
|
+
to,
|
|
265
|
+
filter,
|
|
266
|
+
format,
|
|
267
|
+
includeSource,
|
|
268
|
+
includeChangelog,
|
|
269
|
+
verbose,
|
|
270
|
+
noColor,
|
|
271
|
+
projectDir,
|
|
272
|
+
};
|
|
108
273
|
}
|
|
109
274
|
|
|
110
275
|
function usage() {
|
|
111
276
|
console.error(
|
|
112
|
-
"Uso
|
|
113
|
-
|
|
277
|
+
"Uso:\n" +
|
|
278
|
+
" deplens <pacote> [filtro] [opções]\n" +
|
|
279
|
+
" deplens inspect <pacote> [filtro] [opções]\n" +
|
|
280
|
+
" deplens diff <pacote> [opções]\n\n" +
|
|
281
|
+
"Opções (inspect):\n" +
|
|
282
|
+
" --filter VALUE Filter exports by name\n" +
|
|
283
|
+
" --search QUERY Semantic search (token matching + JSDoc)\n" +
|
|
284
|
+
" --types Show type signatures from .d.ts\n" +
|
|
285
|
+
" --docs Include README preview\n" +
|
|
286
|
+
" --list-sections List available README sections\n" +
|
|
287
|
+
" --docs-sections S1,S2 Extract specific README sections\n" +
|
|
288
|
+
" --examples Include code examples\n" +
|
|
289
|
+
" --format text|json Output format (default: text)\n" +
|
|
290
|
+
" --remote Download package to cache\n" +
|
|
291
|
+
" --remote-version V Version for remote download\n" +
|
|
292
|
+
" --max-exports N Max exports to show (default: 100)\n" +
|
|
293
|
+
" --max-props N Max props per object (default: 10)\n" +
|
|
294
|
+
" --max-examples N Max examples to show (default: 10)\n" +
|
|
295
|
+
" --analyze-source Analyze source for complexity\n" +
|
|
296
|
+
" --source-max-files N Max source files to analyze\n" +
|
|
297
|
+
" --source-include-body Include function body snippets\n" +
|
|
298
|
+
" --kind f,c,... Filter by kind (function,class,object,constant)\n" +
|
|
299
|
+
" --depth N Object inspection depth (0-5)\n" +
|
|
300
|
+
" --resolve-from DIR Base directory for module resolution\n" +
|
|
301
|
+
" --jsdoc off|compact|full JSDoc mode\n" +
|
|
302
|
+
" --jsdoc-output off|section|inline|only JSDoc output mode\n" +
|
|
303
|
+
"\nOpções (diff):\n" +
|
|
304
|
+
" --from VERSION Base version (default: installed)\n" +
|
|
305
|
+
" --to VERSION Target version (default: latest)\n" +
|
|
306
|
+
" --filter VALUE Filter exports by name\n" +
|
|
307
|
+
" --format text|json Output format (default: text)\n" +
|
|
308
|
+
" --include-source Compare source complexity\n" +
|
|
309
|
+
" --no-changelog Skip changelog parsing\n" +
|
|
310
|
+
" --verbose Show detailed changes\n" +
|
|
311
|
+
" --no-color Disable ANSI colors\n" +
|
|
312
|
+
" --project-dir DIR Base directory for installed version\n",
|
|
313
|
+
);
|
|
114
314
|
}
|
|
115
315
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
316
|
+
const argv = process.argv.slice(2);
|
|
317
|
+
const command =
|
|
318
|
+
argv[0] === "diff" || argv[0] === "inspect" ? argv[0] : "inspect";
|
|
319
|
+
const commandArgs =
|
|
320
|
+
command === "inspect" && argv[0] !== "inspect" ? argv : argv.slice(1);
|
|
321
|
+
|
|
322
|
+
const parsed =
|
|
323
|
+
command === "diff"
|
|
324
|
+
? parseDiffArgs(commandArgs)
|
|
325
|
+
: parseInspectArgs(commandArgs);
|
|
326
|
+
if (command === "diff") {
|
|
327
|
+
if (!parsed.packageName) {
|
|
328
|
+
usage();
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const output = await runDiff({
|
|
333
|
+
package: parsed.packageName,
|
|
334
|
+
from: parsed.from,
|
|
335
|
+
to: parsed.to,
|
|
336
|
+
projectDir: parsed.projectDir || process.cwd(),
|
|
337
|
+
includeSource: parsed.includeSource,
|
|
338
|
+
includeChangelog: parsed.includeChangelog,
|
|
339
|
+
filter: parsed.filter,
|
|
340
|
+
format: parsed.format,
|
|
341
|
+
verbose: parsed.verbose,
|
|
342
|
+
colors: !parsed.noColor,
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
if (typeof output?.output === "string" && output.output.length > 0) {
|
|
346
|
+
process.stdout.write(output.output);
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
if (!parsed.target) {
|
|
350
|
+
usage();
|
|
351
|
+
process.exit(1);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const output = await runInspect({
|
|
355
|
+
target: parsed.target,
|
|
356
|
+
filter: parsed.filter,
|
|
357
|
+
showTypes: parsed.showTypes,
|
|
358
|
+
includeDocs: parsed.includeDocs,
|
|
359
|
+
includeExamples: parsed.includeExamples,
|
|
360
|
+
remote: parsed.remote,
|
|
361
|
+
remoteVersion: parsed.remoteVersion,
|
|
362
|
+
jsdoc: parsed.jsdoc,
|
|
363
|
+
jsdocOutput: parsed.jsdocOutput,
|
|
364
|
+
jsdocQuery: parsed.jsdocQuery,
|
|
365
|
+
kind: parsed.kindFilter,
|
|
366
|
+
depth: parsed.depth,
|
|
367
|
+
resolveFrom: parsed.resolveFrom,
|
|
368
|
+
// New options
|
|
369
|
+
format: parsed.format,
|
|
370
|
+
listSections: parsed.listSections,
|
|
371
|
+
docsSections: parsed.docsSections,
|
|
372
|
+
search: parsed.search,
|
|
373
|
+
maxExports: parsed.maxExports,
|
|
374
|
+
maxProps: parsed.maxProps,
|
|
375
|
+
maxExamples: parsed.maxExamples,
|
|
376
|
+
analyzeSource: parsed.analyzeSource,
|
|
377
|
+
sourceMaxFiles: parsed.sourceMaxFiles,
|
|
378
|
+
sourceIncludeBody: parsed.sourceIncludeBody,
|
|
379
|
+
cwd: process.cwd(),
|
|
380
|
+
write: console.log,
|
|
381
|
+
writeError: console.error,
|
|
382
|
+
});
|
|
121
383
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
jsdoc: parsed.jsdoc,
|
|
127
|
-
jsdocOutput: parsed.jsdocOutput,
|
|
128
|
-
jsdocQuery: parsed.jsdocQuery,
|
|
129
|
-
kind: parsed.kindFilter,
|
|
130
|
-
depth: parsed.depth,
|
|
131
|
-
resolveFrom: parsed.resolveFrom,
|
|
132
|
-
cwd: process.cwd(),
|
|
133
|
-
write: console.log,
|
|
134
|
-
writeError: console.error,
|
|
135
|
-
})
|
|
384
|
+
if (typeof output === "string" && output.length > 0) {
|
|
385
|
+
process.stdout.write(output);
|
|
386
|
+
}
|
|
387
|
+
}
|