Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
src: added --full-dependency-tree option (--all)
Browse files Browse the repository at this point in the history
  • Loading branch information
helio-frota committed Nov 21, 2017
1 parent a64f5f7 commit a264b8e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
Empty file modified bin/license-reporter
100644 → 100755
Empty file.
7 changes: 6 additions & 1 deletion lib/commands/console.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ module.exports = () => {
alias: 'ilc',
describe: 'Includes the license content in the xml.',
default: false
},
'full-dependency-tree': {
alias: 'fdt',
describe: 'Will list all production licenses for all modules.',
default: false
}
};

Expand Down Expand Up @@ -60,7 +65,7 @@ module.exports = () => {
checker.check(argv.cwd)
.then((data) => {
const projectMetaData = consoleModule.transform(data,
canonicalNameMapper, argv.cwd, argv.ilc);
canonicalNameMapper, argv.cwd, argv.ilc, argv.fdt);
console.log(consoleModule.asXML(projectMetaData));
})
.catch((e) => {
Expand Down
7 changes: 6 additions & 1 deletion lib/commands/report.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ module.exports = () => {
describe: 'CSS file to apply style on html report.',
default: join(__dirname, '../modules/resources/licenses.css'),
nargs: 1
},
'full-dependency-tree': {
alias: 'fdt',
describe: 'Will list all production licenses for all modules.',
default: false
}
};

Expand Down Expand Up @@ -68,7 +73,7 @@ module.exports = () => {
checker.check(argv.cwd)
.then((data) => {
const projectMetaData = reportModule.transform(data,
canonicalNameMapper, argv.cwd, argv.ilc);
canonicalNameMapper, argv.cwd, argv.ilc, argv.fdt);
reportModule.report(projectMetaData, argv.css);
})
.catch((e) => {
Expand Down
9 changes: 7 additions & 2 deletions lib/commands/save.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ module.exports = () => {
default: join(__dirname, '../modules/resources/default-unified-list.json'),
nargs: 1
},
'full-dependency-tree': {
alias: 'fdt',
describe: 'Will list all production licenses for all modules.',
default: false
},
xml: {
describe: 'Saves as XML.',
type: 'string',
Expand All @@ -47,7 +52,7 @@ module.exports = () => {
describe: 'Saves as YAML.',
type: 'string',
nargs: 1
}
}
};

cmd.handler = (argv) => {
Expand Down Expand Up @@ -79,7 +84,7 @@ module.exports = () => {
checker.check(argv.cwd)
.then((data) => {
const projectMetaData = consoleModule.transform(data,
canonicalNameMapper, argv.cwd, argv.ilc);
canonicalNameMapper, argv.cwd, argv.ilc, argv.fdt);
saveModule.save(projectMetaData, argv);
})
.catch((e) => {
Expand Down
8 changes: 5 additions & 3 deletions lib/modules/console.mdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const licenseNameUrl = (canonicalNameMapper, license) => {
};

const urlValue = (nameUrl, ilc, file) => {
if (file.includes(nameUrl.name.split(' ')[0].toUpperCase())) {
if (file && file.includes(nameUrl.name.split(' ')[0].toUpperCase())) {
return ilc ? fileReader.readLicenseFile(file) : nameUrl.url;
}
return nameUrl.url;
Expand Down Expand Up @@ -65,9 +65,11 @@ const declaredDependencies = (data, dependencies) => {
return filtered;
};

const transform = (data, canonicalNameMapper, cwd, ilc) => {
const transform = (data, canonicalNameMapper, cwd, ilc, fdt) => {
const projectMetaData = project.projectMetaData(cwd);
data = declaredDependencies(data, project.dependencies(cwd));
if (!fdt) {
data = declaredDependencies(data, project.dependencies(cwd));
}
data = packageMetaData(data);
data.forEach((d) => {
d.licenses = licenseMetaData(d.licenses, canonicalNameMapper, ilc, d.file);
Expand Down
6 changes: 4 additions & 2 deletions lib/modules/report.mdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ const licenseMetaData = (licenses, canonicalNameMapper, ilc, file) => {
return licenseData;
};

const transform = (data, canonicalNameMapper, cwd, ilc) => {
const transform = (data, canonicalNameMapper, cwd, ilc, fdt) => {
const projectMetaData = project.projectMetaData(cwd);
data = consoleModule.declaredDependencies(data, project.dependencies(cwd));
if (!fdt) {
data = consoleModule.declaredDependencies(data, project.dependencies(cwd));
}
data = consoleModule.packageMetaData(data);
data.forEach((d) => {
if (d.file) {
Expand Down

0 comments on commit a264b8e

Please sign in to comment.