forked from forgejo/forgejo
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:
parent
82c6f7bf4a
commit
49efd1fb96
6 changed files with 827 additions and 7 deletions
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue