|
| 1 | +const checker = require("license-checker-rseidelsohn"); |
| 2 | +const fs = require("fs"); |
| 3 | + |
| 4 | +const manual = [ |
| 5 | + { |
| 6 | + name: "rss-parser (Adapted Code)", |
| 7 | + licenses: "MIT", |
| 8 | + text: `MIT License |
| 9 | +
|
| 10 | +Copyright (c) 2016 Bobby Brennan |
| 11 | +
|
| 12 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 13 | +of this software and associated documentation files (the "Software"), to deal |
| 14 | +in the Software without restriction, including without limitation the rights |
| 15 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 16 | +copies of the Software, and to permit persons to whom the Software is |
| 17 | +furnished to do so, subject to the following conditions: |
| 18 | +
|
| 19 | +The above copyright notice and this permission notice shall be included in all |
| 20 | +copies or substantial portions of the Software. |
| 21 | +
|
| 22 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 23 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 24 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 25 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 26 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 27 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 28 | +SOFTWARE.` |
| 29 | + } |
| 30 | +]; |
| 31 | + |
| 32 | +checker.init({ |
| 33 | + start: ".", |
| 34 | + production: true, |
| 35 | +}, (err, packages) => { |
| 36 | + if (err) { |
| 37 | + console.error(err); |
| 38 | + process.exit(1); |
| 39 | + } |
| 40 | + |
| 41 | + const all_packages = []; |
| 42 | + |
| 43 | + Object.keys(packages).forEach(pkg_name => { |
| 44 | + // ignore ollieos |
| 45 | + if (pkg_name.startsWith("ollieos@")) { |
| 46 | + return; |
| 47 | + } |
| 48 | + |
| 49 | + // check if licenseText exists, if not read from licenseFile |
| 50 | + let text = "See Repository"; |
| 51 | + if (packages[pkg_name].licenseText) { |
| 52 | + text = packages[pkg_name].licenseText; |
| 53 | + } else if (packages[pkg_name].licenseFile) { |
| 54 | + try { |
| 55 | + text = fs.readFileSync(packages[pkg_name].licenseFile, "utf8"); |
| 56 | + } catch (e) { |
| 57 | + console.warn(`Could not read license file for ${pkg_name}: ${e}`); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + all_packages.push({ |
| 62 | + name: pkg_name, |
| 63 | + licenses: packages[pkg_name].licenses, |
| 64 | + text, |
| 65 | + }); |
| 66 | + }); |
| 67 | + |
| 68 | + manual.forEach(entry => all_packages.push(entry)); |
| 69 | + |
| 70 | + fs.writeFileSync("./public/script/3rdpartylicenses.txt", all_packages.map(pkg => { |
| 71 | + return `Package: ${pkg.name}\nLicense: ${pkg.licenses}\n\n${pkg.text}\n\n-----------------------\n`; |
| 72 | + }).join(""), "utf8"); |
| 73 | +}); |
0 commit comments