Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
3115d2349e | |||
048c329133 | |||
44a303e710 | |||
c5eb97efff | |||
2c4db09ac1 | |||
0450388295 | |||
01068a7ff0 | |||
7320344788 | |||
d82b8a6dbd | |||
40d12bc91e | |||
6477b8a375 | |||
4b5b2e7ca5 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
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
|
||||
@ -109,7 +120,7 @@ pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci command npm install -g @git.zone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
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,12 +4,13 @@
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartlegal",
|
||||
"shortDescription": "go legal programmatically",
|
||||
"npmPackagename": "@pushrocks/smartlegal",
|
||||
"description": "go legal programmatically",
|
||||
"npmPackagename": "@push.rocks/smartlegal",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
|
3104
package-lock.json
generated
3104
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
@ -1,17 +1,18 @@
|
||||
{
|
||||
"name": "@pushrocks/smartlegal",
|
||||
"version": "1.0.21",
|
||||
"name": "@push.rocks/smartlegal",
|
||||
"version": "1.0.26",
|
||||
"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)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pkunz/legal.git"
|
||||
"url": "git+ssh://git@gitlab.com/push.rocks/smartlegal.git"
|
||||
},
|
||||
"keywords": [
|
||||
"legal",
|
||||
@ -22,35 +23,38 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pkunz/legal/issues"
|
||||
"url": "https://gitlab.com/push.rocks/smartlegal/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pkunz/legal#README",
|
||||
"homepage": "https://gitlab.com/push.rocks/smartlegal#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"
|
||||
"@push.rocks/smartmarkdown": "^3.0.1",
|
||||
"@push.rocks/smartmustache": "^3.0.2",
|
||||
"@push.rocks/smartpnpm": "^1.0.6",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartshell": "^3.0.3",
|
||||
"@tsclass/tsclass": "^4.0.43"
|
||||
},
|
||||
"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"
|
||||
"@git.zone/tsbuild": "^2.1.25",
|
||||
"@git.zone/tsrun": "^1.2.12",
|
||||
"@git.zone/tstest": "^1.0.54",
|
||||
"@push.rocks/tapbundle": "^5.0.15",
|
||||
"@types/node": "^20.8.4"
|
||||
},
|
||||
"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"
|
||||
],
|
||||
"type": "module"
|
||||
}
|
||||
|
6429
pnpm-lock.yaml
generated
Normal file
6429
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
37
readme.md
37
readme.md
@ -1,20 +1,26 @@
|
||||
# @pushrocks/smartlegal
|
||||
# @push.rocks/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/)
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartlegal)
|
||||
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartlegal)
|
||||
* [github.com (source mirror)](https://github.com/push.rocks/smartlegal)
|
||||
* [docs (typedoc)](https://push.rocks.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)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -22,7 +28,7 @@ Use TypeScript for best in class instellisense.
|
||||
|
||||
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
|
||||
|
||||
@ -30,7 +36,6 @@ We are always happy for code contributions. If you are not the code contributing
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
|
16
test/test.ts
16
test/test.ts
@ -1,23 +1,17 @@
|
||||
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');
|
||||
});
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import * as legal from '../ts/index.js';
|
||||
|
||||
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);
|
||||
expect(checkResult.failingModules.length).toBeGreaterThan(10);
|
||||
console.log(checkResult);
|
||||
});
|
||||
|
||||
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);
|
||||
expect(checkResult.failingModules.length).toBeGreaterThan(10);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartlegal',
|
||||
version: '1.0.26',
|
||||
description: 'go legal programmatically'
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
import * as plugins from './legal.plugins';
|
||||
import { ICompany } from '@tsclass/tsclass';
|
||||
|
||||
export const createLicenseChecker = async () => {
|
||||
const licenseCheckerMod = await import('./mod.licensechecker/classes.licensechecker');
|
||||
const licenseCheckerMod = await import('./mod.licensechecker/classes.licensechecker.js');
|
||||
return new licenseCheckerMod.LicenseChecker();
|
||||
};
|
||||
|
@ -1,13 +1,8 @@
|
||||
// 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 };
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
export { smartpromise, smartshell };
|
||||
|
14
ts/mod.licensechecker/classes.checkresult.ts
Normal file
14
ts/mod.licensechecker/classes.checkresult.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export class CheckResult {
|
||||
passingModules: plugins.smartpnpm.IPnpmLicenseResult[] = [];
|
||||
failingModules: plugins.smartpnpm.IPnpmLicenseResult[] = [];
|
||||
|
||||
public addPassing(moduleResultArg: plugins.smartpnpm.IPnpmLicenseResult) {
|
||||
this.passingModules.push(moduleResultArg);
|
||||
}
|
||||
|
||||
public addFailing(moduleResultArg: plugins.smartpnpm.IPnpmLicenseResult) {
|
||||
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 plugins from './plugins.js';
|
||||
import { CheckResult } from './classes.checkresult.js';
|
||||
|
||||
export class LicenseChecker {
|
||||
|
||||
async excludeLicenseWithinPath(pathArg: string, licenseArrayArg: string[]) {
|
||||
const checkResult = new CheckResult();
|
||||
const plainResultArray = await this.createPlainResultArray(pathArg);
|
||||
plainResultArray.forEach(licenseResult => {
|
||||
const pnpm = new plugins.smartpnpm.SmartPnpm(pathArg);
|
||||
const plainResultArray = await pnpm.getDependencyLicenseFlatArray();
|
||||
plainResultArray.forEach((licenseResult) => {
|
||||
if (licenseArrayArg.indexOf(licenseResult.license) === -1) {
|
||||
checkResult.addPassing(licenseResult);
|
||||
} else {
|
||||
@ -39,8 +19,9 @@ export class LicenseChecker {
|
||||
|
||||
async includeLicencesWithinPath(pathArg: string, licenseArrayArg: string[]) {
|
||||
const checkResult = new CheckResult();
|
||||
const plainResultArray = await this.createPlainResultArray(pathArg);
|
||||
plainResultArray.forEach(licenseResult => {
|
||||
const pnpm = new plugins.smartpnpm.SmartPnpm(pathArg);
|
||||
const plainResultArray = await pnpm.getDependencyLicenseFlatArray();
|
||||
plainResultArray.forEach((licenseResult) => {
|
||||
if (licenseArrayArg.indexOf(licenseResult.license) !== -1) {
|
||||
checkResult.addPassing(licenseResult);
|
||||
} else {
|
||||
@ -49,39 +30,4 @@ export class LicenseChecker {
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
7
ts/mod.licensechecker/plugins.ts
Normal file
7
ts/mod.licensechecker/plugins.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export * from '../legal.plugins.js'
|
||||
|
||||
import * as smartpnpm from '@push.rocks/smartpnpm';
|
||||
|
||||
export {
|
||||
smartpnpm,
|
||||
}
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"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