diff options
author | silverwind <me@silverwind.io> | 2022-09-07 23:35:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-07 17:35:54 -0400 |
commit | 52c2ef79023541f36fbb72b2e4598cb6f693335f (patch) | |
tree | 1f40ade459d6dbe62feb7e8b57b3cebef56f10ac /webpack.config.js | |
parent | 8b8bdb30fbc522c38a35aad46a0036b926f5db9d (diff) | |
download | gitea-52c2ef79023541f36fbb72b2e4598cb6f693335f.tar.gz gitea-52c2ef79023541f36fbb72b2e4598cb6f693335f.zip |
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>
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/webpack.config.js b/webpack.config.js index 904687098b..39628df049 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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)); |