mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Rewrite go license generator in go (#21078)
This removes the JS dependency in the checks pipeline. JSON output is different because the previous JS did indent the license data differently and a JSON key was changed, but the end result is the same as it gets re-indented by wepack. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
		| @@ -14,6 +14,8 @@ import {readFileSync} from 'fs'; | ||||
| const {VueLoaderPlugin} = VueLoader; | ||||
| const {ESBuildMinifyPlugin} = EsBuildLoader; | ||||
| const {SourceMapDevToolPlugin} = webpack; | ||||
| const formatLicenseText = (licenseText) => wrapAnsi(licenseText || '', 80).trim(); | ||||
|  | ||||
| const glob = (pattern) => fastGlob.sync(pattern, { | ||||
|   cwd: dirname(fileURLToPath(new URL(import.meta.url))), | ||||
|   absolute: true, | ||||
| @@ -206,10 +208,12 @@ export default { | ||||
|       outputFilename: 'js/licenses.txt', | ||||
|       outputWriter: ({dependencies}) => { | ||||
|         const line = '-'.repeat(80); | ||||
|         const goModules = JSON.parse(readFileSync('assets/go-licenses.json', 'utf8')); | ||||
|         const goJson = readFileSync('assets/go-licenses.json', 'utf8'); | ||||
|         const goModules = JSON.parse(goJson).map(({name, licenseText}) => { | ||||
|           return {name, body: formatLicenseText(licenseText)}; | ||||
|         }); | ||||
|         const jsModules = dependencies.map(({name, version, licenseName, licenseText}) => { | ||||
|           const body = wrapAnsi(licenseText || '', 80); | ||||
|           return {name, version, licenseName, body}; | ||||
|           return {name, version, licenseName, body: formatLicenseText(licenseText)}; | ||||
|         }); | ||||
|  | ||||
|         const modules = [...goModules, ...jsModules].sort((a, b) => a.name.localeCompare(b.name)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user