Comparing version 0.0.2 to 0.1.0
var GitHubApi = require("github"); | ||
var Promise = require("bluebird"); | ||
@@ -13,3 +12,7 @@ var github = new GitHubApi({ | ||
function harUrl(harObject) { | ||
function viewerUrl(fileUrl) { | ||
return "http://www.softwareishard.com/har/viewer?inputUrl=" + fileUrl; | ||
} | ||
function harUrl(harObject, cb) { | ||
// Gists require a filename, so we use a timestamp | ||
@@ -24,6 +27,9 @@ var filename = Date.now().toString(); | ||
}; | ||
var createGist = Promise.promisify(github.gists.create); | ||
return createGist(gistOptions).then(function (res) { | ||
var gist = res.files[filename].raw_url; | ||
return 'http://www.softwareishard.com/har/viewer?inputUrl=' + gist; | ||
github.gists.create(gistOptions, function (err, res) { | ||
if (err) { | ||
return cb(err); | ||
} else { | ||
var gist = res.files[filename].raw_url; | ||
return cb(null, viewerUrl(gist)); | ||
} | ||
}); | ||
@@ -30,0 +36,0 @@ } |
62
har.js
#!/usr/bin/env node | ||
var harUrl = require("./har-online.js").harUrl; | ||
var Promise = require("bluebird"); | ||
var validUrl = require("valid-url"); | ||
var fs = Promise.promisifyAll(require("fs")); | ||
var request = Promise.promisify(require("request")); | ||
function success(res) { | ||
console.log(res); | ||
process.exit(0); | ||
} | ||
function failure() { | ||
console.error("Invalid URL or HAR file!"); | ||
process.exit(1); | ||
} | ||
function missingFile(err) { | ||
console.error("File doesn't exist: " + err.path); | ||
process.exit(1); | ||
} | ||
function tryJson(str) { | ||
@@ -32,24 +12,30 @@ try { | ||
function harFromInput(input) { | ||
function harFromInput(input, cb) { | ||
var json = tryJson(input); | ||
if (validUrl.isUri(input)) { | ||
return request(input).spread(function (res, body) { | ||
return harUrl(JSON.parse(body)); | ||
}); | ||
} else if (json) { | ||
return harUrl(json); | ||
if (json) { | ||
return harUrl(json, cb); | ||
} else { | ||
return fs.readFileAsync(input).then(function (file) { | ||
return harUrl(JSON.parse(file)); | ||
}, missingFile).then(success, failure); | ||
return cb("Invalid HAR file"); | ||
} | ||
} | ||
var stdinSize = fs.fstatSync(process.stdin.fd).size; | ||
var input; | ||
if (stdinSize > 0) { | ||
input = fs.readSync(process.stdin.fd, stdinSize)[0]; | ||
} else { | ||
input = process.argv[process.argv.length - 1]; | ||
} | ||
harFromInput(input).then(success, failure); | ||
process.stdin.setEncoding("utf-8"); | ||
var input = []; | ||
process.stdin.on("readable", function () { | ||
var chunk = process.stdin.read(); | ||
if (chunk != null) { | ||
input.push(chunk); | ||
} | ||
}); | ||
process.stdin.on("end", function () { | ||
harFromInput(input.join(""), function (err, url) { | ||
if (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} else { | ||
console.log(url); | ||
process.exit(0); | ||
} | ||
}); | ||
}); | ||
{ | ||
"name": "har-online", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "View HAR files at http://www.softwareishard.com/har/viewer/", | ||
@@ -21,7 +21,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"github": "0.2.4", | ||
"bluebird": "2.9.30", | ||
"valid-url": "1.0.9", | ||
"request": "2.58.0" | ||
"github": "0.2.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
0
21005
69
- Removedbluebird@2.9.30
- Removedrequest@2.58.0
- Removedvalid-url@1.0.9
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@2.6.4(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedbl@0.9.5(transitive)
- Removedbluebird@2.9.30(transitive)
- Removedboom@2.10.1(transitive)
- Removedcaseless@0.10.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedextend@2.0.2(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@1.0.1(transitive)
- Removedgenerate-function@2.3.1(transitive)
- Removedgenerate-object-property@1.2.0(transitive)
- Removedhar-validator@1.8.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhawk@2.3.1(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhttp-signature@0.11.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-my-ip-valid@1.0.1(transitive)
- Removedis-my-json-valid@2.20.6(transitive)
- Removedis-property@1.0.2(transitive)
- Removedisarray@0.0.1(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonpointer@5.0.1(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime-db@1.12.01.52.0(transitive)
- Removedmime-types@2.0.142.1.35(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.8.2(transitive)
- Removedqs@3.1.0(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedrequest@2.58.0(transitive)
- Removedsntp@1.0.9(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedtldts@6.1.71(transitive)
- Removedtldts-core@6.1.71(transitive)
- Removedtough-cookie@5.1.0(transitive)
- Removedtunnel-agent@0.4.3(transitive)
- Removedvalid-url@1.0.9(transitive)
- Removedxtend@4.0.2(transitive)