mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-8215] Filter out dependencies of dependencies in licenses.ts script (#10241)
* [ACS-8215] Filter out dependencies of dependencies in licenses.ts script * ACS-8215 filter out wrong deps from license * ACS-8215 fix license list * ACS-8215 revert md file * Updated md file * ACS-8215 remove mark * add type * [ACS-8215] Add missing fix --------- Co-authored-by: Darya Balvanovich <darya.balvanovich@hyland.com> Co-authored-by: MichalKinas <michal.kinas@hyland.com>
This commit is contained in:
@@ -36,6 +36,7 @@ interface PackageInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
version: string;
|
||||
dependencies: Record<string, string>;
|
||||
}
|
||||
|
||||
const nonStandardLicenses = {
|
||||
@@ -135,6 +136,8 @@ export default function main(_args: string[], workingDir: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(`Checking ${packagePath}`);
|
||||
const packageJsonFile = getPackageFile(packagePath);
|
||||
const mainDependencies = Object.keys(packageJsonFile.dependencies || {});
|
||||
|
||||
checker.init(
|
||||
{
|
||||
@@ -147,29 +150,34 @@ export default function main(_args: string[], workingDir: string) {
|
||||
console.error(err);
|
||||
reject(err);
|
||||
} else {
|
||||
const filteredPackages = {};
|
||||
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (const packageName in packages) {
|
||||
const pack = packages[packageName];
|
||||
pack['licenseExp'] = pack['licenses']
|
||||
.toString()
|
||||
.replace(/\*/g, '')
|
||||
.replace(/[a-zA-Z0-9\-.]+/g, (match: string) => {
|
||||
const lowerMatch = match.toLowerCase();
|
||||
|
||||
if (lowerMatch !== 'and' && lowerMatch !== 'or' && lowerMatch !== 'with') {
|
||||
return licenseWithMDLinks(match);
|
||||
} else {
|
||||
return match;
|
||||
}
|
||||
});
|
||||
const lastAtSignPos = packageName.lastIndexOf('@');
|
||||
const basePackageName = packageName.substring(0, lastAtSignPos);
|
||||
|
||||
if (!pack['repository']) {
|
||||
const lastAtSignPos = packageName.lastIndexOf('@');
|
||||
const mainName = packageName.substring(0, lastAtSignPos);
|
||||
if (mainDependencies.includes(basePackageName)) {
|
||||
pack['licenseExp'] = pack['licenses']
|
||||
.toString()
|
||||
.replace(/\*/g, '')
|
||||
.replace(/[a-zA-Z0-9\-.]+/g, (match: string) => {
|
||||
const lowerMatch = match.toLowerCase();
|
||||
if (lowerMatch !== 'and' && lowerMatch !== 'or' && lowerMatch !== 'with') {
|
||||
return licenseWithMDLinks(match);
|
||||
} else {
|
||||
return match;
|
||||
}
|
||||
});
|
||||
|
||||
if (missingRepositories[mainName]) {
|
||||
pack['repository'] = missingRepositories[mainName];
|
||||
}
|
||||
filteredPackages[packageName] = pack;
|
||||
}
|
||||
|
||||
if (!pack['repository'] && missingRepositories[basePackageName]) {
|
||||
pack['repository'] = missingRepositories[basePackageName];
|
||||
filteredPackages[packageName] = pack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +186,7 @@ export default function main(_args: string[], workingDir: string) {
|
||||
ejs.renderFile(
|
||||
templatePath,
|
||||
{
|
||||
packages,
|
||||
filteredPackages,
|
||||
projVersion: packageJson.version,
|
||||
projName: packageJson.name
|
||||
},
|
||||
|
@@ -10,12 +10,12 @@ This page lists all third party libraries the project depends on.
|
||||
|
||||
| Name | Version | License |
|
||||
| --- | --- | --- |
|
||||
<% for (var packageName in packages) {
|
||||
<% for (var packageName in filteredPackages) {
|
||||
var lastAtSignPos = packageName.lastIndexOf('@');
|
||||
|
||||
var name = packageName.substring(0, lastAtSignPos);
|
||||
var version = packageName.substring(lastAtSignPos + 1);
|
||||
var pack = packages[packageName];
|
||||
var pack = filteredPackages[packageName];
|
||||
var licenses = pack['licenseExp'] || 'N/A';
|
||||
var repo = pack['repository'];
|
||||
var linkedName = name;
|
||||
|
Reference in New Issue
Block a user