1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.PluginOptionsReader = void 0;
|
---|
4 | var PluginOptionsReader = /** @class */ (function () {
|
---|
5 | function PluginOptionsReader(context) {
|
---|
6 | this.context = context;
|
---|
7 | }
|
---|
8 | PluginOptionsReader.prototype.readOptions = function (options) {
|
---|
9 | var licenseInclusionTest = options.licenseInclusionTest || (function () { return true; });
|
---|
10 | var unacceptableLicenseTest = options.unacceptableLicenseTest || (function () { return false; });
|
---|
11 | var perChunkOutput = options.perChunkOutput === undefined || options.perChunkOutput;
|
---|
12 | var licenseTemplateDir = options.licenseTemplateDir;
|
---|
13 | var licenseTextOverrides = options.licenseTextOverrides || {};
|
---|
14 | var licenseTypeOverrides = options.licenseTypeOverrides || {};
|
---|
15 | var handleUnacceptableLicense = options.handleUnacceptableLicense || (function () { });
|
---|
16 | var handleMissingLicenseText = options.handleMissingLicenseText || (function () { return null; });
|
---|
17 | var renderLicenses = options.renderLicenses ||
|
---|
18 | (function (modules) {
|
---|
19 | return modules
|
---|
20 | .sort(function (left, right) {
|
---|
21 | return left.name < right.name ? -1 : 1;
|
---|
22 | })
|
---|
23 | .reduce(function (file, module) {
|
---|
24 | return "" + file + module.name + (module.licenseId ? "\n" + module.licenseId : '') + (module.licenseText ? "\n" + module.licenseText : '') + "\n\n";
|
---|
25 | }, '')
|
---|
26 | .trim() + "\n";
|
---|
27 | });
|
---|
28 | var renderBanner = options.renderBanner ||
|
---|
29 | (function (filename) {
|
---|
30 | return "/*! License information is available at " + filename + " */";
|
---|
31 | });
|
---|
32 | var outputFilename = options.outputFilename ||
|
---|
33 | (perChunkOutput ? '[name].licenses.txt' : 'licenses.txt');
|
---|
34 | var addBanner = options.addBanner === undefined ? false : options.addBanner;
|
---|
35 | var chunkIncludeExcludeTest = options.chunkIncludeExcludeTest || (function () { return true; });
|
---|
36 | var modulesDirectories = options.modulesDirectories || null;
|
---|
37 | var additionalChunkModules = options.additionalChunkModules || {};
|
---|
38 | var additionalModules = options.additionalModules || [];
|
---|
39 | var preferredLicenseTypes = options.preferredLicenseTypes || [];
|
---|
40 | var handleLicenseAmbiguity = options.handleLicenseAmbiguity ||
|
---|
41 | (function (_packageName, licenses) {
|
---|
42 | return licenses[0].type;
|
---|
43 | });
|
---|
44 | var handleMissingLicenseType = options.handleMissingLicenseType || (function () { return null; });
|
---|
45 | var licenseFileOverrides = options.licenseFileOverrides || {};
|
---|
46 | var excludedPackageTest = options.excludedPackageTest || (function () { return false; });
|
---|
47 | var stats = {
|
---|
48 | warnings: options.stats && options.stats.warnings !== undefined
|
---|
49 | ? options.stats.warnings
|
---|
50 | : true,
|
---|
51 | errors: options.stats && options.stats.errors !== undefined
|
---|
52 | ? options.stats.errors
|
---|
53 | : true
|
---|
54 | };
|
---|
55 | var skipChildCompilers = !!options.skipChildCompilers;
|
---|
56 | var constructedOptions = {
|
---|
57 | licenseInclusionTest: licenseInclusionTest,
|
---|
58 | unacceptableLicenseTest: unacceptableLicenseTest,
|
---|
59 | perChunkOutput: perChunkOutput,
|
---|
60 | licenseTemplateDir: licenseTemplateDir,
|
---|
61 | licenseTextOverrides: licenseTextOverrides,
|
---|
62 | licenseFileOverrides: licenseFileOverrides,
|
---|
63 | licenseTypeOverrides: licenseTypeOverrides,
|
---|
64 | handleUnacceptableLicense: handleUnacceptableLicense,
|
---|
65 | handleMissingLicenseText: handleMissingLicenseText,
|
---|
66 | renderLicenses: renderLicenses,
|
---|
67 | renderBanner: renderBanner,
|
---|
68 | outputFilename: outputFilename,
|
---|
69 | addBanner: addBanner,
|
---|
70 | chunkIncludeExcludeTest: chunkIncludeExcludeTest,
|
---|
71 | modulesDirectories: modulesDirectories,
|
---|
72 | additionalChunkModules: additionalChunkModules,
|
---|
73 | additionalModules: additionalModules,
|
---|
74 | preferredLicenseTypes: preferredLicenseTypes,
|
---|
75 | handleLicenseAmbiguity: handleLicenseAmbiguity,
|
---|
76 | handleMissingLicenseType: handleMissingLicenseType,
|
---|
77 | excludedPackageTest: excludedPackageTest,
|
---|
78 | stats: stats,
|
---|
79 | skipChildCompilers: skipChildCompilers,
|
---|
80 | buildRoot: this.context
|
---|
81 | };
|
---|
82 | return constructedOptions;
|
---|
83 | };
|
---|
84 | return PluginOptionsReader;
|
---|
85 | }());
|
---|
86 | exports.PluginOptionsReader = PluginOptionsReader;
|
---|