@lexmanh/shed-cli 0.2.0-beta.3 → 0.2.0-beta.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/dist/cli.js +41 -7
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { createRequire } from "module";
|
|
4
|
+
import { createRequire as createRequire2 } from "module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
|
|
7
7
|
// src/commands/clean.ts
|
|
@@ -395,6 +395,8 @@ async function doctorCommand() {
|
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
// src/commands/scan.ts
|
|
398
|
+
import { createRequire } from "module";
|
|
399
|
+
import { hostname } from "os";
|
|
398
400
|
import { resolve as resolve2 } from "path";
|
|
399
401
|
import * as p4 from "@clack/prompts";
|
|
400
402
|
import {
|
|
@@ -419,6 +421,9 @@ import {
|
|
|
419
421
|
XcodeDetector as XcodeDetector2
|
|
420
422
|
} from "@lexmanh/shed-core";
|
|
421
423
|
import pc4 from "picocolors";
|
|
424
|
+
var require2 = createRequire(import.meta.url);
|
|
425
|
+
var { version: SHED_VERSION } = require2("../package.json");
|
|
426
|
+
var JSON_SCHEMA_VERSION = 1;
|
|
422
427
|
var RISK_LABEL = {
|
|
423
428
|
[RiskTier2.Green]: pc4.green("\u25CF Green"),
|
|
424
429
|
[RiskTier2.Yellow]: pc4.yellow("\u25CF Yellow"),
|
|
@@ -444,6 +449,7 @@ async function scanCommand(path = ".", options = {}) {
|
|
|
444
449
|
const spinner3 = options.json ? null : p4.spinner();
|
|
445
450
|
verbose(`scan root: ${rootDir}`);
|
|
446
451
|
spinner3?.start(`Scanning ${rootDir} \u2026`);
|
|
452
|
+
const scanStartedAt = Date.now();
|
|
447
453
|
const scanner = new Scanner2([
|
|
448
454
|
new NodeDetector2(),
|
|
449
455
|
new PythonDetector2(),
|
|
@@ -482,13 +488,41 @@ async function scanCommand(path = ".", options = {}) {
|
|
|
482
488
|
`Found ${pc4.bold(String(allItems.length))} cleanable items across ${projects.length} project(s).`
|
|
483
489
|
);
|
|
484
490
|
if (options.json) {
|
|
491
|
+
const byRisk = { green: 0, yellow: 0, red: 0 };
|
|
492
|
+
let detectOnly = 0;
|
|
493
|
+
for (const item of allItems) {
|
|
494
|
+
byRisk[item.risk]++;
|
|
495
|
+
if (item.metadata?.detectOnly === true) detectOnly++;
|
|
496
|
+
}
|
|
497
|
+
const projectsOut = projects.map((proj) => ({
|
|
498
|
+
root: proj.root,
|
|
499
|
+
detectors: [...new Set(proj.items.map((i) => i.detector))],
|
|
500
|
+
itemCount: proj.items.length,
|
|
501
|
+
totalBytes: proj.items.reduce((s, i) => s + i.sizeBytes, 0)
|
|
502
|
+
}));
|
|
485
503
|
console.log(
|
|
486
504
|
JSON.stringify(
|
|
487
505
|
{
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
506
|
+
schemaVersion: JSON_SCHEMA_VERSION,
|
|
507
|
+
shedVersion: SHED_VERSION,
|
|
508
|
+
timestamp: new Date(scanStartedAt).toISOString(),
|
|
509
|
+
host: {
|
|
510
|
+
hostname: hostname(),
|
|
511
|
+
platform: process.platform,
|
|
512
|
+
arch: process.arch
|
|
513
|
+
},
|
|
514
|
+
scan: {
|
|
515
|
+
root: rootDir,
|
|
516
|
+
durationMs: Date.now() - scanStartedAt
|
|
517
|
+
},
|
|
518
|
+
summary: {
|
|
519
|
+
totalBytes,
|
|
520
|
+
totalItems: allItems.length,
|
|
521
|
+
byRisk,
|
|
522
|
+
detectOnly
|
|
523
|
+
},
|
|
524
|
+
projects: projectsOut,
|
|
525
|
+
items: allItems
|
|
492
526
|
},
|
|
493
527
|
null,
|
|
494
528
|
2
|
|
@@ -589,8 +623,8 @@ function printLogo(version2) {
|
|
|
589
623
|
}
|
|
590
624
|
|
|
591
625
|
// src/cli.ts
|
|
592
|
-
var
|
|
593
|
-
var { version } =
|
|
626
|
+
var require3 = createRequire2(import.meta.url);
|
|
627
|
+
var { version } = require3("../package.json");
|
|
594
628
|
var program = new Command();
|
|
595
629
|
program.name("shed").description("Safe disk cleanup for dev machines and Linux servers").version(version).option("-v, --verbose", "Enable verbose logging");
|
|
596
630
|
program.command("scan [path]").description("Scan for cleanable items without modifying anything").option("--json", "Output machine-readable JSON").option("--max-age <days>", "Only include items older than N days", "30").action(scanCommand);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexmanh/shed-cli",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.4",
|
|
4
4
|
"description": "Safe disk cleanup CLI for dev machines and Linux servers — git-aware, cross-stack, trash-by-default",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"conf": "^13.1.0",
|
|
24
24
|
"execa": "^9.5.0",
|
|
25
25
|
"picocolors": "^1.1.1",
|
|
26
|
-
"@lexmanh/shed-core": "0.2.0-beta.
|
|
26
|
+
"@lexmanh/shed-core": "0.2.0-beta.4"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.10.0",
|