forked from forgejo/forgejo
Add automatic JS license generation (#11810)
* Add automatic JS license generation Removed librejs file and replaced it with a plaintext file that is built from all JS dependencies that are included in the webpack build. It does not cover the few remaining statically vendored files and fomantic is added manually because it's not yet in the webpack build process. Fixes: https://github.com/go-gitea/gitea/issues/11630 * fix lint * remove jslicense, we're not librejs compatible any more * remove license.txt test as it depens on absent files * small optimization * trailing comma * localize and capitalize the word 'licenses' * reduce text to just 'Licenses' Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
2b573f49cf
commit
bc4f7ba69b
8 changed files with 142 additions and 138 deletions
|
@ -1,5 +1,6 @@
|
|||
const cssnano = require('cssnano');
|
||||
const fastGlob = require('fast-glob');
|
||||
const wrapAnsi = require('wrap-ansi');
|
||||
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
||||
|
@ -11,6 +12,7 @@ const TerserPlugin = require('terser-webpack-plugin');
|
|||
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
||||
const {statSync} = require('fs');
|
||||
const {resolve, parse} = require('path');
|
||||
const {LicenseWebpackPlugin} = require('license-webpack-plugin');
|
||||
const {SourceMapDevToolPlugin} = require('webpack');
|
||||
|
||||
const glob = (pattern) => fastGlob.sync(pattern, {cwd: __dirname, absolute: true});
|
||||
|
@ -241,6 +243,34 @@ module.exports = {
|
|||
new MonacoWebpackPlugin({
|
||||
filename: 'js/monaco-[name].worker.js',
|
||||
}),
|
||||
new LicenseWebpackPlugin({
|
||||
outputFilename: 'js/licenses.txt',
|
||||
perChunkOutput: false,
|
||||
addBanner: false,
|
||||
skipChildCompilers: true,
|
||||
modulesDirectories: [
|
||||
resolve(__dirname, 'node_modules'),
|
||||
],
|
||||
additionalModules: [
|
||||
{
|
||||
name: 'fomantic-ui',
|
||||
directory: resolve(__dirname, 'node_modules/fomantic-ui'),
|
||||
},
|
||||
],
|
||||
renderLicenses: (modules) => {
|
||||
const line = '-'.repeat(80);
|
||||
return modules.map((module) => {
|
||||
const {name, version} = module.packageJson;
|
||||
const {licenseId, licenseText} = module;
|
||||
const body = wrapAnsi(licenseText || '', 80);
|
||||
return `${line}\n${name}@${version} - ${licenseId}\n${line}\n${body}`;
|
||||
}).join('\n');
|
||||
},
|
||||
stats: {
|
||||
warnings: false,
|
||||
errors: true,
|
||||
},
|
||||
}),
|
||||
],
|
||||
performance: {
|
||||
hints: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue