From 9fd357d96e417c3df7e4915968949dc671ad5d18 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Wed, 17 Mar 2021 14:12:57 -0600 Subject: [PATCH] Delete with-config.js --- framework/commerce/with-config.js | 41 ------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 framework/commerce/with-config.js diff --git a/framework/commerce/with-config.js b/framework/commerce/with-config.js deleted file mode 100644 index 1eb1acc19..000000000 --- a/framework/commerce/with-config.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * This file is expected to be used in next.config.js only - */ - -const merge = require('deepmerge') - -const PROVIDERS = ['bigcommerce', 'shopify'] - -function getProviderName() { - // TODO: OSOT. - return process.env.BIGCOMMERCE_STOREFRONT_API_URL ? 'bigcommerce' : null -} - -module.exports = (nextConfig = {}) => { - const commerce = nextConfig.commerce || {} - const name = commerce.provider || getProviderName() - - if (!name) { - throw new Error( - `The commerce provider is missing, please add a valid provider name or its environment variables` - ) - } - if (!PROVIDERS.includes(name)) { - throw new Error( - `The commerce provider "${name}" can't be found, please use one of "${PROVIDERS.join( - ', ' - )}"` - ) - } - - const commerceNextConfig = require(`../${name}/next.config`) - const config = merge(commerceNextConfig, nextConfig) - - config.env = config.env || {} - - Object.entries(config.commerce.features).forEach(([k, v]) => { - if (v) config.env[`COMMERCE_${k.toUpperCase()}_ENABLED`] = true - }) - - return config -}