From 61ba415717a0d9e65d1897f53e5ed72844fa87df Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 25 Sep 2020 21:10:17 +0200 Subject: [PATCH] fix: tighten up ensure-env and env.js (#39694) --- config/env.js | 6 +++--- tools/scripts/build/ensure-env.js | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config/env.js b/config/env.js index af73df467bc..8e4a04faafd 100644 --- a/config/env.js +++ b/config/env.js @@ -39,16 +39,16 @@ module.exports = Object.assign(locations, { ? null : stripePublicKey, algoliaAppId: - !algoliaAppId || algoliaAppId === 'Algolia app id from dashboard' + !algoliaAppId || algoliaAppId === 'app_id_from_algolia_dashboard' ? null : algoliaAppId, algoliaAPIKey: - !algoliaAPIKey || algoliaAPIKey === 'Algolia api key from dashboard' + !algoliaAPIKey || algoliaAPIKey === 'api_key_from_algolia_dashboard' ? null : algoliaAPIKey, paypalClientId: !paypalClientId || paypalClientId === 'id_from_paypal_dashboard' ? null : paypalClientId, - showUpcomingChanges: showUpcomingChanges && showUpcomingChanges === 'true' + showUpcomingChanges: showUpcomingChanges === 'true' }); diff --git a/tools/scripts/build/ensure-env.js b/tools/scripts/build/ensure-env.js index cef67416a7d..4fe5570c477 100644 --- a/tools/scripts/build/ensure-env.js +++ b/tools/scripts/build/ensure-env.js @@ -45,6 +45,12 @@ if (FREECODECAMP_NODE_ENV === 'production') { throw Error(`Env. variable ${key} is missing, build cannot continue`); } } + + if (env['environment'] !== 'production') + throw Error("Production environment should be 'production' "); + + if (env['showUpcomingChanges']) + throw Error("SHOW_UPCOMING_CHANGES should never be 'true' in production"); } fs.writeFileSync(`${clientPath}/config/env.json`, JSON.stringify(env));