From 5f29165bc363f7daca1e8505d6b9e83f60c046db Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 1 Apr 2022 14:03:30 -0500 Subject: [PATCH] craco: add missing dexie-observable license Also throw error on missing (default was only warning). --- craco.config.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/craco.config.js b/craco.config.js index 761be952..051d45e2 100644 --- a/craco.config.js +++ b/craco.config.js @@ -2,12 +2,13 @@ // // https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#configuration -const { addBeforeLoader, loaderByName, getLoader } = require('@craco/craco'); +const { addBeforeLoader, loaderByName } = require('@craco/craco'); const CopyPlugin = require('copy-webpack-plugin'); const LicensePlugin = require('license-webpack-plugin').LicenseWebpackPlugin; const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); const satisfies = require('spdx-satisfies'); const path = require('path'); +const fs = require('fs'); // Permissive licenses can be added here. We would like to avoid copyleft. const approvedLicenses = ['0BSD', 'Apache-2.0', 'BSD-3-Clause', 'ISC', 'MIT']; @@ -37,6 +38,11 @@ function personToString(person) { // Some packages don't have a separate license file, so we have to copy the // license here e.g. from the README. +const dexieLicense = fs.readFileSync( + path.join(__dirname, 'node_modules', 'dexie', 'LICENSE'), + { encoding: 'utf-8' }, +); + function fedorIndutnyLicense(year) { return `This software is licensed under the MIT License. @@ -115,6 +121,7 @@ const licenseTextOverrides = { '@shopify/react': shopifyLicense, '@shopify/react-hooks': shopifyLicense, '@shopify/react-i18n': shopifyLicense, + 'dexie-observable': dexieLicense, 'bn.js': fedorIndutnyLicense(2015), brorand: fedorIndutnyLicense(2014), 'des.js': fedorIndutnyLicense(2015), @@ -266,6 +273,11 @@ module.exports = { ], unacceptableLicenseTest: (licenseType) => !satisfies(licenseType, `(${approvedLicenses.join(' OR ')})`), + handleMissingLicenseText: (packageName, licenseType) => { + throw new Error( + `missing license text for ${packageName} (${licenseType})`, + ); + }, }), new MonacoWebpackPlugin({ languages: ['python'],