@jsreport/jsreport-cli 3.1.1 → 3.2.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/README.md CHANGED
@@ -7,6 +7,19 @@ See http://jsreport.net/learn/cli for documentation
7
7
 
8
8
  ## Changelog
9
9
 
10
+ ### 3.2.0
11
+
12
+ - change the configure command questions to fit better with new `trustUserCode` option
13
+ - changes to enable new `trustUserCode` option
14
+
15
+ ### 3.1.2
16
+
17
+ - update deps to fix npm audit
18
+
19
+ ### 3.1.1
20
+
21
+ - update deps to fix npm audit
22
+
10
23
  ### 3.1.0
11
24
 
12
25
  internal refactor (use latest version of yargs)
@@ -22,7 +22,7 @@
22
22
  "filename": "logs/error.log"
23
23
  }
24
24
  },
25
- "allowLocalFilesAccess": false,
25
+ "trustUserCode": false,
26
26
  "reportTimeout": 60000,
27
27
  "workers": {
28
28
  "numberOfWorkers": 2
@@ -1,5 +1,5 @@
1
1
  const yargs = require('yargs')
2
- const prompt = require('prompt-tmp')
2
+ const prompt = require('prompt')
3
3
  const startCommand = require('./startCommand')
4
4
  const jsreportInstance = require('./jsreportInstance')
5
5
  const cliPackageJson = require('../../package.json')
@@ -45,63 +45,10 @@ exports.handler = async (argv) => {
45
45
  logger.debug('starting with questions..')
46
46
 
47
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
48
  {
92
49
  type: 'input',
93
50
  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
- },
51
+ message: 'Specify the http port for web server:',
105
52
  default: 5488,
106
53
  validate: (input) => {
107
54
  const valid = !isNaN(parseInt(input, 10))
@@ -114,42 +61,13 @@ exports.handler = async (argv) => {
114
61
  },
115
62
  filter: (input) => {
116
63
  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
64
  }
144
65
  },
145
66
  {
146
67
  type: 'confirm',
147
68
  name: 'serverAuthEnabled',
148
69
  message: 'Do you want to enable authentication in web server?',
149
- default: false,
150
- when: (answers) => {
151
- return answers.serverEnabled
152
- }
70
+ default: false
153
71
  },
154
72
  {
155
73
  type: 'input',
@@ -195,30 +113,11 @@ exports.handler = async (argv) => {
195
113
  return answers.serverAuthEnabled
196
114
  }
197
115
  },
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
116
  {
218
117
  type: 'confirm',
219
- name: 'allowLocalFilesAccess',
220
- message: 'Can jsreport trust the rendering requests and allow access to local files and modules?',
221
- default: true
118
+ name: 'trustUserCode',
119
+ message: 'Do you trust the user code and want to disable sandboxing? (sandboxing slightly degrades performance but adds security when running external code)',
120
+ default: false
222
121
  },
223
122
  {
224
123
  type: 'input',
@@ -244,10 +143,7 @@ exports.handler = async (argv) => {
244
143
  type: 'confirm',
245
144
  name: 'createExamples',
246
145
  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
- }
146
+ default: true
251
147
  }
252
148
  ]
253
149
 
@@ -261,96 +157,45 @@ exports.handler = async (argv) => {
261
157
  logger.debug('answers:')
262
158
  logger.debug(JSON.stringify(answers, null, 2))
263
159
 
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
160
+ config.httpPort = answers.serverPort
281
161
 
282
- if (answers.serverProtocol === 'https') {
283
- config.certificate = {
284
- key: answers.serverHttpsKey,
285
- cert: answers.serverHttpsCert
286
- }
287
- }
162
+ if (answers.serverAuthEnabled) {
163
+ extensionsConf.authentication = {
164
+ cookieSession: {
165
+ secret: answers.serverAuthCookieSecret
166
+ },
167
+ admin: {
168
+ username: answers.serverAuthUsername,
169
+ password: answers.serverAuthPassword
170
+ },
171
+ enabled: true
288
172
  }
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
- }
173
+ } else {
174
+ extensionsConf.authentication = {
175
+ cookieSession: {},
176
+ admin: {
177
+ username: 'admin',
178
+ password: 'password'
179
+ },
180
+ enabled: false
310
181
  }
311
182
  }
312
183
 
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
- }
184
+ config.store = {
185
+ provider: 'fs'
186
+ }
343
187
 
344
- config.blobStorage = {
345
- provider: 'memory'
346
- }
188
+ config.blobStorage = {
189
+ provider: 'fs'
190
+ }
347
191
 
348
- config.logger = {
349
- console: { transport: 'console', level: 'debug' }
350
- }
192
+ config.logger = {
193
+ console: { transport: 'console', level: 'debug' },
194
+ file: { transport: 'file', level: 'info', filename: 'logs/reporter.log' },
195
+ error: { transport: 'file', level: 'error', filename: 'logs/error.log' }
351
196
  }
352
197
 
353
- config.allowLocalFilesAccess = answers.allowLocalFilesAccess === true
198
+ config.trustUserCode = answers.trustUserCode === true
354
199
 
355
200
  if (answers.createExamples) {
356
201
  extensionsConf['sample-template'] = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsreport/jsreport-cli",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "description": "Command line interface for jsreport",
5
5
  "keywords": [
6
6
  "jsreport",
@@ -64,16 +64,16 @@
64
64
  "npm-install-package": "2.1.0",
65
65
  "nssocket": "0.6.0",
66
66
  "once": "1.4.0",
67
- "prompt-tmp": "1.0.0",
67
+ "prompt": "1.3.0",
68
68
  "semver": "5.6.0",
69
69
  "silent-spawn": "0.4.0",
70
70
  "yargs": "17.3.1"
71
71
  },
72
72
  "devDependencies": {
73
- "@jsreport/jsreport-authentication": "3.3.0",
74
- "@jsreport/jsreport-core": "3.5.0",
75
- "@jsreport/jsreport-express": "3.4.0",
76
- "@jsreport/jsreport-fs-store": "3.2.0",
73
+ "@jsreport/jsreport-authentication": "3.3.1",
74
+ "@jsreport/jsreport-core": "3.6.1",
75
+ "@jsreport/jsreport-express": "3.4.1",
76
+ "@jsreport/jsreport-fs-store": "3.2.1",
77
77
  "@jsreport/jsreport-handlebars": "3.1.0",
78
78
  "cross-env": "5.2.1",
79
79
  "execa": "1.0.0",