From aae4629e9ac46dff5c53da7b7b0711509f4baff0 Mon Sep 17 00:00:00 2001 From: Andy Stark <30621568+therealandeeee@users.noreply.github.com> Date: Tue, 12 Feb 2019 12:45:56 +0000 Subject: [PATCH] [ADF-4069] Added updated license list tool (#4302) * [ADF-4069] Added updated license list tool * [ADF-4069] Added suggestion for licence info in sidebar --- docs/abn-tree.yml | 1 + docs/license-info/license-info-v3.0.0.md | 42 ++++++++++++ package.json | 1 + tools/doc/licenseList.js | 84 ++++++++++++++++++++++++ tools/doc/templates/licensePage.ejs | 28 ++++++++ 5 files changed, 156 insertions(+) create mode 100644 docs/license-info/license-info-v3.0.0.md create mode 100644 tools/doc/licenseList.js create mode 100644 tools/doc/templates/licensePage.ejs diff --git a/docs/abn-tree.yml b/docs/abn-tree.yml index 40f5fe6e67..8b703cd4c3 100644 --- a/docs/abn-tree.yml +++ b/docs/abn-tree.yml @@ -24,3 +24,4 @@ - versionIndex.md: 'Version index' - compatibility.md: 'Version compatibility' - release-notes: 'Release notes' +- license-info: 'License info' diff --git a/docs/license-info/license-info-v3.0.0.md b/docs/license-info/license-info-v3.0.0.md new file mode 100644 index 0000000000..0e65e44b5f --- /dev/null +++ b/docs/license-info/license-info-v3.0.0.md @@ -0,0 +1,42 @@ +--- +Title: License info, ADF v3.0.0 +--- + +# License information for ADF v3.0.0 + +This page lists all third party libraries that ADF v3.0.0 depends on. + +## Libraries + +| Name | Version | License | +| -- | -- | -- | +| [@angular/compiler](https://github.com/angular/angular) | 7.0.3 | [MIT](http://www.opensource.org/licenses/MIT) | +| [@angular/core](https://github.com/angular/angular) | 7.0.3 | [MIT](http://www.opensource.org/licenses/MIT) | +| [alfresco-components](https://github.com/Alfresco/alfresco-ng2-components) | 2.7.0-beta5 | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | +| [chart.js](https://github.com/chartjs/Chart.js) | 2.5.0 | [MIT](http://www.opensource.org/licenses/MIT) | +| [chart.js](https://github.com/chartjs/Chart.js) | 2.7.2 | [MIT](http://www.opensource.org/licenses/MIT) | +| [chartjs-color-string](https://github.com/chartjs/chartjs-color-string) | 0.5.0 | [MIT](http://www.opensource.org/licenses/MIT) | +| [chartjs-color](https://github.com/chartjs/chartjs-color) | 2.2.0 | [MIT](http://www.opensource.org/licenses/MIT) | +| [classlist.js](https://github.com/eligrey/classList.js) | 1.1.20150312 | [Public Domain](http://opendatacommons.org/licenses/pddl/1.0/) | +| [color-convert](https://github.com/harthur/color-convert) | 0.5.3 | [MIT](http://www.opensource.org/licenses/MIT) | +| [color-name](https://github.com/dfcreative/color-name) | 1.1.3 | [MIT](http://www.opensource.org/licenses/MIT) | +| [core-js](https://github.com/zloirock/core-js) | 2.4.1 | [MIT](http://www.opensource.org/licenses/MIT) | +| [cross-fetch](https://github.com/lquixada/cross-fetch) | 2.2.2 | [MIT](http://www.opensource.org/licenses/MIT) | +| [custom-event-polyfill](https://github.com/krambuhl/custom-event-polyfill) | 0.3.0 | [MIT](http://www.opensource.org/licenses/MIT) | +| [eve-raphael](https://github.com/tomasAlabes/eve) | 0.5.0 | [Apache](http://www.apache.org/licenses/LICENSE-2.0) | +| [graphql-request](https://github.com/graphcool/graphql-request) | 1.8.2 | [MIT](http://www.opensource.org/licenses/MIT) | +| [hammerjs](https://github.com/hammerjs/hammer.js) | 2.0.8 | [MIT](http://www.opensource.org/licenses/MIT) | +| [moment-es6](https://github.com/Agamnentzar/moment-es6) | 1.0.0 | [MIT](http://www.opensource.org/licenses/MIT) | +| [moment](https://github.com/moment/moment) | 2.20.1 | [MIT](http://www.opensource.org/licenses/MIT) | +| [ng2-charts](https://github.com/valor-software/ng2-charts) | 1.6.0 | [MIT](http://www.opensource.org/licenses/MIT) | +| [node-fetch](https://github.com/bitinn/node-fetch) | 2.1.2 | [MIT](http://www.opensource.org/licenses/MIT) | +| [raphael](https://github.com/DmitryBaranovskiy/raphael) | 2.2.7 | [MIT](http://www.opensource.org/licenses/MIT) | +| [reflect-metadata](https://github.com/rbuckton/reflect-metadata) | 0.1.10 | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | +| [rxjs-compat](https://github.com/ReactiveX/rxjs/tree/master/compat) | 6.4.0 | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | +| [rxjs](https://github.com/reactivex/rxjs) | 6.3.3 | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | +| [systemjs](https://github.com/systemjs/systemjs) | 0.19.27 | [MIT](http://www.opensource.org/licenses/MIT) | +| [tslib](https://github.com/Microsoft/tslib) | 1.9.1 | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | +| [web-animations-js](https://github.com/web-animations/web-animations-js) | 2.3.1 | [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) | +| [whatwg-fetch](https://github.com/github/fetch) | 2.0.4 | [MIT](http://www.opensource.org/licenses/MIT) | +| [when](https://github.com/cujojs/when) | 3.7.8 | [MIT](http://www.opensource.org/licenses/MIT) | +| [zone.js](https://github.com/angular/zone.js) | 0.8.26 | [MIT](http://www.opensource.org/licenses/MIT) | diff --git a/package.json b/package.json index 18446359cf..1f2fc04226 100644 --- a/package.json +++ b/package.json @@ -167,6 +167,7 @@ "rxjs-tslint-rules": "^4.10.0", "sass-loader": "7.1.0", "scss-bundle": "2.3.2", + "spdx-license-list": "^5.0.0", "stylelint": "^9.7.1", "systemjs-builder": "0.15.34", "traceur": "0.0.111", diff --git a/tools/doc/licenseList.js b/tools/doc/licenseList.js new file mode 100644 index 0000000000..5fde64e9e0 --- /dev/null +++ b/tools/doc/licenseList.js @@ -0,0 +1,84 @@ +var path = require('path'); +var fs = require('fs'); + +var checker = require('license-checker'); +var ejs = require('ejs'); +var program = require('commander'); +var spdxCodes = require('spdx-license-list'); + +var startPath = path.resolve('.'); +var templatePath = path.resolve(__dirname, 'templates', 'licensePage.ejs'); + + +const nonStandardLicenses = { + "public domain": "PDDL-1.0", + "apache": "Apache-2.0" +} + +const missingRepos = { + "rxjs-compat": "https://github.com/ReactiveX/rxjs/tree/master/compat" +} + +program +.usage('') +.parse(process.argv); + +console.log(`Checking ${startPath}`); + +checker.init({ + start: startPath, + production: true, + failOn: "GPL" +}, function(err, packages) { + if (err) { + console.log(err); + } else { + //console.log(JSON.stringify(packages)); + + for (var packageName in packages) { + var pack = packages[packageName]; + pack['licenseExp'] = licenseWithMDLinks(pack['licenses'].replace(/\*/g, '')); + + if (!pack['repository']) { + var lastAtSignPos = packageName.lastIndexOf('@'); + var mainName = packageName.substring(0, lastAtSignPos); + + if (missingRepos[mainName]) { + pack['repository'] = missingRepos[mainName]; + } + } + } + + ejs.renderFile(templatePath, {packages: packages, projVersion: program.args[0]}, {}, (err, mdText) => { + if (err) { + console.log(err); + } else { + //console.log(mdText); + var licenseFilePath = path.resolve('.', 'docs', 'license-info', `license-info-${program.args[0]}.md`) + fs.writeFileSync(licenseFilePath, mdText); + console.log(`Wrote license list at ${licenseFilePath}`); + } + }); + } +}); + + +function licenseWithMDLinks(licenseExp) { + var licenseUrl = ''; + + if (spdxCodes[licenseExp] && spdxCodes[licenseExp]['url']) { + licenseUrl = spdxCodes[licenseExp]['url']; + } else { + var substituteLicString = nonStandardLicenses[licenseExp.toLowerCase()]; + + if (spdxCodes[substituteLicString] && spdxCodes[substituteLicString]['url']) { + licenseUrl = spdxCodes[substituteLicString]['url']; + } + } + + if (licenseUrl) { + return `[${licenseExp}](${licenseUrl})`; + } else { + return licenseExp; + } +} diff --git a/tools/doc/templates/licensePage.ejs b/tools/doc/templates/licensePage.ejs new file mode 100644 index 0000000000..dcefea96cf --- /dev/null +++ b/tools/doc/templates/licensePage.ejs @@ -0,0 +1,28 @@ +--- +Title: License info, ADF <%= projVersion %> +--- + +# License information for ADF <%= projVersion %> + +This page lists all third party libraries that ADF <%= projVersion %> depends on. + +## Libraries + +| Name | Version | License | +| -- | -- | -- | +<% for (var packageName in packages) { + var lastAtSignPos = packageName.lastIndexOf('@'); + + var name = packageName.substring(0, lastAtSignPos); + var version = packageName.substring(lastAtSignPos + 1); + var pack = packages[packageName]; + var licenses = pack['licenseExp'] || 'N/A'; + var repo = pack['repository']; + var linkedName = name; + + if (repo) { + linkedName = `[${name}](${repo})` + } +-%> +| <%= linkedName %> | <%= version %> | <%= licenses %> | +<% } %> \ No newline at end of file