Skip to content

Commit

Permalink
Merge pull request #12 from snyk/chore/test-and-release
Browse files Browse the repository at this point in the history
Chore/test and release
  • Loading branch information
adrukh authored Aug 6, 2018
2 parents 30e1059 + 459877a commit f77b7bf
Show file tree
Hide file tree
Showing 13 changed files with 294 additions and 169 deletions.
52 changes: 52 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"parserOptions": {
"ecmaVersion": 6
},
"env": {
"node": true,
"es6": true
},
"rules": {
"array-bracket-spacing": [2, "never"],
"block-scoped-var": 2,
"brace-style": 2,
"camelcase": 1,
"comma-dangle": ["error", "always-multiline"],
"computed-property-spacing": [2, "never"],
"curly": 2,
"eol-last": 2,
"eqeqeq": [2, "smart"],
"guard-for-in": 2,
"indent": [
2,
2,
{
"SwitchCase": 1
}
],
"max-depth": [1, 3],
"max-len": [1, 80],
"max-statements": [1, 30],
"new-cap": 0,
"no-caller": 2,
"no-else-return": 2,
"no-extend-native": 2,
"no-mixed-spaces-and-tabs": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-unused-vars": 1,
"no-use-before-define": [2, "nofunc"],
"object-curly-spacing": [2, "never"],
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "always"],
"keyword-spacing": [2, {"before": true, "after": true}],
"space-before-function-paren": [
2,
{
"anonymous": "ignore",
"named": "never"
}
],
"space-unary-ops": 2
}
}
13 changes: 8 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ To release a major you need to add `BREAKING CHANGE: ` to the start of the body

## Code standards

Ensure that your code adheres to the included `.jshintrc` and `.jscsrc` configs.
Ensure that your code adheres to the included `.eslintrc` config by running `npm run lint`.

## Sending pull requests

- new command line options are generally discouraged unless there's a *really* good reason
- add tests for newly added code (and try to mirror directory and file structure if possible)
- spell check
- PRs will not be code reviewed unless all tests are passing
- PRs will not be code reviewed unless all tests are passing (run `npm test`)

*Important:* when fixing a bug, please commit a **failing test** first so that Travis CI (or I can) can show the code failing. Once that commit is in place, then commit the bug fix, so that we can test *before* and *after*.
*Important:* when fixing a bug, please commit a **failing test** first demonstrate the current code is failing. Once that commit is in place, then commit the bug fix, so that we can test *before* and *after*.

Remember that you're developing for multiple platforms and versions of node, so if the tests pass on your Mac or Linux or Windows machine, it *may* not pass elsewhere.
Remember that you're developing for multiple platforms and versions of node, so if the tests pass on your Mac or Linux or Windows machine, it *may* not pass elsewhere.

## Contributor Agreement

