summaryrefslogtreecommitdiffstats
path: root/webpack.config.js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-09-04 00:20:46 +0200
committerGitHub <noreply@github.com>2022-09-04 00:20:46 +0200
commit49efd1fb96e70a0a2517b5183d66dba301649655 (patch)
tree16e2672c5edefb618c452960e6996030eb82aebb /webpack.config.js
parent82c6f7bf4afaa064035daae6094649d47cc3bc70 (diff)
downloadgitea-49efd1fb96e70a0a2517b5183d66dba301649655.tar.gz
gitea-49efd1fb96e70a0a2517b5183d66dba301649655.zip
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.
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/webpack.config.js b/webpack.config.js
index 9252a5a31f..904687098b 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -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: {