This repository was archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·113 lines (100 loc) · 2.63 KB
/
Copy pathcli.js
File metadata and controls
executable file
·113 lines (100 loc) · 2.63 KB
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
#!/usr/bin/env node
var path = require('path')
var program = require('commander')
var cmds = require('./index.js')
var info = require('./package.json')
program.version(info.version)
.option('-d, --dir <dir>', 'set the cwd')
.option('--debug', 'print debug messages')
program
.command('deploy')
.arguments('<ipaddress>')
.option('-u, --user <user>', 'roku device user')
.option('-p, --password <password>', 'roku device password')
.description('deploy roku app')
.action(function(ipaddress, options) {
var cwd = getCwd();
return cmds.deploy({
cwd: cwd,
debug: program.debug,
ipaddress: ipaddress,
user: options.user,
password: options.password
}).then(function(output) {
console.log(output.msg)
return 0;
}).catch(function(err) {
console.log('deploy command error')
console.log(err)
return 1;
})
})
program
.command('install')
.option('-H, --hard', 'copy installed modules into source and components folders')
.description('download dependencies')
.action(function(options) {
var cwd = getCwd()
return cmds.install({
cwd: cwd,
hard: options.hard,
debug: program.debug
}).then(function(results) {
var count = results.length
console.log('Installed ' + count + ' dependencies')
return 0
}).catch(function(err) {
if (err) {
if (err.message) {
console.error(err.message)
}
if (err.innerError && err.innerError.message) {
console.error('innerError', err.innerError.message)
}
}
return 1
})
})
program
.command('pack')
.description('pack and create a zip of the application')
.option('-i, --ignore <ignore>', 'patterns to exclude when creating archive')
.action(function(options) {
var cwd = getCwd()
var ignore = parseIgnore(options)
if (program.debug) {
console.log('ignore', ignore)
}
return cmds.pack({
cwd: cwd,
debug: program.debug,
ignore: ignore
}).then(function() {
console.log('Success')
return 0
}).catch(function(err) {
if (err) {
if (err.message) {
console.error(err.message)
}
if (err.innerError && err.innerError.message) {
console.error('innerError', err.innerError.message)
}
}
return 1
})
})
function getCwd() {
var cwd = process.cwd()
if (program.dir) {
cwd = path.resolve(cwd, program.dir)
}
return cwd
}
function parseIgnore(options) {
if (!options || typeof options.ignore !== 'string') {
return []
}
return options.ignore.split(',')
}
program.parse(process.argv)