@compilr-dev/sdk 0.9.4 → 0.9.5
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/dist/compressors/bash.js +30 -28
- package/package.json +1 -1
package/dist/compressors/bash.js
CHANGED
|
@@ -36,9 +36,11 @@ export function compressBashOutput(command, stdout) {
|
|
|
36
36
|
// Direct linters
|
|
37
37
|
if (cmd.match(/^(eslint|tsc|ruff|cargo\s+clippy|golangci-lint)/))
|
|
38
38
|
return compressLintOutput(stdout);
|
|
39
|
-
// ls
|
|
40
|
-
if (cmd.match(/^
|
|
41
|
-
return
|
|
39
|
+
// ls (strip metadata, keep filenames)
|
|
40
|
+
if (cmd.match(/^ls\b/))
|
|
41
|
+
return compressLsOutput(stdout);
|
|
42
|
+
// find / fd — already minimal (just paths), pass through unchanged
|
|
43
|
+
// tree — already structured, pass through unchanged
|
|
42
44
|
// curl / wget (HTTP responses)
|
|
43
45
|
if (cmd.match(/^(curl|wget)\b/))
|
|
44
46
|
return compressCurlOutput(stdout);
|
|
@@ -292,34 +294,34 @@ function compressBuildOutput(output) {
|
|
|
292
294
|
}
|
|
293
295
|
return output;
|
|
294
296
|
}
|
|
295
|
-
// ───
|
|
296
|
-
function
|
|
297
|
-
const lines = output.split('\n')
|
|
298
|
-
if (lines.length <=
|
|
297
|
+
// ─── ls Output (strip metadata, keep filenames) ────────────────────────────
|
|
298
|
+
function compressLsOutput(output) {
|
|
299
|
+
const lines = output.split('\n');
|
|
300
|
+
if (lines.length <= 10)
|
|
299
301
|
return output;
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
groups.set(dir, arr);
|
|
308
|
-
}
|
|
309
|
-
const maxPerDir = 5;
|
|
302
|
+
// Detect ls -l style output (permissions + metadata + filename)
|
|
303
|
+
// e.g., "drwxr-xr-x@ 15 scozzola staff 480 Apr 11 16:16 .compilr"
|
|
304
|
+
const lsLongPattern = /^[dlrwx\-@+.]{10,}\s+\d+\s+\S+\s+\S+\s+\d+\s+\w+\s+\d+\s+[\d:]+\s+(.+)$/;
|
|
305
|
+
const hasMetadata = lines.some((l) => lsLongPattern.test(l.trim()));
|
|
306
|
+
if (!hasMetadata)
|
|
307
|
+
return output; // Plain ls or unknown format — pass through
|
|
308
|
+
// Strip metadata, keep only filenames with dir/file indicator
|
|
310
309
|
const result = [];
|
|
311
|
-
for (const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
310
|
+
for (const line of lines) {
|
|
311
|
+
const trimmed = line.trim();
|
|
312
|
+
if (!trimmed)
|
|
313
|
+
continue;
|
|
314
|
+
if (trimmed.startsWith('total '))
|
|
315
|
+
continue; // Skip "total N" line
|
|
316
|
+
const match = trimmed.match(lsLongPattern);
|
|
317
|
+
if (match) {
|
|
318
|
+
const name = match[1];
|
|
319
|
+
const isDir = trimmed.startsWith('d');
|
|
320
|
+
result.push(isDir ? `${name}/` : name);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
result.push(trimmed); // Keep unrecognized lines as-is
|
|
319
324
|
}
|
|
320
|
-
}
|
|
321
|
-
if (result.length < lines.length) {
|
|
322
|
-
result.push(`\n(${String(lines.length)} total entries, showing ${String(result.length)} lines)`);
|
|
323
325
|
}
|
|
324
326
|
return result.join('\n');
|
|
325
327
|
}
|