Merge pull request #4598 from GabrielInTheWorld/package-crawler

Implements a crawler to find all directly used packages
This commit is contained in:
Sean 2019-04-16 14:50:24 +02:00 committed by GitHub
commit d2260b02a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 156 additions and 0 deletions

View File

@ -166,6 +166,10 @@ To extract translations run::
$ npm run extract $ npm run extract
When updating, adding or changing used packages from npm, please update the README.md using following command::
$ npm run licenses
OpenSlides in big mode OpenSlides in big mode
====================== ======================

View File

@ -54,3 +54,72 @@ We are using ngx-translate for translation purposes.
Use `npm run extract` to extract strings and update elements an with translation functions. Use `npm run extract` to extract strings and update elements an with translation functions.
Language files can be found in `/src/assets/i18n`. Language files can be found in `/src/assets/i18n`.
### Used software
OpenSlides uses the following software or parts of them:
- [@angular/animations@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/cdk@7.3.3](https://github.com/angular/material2), License: MIT
- [@angular/common@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/compiler@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/core@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/forms@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/http@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/material@7.3.3](https://github.com/angular/material2), License: MIT
- [@angular/platform-browser-dynamic@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/platform-browser@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/pwa@0.13.2](https://github.com/angular/angular-cli), License: MIT
- [@angular/router@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/service-worker@7.2.6](https://github.com/angular/angular), License: MIT
- [@ngx-pwa/local-storage@7.4.1](https://github.com/cyrilletuzi/angular-async-local-storage), License: MIT
- [@ngx-translate/core@11.0.1](https://github.com/ngx-translate/core), License: MIT
- [@ngx-translate/http-loader@4.0.0](https://github.com/ngx-translate/http-loader), License: MIT
- [@tinymce/tinymce-angular@3.0.0](https://github.com/tinymce/tinymce-angular), License: Apache-2.0
- [core-js@2.6.5](https://github.com/zloirock/core-js), License: MIT
- [css-element-queries@1.1.1](https://github.com/marcj/css-element-queries), License: MIT
- [exceljs@1.8.0](https://github.com/exceljs/exceljs), License: MIT
- [file-saver@2.0.1](https://github.com/eligrey/FileSaver.js), License: MIT
- [hammerjs@2.0.8](https://github.com/hammerjs/hammer.js), License: MIT
- [material-icon-font@0.1.0](https://github.com//petergng/svgFontCreator), License: ISC
- [ng-pick-datetime@7.0.0](https://github.com/DanielYKPan/date-time-picker), License: MIT
- [ngx-file-drop@5.0.5](https://github.com/georgipeltekov/ngx-file-drop), License: MIT
- [ngx-mat-select-search@1.5.2](https://github.com/bithost-gmbh/ngx-mat-select-search), License: MIT
- [ngx-papaparse@3.0.2](https://github.com/alberthaff/ngx-papaparse), License: MIT
- [pdfmake@0.1.53](https://github.com/bpampuch/pdfmake), License: MIT
- [po2json@1.0.0-alpha](https://github.com/mikeedwards/po2json), License: GNU Library General Public License
- [rxjs@6.4.0](https://github.com/reactivex/rxjs), License: Apache-2.0
- [tinymce@4.9.2](https://github.com/tinymce/tinymce-dist), License: LGPL-2.1
- [uuid@3.3.2](https://github.com/kelektiv/node-uuid), License: MIT
- [zone.js@0.8.29](https://github.com/angular/zone.js), License: MIT
- [@angular-devkit/build-angular@0.13.2](https://github.com/angular/angular-cli), License: MIT
- [@angular/cli@7.3.2](https://github.com/angular/angular-cli), License: MIT
- [@angular/compiler-cli@7.2.6](https://github.com/angular/angular), License: MIT
- [@angular/language-service@7.2.6](https://github.com/angular/angular), License: MIT
- [@biesbjerg/ngx-translate-extract@2.3.4](https://github.com/biesbjerg/ngx-translate-extract), License: MIT
- [@compodoc/compodoc@1.1.8](https://github.com/compodoc/compodoc), License: MIT
- [@types/jasmine@3.3.9](https://github.com/DefinitelyTyped/DefinitelyTyped), License: MIT
- [@types/jasminewd2@2.0.6](https://github.com/DefinitelyTyped/DefinitelyTyped), License: MIT
- [@types/node@11.9.4](https://github.com/DefinitelyTyped/DefinitelyTyped), License: MIT
- [@types/yargs@12.0.9](https://github.com/DefinitelyTyped/DefinitelyTyped), License: MIT
- [codelyzer@4.5.0](https://github.com/mgechev/codelyzer), License: MIT
- [fs@0.0.1-security](https://github.com/npm/security-holder), License: ISC
- [husky@1.3.1](https://github.com/typicode/husky), License: MIT
- [jasmine-core@3.3.0](https://github.com/jasmine/jasmine), License: MIT
- [jasmine-spec-reporter@4.2.1](https://github.com/bcaudan/jasmine-spec-reporter), License: Apache-2.0
- [karma-chrome-launcher@2.2.0](https://github.com/karma-runner/karma-chrome-launcher), License: MIT
- [karma-coverage-istanbul-reporter@2.0.5](https://github.com/mattlewis92/karma-coverage-istanbul-reporter), License: MIT
- [karma-jasmine-html-reporter@1.4.0](https://github.com/dfederm/karma-jasmine-html-reporter), License: MIT
- [karma-jasmine@2.0.1](https://github.com/karma-runner/karma-jasmine), License: MIT
- [karma@4.0.0](https://github.com/karma-runner/karma), License: MIT
- [npm-license-crawler@0.2.1](https://github.com/mwittig/npm-license-crawler), License: BSD-3-Clause
- [npm-run-all@4.1.5](https://github.com/mysticatea/npm-run-all), License: MIT
- [prettier@1.17.0](https://github.com/prettier/prettier), License: MIT
- [protractor@5.4.2](https://github.com/angular/protractor), License: MIT
- [source-map-explorer@1.7.0](https://github.com/danvk/source-map-explorer), License: Apache-2.0
- [terser@3.16.1](https://github.com/fabiosantoscode/terser), License: BSD-2-Clause
- [ts-node@8.0.2](https://github.com/TypeStrong/ts-node), License: MIT
- [tslint@5.12.1](https://github.com/palantir/tslint), License: Apache-2.0
- [tsutils@3.8.0](https://github.com/ajafff/tsutils), License: MIT
- [typescript@3.2.4](https://github.com/Microsoft/TypeScript), License: Apache-2.0
- [webpack-bundle-analyzer@3.0.4](https://github.com/webpack-contrib/webpack-bundle-analyzer), License: MIT

View File

@ -16,6 +16,7 @@
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e", "e2e": "ng e2e",
"licenses": "node src/crawler.js",
"compodoc": "./node_modules/.bin/compodoc --hideGenerator -p src/tsconfig.app.json -n 'OpenSlides Documentation' -d ../Compodoc -s -w -t -o --port", "compodoc": "./node_modules/.bin/compodoc --hideGenerator -p src/tsconfig.app.json -n 'OpenSlides Documentation' -d ../Compodoc -s -w -t -o --port",
"extract": "ngx-translate-extract -i ./src -o ./src/assets/i18n/template-en.pot --clean --sort --format pot -m _", "extract": "ngx-translate-extract -i ./src -o ./src/assets/i18n/template-en.pot --clean --sort --format pot -m _",
"po2json": "./node_modules/.bin/po2json -f mf src/assets/i18n/de.po src/assets/i18n/de.json && ./node_modules/.bin/po2json -f mf src/assets/i18n/cs.po src/assets/i18n/cs.json", "po2json": "./node_modules/.bin/po2json -f mf src/assets/i18n/de.po src/assets/i18n/de.json && ./node_modules/.bin/po2json -f mf src/assets/i18n/cs.po src/assets/i18n/cs.json",
@ -70,6 +71,7 @@
"@types/node": "^11.9.4", "@types/node": "^11.9.4",
"@types/yargs": "^12.0.9", "@types/yargs": "^12.0.9",
"codelyzer": "~4.5.0", "codelyzer": "~4.5.0",
"fs": "0.0.1-security",
"husky": "^1.3.1", "husky": "^1.3.1",
"jasmine-core": "~3.3.0", "jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",
@ -78,6 +80,7 @@
"karma-coverage-istanbul-reporter": "^2.0.5", "karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "~2.0.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0", "karma-jasmine-html-reporter": "^1.4.0",
"npm-license-crawler": "^0.2.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^1.17.0", "prettier": "^1.17.0",
"protractor": "^5.4.2", "protractor": "^5.4.2",

80
client/src/crawler.js Normal file
View File

@ -0,0 +1,80 @@
const crawler = require('npm-license-crawler');
const fs = require('fs');
/**
* Describes the options for dumping the licenses.
*/
const options = {
start: ['.'],
json: 'licenses.json',
onlyDirectDependencies: true
};
const production = {
...options,
production: true
};
const development = {
...options,
development: true
};
let data = '';
/**
* To the `README.md` the content with used packages and
* their licenses will appended to the end of the default content.
*/
fs.readFile('README.md', {
encoding: 'utf8',
flag: 'r'
}, async (_, copy) => {
let heading = '### Used software';
const index = copy.search(heading);
if (index > 0) {
data = copy.slice(0, index) + heading + '\n';
} else {
data = copy + '\n' + heading + '\n';
}
data += '\nOpenSlides uses the following software or parts of them:\n\n';
});
/**
* Dump the licenses
*/
crawler.dumpLicenses(production, async (_, res) => {
writeToFile(res);
await crawler.dumpLicenses(development, async (_, res) => {
writeToFile(res);
await fs.writeFile('README.md', data, 'utf8', async () => {
// Here the previously created file will be deleted.
await fs.unlink('licenses.json', () => {});
});
});
})
/**
* Function to write down a list of all found packages in the `package.json`.
*
* @param {json} licenses are all found packages in the project.
*/
function writeToFile(licenses) {
let resources = [];
for (let key in licenses) {
resources.push({
name: key,
repository: licenses[key]['repository'],
license: licenses[key]['licenses']
});
}
for (let entry of resources) {
data += '- [' + entry.name + ']' + '(' + entry.repository + ')'
+ ', License: ' + entry.license + '\n';
}
}