Skip to content

Commit

Permalink
makes main (and the extract/index.js) always return a summary
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Dec 11, 2016
1 parent c3a322d commit dbfe694
Show file tree
Hide file tree
Showing 50 changed files with 3,356 additions and 1,561 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ tmp
utl
src/report/*.template.js
test/cli/fixtures/**
test/main/fixtures/**
test/extract/fixtures/**
108 changes: 108 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,111 @@ test/validate/readRuleSet.spec.js: \
test/validate/validate.spec.js: \
src/validate/index.js \
src/validate/readRuleSet.js
# cjs dependencies
test/cli/cli.spec.js: \
src/cli/processCLI.js \
test/utl/testutensils.js

src/cli/processCLI.js: \
src/cli/normalizeOptions.js \
src/cli/validateParameters.js \
src/main/index.js \
src/validate/readRuleSet.js

src/main/index.js: \
src/extract/index.js \
src/report/csvReporter.js \
src/report/dotReporter.js \
src/report/errReporter.js \
src/report/htmlReporter.js \
src/report/jsonReporter.js \
src/report/visReporter.js

src/extract/index.js: \
src/extract/extract.js \
src/extract/gatherInitialSources.js

src/extract/extract.js: \
src/extract/extract-AMD.js \
src/extract/extract-ES6.js \
src/extract/extract-commonJS.js \
src/resolve/index.js \
src/utl/index.js \
src/validate/index.js

src/resolve/index.js: \
src/resolve/resolve-AMD.js \
src/resolve/resolve-commonJS.js

src/resolve/resolve-AMD.js: \
src/utl/index.js

src/extract/extract-AMD.js: \
src/extract/extract-commonJS.js

src/extract/gatherInitialSources.js: \
src/utl/index.js

src/report/csvReporter.js: \
src/report/csv.template.js \
src/report/dependencyToIncidenceTransformer.js

src/report/dotReporter.js: \
src/report/dot.template.js

src/report/htmlReporter.js: \
src/report/dependencyToIncidenceTransformer.js \
src/report/html.template.js

src/report/visReporter.js: \
src/report/vis.template.js

src/validate/readRuleSet.js: \
src/validate/normalizeRuleSet.js \
src/validate/validateRuleSet.js

src/validate/validateRuleSet.js: \
src/validate/jsonschema.json

src/cli/validateParameters.js: \
src/utl/index.js

test/cli/normalizeOptions.spec.js: \
src/cli/normalizeOptions.js

test/cli/validateParameters.spec.js: \
src/cli/validateParameters.js

test/extract/extract-composite.spec.js: \
src/extract/index.js \
src/extract/jsonschema.json

test/extract/extract.spec.js: \
src/extract/extract.js

test/extract/gatherInitialSources.spec.js: \
src/extract/gatherInitialSources.js

test/main/main.spec.js: \
src/extract/jsonschema.json \
src/main/index.js

test/report/dotReporter.spec.js: \
src/report/dotReporter.js

test/report/errReporter.spec.js: \
src/report/errReporter.js

test/report/htmlReporter.spec.js: \
src/report/htmlReporter.js

test/validate/normalizeRuleSet.spec.js: \
src/validate/normalizeRuleSet.js

test/validate/readRuleSet.spec.js: \
src/validate/readRuleSet.js

test/validate/validate.spec.js: \
src/validate/index.js \
src/validate/readRuleSet.js

13 changes: 9 additions & 4 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ These are all the options:
dependencies : when outputType is defined: a string containing the dependencies
in the format specified in outputType
In all other cases: a javascript with the dependencies
meta : meta data with a summary of
{ error : the number of errors,
summary : a summary of the violations found in the dependencies:
{
violations: each violation;
from: the resolved 'from'
to: the resolved 'to'
rule: the violated rule, which consists of a
name: the (short) name of the rule
severity: the severetiy of the violation (error, warn or info)
error : the number of errors,
warn : the number of warnings,
info : the number of informational messages
}
(currently meta is filled for 'err' only - NOTE: we'll change this to
always return this in the near future)
}
```
195 changes: 102 additions & 93 deletions doc/output-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,107 @@ A sample output (for the popular [commander.js](https://github.com/tj/commander.
module):

```json
[
{
"source": "commander/index.js",
"dependencies": [
{
"resolved": "child_process",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "child_process",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "events",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "events",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "fs",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "fs",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "graceful-readlink/index.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"module": "graceful-readlink",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "path",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "path",
"moduleSystem": "cjs",
"valid": true
}
]
},
{
"source": "child_process",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "events",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "fs",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "path",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "graceful-readlink/index.js",
"dependencies": [
{
"resolved": "fs",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "fs",
"moduleSystem": "cjs",
"valid": true
}
]
{
"dependencies": [
{
"source": "commander/index.js",
"dependencies": [
{
"resolved": "child_process",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "child_process",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "events",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "events",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "fs",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "fs",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "graceful-readlink/index.js",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"module": "graceful-readlink",
"moduleSystem": "cjs",
"valid": true
},
{
"resolved": "path",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "path",
"moduleSystem": "cjs",
"valid": true
}
]
},
{
"source": "child_process",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "events",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "fs",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "path",
"followable": false,
"coreModule": true,
"couldNotResolve": false,
"dependencies": []
},
{
"source": "graceful-readlink/index.js",
"dependencies": [
{
"resolved": "fs",
"coreModule": true,
"followable": false,
"couldNotResolve": false,
"module": "fs",
"moduleSystem": "cjs",
"valid": true
}
]
}
],
"summary" {
"violations": [],
"error": 0,
"warn": 0,
"info": 0

}
]
}
```
15 changes: 4 additions & 11 deletions src/cli/processCLI.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,13 @@ module.exports = (pFileDirArray, pOptions) => {
);
}

let lDependencyList = main(
pFileDirArray,
pOptions
);
let lExitCode = lDependencyList.metaData ? lDependencyList.metaData.error : 0;
const lDependencyList = main(pFileDirArray, pOptions);

write(
pOptions.outputTo,
lDependencyList.dependencies
);
write(pOptions.outputTo, lDependencyList.dependencies);

/* istanbul ignore if */
if (lExitCode > 0) {
process.exit(lExitCode);
if (lDependencyList.summary.error > 0) {
process.exit(lDependencyList.summary.error);
}

} catch (e) {
Expand Down
Loading

0 comments on commit dbfe694

Please sign in to comment.