@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
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017 jsreport
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 jsreport
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
# @jsreport/jsreport-cli
|
|
2
|
-
[](https://npmjs.com/package/@jsreport/jsreport-cli)
|
|
3
|
-
|
|
4
|
-
**Command line interface for jsreport**
|
|
5
|
-
|
|
6
|
-
See http://jsreport.net/learn/cli for documentation
|
|
7
|
-
|
|
8
|
-
## Changelog
|
|
9
|
-
|
|
10
|
-
### 3.
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
# @jsreport/jsreport-cli
|
|
2
|
+
[](https://npmjs.com/package/@jsreport/jsreport-cli)
|
|
3
|
+
|
|
4
|
+
**Command line interface for jsreport**
|
|
5
|
+
|
|
6
|
+
See http://jsreport.net/learn/cli for documentation
|
|
7
|
+
|
|
8
|
+
## Changelog
|
|
9
|
+
|
|
10
|
+
### 3.1.0
|
|
11
|
+
|
|
12
|
+
internal refactor (use latest version of yargs)
|
|
13
|
+
|
|
14
|
+
### 3.0.0-beta.1
|
|
15
|
+
|
|
16
|
+
Adaptations for the v3 APIs
|
package/cli.js
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line no-var
|
|
5
|
-
var semver = require('semver')
|
|
6
|
-
// eslint-disable-next-line no-var
|
|
7
|
-
var cliPackageJson = require('./package.json')
|
|
8
|
-
|
|
9
|
-
if (!semver.satisfies(process.versions.node, cliPackageJson.engines.node)) {
|
|
10
|
-
console.error(
|
|
11
|
-
'jsreport cli requires to have installed a nodejs version of at least ' +
|
|
12
|
-
cliPackageJson.engines.node +
|
|
13
|
-
' but you have installed version ' + process.versions.node + '. please update your nodejs version and try again'
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
process.exit(1)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const path = require('path')
|
|
20
|
-
const Liftoff = require('liftoff')
|
|
21
|
-
const commander = require('./lib/commander')
|
|
22
|
-
const { printError } = require('./lib/
|
|
23
|
-
const help = require('./lib/commands/help')
|
|
24
|
-
const init = require('./lib/commands/init')
|
|
25
|
-
const repair = require('./lib/commands/repair')
|
|
26
|
-
const configure = require('./lib/commands/configure')
|
|
27
|
-
const render = require('./lib/commands/render')
|
|
28
|
-
|
|
29
|
-
const cli = new Liftoff({
|
|
30
|
-
processTitle: 'jsreport',
|
|
31
|
-
moduleName: '@jsreport/jsreport-cli',
|
|
32
|
-
configName: '.jsreport'
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
cli.launch({}, initCLI)
|
|
36
|
-
|
|
37
|
-
function initCLI (env) {
|
|
38
|
-
const isCLIDev = process.env.JSREPORT_CLI_DEV === 'enabled'
|
|
39
|
-
const args = process.argv.slice(2)
|
|
40
|
-
const cwd = process.cwd()
|
|
41
|
-
let localCommander
|
|
42
|
-
|
|
43
|
-
if (!isCLIDev && !env.modulePath) {
|
|
44
|
-
// if no local installation is found,
|
|
45
|
-
// try to detect if some global command was specified
|
|
46
|
-
const globalCliHandler = commander(cwd, {
|
|
47
|
-
cliName: 'jsreport',
|
|
48
|
-
builtInCommands: [help, init, repair, configure, render]
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
globalCliHandler.on('started', (err, info) => {
|
|
52
|
-
if (err) {
|
|
53
|
-
printError(err, console)
|
|
54
|
-
return process.exit(1)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!info.handled) {
|
|
58
|
-
if (info.mainCommand != null) {
|
|
59
|
-
console.error('"' + info.mainCommand + '" command not found')
|
|
60
|
-
console.error('Local jsreport-cli not found in:', env.cwd)
|
|
61
|
-
console.error('Try installing jsreport-cli or jsreport package to have more commands available')
|
|
62
|
-
|
|
63
|
-
return process.exit(1)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
console.error('Local jsreport-cli not found in:', env.cwd)
|
|
67
|
-
console.error('Try installing jsreport-cli or jsreport package')
|
|
68
|
-
|
|
69
|
-
return process.exit(1)
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
globalCliHandler.start(args)
|
|
74
|
-
} else {
|
|
75
|
-
if (isCLIDev) {
|
|
76
|
-
localCommander = require(path.join(cwd, 'lib/commander
|
|
77
|
-
} else {
|
|
78
|
-
// Check for semver difference between global cli and local installation
|
|
79
|
-
if (semver.gt(cliPackageJson.version, env.modulePackage.version)) {
|
|
80
|
-
console.log('Warning: jsreport-cli version mismatch:')
|
|
81
|
-
console.log('Global jsreport-cli is', cliPackageJson.version)
|
|
82
|
-
console.log('Local jsreport-cli is', env.modulePackage.version)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
localCommander = require(path.join(path.dirname(env.modulePath), 'lib/commander
|
|
86
|
-
cliName: 'jsreport'
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// start processing
|
|
91
|
-
localCommander.start(args)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line no-var
|
|
5
|
+
var semver = require('semver')
|
|
6
|
+
// eslint-disable-next-line no-var
|
|
7
|
+
var cliPackageJson = require('./package.json')
|
|
8
|
+
|
|
9
|
+
if (!semver.satisfies(process.versions.node, cliPackageJson.engines.node)) {
|
|
10
|
+
console.error(
|
|
11
|
+
'jsreport cli requires to have installed a nodejs version of at least ' +
|
|
12
|
+
cliPackageJson.engines.node +
|
|
13
|
+
' but you have installed version ' + process.versions.node + '. please update your nodejs version and try again'
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
process.exit(1)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const path = require('path')
|
|
20
|
+
const Liftoff = require('liftoff')
|
|
21
|
+
const commander = require('./lib/commander')
|
|
22
|
+
const { printError } = require('./lib/utils/error')
|
|
23
|
+
const help = require('./lib/commands/help')
|
|
24
|
+
const init = require('./lib/commands/init')
|
|
25
|
+
const repair = require('./lib/commands/repair')
|
|
26
|
+
const configure = require('./lib/commands/configure')
|
|
27
|
+
const render = require('./lib/commands/render')
|
|
28
|
+
|
|
29
|
+
const cli = new Liftoff({
|
|
30
|
+
processTitle: 'jsreport',
|
|
31
|
+
moduleName: '@jsreport/jsreport-cli',
|
|
32
|
+
configName: '.jsreport'
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
cli.launch({}, initCLI)
|
|
36
|
+
|
|
37
|
+
function initCLI (env) {
|
|
38
|
+
const isCLIDev = process.env.JSREPORT_CLI_DEV === 'enabled'
|
|
39
|
+
const args = process.argv.slice(2)
|
|
40
|
+
const cwd = process.cwd()
|
|
41
|
+
let localCommander
|
|
42
|
+
|
|
43
|
+
if (!isCLIDev && !env.modulePath) {
|
|
44
|
+
// if no local installation is found,
|
|
45
|
+
// try to detect if some global command was specified
|
|
46
|
+
const globalCliHandler = commander(cwd, {
|
|
47
|
+
cliName: 'jsreport',
|
|
48
|
+
builtInCommands: [help, init, repair, configure, render]
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
globalCliHandler.on('started', (err, info) => {
|
|
52
|
+
if (err) {
|
|
53
|
+
printError(err, console)
|
|
54
|
+
return process.exit(1)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!info.handled) {
|
|
58
|
+
if (info.mainCommand != null) {
|
|
59
|
+
console.error('"' + info.mainCommand + '" command not found')
|
|
60
|
+
console.error('Local jsreport-cli not found in:', env.cwd)
|
|
61
|
+
console.error('Try installing jsreport-cli or jsreport package to have more commands available')
|
|
62
|
+
|
|
63
|
+
return process.exit(1)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.error('Local jsreport-cli not found in:', env.cwd)
|
|
67
|
+
console.error('Try installing jsreport-cli or jsreport package')
|
|
68
|
+
|
|
69
|
+
return process.exit(1)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
globalCliHandler.start(args)
|
|
74
|
+
} else {
|
|
75
|
+
if (isCLIDev) {
|
|
76
|
+
localCommander = require(path.join(cwd, 'lib/commander'))(cwd, { cliName: 'jsreport' })
|
|
77
|
+
} else {
|
|
78
|
+
// Check for semver difference between global cli and local installation
|
|
79
|
+
if (semver.gt(cliPackageJson.version, env.modulePackage.version)) {
|
|
80
|
+
console.log('Warning: jsreport-cli version mismatch:')
|
|
81
|
+
console.log('Global jsreport-cli is', cliPackageJson.version)
|
|
82
|
+
console.log('Local jsreport-cli is', env.modulePackage.version)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
localCommander = require(path.join(path.dirname(env.modulePath), 'lib/commander'))(cwd, {
|
|
86
|
+
cliName: 'jsreport'
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// start processing
|
|
91
|
+
localCommander.start(args)
|
|
92
|
+
}
|
|
93
|
+
}
|
package/example.config.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"httpPort": 5488,
|
|
3
|
-
"store": {
|
|
4
|
-
"provider": "fs"
|
|
5
|
-
},
|
|
6
|
-
"blobStorage": {
|
|
7
|
-
"provider": "fs"
|
|
8
|
-
},
|
|
9
|
-
"logger": {
|
|
10
|
-
"console": {
|
|
11
|
-
"transport": "console",
|
|
12
|
-
"level": "debug"
|
|
13
|
-
},
|
|
14
|
-
"file": {
|
|
15
|
-
"transport": "file",
|
|
16
|
-
"level": "info",
|
|
17
|
-
"filename": "logs/reporter.log"
|
|
18
|
-
},
|
|
19
|
-
"error": {
|
|
20
|
-
"transport": "file",
|
|
21
|
-
"level": "error",
|
|
22
|
-
"filename": "logs/error.log"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"allowLocalFilesAccess": false,
|
|
26
|
-
"reportTimeout": 60000,
|
|
27
|
-
"workers": {
|
|
28
|
-
"numberOfWorkers": 2
|
|
29
|
-
},
|
|
30
|
-
"extensions": {
|
|
31
|
-
"authentication": {
|
|
32
|
-
"cookieSession": {},
|
|
33
|
-
"admin": {
|
|
34
|
-
"username": "admin",
|
|
35
|
-
"password": "password"
|
|
36
|
-
},
|
|
37
|
-
"enabled": false
|
|
38
|
-
},
|
|
39
|
-
"sample-template": {
|
|
40
|
-
"createSamples": true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"httpPort": 5488,
|
|
3
|
+
"store": {
|
|
4
|
+
"provider": "fs"
|
|
5
|
+
},
|
|
6
|
+
"blobStorage": {
|
|
7
|
+
"provider": "fs"
|
|
8
|
+
},
|
|
9
|
+
"logger": {
|
|
10
|
+
"console": {
|
|
11
|
+
"transport": "console",
|
|
12
|
+
"level": "debug"
|
|
13
|
+
},
|
|
14
|
+
"file": {
|
|
15
|
+
"transport": "file",
|
|
16
|
+
"level": "info",
|
|
17
|
+
"filename": "logs/reporter.log"
|
|
18
|
+
},
|
|
19
|
+
"error": {
|
|
20
|
+
"transport": "file",
|
|
21
|
+
"level": "error",
|
|
22
|
+
"filename": "logs/error.log"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"allowLocalFilesAccess": false,
|
|
26
|
+
"reportTimeout": 60000,
|
|
27
|
+
"workers": {
|
|
28
|
+
"numberOfWorkers": 2
|
|
29
|
+
},
|
|
30
|
+
"extensions": {
|
|
31
|
+
"authentication": {
|
|
32
|
+
"cookieSession": {},
|
|
33
|
+
"admin": {
|
|
34
|
+
"username": "admin",
|
|
35
|
+
"password": "password"
|
|
36
|
+
},
|
|
37
|
+
"enabled": false
|
|
38
|
+
},
|
|
39
|
+
"sample-template": {
|
|
40
|
+
"createSamples": true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/example.server.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const jsreport = require('$moduleName$')()
|
|
2
|
-
|
|
3
|
-
if (process.env.JSREPORT_CLI) {
|
|
4
|
-
// export jsreport instance to make it possible to use jsreport-cli
|
|
5
|
-
module.exports = jsreport
|
|
6
|
-
} else {
|
|
7
|
-
jsreport.init().then(() => {
|
|
8
|
-
// running
|
|
9
|
-
}).catch((e) => {
|
|
10
|
-
// error during startup
|
|
11
|
-
console.error(e.stack)
|
|
12
|
-
process.exit(1)
|
|
13
|
-
})
|
|
14
|
-
}
|
|
1
|
+
const jsreport = require('$moduleName$')()
|
|
2
|
+
|
|
3
|
+
if (process.env.JSREPORT_CLI) {
|
|
4
|
+
// export jsreport instance to make it possible to use jsreport-cli
|
|
5
|
+
module.exports = jsreport
|
|
6
|
+
} else {
|
|
7
|
+
jsreport.init().then(() => {
|
|
8
|
+
// running
|
|
9
|
+
}).catch((e) => {
|
|
10
|
+
// error during startup
|
|
11
|
+
console.error(e.stack)
|
|
12
|
+
process.exit(1)
|
|
13
|
+
})
|
|
14
|
+
}
|
package/index.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
newConfig.
|
|
13
|
-
|
|
14
|
-
newConfig
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
module.exports.
|
|
20
|
-
module.exports.
|
|
21
|
-
module.exports.keepAliveProcess = keepAliveProcess
|
|
22
|
-
module.exports.daemonHandler = daemonHandler
|
|
1
|
+
const commander = require('./lib/commander')
|
|
2
|
+
const main = require('./lib/cliExtension')
|
|
3
|
+
const keepAliveProcess = require('./lib/keepAliveProcess')
|
|
4
|
+
const daemonHandler = require('./lib/daemonHandler')
|
|
5
|
+
const config = require('./jsreport.config')
|
|
6
|
+
|
|
7
|
+
module.exports = function (options) {
|
|
8
|
+
const newConfig = Object.assign({}, config)
|
|
9
|
+
|
|
10
|
+
newConfig.options = options
|
|
11
|
+
newConfig.main = main
|
|
12
|
+
newConfig.directory = __dirname
|
|
13
|
+
|
|
14
|
+
return newConfig
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports.commander = commander
|
|
18
|
+
module.exports.tempResources = main.tempResources
|
|
19
|
+
module.exports.keepAliveProcess = keepAliveProcess
|
|
20
|
+
module.exports.daemonHandler = daemonHandler
|
package/jsreport.config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
name: 'cli',
|
|
3
|
-
main: './lib/cliExtension.js',
|
|
4
|
-
dependencies: [],
|
|
5
|
-
requires: {
|
|
6
|
-
core: '3.x.x'
|
|
7
|
-
}
|
|
8
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
name: 'cli',
|
|
3
|
+
main: './lib/cliExtension.js',
|
|
4
|
+
dependencies: [],
|
|
5
|
+
requires: {
|
|
6
|
+
core: '3.x.x'
|
|
7
|
+
}
|
|
8
|
+
}
|
package/lib/cliExtension.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
module.exports = (reporter, definition) => {
|
|
7
|
-
if (reporter.compilation) {
|
|
8
|
-
reporter.compilation.resourceInTemp('nssm.exe', path.join(path.dirname(require.resolve('winser-with-api')), './bin/nssm.exe'))
|
|
9
|
-
reporter.compilation.resourceInTemp('nssm64.exe', path.join(path.dirname(require.resolve('winser-with-api')), './bin/nssm64.exe'))
|
|
10
|
-
reporter.compilation.resourceInTemp('WinRun.exe', path.join(path.dirname(require.resolve('silent-spawn')), './WinRun.exe'))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
reporter.cli = {
|
|
14
|
-
findCommandsInExtensions: async () => {
|
|
15
|
-
const extensionsCommands = await
|
|
16
|
-
reporter.extensionsManager.extensions,
|
|
17
|
-
{ registerCommand: () => {} }
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
return extensionsCommands
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// only require commander and register route when the process was started from keep alive
|
|
25
|
-
if (process.env.JSREPORT_CLI_DAEMON_PROCESS) {
|
|
26
|
-
const Commander = require('./commander')
|
|
27
|
-
|
|
28
|
-
reporter.on('express-configure', (app) => {
|
|
29
|
-
app.post('/api/cli/render-keep-alive', async (req, res) => {
|
|
30
|
-
try {
|
|
31
|
-
const { cwd, args } = req.body
|
|
32
|
-
|
|
33
|
-
const commander = Commander(cwd)
|
|
34
|
-
|
|
35
|
-
const { error, logs } = await commander.startAndWait(args)
|
|
36
|
-
|
|
37
|
-
const respBody = {}
|
|
38
|
-
|
|
39
|
-
if (error) {
|
|
40
|
-
respBody.message = error.message
|
|
41
|
-
respBody.stack = error.stack
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
respBody.logs = logs
|
|
45
|
-
|
|
46
|
-
res.status(error == null ? 200 : 400).json(respBody)
|
|
47
|
-
} catch (e) {
|
|
48
|
-
res.status(500).json({
|
|
49
|
-
message: `Error while executing commander. ${e.message}`,
|
|
50
|
-
stack: e.stack,
|
|
51
|
-
logs: []
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
module.exports.tempResources = ['nssm.exe', 'nssm64.exe', 'WinRun.exe']
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const detectAndRegisterExtensionsCommands = require('./detectAndRegisterExtensionsCommands')
|
|
5
|
+
|
|
6
|
+
module.exports = (reporter, definition) => {
|
|
7
|
+
if (reporter.compilation) {
|
|
8
|
+
reporter.compilation.resourceInTemp('nssm.exe', path.join(path.dirname(require.resolve('winser-with-api')), './bin/nssm.exe'))
|
|
9
|
+
reporter.compilation.resourceInTemp('nssm64.exe', path.join(path.dirname(require.resolve('winser-with-api')), './bin/nssm64.exe'))
|
|
10
|
+
reporter.compilation.resourceInTemp('WinRun.exe', path.join(path.dirname(require.resolve('silent-spawn')), './WinRun.exe'))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
reporter.cli = {
|
|
14
|
+
findCommandsInExtensions: async () => {
|
|
15
|
+
const extensionsCommands = await detectAndRegisterExtensionsCommands(
|
|
16
|
+
reporter.extensionsManager.extensions,
|
|
17
|
+
{ registerCommand: () => {} }
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return extensionsCommands
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// only require commander and register route when the process was started from keep alive
|
|
25
|
+
if (process.env.JSREPORT_CLI_DAEMON_PROCESS) {
|
|
26
|
+
const Commander = require('./commander')
|
|
27
|
+
|
|
28
|
+
reporter.on('express-configure', (app) => {
|
|
29
|
+
app.post('/api/cli/render-keep-alive', async (req, res) => {
|
|
30
|
+
try {
|
|
31
|
+
const { cwd, args } = req.body
|
|
32
|
+
|
|
33
|
+
const commander = Commander(cwd)
|
|
34
|
+
|
|
35
|
+
const { error, logs } = await commander.startAndWait(args)
|
|
36
|
+
|
|
37
|
+
const respBody = {}
|
|
38
|
+
|
|
39
|
+
if (error) {
|
|
40
|
+
respBody.message = error.message
|
|
41
|
+
respBody.stack = error.stack
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
respBody.logs = logs
|
|
45
|
+
|
|
46
|
+
res.status(error == null ? 200 : 400).json(respBody)
|
|
47
|
+
} catch (e) {
|
|
48
|
+
res.status(500).json({
|
|
49
|
+
message: `Error while executing commander. ${e.message}`,
|
|
50
|
+
stack: e.stack,
|
|
51
|
+
logs: []
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports.tempResources = ['nssm.exe', 'nssm64.exe', 'WinRun.exe']
|
|
@@ -1,45 +1,44 @@
|
|
|
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
|
-
// it
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
1
|
+
const yargs = require('yargs')
|
|
2
|
+
|
|
3
|
+
module.exports = function createCommandParser (instance, _cliName) {
|
|
4
|
+
let cli = instance || yargs([])
|
|
5
|
+
const cliName = _cliName || 'jsreport'
|
|
6
|
+
const commandHelp = 'To show more information about a command, type: jsreport <command> -h'
|
|
7
|
+
|
|
8
|
+
if (cliName != null && cliName !== '') {
|
|
9
|
+
cli = cli.scriptName(cliName)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
cli
|
|
14
|
+
.usage(`Usage:\n\njsreport [options] <command> [options]\n\n${commandHelp}`)
|
|
15
|
+
// this makes strict works correctly when passing unknown dashed options
|
|
16
|
+
.parserConfiguration({ 'camel-case-expansion': false })
|
|
17
|
+
.showHidden(false)
|
|
18
|
+
.showHelpOnFail(false)
|
|
19
|
+
.exitProcess(false)
|
|
20
|
+
.version(false)
|
|
21
|
+
.help('help', 'Show help')
|
|
22
|
+
.alias('help', 'h')
|
|
23
|
+
// adding version option explicitly because we have a custom handler for it
|
|
24
|
+
.option('version', {
|
|
25
|
+
global: false,
|
|
26
|
+
alias: 'v',
|
|
27
|
+
description: 'Show version number',
|
|
28
|
+
type: 'boolean'
|
|
29
|
+
})
|
|
30
|
+
// we are only declaring the "context" option to allow passing
|
|
31
|
+
// a context object for other commands,
|
|
32
|
+
// it is not mean to be used by users, that why it is hidden (description: false)
|
|
33
|
+
// it needs to be global because we don't know if other command will be .strict() or not
|
|
34
|
+
// and could cause validation errors
|
|
35
|
+
.option('context', {
|
|
36
|
+
global: false,
|
|
37
|
+
alias: '_context_',
|
|
38
|
+
description: false, // makes the option invisible
|
|
39
|
+
type: 'string' // necessary to don't have any value if option is omitted
|
|
40
|
+
})
|
|
41
|
+
.hide('context')
|
|
42
|
+
.epilog(commandHelp)
|
|
43
|
+
)
|
|
44
|
+
}
|