@jsreport/jsreport-cli 3.0.0-beta.2 → 3.1.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/LICENSE +21 -21
- package/README.md +16 -12
- package/cli.js +93 -93
- package/example.config.json +43 -43
- package/example.server.js +14 -14
- package/index.js +20 -22
- package/jsreport.config.js +8 -8
- package/lib/cliExtension.js +59 -59
- package/lib/{createCommandParser.js → commander/createCommandParser.js} +44 -45
- package/lib/commander/createCustomCommandBuilder.js +150 -0
- package/lib/commander/createLogger.js +51 -0
- package/lib/commander/executeCommand.js +37 -0
- package/lib/commander/getCommandEventName.js +4 -0
- package/lib/commander/index.js +279 -0
- package/lib/commander/jsreportInstance.js +98 -0
- package/lib/commander/registerCommand.js +91 -0
- package/lib/commander/startCommand.js +234 -0
- package/lib/commander/startProcessing.js +208 -0
- package/lib/commands/_initializeApp.js +206 -208
- package/lib/commands/configure.js +393 -395
- package/lib/commands/help.js +453 -454
- package/lib/commands/init.js +76 -77
- package/lib/commands/kill.js +85 -86
- package/lib/commands/render.js +490 -488
- package/lib/commands/repair.js +55 -56
- package/lib/commands/start.js +72 -74
- package/lib/commands/win-install.js +124 -126
- package/lib/commands/win-uninstall.js +100 -102
- package/lib/daemonHandler.js +164 -164
- package/lib/daemonInstance.js +225 -225
- package/lib/{registerExtensionsCommands.js → detectAndRegisterExtensionsCommands.js} +74 -74
- package/lib/instanceHandler.js +316 -316
- package/lib/keepAliveProcess.js +205 -205
- package/lib/{errorUtils.js → utils/error.js} +149 -127
- package/lib/{getTempPaths.js → utils/getTempPaths.js} +39 -39
- package/lib/{normalizePathOptionOrArg.js → utils/normalizePathOptionOrArg.js} +41 -41
- package/lib/{normalizeSocketPath.js → utils/normalizeSocketPath.js} +9 -9
- package/lib/{startSocketServer.js → utils/startSocketServer.js} +53 -53
- package/package.json +105 -106
- package/test/testUtils.js +197 -198
- package/lib/commander.js +0 -1108
|
@@ -1,395 +1,393 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
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
|
-
msg = 'Specify the
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
logger.debug(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
config.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
config.
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
logger.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
}
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const { nanoid } = require('nanoid')
|
|
4
|
+
const inquirer = require('inquirer')
|
|
5
|
+
|
|
6
|
+
const description = 'Generates a jsreport configuration file (*.config.json) based on some questions'
|
|
7
|
+
const command = 'configure'
|
|
8
|
+
|
|
9
|
+
exports.command = command
|
|
10
|
+
exports.description = description
|
|
11
|
+
|
|
12
|
+
exports.builder = (yargs) => {
|
|
13
|
+
const commandOptions = {
|
|
14
|
+
print: {
|
|
15
|
+
alias: 't',
|
|
16
|
+
description: 'Print the generated configuration to the console instead to save it to a file',
|
|
17
|
+
type: 'boolean'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const options = Object.keys(commandOptions)
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
yargs
|
|
25
|
+
.group(options, 'Command options:')
|
|
26
|
+
.options(commandOptions)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.handler = async (argv) => {
|
|
31
|
+
const shouldJustPrint = argv.print
|
|
32
|
+
const context = argv.context
|
|
33
|
+
const cwd = context.cwd
|
|
34
|
+
const logger = context.logger
|
|
35
|
+
const localConfigPath = path.join(cwd, 'jsreport.config.json')
|
|
36
|
+
|
|
37
|
+
let answers
|
|
38
|
+
|
|
39
|
+
if (argv.context.answers != null && typeof argv.context.answers === 'object') {
|
|
40
|
+
logger.debug('questions already answered..')
|
|
41
|
+
|
|
42
|
+
// just useful for testing
|
|
43
|
+
answers = argv.context.answers
|
|
44
|
+
} else {
|
|
45
|
+
logger.debug('starting with questions..')
|
|
46
|
+
|
|
47
|
+
const questions = [
|
|
48
|
+
{
|
|
49
|
+
type: 'confirm',
|
|
50
|
+
name: 'serverEnabled',
|
|
51
|
+
message: 'Do you want to enable web server?',
|
|
52
|
+
default: true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'list',
|
|
56
|
+
name: 'serverProtocol',
|
|
57
|
+
message: 'Which protocol should web server use?',
|
|
58
|
+
choices: [{
|
|
59
|
+
name: 'http',
|
|
60
|
+
value: 'http'
|
|
61
|
+
}, {
|
|
62
|
+
name: 'https',
|
|
63
|
+
value: 'https'
|
|
64
|
+
}, {
|
|
65
|
+
name: 'http and https (http will redirect to https)',
|
|
66
|
+
value: 'http-and-https'
|
|
67
|
+
}],
|
|
68
|
+
default: 0,
|
|
69
|
+
when: (answers) => {
|
|
70
|
+
return answers.serverEnabled
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'input',
|
|
75
|
+
name: 'serverHttpsKey',
|
|
76
|
+
message: 'To use https you need a key file, specify the path to this file:',
|
|
77
|
+
default: 'certificates/server.key',
|
|
78
|
+
when: (answers) => {
|
|
79
|
+
return answers.serverProtocol === 'https' || answers.serverProtocol === 'http-and-https'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'input',
|
|
84
|
+
name: 'serverHttpsCert',
|
|
85
|
+
message: 'To use https you need a cert file, specify the path to this file:',
|
|
86
|
+
default: 'certificates/server.cert',
|
|
87
|
+
when: (answers) => {
|
|
88
|
+
return answers.serverProtocol === 'https' || answers.serverProtocol === 'http-and-https'
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'input',
|
|
93
|
+
name: 'serverPort',
|
|
94
|
+
message: (answers) => {
|
|
95
|
+
let msg
|
|
96
|
+
|
|
97
|
+
if (answers.serverProtocol === 'http-and-https') {
|
|
98
|
+
msg = 'Specify the http port for web server:'
|
|
99
|
+
} else {
|
|
100
|
+
msg = 'Specify the ' + answers.serverProtocol + ' port for web server:'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return msg
|
|
104
|
+
},
|
|
105
|
+
default: 5488,
|
|
106
|
+
validate: (input) => {
|
|
107
|
+
const valid = !isNaN(parseInt(input, 10))
|
|
108
|
+
|
|
109
|
+
if (valid) {
|
|
110
|
+
return true
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return 'port must be a valid number'
|
|
114
|
+
},
|
|
115
|
+
filter: (input) => {
|
|
116
|
+
return parseInt(input, 10)
|
|
117
|
+
},
|
|
118
|
+
when: (answers) => {
|
|
119
|
+
return answers.serverEnabled
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'input',
|
|
124
|
+
name: 'serverHttpsPort',
|
|
125
|
+
message: (answers) => {
|
|
126
|
+
return 'Specify the https port for web server:'
|
|
127
|
+
},
|
|
128
|
+
default: 5489,
|
|
129
|
+
validate: (input) => {
|
|
130
|
+
const valid = !isNaN(parseInt(input, 10))
|
|
131
|
+
|
|
132
|
+
if (valid) {
|
|
133
|
+
return true
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return 'port must be a valid number'
|
|
137
|
+
},
|
|
138
|
+
filter: (input) => {
|
|
139
|
+
return parseInt(input, 10)
|
|
140
|
+
},
|
|
141
|
+
when: (answers) => {
|
|
142
|
+
return answers.serverEnabled && answers.serverProtocol === 'http-and-https'
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
type: 'confirm',
|
|
147
|
+
name: 'serverAuthEnabled',
|
|
148
|
+
message: 'Do you want to enable authentication in web server?',
|
|
149
|
+
default: false,
|
|
150
|
+
when: (answers) => {
|
|
151
|
+
return answers.serverEnabled
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: 'input',
|
|
156
|
+
name: 'serverAuthUsername',
|
|
157
|
+
message: 'Specify the admin username to use in web server authentication:',
|
|
158
|
+
default: 'admin',
|
|
159
|
+
when: (answers) => {
|
|
160
|
+
return answers.serverAuthEnabled
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'password',
|
|
165
|
+
name: 'serverAuthPassword',
|
|
166
|
+
message: 'Specify the admin password to use in web server authentication:',
|
|
167
|
+
validate: (input) => {
|
|
168
|
+
const valid = (String(input) !== '')
|
|
169
|
+
|
|
170
|
+
if (valid) {
|
|
171
|
+
return true
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return 'password can\'t be empty'
|
|
175
|
+
},
|
|
176
|
+
when: (answers) => {
|
|
177
|
+
return answers.serverAuthEnabled
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
type: 'input',
|
|
182
|
+
name: 'serverAuthCookieSecret',
|
|
183
|
+
message: 'Specify a secret text for the authentication cookie session:',
|
|
184
|
+
default: () => {
|
|
185
|
+
return nanoid(16)
|
|
186
|
+
},
|
|
187
|
+
validate: (input) => {
|
|
188
|
+
if (input.length > 0) {
|
|
189
|
+
return true
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return 'secret must be not empty'
|
|
193
|
+
},
|
|
194
|
+
when: (answers) => {
|
|
195
|
+
return answers.serverAuthEnabled
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
type: 'list',
|
|
200
|
+
name: 'store',
|
|
201
|
+
message: 'Do you want to persist jsreport objects and logs on disk?',
|
|
202
|
+
choices: [{
|
|
203
|
+
name: 'Yes templates and logs will be saved on disk',
|
|
204
|
+
value: 'fs',
|
|
205
|
+
short: 'Yes everything saved on disk'
|
|
206
|
+
}, {
|
|
207
|
+
name: 'Yes, but without log files.',
|
|
208
|
+
value: 'fs-without-log',
|
|
209
|
+
short: 'Yes, but logs won\'t be written on disk'
|
|
210
|
+
}, {
|
|
211
|
+
name: 'No, objects will live in memory until process is finished',
|
|
212
|
+
value: 'memory',
|
|
213
|
+
short: 'No, only memory will be used'
|
|
214
|
+
}],
|
|
215
|
+
default: 0
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
type: 'confirm',
|
|
219
|
+
name: 'allowLocalFilesAccess',
|
|
220
|
+
message: 'Can jsreport trust the rendering requests and allow access to local files and modules?',
|
|
221
|
+
default: true
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
type: 'input',
|
|
225
|
+
name: 'reportTimeout',
|
|
226
|
+
message: (answers) => {
|
|
227
|
+
return 'Specify the general timeout for rendering:'
|
|
228
|
+
},
|
|
229
|
+
default: 60000,
|
|
230
|
+
validate: (input) => {
|
|
231
|
+
const valid = !isNaN(parseInt(input, 10))
|
|
232
|
+
|
|
233
|
+
if (valid) {
|
|
234
|
+
return true
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return 'reportTimeout must be a valid number'
|
|
238
|
+
},
|
|
239
|
+
filter: (input) => {
|
|
240
|
+
return parseInt(input, 10)
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
type: 'confirm',
|
|
245
|
+
name: 'createExamples',
|
|
246
|
+
message: 'Would you like that we create some default examples for you?',
|
|
247
|
+
default: true,
|
|
248
|
+
when: (answers) => {
|
|
249
|
+
return answers.store === 'fs' || answers.store.indexOf('fs') === 0
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
|
|
254
|
+
answers = await inquirer.prompt(questions)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const extensionsConf = {}
|
|
258
|
+
const config = {}
|
|
259
|
+
|
|
260
|
+
logger.debug('finishing with questions..')
|
|
261
|
+
logger.debug('answers:')
|
|
262
|
+
logger.debug(JSON.stringify(answers, null, 2))
|
|
263
|
+
|
|
264
|
+
if (!answers.serverEnabled) {
|
|
265
|
+
extensionsConf.express = {
|
|
266
|
+
enabled: false
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (answers.serverEnabled) {
|
|
271
|
+
if (answers.serverProtocol === 'http-and-https') {
|
|
272
|
+
config.httpPort = answers.serverPort
|
|
273
|
+
config.httpsPort = answers.serverHttpsPort
|
|
274
|
+
|
|
275
|
+
config.certificate = {
|
|
276
|
+
key: answers.serverHttpsKey,
|
|
277
|
+
cert: answers.serverHttpsCert
|
|
278
|
+
}
|
|
279
|
+
} else {
|
|
280
|
+
config[answers.serverProtocol === 'http' ? 'httpPort' : 'httpsPort'] = answers.serverPort
|
|
281
|
+
|
|
282
|
+
if (answers.serverProtocol === 'https') {
|
|
283
|
+
config.certificate = {
|
|
284
|
+
key: answers.serverHttpsKey,
|
|
285
|
+
cert: answers.serverHttpsCert
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (answers.serverAuthEnabled) {
|
|
291
|
+
extensionsConf.authentication = {
|
|
292
|
+
cookieSession: {
|
|
293
|
+
secret: answers.serverAuthCookieSecret
|
|
294
|
+
},
|
|
295
|
+
admin: {
|
|
296
|
+
username: answers.serverAuthUsername,
|
|
297
|
+
password: answers.serverAuthPassword
|
|
298
|
+
},
|
|
299
|
+
enabled: true
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
extensionsConf.authentication = {
|
|
303
|
+
cookieSession: {},
|
|
304
|
+
admin: {
|
|
305
|
+
username: 'admin',
|
|
306
|
+
password: 'password'
|
|
307
|
+
},
|
|
308
|
+
enabled: false
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (answers.store === 'fs') {
|
|
314
|
+
config.store = {
|
|
315
|
+
provider: 'fs'
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
config.blobStorage = {
|
|
319
|
+
provider: 'fs'
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
config.logger = {
|
|
323
|
+
console: { transport: 'console', level: 'debug' },
|
|
324
|
+
file: { transport: 'file', level: 'info', filename: 'logs/reporter.log' },
|
|
325
|
+
error: { transport: 'file', level: 'error', filename: 'logs/error.log' }
|
|
326
|
+
}
|
|
327
|
+
} else if (answers.store === 'fs-without-log') {
|
|
328
|
+
config.store = {
|
|
329
|
+
provider: 'fs'
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
config.blobStorage = {
|
|
333
|
+
provider: 'fs'
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
config.logger = {
|
|
337
|
+
console: { transport: 'console', level: 'debug' }
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
config.store = {
|
|
341
|
+
provider: 'memory'
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
config.blobStorage = {
|
|
345
|
+
provider: 'memory'
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
config.logger = {
|
|
349
|
+
console: { transport: 'console', level: 'debug' }
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
config.allowLocalFilesAccess = answers.allowLocalFilesAccess === true
|
|
354
|
+
|
|
355
|
+
if (answers.createExamples) {
|
|
356
|
+
extensionsConf['sample-template'] = {
|
|
357
|
+
createSamples: true
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
config.reportTimeout = answers.reportTimeout
|
|
362
|
+
|
|
363
|
+
config.workers = {
|
|
364
|
+
numberOfWorkers: 2
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
config.extensions = extensionsConf
|
|
368
|
+
|
|
369
|
+
if (shouldJustPrint) {
|
|
370
|
+
logger.info('generated config:')
|
|
371
|
+
logger.info(JSON.stringify(config, null, 2))
|
|
372
|
+
} else {
|
|
373
|
+
logger.debug('generated config:')
|
|
374
|
+
logger.debug(JSON.stringify(config, null, 2))
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (shouldJustPrint) {
|
|
378
|
+
return {
|
|
379
|
+
config: config
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const configFile = localConfigPath
|
|
384
|
+
|
|
385
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2))
|
|
386
|
+
|
|
387
|
+
logger.info('config saved in:', configFile)
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
config: config,
|
|
391
|
+
filePath: configFile
|
|
392
|
+
}
|
|
393
|
+
}
|