const osiApproved = [
	'LPPL-1.3c',
	'UCL-1.0',
	'OSL-2.0',
	'AAL',
	'AFL-1.1',
	'W3C',
	'Sleepycat',
	'SISSL',
	'GPL-3.0-only',
	'LiLiQ-P-1.1',
	'CERN-OHL-S-2.0',
	'BSD-2-Clause',
	'ISC',
	'LGPL-3.0-only',
	'SimPL-2.0',
	'QPL-1.0',
	'OLDAP-2.8',
	'OFL-1.1-RFN',
	'SPL-1.0',
	'OSET-PL-2.1',
	'RPSL-1.0',
	'BSD-3-Clause-LBNL',
	'OGTSL',
	'GPL-3.0',
	'CERN-OHL-P-2.0',
	'AGPL-3.0-or-later',
	'APSL-2.0',
	'BSD-1-Clause',
	'LGPL-2.0-or-later',
	'LGPL-2.0',
	'LGPL-2.0+',
	'CDDL-1.0',
	'Xnet',
	'CPL-1.0',
	'LGPL-3.0-or-later',
	'NASA-1.3',
	'RPL-1.1',
	'GPL-3.0-or-later',
	'Apache-1.1',
	'AGPL-3.0-only',
	'Artistic-2.0',
	'ZPL-2.1',
	'Naumen',
	'RPL-1.5',
	'EFL-1.0',
	'MirOS',
	'MPL-2.0-no-copyleft-exception',
	'LiLiQ-Rplus-1.1',
	'AFL-1.2',
	'OSL-1.0',
	'APSL-1.0',
	'CPAL-1.0',
	'Unlicense',
	'MPL-2.0',
	'Entessa',
	'AFL-2.1',
	'GPL-2.0-only',
	'Frameworx-1.0',
	'CECILL-2.1',
	'CNRI-Python',
	'NCSA',
	'EUPL-1.1',
	'LPL-1.0',
	'EPL-1.0',
	'OSL-3.0',
	'PHP-3.0',
	'APL-1.0',
	'EUDatagrid',
	'Multics',
	'OFL-1.1-no-RFN',
	'Python-2.0',
	'HPND',
	'MPL-1.1',
	'ECL-1.0',
	'LGPL-2.1-or-later',
	'APSL-1.1',
	'CERN-OHL-W-2.0',
	'NTP',
	'PHP-3.01',
	'OCLC-2.0',
	'Zlib',
	'CATOSL-1.1',
	'LGPL-3.0+',
	'CAL-1.0',
	'GPL-2.0+',
	'GPL-2.0-or-later',
	'BSD-2-Clause-Patent',
	'MS-RL',
	'CUA-OPL-1.0',
	'IPA',
	'MIT-Modern-Variant',
	'0BSD',
	'Unicode-DFS-2016',
	'Intel',
	'AFL-2.0',
	'Motosoto',
	'VSL-1.0',
	'LiLiQ-R-1.1',
	'GPL-3.0+',
	'MulanPSL-2.0',
	'APSL-1.2',
	'RSCPL',
	'EFL-2.0',
	'CAL-1.0-Combined-Work-Exception',
	'MS-PL',
	'EUPL-1.2',
	'Watcom-1.0',
	'Jam',
	'Nokia',
	'OSL-2.1',
	'GPL-3.0-with-GCC-exception',
	'MIT',
	'LGPL-2.1+',
	'LGPL-2.1-only',
	'ECL-2.0',
	'IPL-1.0',
	'NGPL',
	'Fair',
	'LPL-1.02',
	'UPL-1.0',
	'ZPL-2.0',
	'MIT-0',
	'LGPL-2.0-only',
	'AGPL-3.0',
	'EPL-2.0',
	'AFL-3.0',
	'Artistic-1.0',
	'MPL-1.0',
	'PostgreSQL',
	'OFL-1.1',
	'BSD-3-Clause',
	'wxWindows',
	'LGPL-3.0',
	'LGPL-2.1',
	'Apache-2.0',
	'Artistic-1.0-cl8',
	'GPL-2.0',
	'BSL-1.0',
	'Artistic-1.0-Perl',
	'NPOSL-3.0',
	'BlueOak-1.0.0', // https://github.com/spdx/license-list-XML/commit/d2709ad9c8c3f92989d2e7cadba3af8d1e0bc166
];

export const osiApprovedWithCCO = [
	'CC0-1.0', // because almost all code here is CC0-1.0
	...osiApproved,
];

const licenseExceptions = [
	{
		// see : https://github.com/Fyrd/caniuse/issues/4062
		file: 'node_modules/caniuse-lite/package.json',
		license: 'CC-BY-4.0',
	},
	{
		// https://github.com/typescript-eslint/typescript-eslint/pull/10481
		file: 'node_modules/@typescript-eslint/parser/package.json',
		license: 'MITClause',
	},
];

export function licenseIsOkByException(file, license) {
	return licenseExceptions.some(exception => {
		return file.endsWith(exception.file) && exception.license === license;
	});
}

const missingLicenseExceptions = [
	{
		file: 'node_modules/filter-iterator/package.json',
	},
];

export function missingLicenseIsOkByException(file) {
	return missingLicenseExceptions.some(exception => {
		return file.endsWith(exception.file);
	});
}
