-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathgenerate.mjs
More file actions
69 lines (63 loc) · 2.15 KB
/
generate.mjs
File metadata and controls
69 lines (63 loc) · 2.15 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
import { Command, Option } from 'commander';
import { publicGenerators } from '../../src/generators/index.mjs';
import createGenerator from '../../src/generators.mjs';
import { setConfig } from '../../src/utils/configuration/index.mjs';
import { errorWrap } from '../utils.mjs';
const { runGenerators } = createGenerator();
/**
* @typedef {Object} CLIOptions
* @property {string[]} input
* @property {string[]} target
* @property {string[]} ignore
* @property {string} output
* @property {number} threads
* @property {number} chunkSize
* @property {string} version
* @property {string} changelog
* @property {string} gitRef
* @property {string} index
* @property {boolean} minify
* @property {string} typeMap
* @property {boolean} progress
*/
export default new Command('generate')
.description('Generate API docs')
.addOption(new Option('--config-file <path>', 'Config file'))
// Options that need to be converted into a configuration
.addOption(
new Option('-i, --input <patterns...>', 'Input file patterns (glob)')
)
.addOption(
new Option('-t, --target <generator...>', 'Target generator(s)').choices(
Object.keys(publicGenerators)
)
)
.addOption(
new Option('--ignore <patterns...>', 'Ignore file patterns (glob)')
)
.addOption(new Option('-o, --output <directory>', 'The output directory'))
.addOption(
new Option(
'-p, --threads <number>',
'Number of threads to use (minimum: 1)'
)
)
.addOption(
new Option(
'--chunk-size <number>',
'Number of items to process per worker thread (minimum: 1)'
)
)
.addOption(new Option('-v, --version <semver>', 'Target Node.js version'))
.addOption(new Option('-c, --changelog <url>', 'Changelog URL or path'))
.addOption(new Option('--git-ref', 'Git ref URL'))
.addOption(new Option('--index <url>', 'index.md URL or path'))
.addOption(new Option('--minify', 'Minify?'))
.addOption(new Option('--type-map <url>', 'Type map URL or path'))
.addOption(new Option('--no-progress', 'Disable the progress bar'))
.action(
errorWrap(async opts => {
const config = await setConfig(opts);
await runGenerators(config);
})
);