saucelabs
Advanced tools
Comparing version 3.0.1 to 3.1.1
31
a.js
const SauceLabs = require('./build').default | ||
const api = new SauceLabs({ | ||
user: process.env.SAUCE_USERNAME, | ||
key: process.env.SAUCE_ACCESS_KEY, | ||
user: 'admin', | ||
key: 'foobar', | ||
}) | ||
api.getPerformanceMetricsByJobId( | ||
'73b1ad4e397e48cbb972e07018280260', | ||
{ full: true } | ||
).then( | ||
(data) => console.log(JSON.stringify(data, null, 4)) | ||
// api.getPerformanceMetricsByJobId( | ||
// '73b1ad4e397e48cbb972e07018280260', | ||
// { full: true } | ||
// ).then( | ||
// (data) => console.log(JSON.stringify(data, null, 4)) | ||
// ) | ||
// api.uploadJobAssets('72e5393899a681f9c4e07a4192ef393b', ['./a.js']).then( | ||
// console.log, | ||
// console.error | ||
// ) | ||
api.createJob({ | ||
name: 'a test', | ||
capabilities: { | ||
browserName: 'Firefox', | ||
platformName: 'Windows 10', | ||
browserVersion: '70' | ||
} | ||
}).then( | ||
console.log, | ||
console.error | ||
) |
@@ -12,3 +12,3 @@ "use strict"; | ||
const protocols = [require('../apis/sauce.json'), require('../apis/rdc.json'), require('../apis/performance.json')]; | ||
const protocols = [require('../apis/sauce.json'), require('../apis/rdc.json'), require('../apis/performance.json'), require('../apis/orchestrator.json')]; | ||
const protocolFlattened = new Map(); | ||
@@ -15,0 +15,0 @@ const parametersFlattened = new Map(); |
@@ -18,2 +18,4 @@ "use strict"; | ||
var _formData = _interopRequireDefault(require("form-data")); | ||
var _utils = require("./utils"); | ||
@@ -99,3 +101,11 @@ | ||
} | ||
/** | ||
* have special implementations for certain operations | ||
*/ | ||
if (propName === 'uploadJobAssets') { | ||
return this.uploadJobAssets.bind(this); | ||
} | ||
return (...args) => { | ||
@@ -177,3 +187,4 @@ const { | ||
const uri = (0, _utils.getSauceEndpoint)(host + basePath, this._options.region, this._options.headless) + url; | ||
const uri = (0, _utils.getSauceEndpoint)('localhost:3000' + '', this._options.region, this._options.headless, 'http://') + url; | ||
console.log(uri); | ||
return new Promise((resolve, reject) => (0, _request.default)({ | ||
@@ -276,4 +287,42 @@ uri, | ||
async uploadJobAssets(jobId, filePaths) { | ||
const base = 'http://localhost:3000'; // getSauceEndpoint('saucelabs.com', this._options.region, this._options.headless) | ||
const uri = base + `/v1/job/${jobId}/upload`; | ||
const form = new _formData.default(); | ||
for (const filePath of filePaths) { | ||
const readStream = _fs.default.createReadStream(filePath.startsWith('/') ? filePath : _path.default.join(process.cwd(), filePath)); | ||
form.append('file[]', readStream); | ||
} | ||
return new Promise((resolve, reject) => { | ||
const req = (0, _request.default)({ | ||
uri, | ||
auth: { | ||
/** | ||
* ToDo get real auth | ||
*/ | ||
user: 'admin', | ||
pass: 'foobar' | ||
}, | ||
method: 'PUT', | ||
headers: form.getHeaders() | ||
}, (err, res, body) => { | ||
/** | ||
* check if request was successful | ||
*/ | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(body); | ||
}); | ||
form.pipe(req); | ||
}); | ||
} | ||
} | ||
exports.default = SauceLabs; |
{ | ||
"name": "saucelabs", | ||
"version": "3.0.1", | ||
"version": "3.1.1", | ||
"author": "Christian Bromann <christian@saucelabs.com>", | ||
@@ -27,3 +27,3 @@ "description": "A wrapper around Sauce Labs REST API", | ||
"generate:docs": "babel-node ./scripts/generate-docs", | ||
"generate:typings": "babel-node ./scripts/generate-typings", | ||
"generate:typings": "", | ||
"prepublishOnly": "NODE_ENV=production run-s build generate:typings", | ||
@@ -40,2 +40,3 @@ "release": "npm run release:patch", | ||
"change-case": "^3.1.0", | ||
"form-data": "^3.0.0", | ||
"hash.js": "^1.1.7", | ||
@@ -42,0 +43,0 @@ "request": "^2.88.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
240534
5
6992
1
+ Addedform-data@^3.0.0
+ Addedform-data@3.0.2(transitive)