codeinf 1.0.2 → 1.0.4
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/bin/cli.js +23 -16
- package/index.js +8 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -32,7 +32,8 @@ function parseArgs(args) {
|
|
|
32
32
|
top: 10,
|
|
33
33
|
help: false,
|
|
34
34
|
version: false,
|
|
35
|
-
noColor: false
|
|
35
|
+
noColor: false,
|
|
36
|
+
includeNodeModules: false
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -85,6 +86,9 @@ function parseArgs(args) {
|
|
|
85
86
|
case '--no-color':
|
|
86
87
|
options.noColor = true;
|
|
87
88
|
break;
|
|
89
|
+
case '--include-node-modules':
|
|
90
|
+
options.includeNodeModules = true;
|
|
91
|
+
break;
|
|
88
92
|
default:
|
|
89
93
|
if (!arg.startsWith('-') && options.path === '.') {
|
|
90
94
|
options.path = arg;
|
|
@@ -103,22 +107,24 @@ function showHelp() {
|
|
|
103
107
|
${c('Usage:', 'yellow')} codeinf [path] [options]
|
|
104
108
|
|
|
105
109
|
${c('Options:', 'yellow')}
|
|
106
|
-
-h, --help
|
|
107
|
-
-v, --version
|
|
108
|
-
-e, --ext <exts>
|
|
109
|
-
-i, --ignore <patterns>
|
|
110
|
-
-f, --format <format>
|
|
111
|
-
--json
|
|
112
|
-
-t, --top <number>
|
|
113
|
-
--no-color
|
|
110
|
+
-h, --help Show this help message
|
|
111
|
+
-v, --version Show version
|
|
112
|
+
-e, --ext <exts> Filter by file extensions (comma-separated)
|
|
113
|
+
-i, --ignore <patterns> Additional ignore patterns (comma-separated)
|
|
114
|
+
-f, --format <format> Output format: ${c('table', 'green')}, ${c('json', 'green')}
|
|
115
|
+
--json Output as JSON
|
|
116
|
+
-t, --top <number> Number of largest files to show (default: 10)
|
|
117
|
+
--no-color Disable colored output
|
|
118
|
+
--include-node-modules Include node_modules in analysis (default: ignored)
|
|
114
119
|
|
|
115
120
|
${c('Examples:', 'yellow')}
|
|
116
|
-
${c('codeinf', 'cyan')}
|
|
117
|
-
${c('codeinf ./src', 'cyan')}
|
|
118
|
-
${c('codeinf -e js,ts', 'cyan')}
|
|
119
|
-
${c('codeinf -e .js --json', 'cyan')}
|
|
120
|
-
${c('codeinf -i "test,dist"', 'cyan')}
|
|
121
|
-
${c('codeinf -t 20', 'cyan')}
|
|
121
|
+
${c('codeinf', 'cyan')} Analyze current directory
|
|
122
|
+
${c('codeinf ./src', 'cyan')} Analyze src directory
|
|
123
|
+
${c('codeinf -e js,ts', 'cyan')} Analyze only JS and TS files
|
|
124
|
+
${c('codeinf -e .js --json', 'cyan')} Output JS stats as JSON
|
|
125
|
+
${c('codeinf -i "test,dist"', 'cyan')} Ignore test and dist folders
|
|
126
|
+
${c('codeinf -t 20', 'cyan')} Show top 20 largest files
|
|
127
|
+
${c('codeinf --include-node-modules', 'cyan')} Include node_modules
|
|
122
128
|
`);
|
|
123
129
|
}
|
|
124
130
|
|
|
@@ -260,7 +266,8 @@ async function main() {
|
|
|
260
266
|
try {
|
|
261
267
|
const result = analyze(options.path, {
|
|
262
268
|
extensions: options.extensions,
|
|
263
|
-
ignore: options.ignore
|
|
269
|
+
ignore: options.ignore,
|
|
270
|
+
includeNodeModules: options.includeNodeModules
|
|
264
271
|
});
|
|
265
272
|
|
|
266
273
|
if (options.format === 'json') {
|
package/index.js
CHANGED
|
@@ -73,13 +73,19 @@ function scanDirectory(dir, options = {}) {
|
|
|
73
73
|
const {
|
|
74
74
|
extensions = [],
|
|
75
75
|
ignore = [],
|
|
76
|
-
recursive = true
|
|
76
|
+
recursive = true,
|
|
77
|
+
includeNodeModules = false
|
|
77
78
|
} = options;
|
|
78
79
|
|
|
80
|
+
// If includeNodeModules is false, add node_modules to ignore list
|
|
81
|
+
const effectiveIgnore = includeNodeModules
|
|
82
|
+
? ignore
|
|
83
|
+
: [...ignore, 'node_modules'];
|
|
84
|
+
|
|
79
85
|
const results = [];
|
|
80
86
|
|
|
81
87
|
function scan(currentPath) {
|
|
82
|
-
if (shouldIgnore(currentPath,
|
|
88
|
+
if (shouldIgnore(currentPath, effectiveIgnore)) {
|
|
83
89
|
return;
|
|
84
90
|
}
|
|
85
91
|
|
package/package.json
CHANGED