mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Allow adb connect
URL to be customized.
This commit is contained in:
parent
7eb6f8f871
commit
caf8d35eb7
4 changed files with 47 additions and 2 deletions
10
lib/cli.js
10
lib/cli.js
|
@ -64,6 +64,10 @@ program
|
|||
, 'screen WebSocket URL pattern'
|
||||
, String
|
||||
, 'ws://${publicIp}:${publicPort}')
|
||||
.option('--connect-url-pattern <pattern>'
|
||||
, 'adb connect URL pattern'
|
||||
, String
|
||||
, '${publicIp}:${publicPort}')
|
||||
.action(function() {
|
||||
var serials = cliutil.allUnknownArgs(arguments)
|
||||
, options = cliutil.lastArg(arguments)
|
||||
|
@ -101,6 +105,7 @@ program
|
|||
, '--adb-host', options.adbHost
|
||||
, '--adb-port', options.adbPort
|
||||
, '--screen-ws-url-pattern', options.screenWsUrlPattern
|
||||
, '--connect-url-pattern', options.connectUrlPattern
|
||||
, '--heartbeat-interval', options.heartbeatInterval
|
||||
])
|
||||
}
|
||||
|
@ -131,6 +136,10 @@ program
|
|||
.option('--connect-port <port>'
|
||||
, 'port allocated to adb connect'
|
||||
, Number)
|
||||
.option('--connect-url-pattern <pattern>'
|
||||
, 'adb connect URL pattern'
|
||||
, String
|
||||
, '${publicIp}:${publicPort}')
|
||||
.option('--public-ip <ip>'
|
||||
, 'public ip for global access'
|
||||
, String
|
||||
|
@ -192,6 +201,7 @@ program
|
|||
, adbPort: options.adbPort
|
||||
, screenWsUrlPattern: options.screenWsUrlPattern
|
||||
, screenPort: options.screenPort
|
||||
, connectUrlPattern: options.connectUrlPattern
|
||||
, connectPort: options.connectPort
|
||||
, heartbeatInterval: options.heartbeatInterval
|
||||
})
|
||||
|
|
|
@ -15,13 +15,14 @@ module.exports = syrup.serial()
|
|||
.dependency(require('../support/push'))
|
||||
.dependency(require('./group'))
|
||||
.dependency(require('./solo'))
|
||||
.define(function(options, adb, router, push, group, solo) {
|
||||
.dependency(require('./util/urlformat'))
|
||||
.define(function(options, adb, router, push, group, solo, urlformat) {
|
||||
var log = logger.createLogger('device:plugins:connect')
|
||||
, plugin = Object.create(null)
|
||||
, activeServer = null
|
||||
|
||||
plugin.port = options.connectPort
|
||||
plugin.url = util.format('%s:%s', options.publicIp, plugin.port)
|
||||
plugin.url = urlformat(options.connectUrlPattern, plugin.port)
|
||||
|
||||
plugin.start = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
|
33
lib/units/device/plugins/util/urlformat.js
Normal file
33
lib/units/device/plugins/util/urlformat.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
var syrup = require('stf-syrup')
|
||||
var _ = require('lodash')
|
||||
var tr = require('transliteration')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.dependency(require('../identity'))
|
||||
.dependency(require('../data'))
|
||||
.define(function(options, identity, data) {
|
||||
function createSlug() {
|
||||
var model = identity.model
|
||||
, name = data ? data.name.id : ''
|
||||
|
||||
return (name === '' || model.toLowerCase() === name.toLowerCase())
|
||||
? tr.slugify(model)
|
||||
: tr.slugify(name + ' ' + model)
|
||||
}
|
||||
|
||||
var defaults = {
|
||||
publicIp: options.publicIp
|
||||
, serial: options.serial
|
||||
, model: identity.model
|
||||
, name: data ? data.name.id : ''
|
||||
, slug: createSlug()
|
||||
}
|
||||
|
||||
return function(template, port) {
|
||||
return _.template(template, {
|
||||
imports: {
|
||||
slugify: tr.slugify
|
||||
}
|
||||
})(_.defaults({publicPort: port}, defaults))
|
||||
}
|
||||
})
|
|
@ -73,6 +73,7 @@
|
|||
"stf-syrup": "^1.0.0",
|
||||
"stf-wiki": "^1.0.0",
|
||||
"temp": "^0.8.1",
|
||||
"transliteration": "^0.1.1",
|
||||
"ws": "^0.7.2",
|
||||
"zmq": "^2.12.0"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue