-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.ts
More file actions
executable file
·89 lines (78 loc) · 2.55 KB
/
index.ts
File metadata and controls
executable file
·89 lines (78 loc) · 2.55 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env node
import { createCommand, Option } from 'commander'
import build from './build'
import { setVerbose } from './build/utils'
import doc from './doc'
import lint from './lint'
import perf from './performance'
import test from './test'
const program = createCommand()
program.version((require('../package.json') as { version: string }).version)
program
.command('build')
.description('Build package using Rollup and TypeScript')
.requiredOption('-c --config <config>')
.option('-w --watch')
.option('-o --output <path>')
.option('-v --verbose')
.action(async (options: { config: string, watch?: boolean, output?: string, verbose?: boolean }) => {
if (options.verbose) setVerbose(true)
await build(options.config, options.watch, options.output?.split(','))
})
program
.command('lint')
.description('Lint using ESLint and TS parser')
.option('--fix')
.addOption(new Option('--output <output...>', 'Output target')
.choices(['sonar', 'stdout'])
.default('stdout'))
.option('--quiet')
.action(async (options: { fix?: boolean, quiet?: boolean, output: ('sonar' | 'stdout')[] }) => {
await lint({
fix: options.fix,
quiet: options.quiet,
output: options.output
})
})
program
.command('doc')
.description('Generate API docs')
.option('--entries <entries>', 'Comma-separated list of entry points')
.action(async (options: { entries?: string }) => {
await doc(options.entries
? options.entries.split(',')
: void 0)
})
program
.command('test')
.description('Run tests using Jest')
.option('-w --watch')
.action(async (options: { watch?: boolean }) => {
await test(options.watch)
})
program
.command('perf')
.description('⚠️ EXPERIMENTAL Run performance tests and benchmarks (interface may change)')
.option('--pattern <pattern>', 'Test file pattern (default: **/*.perf.ts)')
.option('--iterations <number>', 'Number of iterations', '1')
.addOption(new Option('--output <format>', 'Output format')
.choices(['console', 'json', 'both'])
.default('console'))
.option('--output-file <file>', 'Output file path', 'performance-results.json')
.action(async (options: {
pattern?: string
iterations?: string
output?: 'json' | 'console' | 'both'
outputFile?: string
}) => {
await perf({
testPattern: options.pattern,
iterations: options.iterations
? parseInt(options.iterations, 10)
: undefined,
outputFormat: options.output,
outputFile: options.outputFile
})
})
program.parse(process.argv)
export { }