Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d82b8a6dbd | |||
40d12bc91e | |||
6477b8a375 | |||
4b5b2e7ca5 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -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
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"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
|
11471
package-lock.json
generated
11471
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",
|
"name": "@pushrocks/smartlegal",
|
||||||
"version": "1.0.21",
|
"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"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
23
readme.md
23
readme.md
@ -8,13 +8,20 @@ go legal programmatically
|
|||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartlegal/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartlegal/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartlegal/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartlegal/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartlegal)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartlegal)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
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
|
## Usage
|
||||||
|
|
||||||
@ -22,7 +29,7 @@ Use TypeScript for best in class instellisense.
|
|||||||
|
|
||||||
smartlegal implements
|
smartlegal implements
|
||||||
|
|
||||||
* a license checker for checking dependency trees against a set of licenses
|
- a license checker for checking dependency trees against a set of licenses
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
@ -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');
|
||||||
});
|
});
|
||||||
|
@ -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();
|
||||||
|
@ -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 };
|
|
||||||
|
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 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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