@bobfrankston/tswalk 1.0.1

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/index.js ADDED
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+ import { DiskWalker } from './diskwalker.js';
3
+ import { DiskWalker as DiskWalker2 } from './diskwalker2.js';
4
+ import { styleText } from 'node:util';
5
+ function showUsage() {
6
+ console.log(`
7
+ Usage: tswalk [path] [depth] [options]
8
+ path Directory to analyze (default: current directory)
9
+ depth Maximum depth to show in output (default: 1)
10
+
11
+ Options:
12
+ -d, -depth Set maximum depth to show in output
13
+ -t Threshold in MB/GB for showing directories
14
+ -mb Show sizes in megabytes (default)
15
+ -gb Show sizes in gigabytes
16
+ -c Show compressed sizes (Windows only)
17
+ -r "cmd" Run command in each directory
18
+ -f pattern Find files matching pattern (can use ;-separated patterns)
19
+ -v Verbose output (show all errors including ENOENT/EPERM)
20
+ -q Quiet mode (no progress updates, minimal errors)
21
+ -acl Force ACL operations (Windows only)
22
+ -1 Use original fs API implementation
23
+ -2 Use dirutil API implementation (default)
24
+
25
+ Progress:
26
+ Shows current directory being processed every second in blue.
27
+ Long paths are truncated in progress display.
28
+
29
+ Error Handling:
30
+ Default: Shows significant errors (excluding ENOENT/EPERM)
31
+ -v: Shows all errors including access denied and not found
32
+ -q: Shows only fatal errors
33
+
34
+ Examples:
35
+ tswalk . # Analyze current directory
36
+ tswalk /path 3 # Show 3 levels deep
37
+ tswalk /path -d 3 -gb # Same, but show sizes in GB
38
+ tswalk /path -t 100 -gb # Show dirs > 100GB
39
+ tswalk . -f "*.ts;*.js" # Find TypeScript and JavaScript files
40
+ tswalk /path -v # Show all errors while processing
41
+ `);
42
+ process.exit(0);
43
+ }
44
+ async function main() {
45
+ const args = process.argv.slice(2);
46
+ console.log('tswalk v1.0.7 (dirutil)');
47
+ if (args.includes('-h') || args.includes('-help') || args.includes('--help')) {
48
+ showUsage();
49
+ }
50
+ const options = {};
51
+ let topPath = '.';
52
+ let foundPath = false;
53
+ let foundDepth = false;
54
+ let useV2 = true;
55
+ for (let i = 0; i < args.length; i++) {
56
+ const arg = args[i];
57
+ if (arg.startsWith('-')) {
58
+ switch (arg) {
59
+ case '-r':
60
+ case '-run':
61
+ options.cmd = args[++i];
62
+ break;
63
+ case '-d':
64
+ case '-depth':
65
+ options.depth = parseInt(args[++i]);
66
+ foundDepth = true;
67
+ break;
68
+ case '-t':
69
+ case '-threshold':
70
+ options.threshold = parseInt(args[++i]);
71
+ break;
72
+ case '-c':
73
+ case '-compressed':
74
+ options.showCompressed = true;
75
+ break;
76
+ case '-f':
77
+ case '-find':
78
+ options.finding = args[++i].split(';');
79
+ break;
80
+ case '-v':
81
+ case '-verbose':
82
+ options.verbose = true;
83
+ break;
84
+ case '-q':
85
+ case '-quiet':
86
+ options.quiet = true;
87
+ break;
88
+ case '-mb':
89
+ options.sizeUnit = 'MB';
90
+ break;
91
+ case '-gb':
92
+ options.sizeUnit = 'GB';
93
+ break;
94
+ case '-acl':
95
+ options.forceAcl = true;
96
+ break;
97
+ case '-1':
98
+ useV2 = false;
99
+ break;
100
+ case '-2':
101
+ useV2 = true;
102
+ break;
103
+ case '-h':
104
+ case '-help':
105
+ case '--help':
106
+ showUsage();
107
+ break;
108
+ default:
109
+ console.error(styleText(['red'], 'Invalid option:'), arg);
110
+ showUsage();
111
+ }
112
+ }
113
+ else {
114
+ // Not a flag
115
+ if (!foundPath) {
116
+ topPath = arg;
117
+ foundPath = true;
118
+ }
119
+ else if (!foundDepth && !isNaN(Number(arg))) {
120
+ options.depth = parseInt(arg);
121
+ foundDepth = true;
122
+ }
123
+ }
124
+ }
125
+ if (options.quiet && options.verbose) {
126
+ console.warn(styleText(['yellow'], 'Warning: Both -q and -v specified; verbose output will be used'));
127
+ options.quiet = false;
128
+ }
129
+ try {
130
+ const WalkerClass = useV2 ? DiskWalker2 : DiskWalker;
131
+ const walker = new WalkerClass(topPath, options);
132
+ await walker.walk();
133
+ }
134
+ catch (err) {
135
+ console.error(styleText(['red'], '\nFatal error:'), err);
136
+ process.exit(1);
137
+ }
138
+ }
139
+ main().catch(err => {
140
+ console.error(styleText(['red'], '\nFatal error:'), err);
141
+ process.exit(1);
142
+ });
143
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,SAAS,SAAS;IACd,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCX,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,KAAK,UAAU,IAAI;IACf,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAEvC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAC1E,SAAS,EAAE,CAAC;KACf;IAED,MAAM,OAAO,GAAyB,EAAE,CAAC;IACzC,IAAI,OAAO,GAAG,GAAG,CAAC;IAClB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,KAAK,GAAG,IAAI,CAAC;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAClC,MAAM,GAAG,GAAG,IAAI,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CAAC,CAAC,CAAC,CAAC;KACnB;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
package/index.ts ADDED
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+ import { DiskWalker, WalkOptions } from './diskwalker.js';
3
+ import { DiskWalker as DiskWalker2 } from './diskwalker2.js';
4
+ import { styleText } from 'node:util';
5
+
6
+ function showUsage() {
7
+ console.log(`
8
+ Usage: tswalk [path] [depth] [options]
9
+ path Directory to analyze (default: current directory)
10
+ depth Maximum depth to show in output (default: 1)
11
+
12
+ Options:
13
+ -d, -depth Set maximum depth to show in output
14
+ -t Threshold in MB/GB for showing directories
15
+ -mb Show sizes in megabytes (default)
16
+ -gb Show sizes in gigabytes
17
+ -c Show compressed sizes (Windows only)
18
+ -r "cmd" Run command in each directory
19
+ -f pattern Find files matching pattern (can use ;-separated patterns)
20
+ -v Verbose output (show all errors including ENOENT/EPERM)
21
+ -q Quiet mode (no progress updates, minimal errors)
22
+ -acl Force ACL operations (Windows only)
23
+ -1 Use original fs API implementation
24
+ -2 Use dirutil API implementation (default)
25
+
26
+ Progress:
27
+ Shows current directory being processed every second in blue.
28
+ Long paths are truncated in progress display.
29
+
30
+ Error Handling:
31
+ Default: Shows significant errors (excluding ENOENT/EPERM)
32
+ -v: Shows all errors including access denied and not found
33
+ -q: Shows only fatal errors
34
+
35
+ Examples:
36
+ tswalk . # Analyze current directory
37
+ tswalk /path 3 # Show 3 levels deep
38
+ tswalk /path -d 3 -gb # Same, but show sizes in GB
39
+ tswalk /path -t 100 -gb # Show dirs > 100GB
40
+ tswalk . -f "*.ts;*.js" # Find TypeScript and JavaScript files
41
+ tswalk /path -v # Show all errors while processing
42
+ `);
43
+ process.exit(0);
44
+ }
45
+
46
+ async function main() {
47
+ const args = process.argv.slice(2);
48
+
49
+ console.log('tswalk v1.0.7 (dirutil)');
50
+
51
+ if (args.includes('-h') || args.includes('-help') || args.includes('--help')) {
52
+ showUsage();
53
+ }
54
+
55
+ const options: Partial<WalkOptions> = {};
56
+ let topPath = '.';
57
+ let foundPath = false;
58
+ let foundDepth = false;
59
+ let useV2 = true;
60
+
61
+ for (let i = 0; i < args.length; i++) {
62
+ const arg = args[i];
63
+
64
+ if (arg.startsWith('-')) {
65
+ switch (arg) {
66
+ case '-r':
67
+ case '-run':
68
+ options.cmd = args[++i];
69
+ break;
70
+ case '-d':
71
+ case '-depth':
72
+ options.depth = parseInt(args[++i]);
73
+ foundDepth = true;
74
+ break;
75
+ case '-t':
76
+ case '-threshold':
77
+ options.threshold = parseInt(args[++i]);
78
+ break;
79
+ case '-c':
80
+ case '-compressed':
81
+ options.showCompressed = true;
82
+ break;
83
+ case '-f':
84
+ case '-find':
85
+ options.finding = args[++i].split(';');
86
+ break;
87
+ case '-v':
88
+ case '-verbose':
89
+ options.verbose = true;
90
+ break;
91
+ case '-q':
92
+ case '-quiet':
93
+ options.quiet = true;
94
+ break;
95
+ case '-mb':
96
+ options.sizeUnit = 'MB';
97
+ break;
98
+ case '-gb':
99
+ options.sizeUnit = 'GB';
100
+ break;
101
+ case '-acl':
102
+ options.forceAcl = true;
103
+ break;
104
+ case '-1':
105
+ useV2 = false;
106
+ break;
107
+ case '-2':
108
+ useV2 = true;
109
+ break;
110
+ case '-h':
111
+ case '-help':
112
+ case '--help':
113
+ showUsage();
114
+ break;
115
+ default:
116
+ console.error(styleText(['red'], 'Invalid option:'), arg);
117
+ showUsage();
118
+ }
119
+ } else {
120
+ // Not a flag
121
+ if (!foundPath) {
122
+ topPath = arg;
123
+ foundPath = true;
124
+ } else if (!foundDepth && !isNaN(Number(arg))) {
125
+ options.depth = parseInt(arg);
126
+ foundDepth = true;
127
+ }
128
+ }
129
+ }
130
+
131
+ if (options.quiet && options.verbose) {
132
+ console.warn(styleText(['yellow'], 'Warning: Both -q and -v specified; verbose output will be used'));
133
+ options.quiet = false;
134
+ }
135
+
136
+ try {
137
+ const WalkerClass = useV2 ? DiskWalker2 : DiskWalker;
138
+ const walker = new WalkerClass(topPath, options);
139
+ await walker.walk();
140
+ } catch (err) {
141
+ console.error(styleText(['red'], '\nFatal error:'), err);
142
+ process.exit(1);
143
+ }
144
+ }
145
+
146
+ main().catch(err => {
147
+ console.error(styleText(['red'], '\nFatal error:'), err);
148
+ process.exit(1);
149
+ });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@bobfrankston/tswalk",
3
+ "version": "1.0.1",
4
+ "main": "index.js",
5
+ "bin": {
6
+ "tswalk": "./index.js"
7
+ },
8
+ "module": "main.js",
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [
13
+ "typescript"
14
+ ],
15
+ "author": "",
16
+ "license": "ISC",
17
+ "type": "module",
18
+ "description": "",
19
+ "dependencies": {
20
+ "@bobfrankston/dirutil": "^1.6.0",
21
+ "esm": "^3.2.25"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^24.0.15"
25
+ }
26
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "sourceMap": true,
7
+ "newLine": "lf",
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "strict": true,
11
+ "strictNullChecks": false,
12
+ "skipLibCheck": true
13
+ }
14
+ }