mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Allow screen URL pattern to be changed.
This commit is contained in:
parent
91b1861d8d
commit
2d4d24a19d
2 changed files with 30 additions and 7 deletions
19
lib/cli.js
19
lib/cli.js
|
@ -59,6 +59,12 @@ program
|
||||||
, 'ADB port (defaults to 5037)'
|
, 'ADB port (defaults to 5037)'
|
||||||
, Number
|
, Number
|
||||||
, 5037)
|
, 5037)
|
||||||
|
.option('--screen-ws-url-pattern <pattern>'
|
||||||
|
, 'screen WebSocket URL pattern'
|
||||||
|
, String
|
||||||
|
, 'ws://${publicIp}:${publicPort}')
|
||||||
|
.option('--disable-screen-public-proxy'
|
||||||
|
, 'no public proxy for screen')
|
||||||
.action(function() {
|
.action(function() {
|
||||||
var serials = cliutil.allUnknownArgs(arguments)
|
var serials = cliutil.allUnknownArgs(arguments)
|
||||||
, options = cliutil.lastArg(arguments)
|
, options = cliutil.lastArg(arguments)
|
||||||
|
@ -94,7 +100,10 @@ program
|
||||||
, '--storage-url', options.storageUrl
|
, '--storage-url', options.storageUrl
|
||||||
, '--adb-host', options.adbHost
|
, '--adb-host', options.adbHost
|
||||||
, '--adb-port', options.adbPort
|
, '--adb-port', options.adbPort
|
||||||
])
|
, '--screen-ws-url-pattern', options.screenWsUrlPattern
|
||||||
|
]
|
||||||
|
.concat(options.disableScreenPublicProxy
|
||||||
|
? ['--disable-screen-public-proxy'] : []))
|
||||||
}
|
}
|
||||||
, endpoints: {
|
, endpoints: {
|
||||||
sub: options.connectSub
|
sub: options.connectSub
|
||||||
|
@ -139,6 +148,12 @@ program
|
||||||
, 'ADB port (defaults to 5037)'
|
, 'ADB port (defaults to 5037)'
|
||||||
, Number
|
, Number
|
||||||
, 5037)
|
, 5037)
|
||||||
|
.option('--screen-ws-url-pattern <pattern>'
|
||||||
|
, 'screen WebSocket URL pattern'
|
||||||
|
, String
|
||||||
|
, 'ws://${publicIp}:${publicPort}')
|
||||||
|
.option('--disable-screen-public-proxy'
|
||||||
|
, 'no public proxy for screen')
|
||||||
.action(function(serial, options) {
|
.action(function(serial, options) {
|
||||||
if (!options.connectSub) {
|
if (!options.connectSub) {
|
||||||
this.missingArgument('--connect-sub')
|
this.missingArgument('--connect-sub')
|
||||||
|
@ -169,6 +184,8 @@ program
|
||||||
, storageUrl: options.storageUrl
|
, storageUrl: options.storageUrl
|
||||||
, adbHost: options.adbHost
|
, adbHost: options.adbHost
|
||||||
, adbPort: options.adbPort
|
, adbPort: options.adbPort
|
||||||
|
, disableScreenPublicProxy: !!options.disableScreenPublicProxy
|
||||||
|
, screenWsUrlPattern: options.screenWsUrlPattern
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ var Promise = require('bluebird')
|
||||||
var syrup = require('stf-syrup')
|
var syrup = require('stf-syrup')
|
||||||
var httpProxy = require('http-proxy')
|
var httpProxy = require('http-proxy')
|
||||||
var adbkit = require('adbkit')
|
var adbkit = require('adbkit')
|
||||||
|
var _ = require('lodash')
|
||||||
|
|
||||||
var logger = require('../../../util/logger')
|
var logger = require('../../../util/logger')
|
||||||
var lifecycle = require('../../../util/lifecycle')
|
var lifecycle = require('../../../util/lifecycle')
|
||||||
|
@ -32,11 +33,12 @@ module.exports = syrup.serial()
|
||||||
)
|
)
|
||||||
|
|
||||||
plugin.publicPort = options.ports.pop()
|
plugin.publicPort = options.ports.pop()
|
||||||
plugin.publicUrl = util.format(
|
plugin.publicUrl = _.template(options.screenWsUrlPattern, {
|
||||||
'ws://%s:%s'
|
publicIp: options.publicIp
|
||||||
, options.publicIp
|
, publicPort: plugin.publicPort
|
||||||
, plugin.publicPort
|
, privatePort: plugin.privatePort
|
||||||
)
|
, serial: options.serial
|
||||||
|
})
|
||||||
|
|
||||||
function run(cmd) {
|
function run(cmd) {
|
||||||
return adb.shell(options.serial, util.format(
|
return adb.shell(options.serial, util.format(
|
||||||
|
@ -165,7 +167,11 @@ module.exports = syrup.serial()
|
||||||
|
|
||||||
return startService()
|
return startService()
|
||||||
.then(forwardService)
|
.then(forwardService)
|
||||||
.then(startProxy)
|
.then(function() {
|
||||||
|
if (!options.disableScreenPublicProxy) {
|
||||||
|
return startProxy()
|
||||||
|
}
|
||||||
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
plugin.info = function(id) {
|
plugin.info = function(id) {
|
||||||
return run(util.format('-d %d -i', id))
|
return run(util.format('-d %d -i', id))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue