Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
176 lines (172 loc) · 5.04 KB
/
Copy pathindex.js
File metadata and controls
176 lines (172 loc) · 5.04 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
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
module.exports.command = 'device'
module.exports.builder = function(yargs) {
return yargs
.strict()
.option('adb-host', {
describe: 'The ADB server host.'
, type: 'string'
, default: '127.0.0.1'
})
.option('adb-port', {
describe: 'The ADB server port.'
, type: 'number'
, default: 5037
})
.option('boot-complete-timeout', {
describe: 'How long to wait for boot to complete during device setup.'
, type: 'number'
, default: 60000
})
.option('cleanup', {
describe: 'Attempt to reset the device between uses by uninstalling' +
'apps, resetting accounts and clearing caches. Does not do a perfect ' +
'job currently. Negate with --no-cleanup.'
, type: 'boolean'
, default: true
})
.option('connect-port', {
describe: 'Port allocated to adb connections.'
, type: 'number'
, demand: true
})
.option('connect-push', {
alias: 'p'
, describe: 'ZeroMQ PULL endpoint to connect to.'
, array: true
, demand: true
})
.option('connect-sub', {
alias: 's'
, describe: 'ZeroMQ PUB endpoint to connect to.'
, array: true
, demand: true
})
.option('connect-url-pattern', {
describe: 'The URL pattern to use for `adb connect`.'
, type: 'string'
, default: '${publicIp}:${publicPort}'
})
.option('group-timeout', {
alias: 't'
, describe: 'Timeout in seconds for automatic release of inactive devices.'
, type: 'number'
, default: 900
})
.option('heartbeat-interval', {
describe: 'Send interval in milliseconds for heartbeat messages.'
, type: 'number'
, default: 10000
})
.option('lock-rotation', {
describe: 'Whether to lock rotation when devices are being used. ' +
'Otherwise changing device orientation may not always work due to ' +
'sensitive sensors quickly or immediately reverting it back to the ' +
'physical orientation.'
, type: 'boolean'
})
.option('mute-master', {
describe: 'Whether to mute master volume.'
, choices: ['always', 'inuse', 'never']
, default: 'never'
, coerce: val => {
if (val === true) {
return 'inuse' // For backwards compatibility.
}
if (val === false) {
return 'never' // For backwards compatibility.
}
return val
}
})
.option('provider', {
alias: 'n'
, describe: 'Name of the provider.'
, type: 'string'
, demand: true
})
.option('public-ip', {
describe: 'The IP or hostname to use in URLs.'
, type: 'string'
, demand: true
})
.option('screen-jpeg-quality', {
describe: 'The JPG quality to use for the screen.'
, type: 'number'
, default: process.env.SCREEN_JPEG_QUALITY || 80
})
.option('screen-ping-interval', {
describe: 'The interval at which to send ping messages to keep the ' +
'screen WebSocket alive.'
, type: 'number'
, default: 30000
})
.option('screen-port', {
describe: 'Port allocated to the screen WebSocket.'
, type: 'number'
, demand: true
})
.option('screen-reset', {
describe: 'Go back to home screen and reset screen rotation ' +
'when user releases device. Negate with --no-screen-reset.'
, type: 'boolean'
, default: true
})
.option('screen-ws-url-pattern', {
describe: 'The URL pattern to use for the screen WebSocket.'
, type: 'string'
, default: 'ws://${publicIp}:${publicPort}'
})
.option('serial', {
describe: 'The USB serial number of the device.'
, type: 'string'
, demand: true
})
.option('storage-url', {
alias: 'r'
, describe: 'The URL to the storage unit.'
, type: 'string'
, demand: true
})
.option('vnc-initial-size', {
describe: 'The initial size to use for the experimental VNC server.'
, type: 'string'
, default: '600x800'
, coerce: function(val) {
return val.split('x').map(Number)
}
})
.option('vnc-port', {
describe: 'Port allocated to VNC connections.'
, type: 'number'
, demand: true
})
}
module.exports.handler = function(argv) {
return require('../../units/device')({
serial: argv.serial
, provider: argv.provider
, publicIp: argv.publicIp
, endpoints: {
sub: argv.connectSub
, push: argv.connectPush
}
, groupTimeout: argv.groupTimeout * 1000 // change to ms
, storageUrl: argv.storageUrl
, adbHost: argv.adbHost
, adbPort: argv.adbPort
, screenJpegQuality: argv.screenJpegQuality
, screenPingInterval: argv.screenPingInterval
, screenPort: argv.screenPort
, screenWsUrlPattern: argv.screenWsUrlPattern
, connectUrlPattern: argv.connectUrlPattern
, connectPort: argv.connectPort
, vncPort: argv.vncPort
, vncInitialSize: argv.vncInitialSize
, heartbeatInterval: argv.heartbeatInterval
, bootCompleteTimeout: argv.bootCompleteTimeout
, muteMaster: argv.muteMaster
, lockRotation: argv.lockRotation
, cleanup: argv.cleanup
, screenReset: argv.screenReset
})
}