8 Commits

Author SHA1 Message Date
d82b8a6dbd 1.0.23 2021-05-17 15:47:00 +00:00
40d12bc91e fix(core): update 2021-05-17 15:46:59 +00:00
6477b8a375 1.0.22 2021-05-17 15:45:46 +00:00
4b5b2e7ca5 fix(core): update 2021-05-17 15:45:46 +00:00
83a9cabab8 1.0.21 2020-01-17 16:36:01 +00:00
b046812ff9 fix(core): update 2020-01-17 16:36:00 +00:00
46a1048884 1.0.20 2020-01-17 16:35:39 +00:00
69b6aa38c3 fix(readme): update 2020-01-17 16:35:38 +00:00
14 changed files with 10644 additions and 1096 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

View File

@ -19,22 +19,35 @@ mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
only:
- tags
tags: tags:
- lossless - lossless
- docker - docker
- notpriv - notpriv
snyk: auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags: tags:
- lossless
- docker - docker
- notpriv allow_failure: true
# ==================== # ====================
# test stage # test stage
@ -49,9 +62,7 @@ testStable:
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- priv
testBuild: testBuild:
stage: test stage: test
@ -62,9 +73,7 @@ testBuild:
- npmci command npm run build - npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- notpriv
release: release:
stage: release stage: release
@ -84,6 +93,8 @@ release:
codequality: codequality:
stage: metadata stage: metadata
allow_failure: true allow_failure: true
only:
- tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g tslint typescript
- npmci npm prepare - npmci npm prepare

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -4,6 +4,7 @@
"npmAccessLevel": "public" "npmAccessLevel": "public"
}, },
"gitzone": { "gitzone": {
"projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",

11509
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
{ {
"name": "@pushrocks/smartlegal", "name": "@pushrocks/smartlegal",
"version": "1.0.19", "version": "1.0.23",
"private": false, "private": false,
"description": "go legal programmatically", "description": "go legal programmatically",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "tstest test/", "test": "(tstest test/ --web)",
"build": "tsbuild" "build": "(tsbuild --web)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -26,31 +26,36 @@
}, },
"homepage": "https://gitlab.com/pkunz/legal#README", "homepage": "https://gitlab.com/pkunz/legal#README",
"dependencies": { "dependencies": {
"@pushrocks/smartmarkdown": "^2.0.2", "@pushrocks/smartmarkdown": "^2.0.6",
"@pushrocks/smartmustache": "^2.0.9", "@pushrocks/smartmustache": "^2.0.11",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.1.5",
"@tsclass/tsclass": "^2.0.13", "@tsclass/tsclass": "^3.0.33",
"@types/license-checker": "^25.0.1",
"@umbrellazone/legal-docs": "^1.0.12", "@umbrellazone/legal-docs": "^1.0.12",
"license-checker": "^25.0.1" "license-checker": "^25.0.1"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.28", "@gitzone/tstest": "^1.0.54",
"@pushrocks/tapbundle": "^3.2.0", "@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^13.1.7", "@types/node": "^15.3.0",
"tslint": "^5.20.1", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
"dist/**/*", "dist/**/*",
"dist_web/**/*", "dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
],
"browserslist": [
"last 1 chrome versions"
] ]
} }

View File

@ -8,26 +8,28 @@ go legal programmatically
* [docs (typedoc)](https://pushrocks.gitlab.io/smartlegal/) * [docs (typedoc)](https://pushrocks.gitlab.io/smartlegal/)
## Status for master ## Status for master
[![build status](https://gitlab.com/pushrocks/smartlegal/badges/master/build.svg)](https://gitlab.com/pushrocks/smartlegal/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartlegal/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartlegal/commits/master) Status Category | Status Badge
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartlegal.svg)](https://www.npmjs.com/package/@pushrocks/smartlegal) -- | --
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartlegal/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartlegal) GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartlegal/badges/master/pipeline.svg)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartlegal/badges/master/coverage.svg)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartlegal)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartlegal)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartlegal)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartlegal)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartlegal)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage
Use TypeScript for best in class instellisense. Use TypeScript for best in class instellisense.
legal implements classes that are designed to smartlegal implements
For further information read the linked docs at the top of this README. - a license checker for checking dependency trees against a set of licenses
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://umbrellazone.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
## Contribution ## Contribution

View File

@ -3,7 +3,7 @@ import * as legal from '../ts/index';
tap.test('should create instance of licenseChecker', async () => { tap.test('should create instance of licenseChecker', async () => {
const licenseChecker = await legal.createLicenseChecker(); const licenseChecker = await legal.createLicenseChecker();
let plainResultArray = await licenseChecker.createPlainResultArray(process.cwd()); const plainResultArray = await licenseChecker.createPlainResultArray(process.cwd());
expect(plainResultArray).to.be.instanceof(Array); expect(plainResultArray).to.be.instanceof(Array);
expect(plainResultArray[0]).to.have.property('license'); expect(plainResultArray[0]).to.have.property('license');
}); });

View File

