Comparing version 1.0.1 to 2.0.0
var fs = require('fs'); | ||
var path = require('path'); | ||
var request = require('request'); | ||
var urlgrey = require('urlgrey'); | ||
var execSync = require('child_process').execSync; | ||
if (!execSync) { | ||
var exec = require('execSync').exec; | ||
var execSync = function(cmd){ | ||
return exec(cmd).stdout; | ||
}; | ||
} | ||
@@ -77,3 +72,3 @@ var detectProvider = require('./detect'); | ||
var sendToCodecovV2 = function(codecov_endpoint, query, body, on_success, on_failure){ | ||
var sendToCodecovV2 = function(codecov_endpoint, query, upload_body, on_success, on_failure){ | ||
// Direct to Codecov | ||
@@ -83,3 +78,3 @@ request.post( | ||
url : urlgrey(codecov_endpoint + '/upload/v2').query(query).toString(), | ||
body : body, | ||
body : upload_body, | ||
headers : { | ||
@@ -89,6 +84,6 @@ 'Content-Type': 'text/plain', | ||
} | ||
}, function(err, response, body){ | ||
}, function(err, response, result){ | ||
if (err || response.statusCode !== 200) { | ||
console.log(' ' + (err || response.body)); | ||
return on_failure(response.statusCode, response.body); | ||
return response ? on_failure(response.statusCode, response.body) : on_failure(err.code, err.message); | ||
@@ -107,3 +102,3 @@ } else { | ||
var sendToCodecovV3 = function(codecov_endpoint, query, body, on_success, on_failure){ | ||
var sendToCodecovV3 = function(codecov_endpoint, query, upload_body, on_success, on_failure){ | ||
// Direct to S3 | ||
@@ -120,3 +115,3 @@ request.post( | ||
if (err) { | ||
sendToCodecovV2(codecov_endpoint, query, body, on_success, on_failure); | ||
sendToCodecovV2(codecov_endpoint, query, upload_body, on_success, on_failure); | ||
@@ -128,3 +123,3 @@ } else { | ||
url : result.split('\n')[1], | ||
body : body, | ||
body : upload_body, | ||
headers : { | ||
@@ -136,3 +131,3 @@ 'Content-Type': 'plain/text', | ||
if (err) { | ||
sendToCodecovV2(codecov_endpoint, query, body, on_success, on_failure); | ||
sendToCodecovV2(codecov_endpoint, query, upload_body, on_success, on_failure); | ||
@@ -168,2 +163,6 @@ } else { | ||
query.yaml = ['codecov.yml', '.codecov.yml'].reduce(function (result, file) { | ||
return result || (fs.existsSync(path.resolve(process.cwd(), file)) ? file : undefined) | ||
}, undefined) | ||
if ((args.options.disable || '').split(',').indexOf('detect') === -1) { | ||
@@ -170,0 +169,0 @@ console.log('==> Detecting CI Provider'); |
@@ -16,6 +16,21 @@ module.exports = { | ||
pr: process.env.CIRCLE_PR_NUMBER, | ||
slug : process.env.CIRCLE_PROJECT_USERNAME + '/' + process.env.CIRCLE_PROJECT_REPONAME, | ||
slug : detectRepoSlug(), | ||
}; | ||
function detectRepoSlug(){ | ||
if (process.env.CIRCLE_PROJECT_REPONAME) { | ||
// CircleCI 1.0 | ||
// CIRCLE_PROJECT_REPONAME=codecov | ||
// CIRCLE_PROJECT_USERNAME=codecov-node | ||
// CIRCLE_REPOSITORY_URL=https://github.com/codecov/codecov-node (note: GitHub Web URL) | ||
return process.env.CIRCLE_PROJECT_USERNAME + '/' + process.env.CIRCLE_PROJECT_REPONAME; | ||
} | ||
if (process.env.CIRCLE_REPOSITORY_URL) { | ||
// CircleCI 2.0 | ||
// CIRCLE_REPOSITORY_URL=git@github.com:codecov/codecov-node.git (note: Git/SSH URL) | ||
return process.env.CIRCLE_REPOSITORY_URL.replace(/^.*:/, '').replace(/\.git$/, ''); | ||
} | ||
throw new Error('Cannot detect repository slug.'); | ||
} | ||
} | ||
}; |
var execSync = require('child_process').execSync; | ||
if (!execSync) { | ||
var exec = require('execSync').exec; | ||
var execSync = function(cmd){ | ||
return exec(cmd).stdout; | ||
}; | ||
} | ||
@@ -9,0 +3,0 @@ module.exports = { |
@@ -1,3 +0,2 @@ | ||
// http://doc.gitlab.com/ci/examples/README.html#environmental-variables | ||
// https://gitlab.com/gitlab-org/gitlab-ci-runner/blob/master/lib/build.rb#L96 | ||
// https://docs.gitlab.com/ce/ci/variables/README.html | ||
@@ -7,3 +6,3 @@ module.exports = { | ||
detect : function(){ | ||
return process.env.CI_SERVER_NAME == 'GitLab CI'; | ||
return !!process.env.GITLAB_CI; | ||
}, | ||
@@ -10,0 +9,0 @@ |
var execSync = require('child_process').execSync; | ||
if (!execSync) { | ||
var exec = require('execSync').exec; | ||
var execSync = function(cmd){ | ||
return exec(cmd).stdout; | ||
}; | ||
} | ||
@@ -9,0 +3,0 @@ module.exports = { |
{ | ||
"name": "codecov", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Uploading report to Codecov: https://codecov.io", | ||
@@ -22,2 +22,5 @@ "main": "index.js", | ||
}, | ||
"engines": { | ||
"node": ">=0.12" | ||
}, | ||
"author": "Codecov <hello@codecov.io>", | ||
@@ -30,13 +33,12 @@ "license": "MIT", | ||
"dependencies": { | ||
"request": ">=2.42.0", | ||
"urlgrey": ">=0.4.0", | ||
"argv": ">=0.0.2", | ||
"execSync": "1.0.2" | ||
"request": "2.79.0", | ||
"urlgrey": "0.4.4", | ||
"argv": "0.0.2" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "0.3.1", | ||
"istanbul": "0.3.2", | ||
"jshint": "2.5.5", | ||
"mocha": "2.2.1" | ||
"expect.js": "^0.3.1", | ||
"istanbul": "^0.4.5", | ||
"jshint": "^2.9.3", | ||
"mocha": "^3.0.2" | ||
} | ||
} |
@@ -13,3 +13,3 @@ # Codecov NodeJS Uploader | ||
``` | ||
npm install codecov --save | ||
npm install codecov --save-dev | ||
``` | ||
@@ -59,22 +59,7 @@ | ||
---- | ||
## Advanced: Partial Line Coverage | ||
**Codecov does support partial line coverage**. However, some node projects do not report partial coverage accurate enough. | ||
You can decide to upload the partial coverage report by chaning the target upload file to `./coverage/coverage.json`. | ||
View your report on Codecov, if the reports are not accurate then switch back to the `lcov` provided above. | ||
We are working on improving this implementation and appreciate your patience. | ||
## Contributing | ||
I generally don't accept pull requests that are untested, or break the build, because I'd like to keep the quality high (this is a coverage tool afterall!). | ||
I also don't care for "soft-versioning" or "optimistic versioning" (dependencies that have ^, x, > in them, or anything other than numbers and dots). There have been too many problems with bad semantic versioning in dependencies, and I'd rather have a solid library than a bleeding edge one. | ||
[travis-image]: https://travis-ci.org/codecov/codecov-node.svg?branch=master | ||
[travis-url]: https://travis-ci.org/codecov/codecov-node | ||
[npm-url]: https://npmjs.org/package/codecov.io | ||
[npm-image]: https://img.shields.io/npm/v/codecov.io.svg | ||
[npm-url]: https://npmjs.org/package/codecov | ||
[npm-image]: https://img.shields.io/npm/v/codecov.svg | ||
@@ -86,1 +71,9 @@ [depstat-url]: https://david-dm.org/codecov/codecov-node | ||
[devdepstat-image]: https://img.shields.io/david/dev/codecov/codecov-node/master.svg | ||
**With NYC** | ||
``` | ||
nyc npm test | ||
nyc report --reporter=text-lcov > coverage.lcov | ||
./node_modules/.bin/codecov | ||
``` |
@@ -54,7 +54,7 @@ var fs = require('fs'); | ||
it("can detect .bowerrc with directory", function(){ | ||
fs.writeFileSync('.bowerrc', '{"directory": "test"}'); | ||
var res = codecov.upload({options: {dump: true}}); | ||
expect(res.files).to.eql([]); | ||
}); | ||
// it("can detect .bowerrc with directory", function(){ | ||
// fs.writeFileSync('.bowerrc', '{"directory": "test"}'); | ||
// var res = codecov.upload({options: {dump: true}}); | ||
// expect(res.files).to.eql([]); | ||
// }); | ||
@@ -61,0 +61,0 @@ it("can detect .bowerrc without directory", function(){ |
@@ -10,3 +10,3 @@ var circle = require("../../lib/services/circle"); | ||
it ("can get circle env info get_commit_status", function(){ | ||
it ("can get circle env info (CircleCI 1.0)", function(){ | ||
process.env.CIRCLECI = 'true'; | ||
@@ -31,2 +31,36 @@ process.env.CIRCLE_BUILD_NUM = '1234'; | ||
it ("can get circle env info (CircleCI 2.0)", function(){ | ||
process.env.CIRCLECI = 'true'; | ||
process.env.CIRCLE_BRANCH = 'master'; | ||
process.env.CIRCLE_BUILD_NUM = '1234'; | ||
process.env.CIRCLE_SHA1 = 'abcd'; | ||
process.env.CIRCLE_NODE_INDEX = '1'; | ||
process.env.CIRCLE_BUILD_URL = 'https://circleci.com/gh/owner/repo/1234'; | ||
process.env.CIRCLE_COMPARE_URL = 'https://github.com/owner/repo/2408ca9...3c36cfa'; | ||
process.env.CIRCLE_NODE_INDEX = '1'; | ||
process.env.CIRCLE_REPOSITORY_URL = 'git@github.com:owner/repo.git'; | ||
delete process.env.CIRCLE_PR_NUMBER; | ||
delete process.env.CIRCLE_PROJECT_USERNAME; | ||
delete process.env.CIRCLE_PROJECT_REPONAME; | ||
expect(circle.configuration()).to.eql({ | ||
service : 'circleci', | ||
commit : 'abcd', | ||
build : '1234.1', | ||
job : '1234.1', | ||
branch : 'master', | ||
pr : undefined, | ||
slug : 'owner/repo' | ||
}); | ||
}); | ||
it ("throws if repo slug cannot be detected", function(){ | ||
delete process.env.CIRCLE_PR_NUMBER; | ||
delete process.env.CIRCLE_PROJECT_USERNAME; | ||
delete process.env.CIRCLE_PROJECT_REPONAME; | ||
delete process.env.CIRCLE_REPOSITORY_URL; | ||
expect(function(){ | ||
circle.configuration(); | ||
}).to.throw(Error); | ||
}); | ||
}); |
@@ -6,3 +6,3 @@ var gitlab = require("../../lib/services/gitlab"); | ||
it ("can detect gitlab", function(){ | ||
process.env.CI_SERVER_NAME = "GitLab CI"; | ||
process.env.GITLAB_CI = "true"; | ||
expect(gitlab.detect()).to.be(true); | ||
@@ -9,0 +9,0 @@ }); |
@@ -26,6 +26,7 @@ var snap = require("../../lib/services/snap"); | ||
it ("can get snap env info get_commit_status for pull requests", function(){ | ||
process.env.SNAP_COMMIT = ''; | ||
process.env.SNAP_BRANCH = ''; | ||
process.env.SNAP_CI = "true"; | ||
process.env.SNAP_PIPELINE_COUNTER = '1234'; | ||
process.env.SNAP_COMMIT = '5678'; | ||
process.env.SNAP_UPSTREAM_COMMIT = '5678'; | ||
process.env.SNAP_UPSTREAM_BRANCH = 'upstream-branch'; | ||
@@ -32,0 +33,0 @@ process.env.SNAP_PULL_REQUEST_NUMBER = 'blah'; |
var fs = require('fs'); | ||
var codecov = require("../lib/codecov"); | ||
var codecov = require('../lib/codecov'); | ||
var offlineErrors = require('../lib/offline'); | ||
var execSync = require('child_process').execSync; | ||
@@ -14,5 +15,6 @@ if (!execSync) { | ||
it("can get upload to v2", function(done){ | ||
var self = this; | ||
codecov.sendToCodecovV2('https://codecov.io', | ||
{ | ||
token: '473c8c5b-10ee-4d83-86c6-bfd72a185a27', | ||
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506', | ||
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a', | ||
@@ -23,7 +25,11 @@ branch: 'master' | ||
function(body){ | ||
expect(body).to.contain('http://codecov.io/github/codecov/ci-repo?ref=c739768fcac68144a3a6d82305b9c4106934d31a'); | ||
expect(body).to.contain('https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a'); | ||
done(); | ||
}, | ||
function(err){ | ||
throw err; | ||
function(errCode, errMsg){ | ||
if(offlineErrors.indexOf(errCode) !== -1){ | ||
self.skip(); // offline - we can not test upload | ||
return; | ||
} | ||
throw new Error(errMsg); | ||
}); | ||
@@ -33,5 +39,7 @@ }); | ||
it("can get upload to v3", function(done){ | ||
var self = this; | ||
this.timeout(3000); // give this test extra time to run (default is 2000ms) | ||
codecov.sendToCodecovV3('https://codecov.io', | ||
{ | ||
token: '473c8c5b-10ee-4d83-86c6-bfd72a185a27', | ||
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506', | ||
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a', | ||
@@ -42,10 +50,36 @@ branch: 'master' | ||
function(body){ | ||
expect(body).to.contain('http://codecov.io/github/codecov/ci-repo?ref=c739768fcac68144a3a6d82305b9c4106934d31a'); | ||
expect(body).to.contain('https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a'); | ||
done(); | ||
}, | ||
function(err){ | ||
throw err; | ||
function(errCode, errMsg){ | ||
if(offlineErrors.indexOf(errCode) !== -1){ | ||
self.skip(); // offline - we can not test upload | ||
return; | ||
} | ||
throw new Error(errMsg); | ||
}); | ||
}); | ||
it("upload v2 doesn't throw runtime error", function(done){ | ||
expect(codecov.sendToCodecovV2.bind(null, | ||
'https://codecov.io', | ||
{ | ||
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506', | ||
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a', | ||
branch: 'master' | ||
}, | ||
'testing node-'+codecov.version, | ||
function(body){ | ||
expect(body).to.contain('https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a'); | ||
done(); | ||
}, | ||
function(errCode, errMsg){ | ||
if(offlineErrors.indexOf(errCode) !== -1){ | ||
done(); | ||
} | ||
throw new Error(errMsg); | ||
} | ||
)).to.not.throwException(); | ||
}) | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 11 instances 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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
48434
3
45
1116
77
139
9
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedargv@0.0.2(transitive)
+ Addedassert-plus@0.2.0(transitive)
+ Addedaws-sign2@0.6.0(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedcaseless@0.11.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedform-data@2.1.4(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedhar-validator@2.0.6(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhawk@3.1.3(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedhttp-signature@1.1.1(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedoauth-sign@0.8.2(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.3.3(transitive)
+ Addedrequest@2.79.0(transitive)
+ Addedsntp@1.0.9(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedtough-cookie@2.3.4(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedurlgrey@0.4.4(transitive)
+ Addedxtend@4.0.2(transitive)
- RemovedexecSync@1.0.2
- Removedajv@6.12.6(transitive)
- Removedargv@0.0.3(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedcaseless@0.12.0(transitive)
- RemovedexecSync@1.0.2(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgraceful-fs@1.2.3(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrimraf@2.1.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedtemp@0.5.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedurlgrey@2.1.0(transitive)
Updatedargv@0.0.2
Updatedrequest@2.79.0
Updatedurlgrey@0.4.4