fix(core): update

This commit is contained in:
2023-10-12 01:21:12 +02:00
parent 2c4db09ac1
commit c5eb97efff
18 changed files with 4227 additions and 14208 deletions

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartlegal',
version: '1.0.25',
description: 'go legal programmatically'
}

View File

@ -1,5 +1,4 @@
export * from './mod.licensechecker/interfaces';
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();
};

View File

@ -1,11 +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';
export { smartpromise };
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartshell from '@push.rocks/smartshell';
export { smartpromise, smartshell };

View File

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

View File

@ -1,12 +1,12 @@
import * as plugins from '../legal.plugins';
import * as licenseChecker from 'license-checker';
import * as interfaces from './interfaces';
import { CheckResult } from './classes.checkresult';
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);
const pnpm = new plugins.smartpnpm.SmartPnpm(pathArg);
const plainResultArray = await pnpm.getDependencyLicenseFlatArray();
plainResultArray.forEach((licenseResult) => {
if (licenseArrayArg.indexOf(licenseResult.license) === -1) {
checkResult.addPassing(licenseResult);
@ -19,7 +19,8 @@ export class LicenseChecker {
async includeLicencesWithinPath(pathArg: string, licenseArrayArg: string[]) {
const checkResult = new CheckResult();
const plainResultArray = await this.createPlainResultArray(pathArg);
const pnpm = new plugins.smartpnpm.SmartPnpm(pathArg);
const plainResultArray = await pnpm.getDependencyLicenseFlatArray();
plainResultArray.forEach((licenseResult) => {
if (licenseArrayArg.indexOf(licenseResult.license) !== -1) {
checkResult.addPassing(licenseResult);
@ -29,39 +30,4 @@ export class LicenseChecker {
});
return checkResult;
}
async createPlainResultArray(pathArg: string) {
const licenseJson = await this.getJsonForPath(pathArg);
const resultArray: interfaces.IModuleLicenseResult[] = [];
for (const moduleKey of Object.keys(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) {
const done = plugins.smartpromise.defer<any>();
licenseChecker.init(
{
start: checkPathArg,
},
(err, licenseJson) => {
if (err) {
done.reject(err);
} else {
done.resolve(licenseJson);
}
}
);
return done.promise;
}
}

View File

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

View File

@ -0,0 +1,7 @@
export * from '../legal.plugins.js'
import * as smartpnpm from '@push.rocks/smartpnpm';
export {
smartpnpm,
}