A pull-request will only be considered for merging into the upstream codebase after you have signed our [contributor agreement](https://github.com/snyk/snyk-gradle-plugin/blob/master/Contributor-Agreement.md), assigning us the rights to the contributed code and granting you a license to use it in return. If you submit a pull request, you will be prompted to review and sign the agreement with one click (we use [CLA assistant](https://cla-assistant.io/)).
14 changes: 0 additions & 14 deletions .jscsrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ node_js:
cache:
directories:
- node_modules
script: npm run test && npm run test-system
script:
- npm test
- npm run test-system
jobs:
include:
- stage: npm release
node_js: "8" # This *has* to be the "build leader"
script: skip
after_success:
- TRAVIS_JOB_NUMBER=WORKAROUND.1 npm run semantic-release
- npm run semantic-release
branches:
only:
- master
39 changes: 39 additions & 0 deletions Contributor-Agreement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Snyk CLI tool contributor agreement

This Snyk CLI tool Agreement (this **"Agreement"**) applies to any Contribution you make to any Work.

This is a binding legal agreement on you and any organization you represent. If you are signing this Agreement on behalf of your employer or other organization, you represent and warrant that you have the authority to agree to this Agreement on behalf of the organization.

## 1. Definitions

**"Contribution"** means any original work, including any modification of or addition to an existing work, that you submit to Snyk CLI tool repo in any manner for inclusion in any Work.

**"Snyk", "we"** and **"us"** means Snyk Ltd.

**"Work"** means any project, work or materials owned or managed by Snyk Ltd.

**"You"** and **"your"** means you and any organization on whose behalf you are entering this Agreement.

## 2. Copyright Assignment, License and Waiver

**(a) Assignment.** By submitting a Contribution, you assign to Snyk all right, title and interest in any copright you have in the Contribution, and you waive any rights, including any moral rights, database rights, etc., that may affect your ownership of the copyright in the Contribution.

**(b) License to Snyk.** If your assignment in Section 2(a) is ineffective for any reason, you grant to us and to any recipient of any Work distributed by use, a perpetual, worldwide, transferable, non-exclusive, no-charge, royalty-free, irrevocable, and sublicensable licence to use, reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Contributions and any derivative work created based on a Contribution. If your license grant is ineffective for any reason, you irrevocably waive and covenant to not assert any claim you may have against us, our successors in interest, and any of our direct or indirect licensees and customers, arising out of our, our successors in interest's, or any of our direct or indirect licensees' or customers' use, reproduction, preparation of derivative works, public display, public performance, sublicense, and distribution of a Contribution. You also agree that we may publicly use your name and the name of any organization on whose behalf you're entering into this Agreement in connection with publicizing the Work.

**(c) License to you.** We grant to you a perpetual, worldwide, transferable, non-exclusive, no-charge, royalty-free, irrevocable, and sublicensable license to use, reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute a Contribution and any derivative works you create based on a Contribution.

## 3. Patent License
You grant to us and to any recipient of any Work distributed by us, a perpetual, worldwide, transferable, non-exclusive, no-charge, royalty-free, irrevocable, and sublicensable patent license to make, have made, use, sell, offer to sell, import, and otherwise transfer the Contribution in whole or in part, along or included in any Work under any patent you own, or license from a third party, that is necessarily infringed by the Contribution or by combination of the Contribution with any Work.

## 4. Your Representation and Warranties.
By submitting a Contribution, you represent and warrant that: (a) each Contribution you submit is an original work and you can legally grant the rights set out in this Agreement; (b) the Contribution does not, and any exercise of the rights granted by you will not, infringe any third party's intellectual property or other right; and (c) you are not aware of any claims, suits, or actions pertaining to the Contribution. You will notify us immediately if you become aware or have reason to believe that any of your representations and warranties is or becomes inaccurate.

##5. Intellectual Property
Except for the assignment and licenses set forth in this Agreement, this Agreement does not transfer any right, title or interest in any intellectual property right of either party to the other. If you choose to provide us with suggestions, ideas for improvement, recommendations or other feedback, on any Work we may use your feedback without any restriction or payment.

## Miscellaneous
English law governs this Agreement, excluding any applicable conflict of laws rules or principles, and the parties agree to the exclusive jurisdiction of the courts in England, UK. This Agreement does not create a partnership, agency relationship, or joint venture between the parties. We may assign this Agreement without notice or restriction. If any provision of this Agreement is unenforcable, that provision will be modified to render it enforceable to the extent possible to effect the parties' intention and the remaining provisions will not be affected. The parties may amend this Agreement only in a written amendment signed by both parties. This Agreement comprises the parties' entire agreement relating to the subject matter of this Agreement.

**Agreed and accepted on my behalf and on behalf of my organization**

Our contributor agreement is based on the [mongoDB contributor agreement] (https://www.mongodb.com/legal/contributor-agreement).
34 changes: 34 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# https://www.appveyor.com/docs/appveyor-yml

# to disable automatic builds
build: off
branches:
only:
- master

init:
- git config --global core.autocrlf true

shallow_clone: true
clone_depth: 1

cache:
- node_modules -> package.json

environment:
matrix:
- nodejs_version: "8"
- nodejs_version: "6"
- nodejs_version: "4"

matrix:
fast_finish: true

install:
- ps: Install-Product node $env:nodejs_version
- node --version
- npm --version
- npm install

test_script:
- npm run test
82 changes: 41 additions & 41 deletions lib/gradle-dep-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
function parse(text, from) {
var data = processGradleOutput(text);
var depArray = createTree(
data.lines, data.omittedDeps, { from: [from] });
data.lines, data.omittedDeps, {from: [from]});
fillOmittedDependencies(depArray, data.omittedDeps);
var depTree = convertNodeArrayToObject(depArray);
return depTree;
Expand All @@ -16,54 +16,54 @@ function parse(text, from) {
function processGradleOutput(text) {
var omittedDeps = {};
var lines = text.split('\n')
.filter(function (element) {
.filter(function (element) {
// filter out stuff that isn't dependencies
return element.indexOf('\\---') !== -1 ||
return element.indexOf('\\---') !== -1 ||
element.indexOf('+---') !== -1 ||
element === '';
})
.reduce(function (acc, element) {
})
.reduce(function (acc, element) {
// only return the first configuration, in case there are multiple
if (acc.done) {
return acc;
}
if (element === '') {
if (acc.length > 0) {
acc.done = true;
if (acc.done) {
return acc;
}
if (element === '') {
if (acc.length > 0) {
acc.done = true;
}
return acc;
}
acc.push(element);
return acc;
}
acc.push(element);
return acc;
}, [])
.filter(function (element) {
}, [])
.filter(function (element) {
// filter out FAILED dependencies
return element.match(/ FAILED$/) === null;
})
.map(function (element) {
return element.match(/ FAILED$/) === null;
})
.map(function (element) {
// remove all hierarchy markings, but keep the hierarchy structure
element = element
.replace(/\|/g, ' ') // remove pipe symbol
.replace(/\\/g, '+') // convert all prefixes to '+---'
.replace(/\+\-\-\-/g, ' ') // remove all prefixes
.replace(/ /g, ' '); // convert each 5 spaces to 1 space
// update the element with its resolved version, if exists
var elementParts = element.split(' -> ');
if (elementParts.length > 1) {
element = element.replace(/[^:]*$/, elementParts[1]);
}
// mark omitted dependencies for later review,
// and remove the '(*)' at the end of the element
var omitStarSplit = element.split(' (*)');
if (omitStarSplit.length > 1) {
element = omitStarSplit[0];
var parts = element.split(':');
// omittedDeps key is 'groupId:artifactId' (without the version)
omittedDeps[parts[0].trim() + ':' + parts[1]] = true;
}
element = element
.replace(/\|/g, ' ') // remove pipe symbol
.replace(/\\/g, '+') // convert all prefixes to '+---'
.replace(/\+\-\-\-/g, ' ') // remove all prefixes
.replace(/ /g, ' '); // convert each 5 spaces to 1 space
// update the element with its resolved version, if exists
var elementParts = element.split(' -> ');
if (elementParts.length > 1) {
element = element.replace(/[^:]*$/, elementParts[1]);
}
// mark omitted dependencies for later review,
// and remove the '(*)' at the end of the element
var omitStarSplit = element.split(' (*)');
if (omitStarSplit.length > 1) {
element = omitStarSplit[0];
var parts = element.split(':');
// omittedDeps key is 'groupId:artifactId' (without the version)
omittedDeps[parts[0].trim() + ':' + parts[1]] = true;
}

return element;
});
return element;
});
return {
lines: lines,
omittedDeps: omittedDeps,
Expand All @@ -77,7 +77,7 @@ function getIndent(line) {
return 0;
}

function getElementAsObject(element, parentElement) {
function getElementAsObject(element) {
if (!element) {
return null;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/gradle-jar-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function parse(text) {
var ext = '.jar';
if (text && text.length) {
return text.split('\n')
.map(trim)
.filter(function (line) {
return line && line.length > ext.length &&
.map(trim)
.filter(function (line) {
return line && line.length > ext.length &&
line.substr(line.length - ext.length, ext.length) === ext;
});
});
}
return [];
}
Expand Down
Loading

0 comments on commit f77b7bf

Please sign in to comment.