@ -1,6 +1,4 @@
import * as plugins from './legal.plugins'; export * from './mod.licensechecker/interfaces';
import { ICompany } from '@tsclass/tsclass';
export const createLicenseChecker = async () => { export const createLicenseChecker = async () => {
const licenseCheckerMod = await import('./mod.licensechecker/classes.licensechecker'); const licenseCheckerMod = await import('./mod.licensechecker/classes.licensechecker');
return new licenseCheckerMod.LicenseChecker(); return new licenseCheckerMod.LicenseChecker();

View File

@ -8,6 +8,4 @@ export { tsclass };
// @pushrocks // @pushrocks
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartmarkdown from '@pushrocks/smartmarkdown'; export { smartpromise };
import * as smartmustache from '@pushrocks/smartmustache';
export { smartpromise, smartmarkdown, smartmustache };

View File

@ -0,0 +1,14 @@
import { IModuleLicenseResult } from './interfaces';
export class CheckResult {
passingModules: IModuleLicenseResult[] = [];
failingModules: IModuleLicenseResult[] = [];
public addPassing(moduleResultArg: IModuleLicenseResult) {
this.passingModules.push(moduleResultArg);
}
public addFailing(moduleResultArg: IModuleLicenseResult) {
this.failingModules.push(moduleResultArg);
}
}

View File

@ -1,33 +1,13 @@
import * as plugins from '../legal.plugins'; import * as plugins from '../legal.plugins';
import * as licenseChecker from 'license-checker'; import * as licenseChecker from 'license-checker';
import * as interfaces from './interfaces';
export interface IModuleLicenseResult { import { CheckResult } from './classes.checkresult';
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 { export class LicenseChecker {
async excludeLicenseWithinPath(pathArg: string, licenseArrayArg: string[]) { async excludeLicenseWithinPath(pathArg: string, licenseArrayArg: string[]) {
const checkResult = new CheckResult(); const checkResult = new CheckResult();
const plainResultArray = await this.createPlainResultArray(pathArg); const plainResultArray = await this.createPlainResultArray(pathArg);
plainResultArray.forEach(licenseResult => { plainResultArray.forEach((licenseResult) => {
if (licenseArrayArg.indexOf(licenseResult.license) === -1) { if (licenseArrayArg.indexOf(licenseResult.license) === -1) {
checkResult.addPassing(licenseResult); checkResult.addPassing(licenseResult);
} else { } else {
@ -40,7 +20,7 @@ export class LicenseChecker {
async includeLicencesWithinPath(pathArg: string, licenseArrayArg: string[]) { async includeLicencesWithinPath(pathArg: string, licenseArrayArg: string[]) {
const checkResult = new CheckResult(); const checkResult = new CheckResult();
const plainResultArray = await this.createPlainResultArray(pathArg); const plainResultArray = await this.createPlainResultArray(pathArg);
plainResultArray.forEach(licenseResult => { plainResultArray.forEach((licenseResult) => {
if (licenseArrayArg.indexOf(licenseResult.license) !== -1) { if (licenseArrayArg.indexOf(licenseResult.license) !== -1) {
checkResult.addPassing(licenseResult); checkResult.addPassing(licenseResult);
} else { } else {
@ -52,8 +32,8 @@ export class LicenseChecker {
async createPlainResultArray(pathArg: string) { async createPlainResultArray(pathArg: string) {
const licenseJson = await this.getJsonForPath(pathArg); const licenseJson = await this.getJsonForPath(pathArg);
const resultArray: IModuleLicenseResult[] = []; const resultArray: interfaces.IModuleLicenseResult[] = [];
for (let moduleKey in licenseJson) { for (const moduleKey of Object.keys(licenseJson)) {
const refObject = licenseJson[moduleKey]; const refObject = licenseJson[moduleKey];
resultArray.push({ resultArray.push({
moduleName: moduleKey, moduleName: moduleKey,
@ -62,19 +42,19 @@ export class LicenseChecker {
license: refObject.licenses, license: refObject.licenses,
path: refObject.path, path: refObject.path,
publisher: refObject.publisher, publisher: refObject.publisher,
repository: refObject.repository repository: refObject.repository,
}); });
} }
return resultArray; return resultArray;
} }
private async getJsonForPath(checkPathArg) { private async getJsonForPath(checkPathArg) {
let done = plugins.smartpromise.defer<any>(); const done = plugins.smartpromise.defer<any>();
licenseChecker.init( licenseChecker.init(
{ {
start: checkPathArg start: checkPathArg,
}, },
function(err, licenseJson) { (err, licenseJson) => {
if (err) { if (err) {
done.reject(err); done.reject(err);
} else { } else {
@ -82,6 +62,6 @@ export class LicenseChecker {
} }
} }
); );
return await done.promise; return done.promise;
} }
} }

View File

@ -0,0 +1,9 @@
export interface IModuleLicenseResult {
moduleName: string;
license: string;
repository: string;
publisher: string;
email: string;
path: string;
licenseFile: string;
}