refactor: remove SHOW_NEW_CURRICULUM (#57977)

This commit is contained in:
Oliver Eyton-Williams
2025-01-07 11:17:05 +01:00
committed by GitHub
parent 09a5415d03
commit 232f6d50aa
15 changed files with 10 additions and 66 deletions

View File

@@ -194,7 +194,6 @@ jobs:
run: |
cp sample.env .env
echo 'SHOW_UPCOMING_CHANGES=true' >> .env
echo 'SHOW_NEW_CURRICULUM=true' >> .env
cat .env
- name: Start MongoDB

View File

@@ -51,7 +51,6 @@ jobs:
--build-arg PATREON_CLIENT_ID=id_from_patreon_dashboard \
--build-arg DEPLOYMENT_ENV=staging \
--build-arg SHOW_UPCOMING_CHANGES=false \
--build-arg SHOW_NEW_CURRICULUM=false \
--build-arg GROWTHBOOK_URI=api_URI_from_Growthbook_dashboard \
--build-arg FREECODECAMP_NODE_ENV=development \
-f docker/web/Dockerfile .

View File

@@ -14,10 +14,7 @@ import { SuperBlockIcon } from '../../assets/superblock-icon';
import LinkButton from '../../assets/icons/link-button';
import { ButtonLink } from '../helpers';
import { getSuperBlockTitleForMap } from '../../utils/superblock-map-titles';
import {
showUpcomingChanges,
showNewCurriculum
} from '../../../config/env.json';
import { showUpcomingChanges } from '../../../config/env.json';
import './map.css';
@@ -165,7 +162,6 @@ function Map({
return (
<div className='map-ui' data-test-label='curriculum-map'>
{getStageOrder({
showNewCurriculum,
showUpcomingChanges
}).map(stage => (
<Fragment key={stage}>

View File

@@ -49,8 +49,7 @@ if (FREECODECAMP_NODE_ENV !== 'development') {
'curriculumLocale',
'deploymentEnv',
'environment',
'showUpcomingChanges',
'showNewCurriculum'
'showUpcomingChanges'
];
const searchKeys = ['algoliaAppId', 'algoliaAPIKey'];
const donationKeys = ['stripePublicKey', 'paypalClientId', 'patreonClientId'];
@@ -114,14 +113,9 @@ if (FREECODECAMP_NODE_ENV !== 'development') {
checkCurriculumLocale();
if (fs.existsSync(`${configPath}/env.json`)) {
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment */
const { showNewCurriculum, showUpcomingChanges } = require(
`${configPath}/env.json`
);
const { showUpcomingChanges } = require(`${configPath}/env.json`);
/* eslint-enable @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment */
if (
env['showUpcomingChanges'] !== showUpcomingChanges ||
env['showNewCurriculum'] !== showNewCurriculum
) {
if (env['showUpcomingChanges'] !== showUpcomingChanges) {
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
console.log('Feature flags have been changed, cleaning client cache.');
const child = spawn('pnpm', ['run', '-w', 'clean:client']);

View File

@@ -32,7 +32,6 @@ const {
PATREON_CLIENT_ID: patreonClientId,
DEPLOYMENT_ENV: deploymentEnv,
SHOW_UPCOMING_CHANGES: showUpcomingChanges,
SHOW_NEW_CURRICULUM: showNewCurriculum,
GROWTHBOOK_URI: growthbookUri
} = process.env;
@@ -72,7 +71,6 @@ export default Object.assign(locations, {
? null
: patreonClientId,
showUpcomingChanges: showUpcomingChanges === 'true',
showNewCurriculum: showNewCurriculum === 'true',
growthbookUri:
!growthbookUri || growthbookUri === 'api_URI_from_Growthbook_dashboard'
? null

View File

@@ -341,10 +341,7 @@ function generateChallengeCreator(lang, englishPath, i18nPath) {
// const superOrder = getSuperOrder(meta.superBlock);
// NOTE: Use this version when a super block is in beta.
const superOrder = getSuperOrder(meta.superBlock, {
// switch this back to SHOW_NEW_CURRICULUM when we're ready to beta the JS superblock
showNewCurriculum: process.env.SHOW_UPCOMING_CHANGES === 'true'
});
const superOrder = getSuperOrder(meta.superBlock);
if (superOrder !== null) challenge.superOrder = superOrder;
/* Since there can be more than one way to complete a certification (using the
legacy curriculum or the new one, for instance), we need a certification

View File

@@ -300,16 +300,11 @@ function populateTestsForLang({ lang, challenges, meta, superBlocks }) {
return;
}
it(`${superBlock} should have the same order in every meta`, function () {
const firstOrder = getSuperOrder(filteredMeta[0].superBlock, {
showNewCurriculum: process.env.SHOW_NEW_CURRICULUM
});
const firstOrder = getSuperOrder(filteredMeta[0].superBlock);
assert.isNumber(firstOrder);
assert.isTrue(
filteredMeta.every(
el =>
getSuperOrder(el.superBlock, {
showNewCurriculum: process.env.SHOW_NEW_CURRICULUM
}) === firstOrder
el => getSuperOrder(el.superBlock) === firstOrder
),
'The superOrder properties are mismatched.'
);

View File

@@ -43,7 +43,6 @@ function createSuperOrder(superBlocks) {
}
const flatSuperBlockMap = generateSuperBlockList({
showNewCurriculum: process.env.SHOW_NEW_CURRICULUM === 'true',
showUpcomingChanges: process.env.SHOW_UPCOMING_CHANGES === 'true'
});
const superOrder = createSuperOrder(flatSuperBlockMap);

View File

@@ -141,14 +141,7 @@ describe('getSuperOrder', () => {
});
it.skip('returns unique numbers for all current curriculum', () => {
if (
process.env.SHOW_NEW_CURRICULUM !== 'true' &&
process.env.SHOW_UPCOMING_CHANGES !== 'true'
) {
expect.assertions(17);
} else if (process.env.SHOW_NEW_CURRICULUM !== 'true') {
expect.assertions(17);
} else if (process.env.SHOW_UPCOMING_CHANGES !== 'true') {
if (process.env.SHOW_UPCOMING_CHANGES !== 'true') {
expect.assertions(17);
} else {
expect.assertions(19);
@@ -172,15 +165,7 @@ describe('getSuperOrder', () => {
expect(getSuperOrder(SuperBlocks.RespWebDesign)).toBe(15);
expect(getSuperOrder(SuperBlocks.JsAlgoDataStruct)).toBe(16);
if (
process.env.SHOW_NEW_CURRICULUM === 'true' &&
process.env.SHOW_UPCOMING_CHANGES === 'true'
) {
expect(getSuperOrder(SuperBlocks.TheOdinProject)).toBe(17);
expect(getSuperOrder(SuperBlocks.FullStackDeveloper)).toBe(18);
} else if (process.env.SHOW_NEW_CURRICULUM === 'true') {
return;
} else if (process.env.SHOW_UPCOMING_CHANGES === 'true') {
if (process.env.SHOW_UPCOMING_CHANGES === 'true') {
expect(getSuperOrder(SuperBlocks.TheOdinProject)).toBe(17);
expect(getSuperOrder(SuperBlocks.FullStackDeveloper)).toBe(18);
}

View File

@@ -27,8 +27,6 @@ RUN pnpm -F=api-server -F=tools/scripts/build -F=challenge-parser -F=curriculum
# following env vars.
ARG SHOW_UPCOMING_CHANGES=false
ENV SHOW_UPCOMING_CHANGES=$SHOW_UPCOMING_CHANGES
ARG SHOW_NEW_CURRICULUM=false
ENV SHOW_NEW_CURRICULUM=$SHOW_NEW_CURRICULUM
RUN pnpm build:curriculum
RUN pnpm build:server

View File

@@ -29,8 +29,6 @@ RUN cd api && npx prisma@$(jq -r '.devDependencies.prisma' < package.json) gener
# following env vars.
ARG SHOW_UPCOMING_CHANGES=false
ENV SHOW_UPCOMING_CHANGES=$SHOW_UPCOMING_CHANGES
ARG SHOW_NEW_CURRICULUM=false
ENV SHOW_NEW_CURRICULUM=$SHOW_NEW_CURRICULUM
RUN pnpm build:curriculum
RUN pnpm -F=api build

View File

@@ -26,7 +26,6 @@ ARG PAYPAL_CLIENT_ID
ARG PATREON_CLIENT_ID
ARG DEPLOYMENT_ENV
ARG SHOW_UPCOMING_CHANGES
ARG SHOW_NEW_CURRICULUM
ARG GROWTHBOOK_URI
ARG FREECODECAMP_NODE_ENV

View File

@@ -52,7 +52,6 @@ CURRICULUM_LOCALE=english
# Show or hide WIP in progress challenges
SHOW_UPCOMING_CHANGES=false
SHOW_NEW_CURRICULUM=false
# ---------------------
# Debugging Mode Keys - these should not be used in production

View File

@@ -22,19 +22,16 @@ describe('superBlockOrder', () => {
describe('generateSuperBlockList', () => {
it('should return an array of SuperBlocks object with all elements when if all configs are true', () => {
const result = generateSuperBlockList({
showNewCurriculum: true,
showUpcomingChanges: true
});
expect(result).toHaveLength(Object.values(superBlockStages).flat().length);
});
it('should return an array of SuperBlocks without New and Upcoming when { showNewCurriculum: false, showUpcomingChanges: false }', () => {
it('should return an array of SuperBlocks without Upcoming when { showUpcomingChanges: false }', () => {
const result = generateSuperBlockList({
showNewCurriculum: false,
showUpcomingChanges: false
});
const tempSuperBlockMap = { ...superBlockStages };
tempSuperBlockMap[SuperBlockStage.New] = [];
tempSuperBlockMap[SuperBlockStage.Upcoming] = [];
expect(result).toHaveLength(Object.values(tempSuperBlockMap).flat().length);
});

View File

@@ -30,9 +30,6 @@ export enum SuperBlocks {
}
/*
* SuperBlockStages.New = SHOW_NEW_CURRICULUM === 'true'
* 'New' -> shown only on english staging at the moment
*
* SuperBlockStages.Upcoming = SHOW_UPCOMING_CHANGES === 'true'
* 'Upcoming' is for development -> not shown on stag or prod anywhere
*
@@ -46,7 +43,6 @@ export enum SuperBlockStage {
Professional,
Extra,
Legacy,
New,
Upcoming,
Next,
NextEnglish
@@ -63,12 +59,10 @@ const defaultStageOrder = [
];
export function getStageOrder({
showNewCurriculum,
showUpcomingChanges
}: Config): SuperBlockStage[] {
const stageOrder = [...defaultStageOrder];
if (showNewCurriculum) stageOrder.push(SuperBlockStage.New);
if (showUpcomingChanges) stageOrder.push(SuperBlockStage.Upcoming);
return stageOrder;
}
@@ -108,7 +102,6 @@ export const superBlockStages: StageMap = {
SuperBlocks.JsAlgoDataStruct,
SuperBlocks.PythonForEverybody
],
[SuperBlockStage.New]: [],
[SuperBlockStage.Upcoming]: []
};
@@ -251,7 +244,6 @@ export const notAuditedSuperBlocks: NotAuditedSuperBlocks = {
Object.freeze(notAuditedSuperBlocks);
type Config = {
showNewCurriculum: boolean;
showUpcomingChanges: boolean;
};
@@ -272,7 +264,6 @@ export function getAuditedSuperBlocks({
// To find the audited superblocks, we need to start with all superblocks.
const flatSuperBlockMap = generateSuperBlockList({
showNewCurriculum: true,
showUpcomingChanges: true
});
const auditedSuperBlocks = flatSuperBlockMap.filter(