From 52c2ef79023541f36fbb72b2e4598cb6f693335f Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 7 Sep 2022 23:35:54 +0200 Subject: 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 Co-authored-by: zeripath --- webpack.config.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'webpack.config.js') 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)); -- cgit v1.2.3