-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathfuge.js
executable file
·86 lines (68 loc) · 2.78 KB
/
fuge.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
#!/usr/bin/env node
/*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
'use strict'
var program = require('commist')()
var shell = require('./shell')(true)
var util = require('./util')()
function showVersion (args, system, cb) {
console.log('')
console.log('fuge: ' + require('./package.json').version)
console.log('fuge-runner: ' + require('fuge-runner/package.json').version)
console.log('fuge-config: ' + require('fuge-config/package.json').version)
console.log('fuge-dns: ' + require('fuge-dns/package.json').version)
}
var showHelp = function () {
console.log('')
console.log('usage: fuge <command> <options>')
console.log('fuge shell <fuge-file> start the fuge shell')
console.log('fuge pull <fuge-file> update a system by running a pull against each service repository')
console.log('fuge status <fuge-file> determine git branch and status against each service repository')
console.log('fuge test <fuge-file> execute test scripts for all services')
console.log('fuge version display fuge version information')
console.log('fuge help show this help')
}
var runCommand = function (command) {
return function (args) {
console.log('compiling...')
util.compile(args, function (err, system) {
if (err) { return console.error(err) }
shell.runSingleCommand(system, command)
})
}
}
var runShell = function (args) {
process.env.yamlPath = args
console.log('compiling....')
util.compile(args, function (err, system) {
if (err) { return console.error(err) }
shell.run(system)
})
}
program.register('version', showVersion)
program.register('--version', showVersion)
program.register('help', showHelp)
program.register('--help', showHelp)
program.register('pull', runCommand('pull'))
program.register('status', runCommand('status'))
program.register('test', runCommand('test'))
program.register('shell', runShell)
function start (argv) {
var remaining = program.parse(argv)
if (remaining) { console.error('No matching command.') }
}
module.exports = start
if (require.main === module) {
start(process.argv.slice(2))
}