diff --git a/config/read-env.js b/config/read-env.js index a2b67d3833..81b78e932c 100644 --- a/config/read-env.js +++ b/config/read-env.js @@ -31,7 +31,8 @@ const { PAYPAL_CLIENT_ID: paypalClientId, PATREON_CLIENT_ID: patreonClientId, DEPLOYMENT_ENV: deploymentEnv, - SHOW_UPCOMING_CHANGES: showUpcomingChanges + SHOW_UPCOMING_CHANGES: showUpcomingChanges, + SHOW_NEW_CURRICULUM: showNewCurriculum } = process.env; const locations = { @@ -70,5 +71,6 @@ module.exports = Object.assign(locations, { !patreonClientId || patreonClientId === 'id_from_patreon_dashboard' ? null : patreonClientId, - showUpcomingChanges: showUpcomingChanges === 'true' + showUpcomingChanges: showUpcomingChanges === 'true', + showNewCurriculum: showNewCurriculum === 'true' }); diff --git a/sample.env b/sample.env index 22c5a5fd83..b335f3e1d4 100644 --- a/sample.env +++ b/sample.env @@ -57,6 +57,7 @@ CURRICULUM_LOCALE=english # Show or hide WIP in progress challenges SHOW_UPCOMING_CHANGES=false +SHOW_NEW_CURRICULUM=false # Application paths HOME_LOCATION=http://localhost:8000 diff --git a/tools/scripts/build/ensure-env.ts b/tools/scripts/build/ensure-env.ts index 6da64c1610..326d43e09e 100644 --- a/tools/scripts/build/ensure-env.ts +++ b/tools/scripts/build/ensure-env.ts @@ -49,7 +49,8 @@ if (FREECODECAMP_NODE_ENV !== 'development') { 'showLocaleDropdownMenu', 'deploymentEnv', 'environment', - 'showUpcomingChanges' + 'showUpcomingChanges', + 'showNewCurriculum' ]; const searchKeys = ['algoliaAppId', 'algoliaAPIKey']; const donationKeys = ['stripePublicKey', 'paypalClientId', 'patreonClientId']; @@ -112,13 +113,18 @@ if (FREECODECAMP_NODE_ENV !== 'development') { checkClientLocale(); checkCurriculumLocale(); if (fs.existsSync(`${globalConfigPath}/env.json`)) { - // eslint-disable-next-line - const { showUpcomingChanges } = require(`${globalConfigPath}/env.json`); - if (env['showUpcomingChanges'] !== showUpcomingChanges) { + /* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment */ + const { + showNewCurriculum, + showUpcomingChanges + } = require(`${globalConfigPath}/env.json`); + /* eslint-enable @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment */ + if ( + env['showUpcomingChanges'] !== showUpcomingChanges || + env['showNewCurriculum'] !== showNewCurriculum + ) { /* eslint-enable @typescript-eslint/no-unsafe-member-access */ - console.log( - 'SHOW_UPCOMING_CHANGES value has changed, cleaning client cache.' - ); + console.log('Feature flags have been changed, cleaning client cache.'); const child = spawn('npm', ['run', 'clean:client']); child.stdout.setEncoding('utf8'); child.stdout.on('data', function (data) {