forked from anvilco/spectaql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
189 lines (171 loc) · 5.38 KB
/
cli.js
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import pkg from '../package.json'
import { Command } from 'commander'
const program = new Command()
export default function () {
//
//= Process CLI input
program
.version(pkg.version)
.usage('[options] [-c <config.yml> | <config.yml>]')
.description(pkg.description)
.option(
'-q, --quiet',
'Silence the output from the generator (default: false)'
)
.option(
'-c, --config <file>',
'Specify the config yaml. Will take precedence over passing via the first argument.'
)
.option(
'-t, --target-dir <dir>',
'the target build directory. Set to "null" to not write the output to the filesystem, making it only available via the API (default: public)',
String
)
// This option specifies where the generated documentation HTML files will be output.
.option(
'-f, --target-file <file>',
'the target build HTML file (default: index.html)',
String
)
// This option lets you build a minimal version of the documentation without the HTML `<body>` tags, so you can embed
// SpectaQL into your own website template.
.option(
'-e, --embeddable',
'omit the HTML <body/> and generate the documentation content only (default: false)'
)
.option(
'-1, --one-file',
'Embed all resources (CSS and JS) into the same file (default: false)'
)
//**************************************
//
// Theme Stuff
//
//
.option(
'-T, --theme-dir <path-or-theme-name>',
'specify a path to a directory containing a theme to use. Or specify a built-in theme of "default", "basic" or "spectaql" (default: "default")',
String
)
//
//
//**************************************
//**************************************
//
// CSS Stuff
//
//
.option('-C, --disable-css', 'omit CSS generation (default: false)')
//
//
//**************************************
//**************************************
//
// JS Stuff
//
//
.option('-J, --disable-js', 'omit JavaScript generation (default: false)')
//
//
//**************************************
.option(
'--logo-file <file>',
'specify a custom logo file (default: null)',
String
)
.option(
'--no-logo-file',
'do not use a custom logo file, overriding what may be in the config'
)
.option(
'--favicon-file <file>',
'specify a custom favicon file (default: null)',
String
)
.option(
'--no-favicon-file',
'do not use a custom favicon file, overriding what may be in the config'
)
.option(
'--schema-file <file...>',
'specify a file, files or glob to files that contain a GraphQL Schema Definitions written in SDL to be used instead of an Introspection Query call (default: none)'
)
.option(
'--introspection-url <url>',
'specify a URL for an Introspection Query(default: none)',
String
)
.option(
'--introspection-file <file>',
'specify a file that contains an Introspection Query response (default: none)',
String
)
.option(
'--introspection-metadata-file <file>',
'specify a file that contains metadata to be added to the Introspection Query response (default: none)',
String
)
.option(
'--dynamic-examples-processing-module <file>',
'specify a JS module that will dynamically generate schema examples (default: none',
String
)
.option(
'-H, --headers <headers>',
'specify arbitrary HTTP headers for the Introspection Query as a JSON string (default: none)',
String
)
.option(
'-d, --development-mode',
'start HTTP server with the file watcher (default: false)'
)
.option(
'-D, --development-mode-live',
'start HTTP server with the file watcher and live reload (default: false)'
)
.option(
'-s, --start-server',
'start the HTTP server without any development features'
)
.option(
'-p, --port <port>',
'the port number for the HTTP server to listen on (default: 4400)',
Number
)
.option(
'-P, --port-live <port>',
'the port number for the live reload to listen on (default: 4401)',
Number
)
// This option overrides the default directory which contains all the Handlebars templates, SCSS, and JavaScript
// source files. This option is useful if you've copied the contents of `app` to a remote location or a separate
// repo and customized it. Probably not something you need to use if you have cloned/forked the repo and customized
// it
.option(
'-a, --app-dir <dir>',
'the application source directory (default: app)',
String
)
.option(
'-g, --grunt-config-file <file>',
'specify a custom Grunt configuration file (default: dist/lib/gruntConfig.js)',
String
)
.option(
'-N, --noop',
'This option does nothing, but may be useful in complex CLI scenarios to get argument parsing correct'
)
.parse(process.argv)
const options = program.opts()
if (options.config) {
// config => specFile
options.specFile = options.config
delete options.config
} else if (program.args.length >= 1) {
options.specFile = program.args[0]
} else {
// Show help if no specfile or options are specified
program.help()
}
return options
}