forked from MapComplete/MapComplete
		
	More steps toward REUSE-compliance
This commit is contained in:
		
							parent
							
								
									d3aa5562a5
								
							
						
					
					
						commit
						0d598ad094
					
				
					 795 changed files with 3082 additions and 92 deletions
				
			
		|  | @ -2,6 +2,7 @@ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from " | |||
| import SmallLicense from "../src/Models/smallLicense" | ||||
| import ScriptUtils from "./ScriptUtils" | ||||
| import Script from "./Script" | ||||
| import { Utils } from "../src/Utils" | ||||
| 
 | ||||
| const prompt = require("prompt-sync")() | ||||
| 
 | ||||
|  | @ -185,6 +186,41 @@ export class GenerateLicenseInfo extends Script { | |||
|         writeFileSync(path + ".license_info.json", JSON.stringify(li, null, "  ")) | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Rewrites a license into a SPDX-valid-ID. | ||||
|      * Might involve some guesswork (e.g. 'CC-BY-SA' --> 'CC-BY-SA 4.0" | ||||
|      * @param licenseId | ||||
|      */ | ||||
|     toSPDXCompliantLicense(licenseId: string): string { | ||||
|         licenseId = licenseId.trim().replaceAll(" ", "-") | ||||
|         if (!(licenseId.endsWith("-only") || licenseId.endsWith("-or-later"))) { | ||||
|             licenseId = licenseId.toUpperCase() | ||||
|         } | ||||
|         // https://spdx.org/licenses/
 | ||||
|         const mappings: Record<string, string> = { | ||||
|             "CC-0": "CC0-1.0", | ||||
|             CC0: "CC0-1.0", | ||||
|             "CC-BY-4.0-INTERNATIONAL": "CC-BY-4.0", | ||||
|             "CC-4.0": "CC-BY-4.0", | ||||
|             "CC-BY": "CC-BY-4.0", | ||||
|             "CC-BY-SA-4.0-INTERNATIONAL": "CC-BY-SA-4.0", | ||||
|             "CC-BY-SA": "CC-BY-SA-4.0", | ||||
|             "CREATIVE-COMMONS-4.0-BY-NC": "CC-BY-NC-4.0", | ||||
|             "CC-BY-SA-3.0-UNPORTED": "CC-BY-SA-3.0", | ||||
|             "ISC-LICENSE": "ISC", | ||||
|             /*  ALL-RIGHTS-RESERVED: | ||||
|             PD: | ||||
|                 PUBLIC-DOMAIN: | ||||
|         GNU: | ||||
|             GPL: | ||||
|                 ISC-LICENSE: | ||||
|         LOGO-BY-THE-GOVERNMENT: | ||||
|         LOGO: | ||||
|         TRIVIAL: //*/
 | ||||
|         } | ||||
| 
 | ||||
|         return mappings[licenseId] ?? licenseId | ||||
|     } | ||||
|     cleanLicenseInfo(allPaths: string[], allLicenseInfos: SmallLicense[]) { | ||||
|         // Read the license info file from the generated assets, creates a compiled license info in every directory
 | ||||
|         // Note: this removes all the old license infos
 | ||||
|  | @ -208,6 +244,11 @@ export class GenerateLicenseInfo extends Script { | |||
|                 authors: license.authors, | ||||
|                 sources: license.sources, | ||||
|             } | ||||
| 
 | ||||
|             cloned.license = Utils.Dedup( | ||||
|                 cloned.license.split(";").map((l) => this.toSPDXCompliantLicense(l)) | ||||
|             ).join("; ") | ||||
| 
 | ||||
|             perDirectory.get(dir).push(cloned) | ||||
|         } | ||||
| 
 | ||||
|  | @ -339,6 +380,14 @@ export class GenerateLicenseInfo extends Script { | |||
|                     invalidLicenses.push("Not a valid URL: " + source) | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             const spdxPath = licenseInfo.path + ".license" | ||||
| 
 | ||||
|             const spdxContent = [ | ||||
|                 "SPDX-FileCopyrightText: " + licenseInfo.authors.join("; "), | ||||
|                 "SPDX-License-Identifier: " + licenseInfo.license, | ||||
|             ] | ||||
|             writeFileSync(spdxPath, spdxContent.join("\n")) | ||||
|         } | ||||
| 
 | ||||
|         if (missingLicenses.length > 0 || invalidLicenses.length) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue