fix(core): initial
This commit is contained in:
		
							
								
								
									
										22
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | .nogit/ | ||||||
|  |  | ||||||
|  | # artifacts | ||||||
|  | coverage/ | ||||||
|  | public/ | ||||||
|  | pages/ | ||||||
|  |  | ||||||
|  | # installs | ||||||
|  | node_modules/ | ||||||
|  |  | ||||||
|  | # caches | ||||||
|  | .yarn/ | ||||||
|  | .cache/ | ||||||
|  | .rpt2_cache | ||||||
|  |  | ||||||
|  | # builds | ||||||
|  | dist/ | ||||||
|  | dist_web/ | ||||||
|  | dist_serve/ | ||||||
|  | dist_ts_web/ | ||||||
|  |  | ||||||
|  | # custom | ||||||
							
								
								
									
										126
									
								
								.gitlab-ci.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								.gitlab-ci.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,126 @@ | |||||||
|  | # gitzone ci_default | ||||||
|  | image: registry.gitlab.com/hosttoday/ht-docker-node:npmci | ||||||
|  |  | ||||||
|  | cache: | ||||||
|  |   paths: | ||||||
|  |     - .npmci_cache/ | ||||||
|  |   key: '$CI_BUILD_STAGE' | ||||||
|  |  | ||||||
|  | stages: | ||||||
|  |   - security | ||||||
|  |   - test | ||||||
|  |   - release | ||||||
|  |   - metadata | ||||||
|  |  | ||||||
|  | # ==================== | ||||||
|  | # security stage | ||||||
|  | # ==================== | ||||||
|  | mirror: | ||||||
|  |   stage: security | ||||||
|  |   script: | ||||||
|  |     - npmci git mirror | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - notpriv | ||||||
|  |  | ||||||
|  | snyk: | ||||||
|  |   image: registry.gitlab.com/hosttoday/ht-docker-node:snyk | ||||||
|  |   stage: security | ||||||
|  |   script: | ||||||
|  |     - npmci npm prepare | ||||||
|  |     - npmci command npm install --ignore-scripts | ||||||
|  |     - npmci command snyk test | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - notpriv | ||||||
|  |  | ||||||
|  | # ==================== | ||||||
|  | # test stage | ||||||
|  | # ==================== | ||||||
|  |  | ||||||
|  | testStable: | ||||||
|  |   stage: test | ||||||
|  |   script: | ||||||
|  |     - npmci npm prepare | ||||||
|  |     - npmci node install stable | ||||||
|  |     - npmci npm install | ||||||
|  |     - npmci npm test | ||||||
|  |   coverage: /\d+.?\d+?\%\s*coverage/ | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - priv | ||||||
|  |  | ||||||
|  | testBuild: | ||||||
|  |   stage: test | ||||||
|  |   script: | ||||||
|  |     - npmci npm prepare | ||||||
|  |     - npmci node install stable | ||||||
|  |     - npmci npm install | ||||||
|  |     - npmci command npm run build | ||||||
|  |   coverage: /\d+.?\d+?\%\s*coverage/ | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - notpriv | ||||||
|  |  | ||||||
|  | release: | ||||||
|  |   stage: release | ||||||
|  |   script: | ||||||
|  |     - npmci node install stable | ||||||
|  |     - npmci npm publish | ||||||
|  |   only: | ||||||
|  |     - tags | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - notpriv | ||||||
|  |  | ||||||
|  | # ==================== | ||||||
|  | # metadata stage | ||||||
|  | # ==================== | ||||||
|  | codequality: | ||||||
|  |   stage: metadata | ||||||
|  |   allow_failure: true | ||||||
|  |   script: | ||||||
|  |     - npmci command npm install -g tslint typescript | ||||||
|  |     - npmci npm prepare | ||||||
|  |     - npmci npm install | ||||||
|  |     - npmci command "tslint -c tslint.json ./ts/**/*.ts" | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - priv | ||||||
|  |  | ||||||
|  | trigger: | ||||||
|  |   stage: metadata | ||||||
|  |   script: | ||||||
|  |     - npmci trigger | ||||||
|  |   only: | ||||||
|  |     - tags | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - notpriv | ||||||
|  |  | ||||||
|  | pages: | ||||||
|  |   stage: metadata | ||||||
|  |   script: | ||||||
|  |     - npmci node install lts | ||||||
|  |     - npmci command npm install -g @gitzone/tsdoc | ||||||
|  |     - npmci npm prepare | ||||||
|  |     - npmci npm install | ||||||
|  |     - npmci command tsdoc | ||||||
|  |   tags: | ||||||
|  |     - lossless | ||||||
|  |     - docker | ||||||
|  |     - notpriv | ||||||
|  |   only: | ||||||
|  |     - tags | ||||||
|  |   artifacts: | ||||||
|  |     expire_in: 1 week | ||||||
|  |     paths: | ||||||
|  |       - public | ||||||
|  |   allow_failure: true | ||||||
							
								
								
									
										16
									
								
								npmextra.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								npmextra.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  | { | ||||||
|  |   "npmci": { | ||||||
|  |     "npmGlobalTools": [], | ||||||
|  |     "npmAccessLevel": "public" | ||||||
|  |   }, | ||||||
|  |   "gitzone": { | ||||||
|  |     "module": { | ||||||
|  |       "githost": "gitlab.com", | ||||||
|  |       "gitscope": "pushrocks", | ||||||
|  |       "gitrepo": "smartlegal", | ||||||
|  |       "shortDescription": "go legal programmatically", | ||||||
|  |       "npmPackagename": "@pushrocks/smartlegal", | ||||||
|  |       "license": "MIT" | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										3104
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										3104
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										56
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | |||||||
|  | { | ||||||
|  |   "name": "@pushrocks/smartlegal", | ||||||
|  |   "version": "1.0.18", | ||||||
|  |   "private": false, | ||||||
|  |   "description": "go legal programmatically", | ||||||
|  |   "main": "dist/index.js", | ||||||
|  |   "typings": "dist/index.d.ts", | ||||||
|  |   "scripts": { | ||||||
|  |     "test": "tstest test/", | ||||||
|  |     "build": "tsbuild" | ||||||
|  |   }, | ||||||
|  |   "repository": { | ||||||
|  |     "type": "git", | ||||||
|  |     "url": "git+ssh://git@gitlab.com/pkunz/legal.git" | ||||||
|  |   }, | ||||||
|  |   "keywords": [ | ||||||
|  |     "legal", | ||||||
|  |     "docs", | ||||||
|  |     "privacy", | ||||||
|  |     "policy" | ||||||
|  |   ], | ||||||
|  |   "author": "Lossless GmbH", | ||||||
|  |   "license": "MIT", | ||||||
|  |   "bugs": { | ||||||
|  |     "url": "https://gitlab.com/pkunz/legal/issues" | ||||||
|  |   }, | ||||||
|  |   "homepage": "https://gitlab.com/pkunz/legal#README", | ||||||
|  |   "dependencies": { | ||||||
|  |     "@pushrocks/smartmarkdown": "^2.0.2", | ||||||
|  |     "@pushrocks/smartmustache": "^2.0.9", | ||||||
|  |     "@pushrocks/smartpromise": "^3.0.6", | ||||||
|  |     "@tsclass/tsclass": "^2.0.13", | ||||||
|  |     "@umbrellazone/legal-docs": "^1.0.12", | ||||||
|  |     "license-checker": "^25.0.1" | ||||||
|  |   }, | ||||||
|  |   "devDependencies": { | ||||||
|  |     "@gitzone/tsbuild": "^2.1.17", | ||||||
|  |     "@gitzone/tsrun": "^1.2.8", | ||||||
|  |     "@gitzone/tstest": "^1.0.28", | ||||||
|  |     "@pushrocks/tapbundle": "^3.2.0", | ||||||
|  |     "@types/node": "^13.1.7", | ||||||
|  |     "tslint": "^5.20.1", | ||||||
|  |     "tslint-config-prettier": "^1.18.0" | ||||||
|  |   }, | ||||||
|  |   "files": [ | ||||||
|  |     "ts/**/*", | ||||||
|  |     "ts_web/**/*", | ||||||
|  |     "dist/**/*", | ||||||
|  |     "dist_web/**/*", | ||||||
|  |     "dist_ts_web/**/*", | ||||||
|  |     "assets/**/*", | ||||||
|  |     "cli.js", | ||||||
|  |     "npmextra.json", | ||||||
|  |     "readme.md" | ||||||
|  |   ] | ||||||
|  | } | ||||||
							
								
								
									
										41
									
								
								readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								readme.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | |||||||
|  | # @pushrocks/smartlegal | ||||||
|  | go legal programmatically | ||||||
|  |  | ||||||
|  | ## Availabililty and Links | ||||||
|  | * [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartlegal) | ||||||
|  | * [gitlab.com (source)](https://gitlab.com/pushrocks/smartlegal) | ||||||
|  | * [github.com (source mirror)](https://github.com/pushrocks/smartlegal) | ||||||
|  | * [docs (typedoc)](https://pushrocks.gitlab.io/smartlegal/) | ||||||
|  |  | ||||||
|  | ## Status for master | ||||||
|  | [](https://gitlab.com/pushrocks/smartlegal/commits/master) | ||||||
|  | [](https://gitlab.com/pushrocks/smartlegal/commits/master) | ||||||
|  | [](https://www.npmjs.com/package/@pushrocks/smartlegal) | ||||||
|  | [](https://snyk.io/test/npm/@pushrocks/smartlegal) | ||||||
|  | [](https://nodejs.org/dist/latest-v10.x/docs/api/) | ||||||
|  | [](https://nodejs.org/dist/latest-v10.x/docs/api/) | ||||||
|  | [](https://prettier.io/) | ||||||
|  |  | ||||||
|  | ## Usage | ||||||
|  |  | ||||||
|  | Use TypeScript for best in class instellisense. | ||||||
|  |  | ||||||
|  | legal implements classes that are designed to | ||||||
|  |  | ||||||
|  | For further information read the linked docs at the top of this README. | ||||||
|  |  | ||||||
|  | > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) | ||||||
|  | > | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) | ||||||
|  |  | ||||||
|  | [](https://push.rocks) | ||||||
|  |  | ||||||
|  | ## Contribution | ||||||
|  |  | ||||||
|  | We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) | ||||||
|  |  | ||||||
|  | For further information read the linked docs at the top of this readme. | ||||||
|  |  | ||||||
|  | > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) | ||||||
|  | | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | ||||||
|  |  | ||||||
|  | [](https://maintainedby.lossless.com) | ||||||
							
								
								
									
										23
									
								
								test/test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								test/test.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | import { tap, expect } from '@pushrocks/tapbundle'; | ||||||
|  | import * as legal from '../ts/index'; | ||||||
|  |  | ||||||
|  | tap.test('should create instance of licenseChecker', async () => { | ||||||
|  |   const licenseChecker = await legal.createLicenseChecker(); | ||||||
|  |   let plainResultArray = await licenseChecker.createPlainResultArray(process.cwd()); | ||||||
|  |   expect(plainResultArray).to.be.instanceof(Array); | ||||||
|  |   expect(plainResultArray[0]).to.have.property('license'); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | tap.test('should exclude certain licenses', async () => { | ||||||
|  |   const licenseChecker = await legal.createLicenseChecker(); | ||||||
|  |   const checkResult = await licenseChecker.excludeLicenseWithinPath(process.cwd(), ['MIT']); | ||||||
|  |   expect(checkResult.failingModules.length).to.be.greaterThan(10); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | tap.test('should include certain licenses', async () => { | ||||||
|  |   const licenseChecker = await legal.createLicenseChecker(); | ||||||
|  |   const checkResult = await licenseChecker.includeLicencesWithinPath(process.cwd(), ['MIT']); | ||||||
|  |   expect(checkResult.failingModules.length).to.be.greaterThan(10); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | tap.start(); | ||||||
							
								
								
									
										7
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | import * as plugins from './legal.plugins'; | ||||||
|  | import { ICompany } from '@tsclass/tsclass'; | ||||||
|  |  | ||||||
|  | export const createLicenseChecker = async () => { | ||||||
|  |   const licenseCheckerMod = await import('./mod.licensechecker/classes.licensechecker'); | ||||||
|  |   return new licenseCheckerMod.LicenseChecker(); | ||||||
|  | }; | ||||||
							
								
								
									
										13
									
								
								ts/legal.plugins.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								ts/legal.plugins.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | // sub packages | ||||||
|  | import * as legalDocs from '@umbrellazone/legal-docs'; | ||||||
|  | export { legalDocs }; | ||||||
|  |  | ||||||
|  | // @tsclass | ||||||
|  | import * as tsclass from '@tsclass/tsclass'; | ||||||
|  | export { tsclass }; | ||||||
|  |  | ||||||
|  | // @pushrocks | ||||||
|  | import * as smartpromise from '@pushrocks/smartpromise'; | ||||||
|  | import * as smartmarkdown from '@pushrocks/smartmarkdown'; | ||||||
|  | import * as smartmustache from '@pushrocks/smartmustache'; | ||||||
|  | export { smartpromise, smartmarkdown, smartmustache }; | ||||||
							
								
								
									
										87
									
								
								ts/mod.licensechecker/classes.licensechecker.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								ts/mod.licensechecker/classes.licensechecker.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,87 @@ | |||||||
|  | import * as plugins from '../legal.plugins'; | ||||||
|  | import * as licenseChecker from 'license-checker'; | ||||||
|  |  | ||||||
|  | export interface IModuleLicenseResult { | ||||||
|  |   moduleName: string; | ||||||
|  |   license: string; | ||||||
|  |   repository: string; | ||||||
|  |   publisher: string; | ||||||
|  |   email: string; | ||||||
|  |   path: string; | ||||||
|  |   licenseFile: string; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export class CheckResult { | ||||||
|  |   passingModules: IModuleLicenseResult[] = []; | ||||||
|  |   failingModules: IModuleLicenseResult[] = []; | ||||||
|  |   addPassing(moduleResultArg: IModuleLicenseResult) { | ||||||
|  |     this.passingModules.push(moduleResultArg); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   addFailing(moduleResultArg: IModuleLicenseResult) { | ||||||
|  |     this.failingModules.push(moduleResultArg); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export class LicenseChecker { | ||||||
|  |   async excludeLicenseWithinPath(pathArg: string, licenseArrayArg: string[]) { | ||||||
|  |     const checkResult = new CheckResult(); | ||||||
|  |     const plainResultArray = await this.createPlainResultArray(pathArg); | ||||||
|  |     plainResultArray.forEach(licenseResult => { | ||||||
|  |       if (licenseArrayArg.indexOf(licenseResult.license) === -1) { | ||||||
|  |         checkResult.addPassing(licenseResult); | ||||||
|  |       } else { | ||||||
|  |         checkResult.addFailing(licenseResult); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |     return checkResult; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   async includeLicencesWithinPath(pathArg: string, licenseArrayArg: string[]) { | ||||||
|  |     const checkResult = new CheckResult(); | ||||||
|  |     const plainResultArray = await this.createPlainResultArray(pathArg); | ||||||
|  |     plainResultArray.forEach(licenseResult => { | ||||||
|  |       if (licenseArrayArg.indexOf(licenseResult.license) !== -1) { | ||||||
|  |         checkResult.addPassing(licenseResult); | ||||||
|  |       } else { | ||||||
|  |         checkResult.addFailing(licenseResult); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |     return checkResult; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   async createPlainResultArray(pathArg: string) { | ||||||
|  |     const licenseJson = await this.getJsonForPath(pathArg); | ||||||
|  |     const resultArray: IModuleLicenseResult[] = []; | ||||||
|  |     for (let moduleKey in licenseJson) { | ||||||
|  |       const refObject = licenseJson[moduleKey]; | ||||||
|  |       resultArray.push({ | ||||||
|  |         moduleName: moduleKey, | ||||||
|  |         email: refObject.email, | ||||||
|  |         licenseFile: refObject.licenseFile, | ||||||
|  |         license: refObject.licenses, | ||||||
|  |         path: refObject.path, | ||||||
|  |         publisher: refObject.publisher, | ||||||
|  |         repository: refObject.repository | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |     return resultArray; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   private async getJsonForPath(checkPathArg) { | ||||||
|  |     let done = plugins.smartpromise.defer<any>(); | ||||||
|  |     licenseChecker.init( | ||||||
|  |       { | ||||||
|  |         start: checkPathArg | ||||||
|  |       }, | ||||||
|  |       function(err, licenseJson) { | ||||||
|  |         if (err) { | ||||||
|  |           done.reject(err); | ||||||
|  |         } else { | ||||||
|  |           done.resolve(licenseJson); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     ); | ||||||
|  |     return await done.promise; | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										17
									
								
								tslint.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tslint.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | |||||||
|  | { | ||||||
|  |   "extends": ["tslint:latest", "tslint-config-prettier"], | ||||||
|  |   "rules": { | ||||||
|  |     "semicolon": [true, "always"], | ||||||
|  |     "no-console": false, | ||||||
|  |     "ordered-imports": false, | ||||||
|  |     "object-literal-sort-keys": false, | ||||||
|  |     "member-ordering": { | ||||||
|  |       "options":{ | ||||||
|  |         "order": [ | ||||||
|  |           "static-method" | ||||||
|  |         ] | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   "defaultSeverity": "warning" | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user