Socket
Socket
Sign inDemoInstall

digdug

Package Overview
Dependencies
58
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.1 to 1.5.0

.travis.yml

67

BrowserStackTunnel.js

@@ -97,4 +97,9 @@ /**

/**
* The URL of a service that provides a list of environments supported by BrowserStack.
*/
environmentUrl: 'https://www.browserstack.com/automate/browsers.json',
get auth() {
return this.username + ':' + this.accessKey;
return (this.username || '') + ':' + (this.accessKey || '');
},

@@ -139,5 +144,6 @@

download: function () {
var executable = pathUtil.join(this.directory, this.executable);
return _super.download.apply(this, arguments).then(function () {
_postDownloadFile: function (response) {
var self = this;
return util.decompress(response.data, this.directory).then(function () {
var executable = pathUtil.join(self.directory, self.executable);
fs.chmodSync(executable, parseInt('0755', 8));

@@ -259,2 +265,55 @@ });

return dfd.promise;
},
/**
* Attempt to normalize a BrowserStack described environment with the standard Selenium capabilities
*
* BrowserStack returns a list of environments that looks like:
*
* {
* "browser": "opera",
* "os_version": "Lion",
* "browser_version":"12.15",
* "device": null,
* "os": "OS X"
* }
*
* @param {Object} environment a BrowserStack environment descriptor
* @returns a normalized descriptor
* @private
*/
_normalizeEnvironment: function (environment) {
var platformMap = {
Windows: {
'10': 'WINDOWS',
'8.1': 'WIN8',
'8': 'WIN8',
'7': 'WINDOWS',
'XP': 'XP'
},
'OS X': 'MAC'
};
var browserMap = {
ie: 'internet explorer'
};
// Create the BS platform name for a given os + version
var platform = platformMap[environment.os] || environment.os;
if (typeof platform === 'object') {
platform = platform[environment.os_version];
}
return {
platform: platform,
platformName: environment.os,
platformVersion: environment.os_version,
browserName: browserMap[environment.browser] || environment.browser,
browserVersion: environment.browser_version,
version: environment.browser_version,
descriptor: environment
};
}

@@ -261,0 +320,0 @@ });

53

package.json
{
"name": "digdug",
"version": "1.4.1",
"description": "Dig Dug. A simple abstraction library for downloading and launching WebDriver service tunnels.",
"repository": {
"type": "git",
"url": "https://github.com/theintern/digdug.git"
},
"license": "BSD-3-Clause",
"dependencies": {
"dojo": "2.0.0-alpha.7",
"decompress": "3.0.0"
},
"devDependencies": {
"intern": "3.0.6"
},
"scripts": {
"test": "./node_modules/.bin/intern-client config=tests/intern"
},
"bugs": "https://github.com/theintern/digdug/issues",
"keywords": [ "javascript", "test", "functional", "selenium", "webdriver", "sauce labs", "browserstack", "testingbot" ],
"homepage": "https://github.com/theintern/digdug"
}
"name": "digdug",
"version": "1.5.0",
"description": "Dig Dug. A simple abstraction library for downloading and launching WebDriver service tunnels.",
"repository": {
"type": "git",
"url": "https://github.com/theintern/digdug.git"
},
"license": "BSD-3-Clause",
"dependencies": {
"dojo": "2.0.0-alpha.7",
"decompress": "4.0.0"
},
"devDependencies": {
"intern": "3.2.3"
},
"scripts": {
"test": "./node_modules/.bin/intern-client config=tests/intern"
},
"bugs": "https://github.com/theintern/digdug/issues",
"keywords": [
"javascript",
"test",
"functional",
"selenium",
"webdriver",
"sauce labs",
"browserstack",
"testingbot"
],
"homepage": "https://github.com/theintern/digdug"
}
# ディグダグ
[![Build Status](https://travis-ci.org/theintern/digdug.svg?branch=master)](https://travis-ci.org/theintern/digdug)
[![npm version](https://badge.fury.io/js/digdug.svg)](https://badge.fury.io/js/digdug)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/theintern/digdug.svg)](http://isitmaintained.com/project/theintern/digdug "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/theintern/digdug.svg)](http://isitmaintained.com/project/theintern/digdug "Percentage of issues still open")
Dig Dug is a simple abstraction library for downloading and launching WebDriver service tunnels and interacting with
the REST APIs of these services.
The following services are currently supported:
Dig Dug can run a local Selenium server, and it supports the following cloud testing services:

@@ -12,3 +17,2 @@ * [BrowserStack](http://www.browserstack.com)

## Configuration

@@ -15,0 +19,0 @@

@@ -36,2 +36,3 @@ /**

var _super = Tunnel.prototype;
SauceLabsTunnel.prototype = util.mixin(Object.create(_super), /** @lends module:digdug/SauceLabsTunnel# */ {

@@ -167,4 +168,9 @@ constructor: SauceLabsTunnel,

/**
* The URL of a service that provides a list of environments supported by Sauce Labs.
*/
environmentUrl: 'https://saucelabs.com/rest/v1/info/platforms/webdriver',
get auth() {
return this.username + ':' + this.accessKey;
return (this.username || '') + ':' + (this.accessKey || '');
},

@@ -195,3 +201,3 @@

get isDownloaded() {
return fs.existsSync(this.executable === 'java' ?
return util.fileExists(this.executable === 'java' ?
pathUtil.join(this.directory, 'Sauce-Connect.jar') :

@@ -221,8 +227,7 @@ pathUtil.join(this.directory, this.executable)

download: function () {
_postDownloadFile: function (response) {
var self = this;
var executable = this.executable;
return _super.download.apply(this, arguments).then(function () {
return util.decompress(response.data, this.directory).then(function () {
if (self.executable !== 'java') {
fs.chmodSync(pathUtil.join(self.directory, executable), parseInt('0755', 8));
fs.chmodSync(pathUtil.join(self.directory, self.executable), parseInt('0755', 8));
}

@@ -463,2 +468,60 @@ });

return child;
},
/**
* Attempt to normalize a SauceLabs described environment with the standard Selenium capabilities
*
* SauceLabs returns a list of environments that looks like:
*
* {
* "short_version": "25",
* "long_name": "Firefox",
* "api_name": "firefox",
* "long_version": "25.0b2.",
* "latest_stable_version": "",
* "automation_backend": "webdriver",
* "os": "Windows 2003"
* }
*
* @param {Object} environment a SauceLabs environment descriptor
* @returns a normalized descriptor
* @private
*/
_normalizeEnvironment: function (environment) {
var windowsMap = {
'Windows 2003': 'Windows XP',
'Windows 2008': 'Windows 7',
'Windows 2012': 'Windows 8',
'Windows 2012 R2': 'Windows 8.1',
'Windows 10': 'Windows 10'
};
var browserMap = {
'microsoftedge': 'MicrosoftEdge'
};
var os = environment.os;
var platformName = os;
var platformVersion;
if (os.indexOf('Windows') === 0) {
os = windowsMap[os] || os;
platformName = 'Windows';
platformVersion = os.slice('Windows '.length);
}
else if (os.indexOf('Mac') === 0) {
platformName = 'OS X';
platformVersion = os.slice('Mac '.length);
}
return {
platform: platformName + (platformVersion ? ' ' + platformVersion : ''),
platformName: platformName,
platformVersion: platformVersion,
browserName: browserMap[environment.api_name] || environment.api_name,
browserVersion: environment.short_version,
version: environment.short_version,
descriptor: environment
};
}

@@ -465,0 +528,0 @@ });

@@ -68,3 +68,3 @@ /**

url: 'http://testingbot.com/downloads/testingbot-tunnel.zip',
url: 'https://testingbot.com/downloads/testingbot-tunnel.zip',

@@ -103,8 +103,13 @@ /**

/**
* The URL of a service that provides a list of environments supported by TestingBot.
*/
environmentUrl: 'https://api.testingbot.com/v1/browsers',
get auth() {
return this.apiKey + ':' + this.apiSecret;
return (this.apiKey || '') + ':' + (this.apiSecret || '');
},
get isDownloaded() {
return fs.existsSync(pathUtil.join(this.directory, 'testingbot-tunnel/testingbot-tunnel.jar'));
return util.fileExists(pathUtil.join(this.directory, 'testingbot-tunnel/testingbot-tunnel.jar'));
},

@@ -216,2 +221,5 @@

}
else if (message.indexOf('SEVERE: ') === 0) {
dfd.reject(message);
}
});

@@ -222,2 +230,32 @@ })

return child;
},
/**
* Attempt to normalize a TestingBot described environment with the standard Selenium capabilities
*
* TestingBot returns a list of environments that looks like:
*
* {
* "selenium_name": "Chrome36",
* "name": "googlechrome",
* "platform": "CAPITAN",
* "version":"36"
* }
*
* @param {Object} environment a TestingBot environment descriptor
* @returns a normalized descriptor
* @private
*/
_normalizeEnvironment: function (environment) {
var browserMap = {
googlechrome: 'chrome',
iexplore: 'internet explorer'
};
return {
platform: environment.platform,
browserName: browserMap[environment.name] || environment.name,
version: environment.version,
descriptor: environment
};
}

@@ -224,0 +262,0 @@ });

@@ -13,3 +13,4 @@ /* jshint dojo:true */

suites: [
'dojo/has!host-node?digdug/tests/all'
'dojo/has!host-node?digdug/tests/unit/all',
'dojo/has!host-node?digdug/tests/integration/all'
],

@@ -16,0 +17,0 @@ functionalSuites: [],

@@ -5,9 +5,7 @@ /**

var Decompress = require('decompress');
var Evented = require('dojo/Evented');
var fs = require('fs');
var pathUtil = require('path');
var Promise = require('dojo/Promise');
var sendRequest = require('dojo/request');
var spawnUtil = require('child_process');
var childProcess = require('child_process');
var urlUtil = require('url');

@@ -60,2 +58,3 @@ var util = require('./util');

var _super = Evented.prototype;
Tunnel.prototype = util.mixin(Object.create(_super), /** @lends module:digdug/Tunnel# */ {

@@ -255,3 +254,3 @@ /**

get isDownloaded() {
return fs.existsSync(pathUtil.join(this.directory, this.executable));
return util.fileExists(pathUtil.join(this.directory, this.executable));
},

@@ -269,2 +268,9 @@

download: function (forceDownload) {
if (!forceDownload && this.isDownloaded) {
return Promise.resolve();
}
return this._downloadFile(this.url, this.proxy);
},
_downloadFile: function (url, proxy, options) {
var self = this;

@@ -277,23 +283,6 @@

if (!forceDownload && self.isDownloaded) {
resolve();
return;
}
var request = sendRequest(self.url, { proxy: self.proxy });
var request = sendRequest(url, { proxy: proxy });
request.then(
function (response) {
var decompressor = new Decompress();
decompressor.src(response.data)
.use(Decompress.zip())
.use(Decompress.targz())
.dest(self.directory)
.run(function (error) {
if (error) {
reject(error);
}
else {
resolve();
}
});
resolve(self._postDownloadFile(response, options));
},

@@ -306,10 +295,20 @@ function (error) {

},
progress
);
return request;
function (info) {
self.emit('downloadprogress', util.mixin({}, info, { url: url }));
progress(info);
}
).catch(function (error) {
reject(error);
});
});
},
/**
* Called with the response after a file download has completed
*/
_postDownloadFile: function (response) {
return util.decompress(response.data, this.directory);
},
/**
* Creates the list of command-line arguments to be passed to the spawned tunnel. Implementations should

@@ -359,3 +358,3 @@ * override this method to provide the appropriate command-line arguments.

});
var child = spawnUtil.spawn(command, args, options);
var child = childProcess.spawn(command, args, options);

@@ -454,5 +453,2 @@ child.stdout.setEncoding('utf8');

.download()
.then(null, null, function (progress) {
self.emit('downloadprogress', progress);
})
.then(function () {

@@ -476,12 +472,15 @@ self._handles = [];

this._startTask.then(function () {
self._startTask = null;
self.isStarting = false;
self.isRunning = true;
self.emit('status', 'Ready');
}, function (error) {
self._startTask = null;
self.isStarting = false;
self.emit('status', error.name === 'CancelError' ? 'Start cancelled' : 'Failed to start tunnel');
});
this._startTask.then(
function () {
self._startTask = null;
self.isStarting = false;
self.isRunning = true;
self.emit('status', 'Ready');
},
function (error) {
self._startTask = null;
self.isStarting = false;
self.emit('status', error.name === 'CancelError' ? 'Start cancelled' : 'Failed to start tunnel');
}
);

@@ -547,12 +546,15 @@ return this._startTask;

var self = this;
return this._stop().then(function (returnValue) {
clearHandles(self._handles);
self._process = self._handles = null;
self.isRunning = self.isStopping = false;
return returnValue;
}, function (error) {
self.isRunning = true;
self.isStopping = false;
throw error;
});
return this._stop().then(
function (returnValue) {
clearHandles(self._handles);
self._process = self._handles = null;
self.isRunning = self.isStopping = false;
return returnValue;
},
function (error) {
self.isRunning = true;
self.isStopping = false;
throw error;
}
);
},

@@ -579,2 +581,48 @@

return dfd.promise;
},
/**
* Get a list of environments available on the service.
*
* This method should be overridden and use a specific implementation that returns normalized
* environments from the service. E.g.
*
* {
* browserName: 'firefox',
* version: '12',
* platform: 'windows',
* descriptor: { <original returned environment> }
* }
*
* @returns An object containing the response and helper functions
*/
getEnvironments: function () {
if (!this.environmentUrl) {
return Promise.resolve([]);
}
var normalizeEnvironment = this._normalizeEnvironment.bind(this);
return sendRequest(this.environmentUrl, {
password: this.accessKey,
user: this.username,
proxy: this.proxy
}).then(function (response) {
if (response.statusCode >= 200 && response.statusCode < 400) {
return JSON.parse(response.data.toString()).map(normalizeEnvironment);
}
else {
throw new Error('Server replied with a status of ' + response.statusCode);
}
});
},
/**
* Normalizes a specific Tunnel environment descriptor to a general form. To be overriden by a child implementation.
* @param environment an environment descriptor specific to the Tunnel
* @returns a normalized environment
* @protected
*/
_normalizeEnvironment: function (environment) {
return environment;
}

@@ -581,0 +629,0 @@ });

@@ -0,1 +1,6 @@

var decompress = require('decompress');
var Promise = require('dojo/Promise');
var fs = require('fs');
var path = require('path');
module.exports = {

@@ -39,3 +44,75 @@ /**

};
},
/**
* Returns true if a file or directory exists
*
* @param {string} filename
* @returns {bool} true if filename exists, false otherwise
*/
fileExists: function (filename) {
try {
fs.statSync(filename);
return true;
}
catch (error) {
return false;
}
},
/**
* Decompresses archive data into a given directory
*
* @param {Buffer} data
* @param {string} directory
* @returns {Promise.<void>} A Promise that resolves when the data is decompressed
*/
decompress: function (data, directory) {
return decompress(data, directory);
},
/**
* Writes data to a file.
*
* The file's parent directories will be created if they do not already exist.
*
* @param {Buffer} data
* @param {string} filename
* @returns {Promise.<void>} A Promise that resolves when the file has been written
*/
writeFile: function (data, filename) {
return new Promise(function (resolve, reject) {
function mkdirp(dir) {
if (!dir) {
return;
}
try {
fs.mkdirSync(dir);
}
catch (error) {
// A parent directory didn't exist, create it
if (error.code === 'ENOENT') {
mkdirp(path.dirname(dir));
mkdirp(dir);
}
else {
if (!fs.statSync(dir).isDirectory()) {
throw error;
}
}
}
}
mkdirp(path.dirname(filename));
fs.writeFile(filename, data, function (error) {
if (error) {
reject(error);
}
else {
resolve();
}
});
});
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc