Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
d82b8a6dbd | |||
40d12bc91e | |||
6477b8a375 | |||
4b5b2e7ca5 | |||
83a9cabab8 | |||
b046812ff9 | |||
46a1048884 | |||
69b6aa38c3 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -19,22 +19,35 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||
auditProductionDependencies:
|
||||
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
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- 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:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -49,9 +62,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -62,9 +73,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -84,6 +93,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
|
11509
package-lock.json
generated
11509
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@pushrocks/smartlegal",
|
||||
"version": "1.0.19",
|
||||
"version": "1.0.23",
|
||||
"private": false,
|
||||
"description": "go legal programmatically",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "tstest test/",
|
||||
"build": "tsbuild"
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -26,31 +26,36 @@
|
||||
},
|
||||
"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",
|
||||
"@pushrocks/smartmarkdown": "^2.0.6",
|
||||
"@pushrocks/smartmustache": "^2.0.11",
|
||||
"@pushrocks/smartpromise": "^3.1.5",
|
||||
"@tsclass/tsclass": "^3.0.33",
|
||||
"@types/license-checker": "^25.0.1",
|
||||
"@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",
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsrun": "^1.2.12",
|
||||
"@gitzone/tstest": "^1.0.54",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^15.3.0",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
30
readme.md
30
readme.md
@ -8,26 +8,28 @@ go legal programmatically
|
||||
* [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/)
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
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.
|
||||
|
||||
> 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)
|
||||
- a license checker for checking dependency trees against a set of licenses
|
||||
|
||||
## Contribution
|
||||
|
||||
|
@ -3,7 +3,7 @@ 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());
|
||||
const plainResultArray = await licenseChecker.createPlainResultArray(process.cwd());
|
||||
expect(plainResultArray).to.be.instanceof(Array);
|
||||
expect(plainResultArray[0]).to.have.property('license');
|
||||
});
|
||||
|
@ -1,6 +1,4 @@
|
||||
import * as plugins from './legal.plugins';
|
||||
import { ICompany } from '@tsclass/tsclass';
|
||||
|
||||
export * from './mod.licensechecker/interfaces';
|
||||
export const createLicenseChecker = async () => {
|
||||
const licenseCheckerMod = await import('./mod.licensechecker/classes.licensechecker');
|
||||
return new licenseCheckerMod.LicenseChecker();
|
||||
|
@ -8,6 +8,4 @@ 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 };
|
||||
export { smartpromise };
|
||||
|
14
ts/mod.licensechecker/classes.checkresult.ts
Normal file
14
ts/mod.licensechecker/classes.checkresult.ts
Normal 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);
|
||||
}
|
||||
}
|
@ -1,33 +1,13 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
import * as interfaces from './interfaces';
|
||||
import { CheckResult } from './classes.checkresult';
|
||||
|
||||
export class LicenseChecker {
|
||||
async excludeLicenseWithinPath(pathArg: string, licenseArrayArg: string[]) {
|
||||
const checkResult = new CheckResult();
|
||||
const plainResultArray = await this.createPlainResultArray(pathArg);
|
||||
plainResultArray.forEach(licenseResult => {
|
||||
plainResultArray.forEach((licenseResult) => {
|
||||
if (licenseArrayArg.indexOf(licenseResult.license) === -1) {
|
||||
checkResult.addPassing(licenseResult);
|
||||
} else {
|
||||
@ -40,7 +20,7 @@ export class LicenseChecker {
|
||||
async includeLicencesWithinPath(pathArg: string, licenseArrayArg: string[]) {
|
||||
const checkResult = new CheckResult();
|
||||
const plainResultArray = await this.createPlainResultArray(pathArg);
|
||||
plainResultArray.forEach(licenseResult => {
|
||||
plainResultArray.forEach((licenseResult) => {
|
||||
if (licenseArrayArg.indexOf(licenseResult.license) !== -1) {
|
||||
checkResult.addPassing(licenseResult);
|
||||
} else {
|
||||
@ -52,8 +32,8 @@ export class LicenseChecker {
|
||||
|
||||
async createPlainResultArray(pathArg: string) {
|
||||
const licenseJson = await this.getJsonForPath(pathArg);
|
||||
const resultArray: IModuleLicenseResult[] = [];
|
||||
for (let moduleKey in licenseJson) {
|
||||
const resultArray: interfaces.IModuleLicenseResult[] = [];
|
||||
for (const moduleKey of Object.keys(licenseJson)) {
|
||||
const refObject = licenseJson[moduleKey];
|
||||
resultArray.push({
|
||||
moduleName: moduleKey,
|
||||
@ -62,19 +42,19 @@ export class LicenseChecker {
|
||||
license: refObject.licenses,
|
||||
path: refObject.path,
|
||||
publisher: refObject.publisher,
|
||||
repository: refObject.repository
|
||||
repository: refObject.repository,
|
||||
});
|
||||
}
|
||||
return resultArray;
|
||||
}
|
||||
|
||||
private async getJsonForPath(checkPathArg) {
|
||||
let done = plugins.smartpromise.defer<any>();
|
||||
const done = plugins.smartpromise.defer<any>();
|
||||
licenseChecker.init(
|
||||
{
|
||||
start: checkPathArg
|
||||
start: checkPathArg,
|
||||
},
|
||||
function(err, licenseJson) {
|
||||
(err, licenseJson) => {
|
||||
if (err) {
|
||||
done.reject(err);
|
||||
} else {
|
||||
@ -82,6 +62,6 @@ export class LicenseChecker {
|
||||
}
|
||||
}
|
||||
);
|
||||
return await done.promise;
|
||||
return done.promise;
|
||||
}
|
||||
}
|
||||
|
9
ts/mod.licensechecker/interfaces.ts
Normal file
9
ts/mod.licensechecker/interfaces.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export interface IModuleLicenseResult {
|
||||
moduleName: string;
|
||||
license: string;
|
||||
repository: string;
|
||||
publisher: string;
|
||||
email: string;
|
||||
path: string;
|
||||
licenseFile: string;
|
||||
}
|
Reference in New Issue
Block a user