fix(core): update
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
export interface IModuleLicenseResult {
|
||||
moduleName: string;
|
||||
license: string;
|
||||
repository: string;
|
||||
publisher: string;
|
||||
email: string;
|
||||
path: string;
|
||||
licenseFile: string;
|
||||
}
|
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,
|
||||
}
|
Reference in New Issue
Block a user