-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.ts
77 lines (64 loc) Β· 1.36 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Reimplmentation of pkg-size CLI: https://github.com/pkg-size/pkg-size
*
* Usage:
* npx esno examples/pkg-size --help
*/
import { cli } from '../../src';
const argv = cli({
name: 'pkg-size',
version: '1.0.0',
parameters: ['<pkg-path>'],
flags: {
sizes: {
type: [String],
alias: 'S',
default: () => ['size', 'gzip', 'brotli'],
description: 'Comma separated list of sizes to show (size, gzip, brotli)',
placeholder: '<size>',
},
sortBy: {
type: String,
alias: 's',
default: 'brotli',
description: 'Sort list by (name, size, gzip, brotli)',
placeholder: '<column>',
},
unit: {
type: String,
alias: 'u',
default: 'metric',
description: 'Display units (metric, iec, metric_octet, iec_octet)',
placeholder: '<unit>',
},
ignoreFiles: {
type: String,
alias: 'i',
description: 'Glob to ignores files from list. Total size will still include them.',
placeholder: '<glob>',
},
json: {
type: Boolean,
description: 'JSON output',
},
},
help: {
examples: [
'pkg-size',
'pkg-size ./package/path',
'',
'# Display formats',
'pkg-size --sizes=size,gzip,brotli',
'pkg-size -S brotli',
'',
'# Sorting',
'pkg-size --sort-by=name',
'pkg-size -s size',
'pkg-size --unit=iec',
'',
'# Formatting',
'pkg-size -u metric_octet',
],
},
});
console.log(argv);