mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +01:00 
			
		
		
		
	Add go licenses to licenses.txt (#21034)
`make go-licenses` will generate `assets/go-licenses.json` which is then included in the webpack build. This step depends on both go and node being present, so unfortunately, I could not automate the generation by hooking it up to `tidy` as that target is triggered on CI where we do not have a docker image with both go an node. It should be ran from time to time, ideally after each go mod update.
This commit is contained in:
		| @@ -9,6 +9,7 @@ import EsBuildLoader from 'esbuild-loader'; | ||||
| import {parse, dirname} from 'path'; | ||||
| import webpack from 'webpack'; | ||||
| import {fileURLToPath} from 'url'; | ||||
| import {readFileSync} from 'fs'; | ||||
|  | ||||
| const {VueLoaderPlugin} = VueLoader; | ||||
| const {ESBuildMinifyPlugin} = EsBuildLoader; | ||||
| @@ -205,10 +206,16 @@ export default { | ||||
|       outputFilename: 'js/licenses.txt', | ||||
|       outputWriter: ({dependencies}) => { | ||||
|         const line = '-'.repeat(80); | ||||
|         return dependencies.map((module) => { | ||||
|           const {name, version, licenseName, licenseText} = module; | ||||
|         const goModules = JSON.parse(readFileSync('assets/go-licenses.json', 'utf8')); | ||||
|         const jsModules = dependencies.map(({name, version, licenseName, licenseText}) => { | ||||
|           const body = wrapAnsi(licenseText || '', 80); | ||||
|           return `${line}\n${name}@${version} - ${licenseName}\n${line}\n${body}`; | ||||
|           return {name, version, licenseName, body}; | ||||
|         }); | ||||
|  | ||||
|         const modules = [...goModules, ...jsModules].sort((a, b) => a.name.localeCompare(b.name)); | ||||
|         return modules.map(({name, version, licenseName, body}) => { | ||||
|           const title = licenseName ? `${name}@${version} - ${licenseName}` : name; | ||||
|           return `${line}\n${title}\n${line}\n${body}`; | ||||
|         }).join('\n'); | ||||
|       }, | ||||
|       override: { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user