refactor: move superblock folder maps to config (#60714)

This commit is contained in:
Tom
2025-06-08 09:01:16 -05:00
committed by GitHub
parent 4912a0aac5
commit f4121968e4
6 changed files with 50 additions and 126 deletions

View File

@@ -1,7 +1,8 @@
const path = require('path');
const {
generateSuperBlockList,
SuperBlocks
SuperBlocks,
folderToSuperBlockMap
} = require('../shared/config/curriculum');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
@@ -59,35 +60,7 @@ function getSuperOrder(superblock) {
const directoryToSuperblock = {
'00-certifications': 'certifications', // treating certifications as a superblock for simplicity
'01-responsive-web-design': 'responsive-web-design',
'02-javascript-algorithms-and-data-structures':
'javascript-algorithms-and-data-structures',
'03-front-end-development-libraries': 'front-end-development-libraries',
'04-data-visualization': 'data-visualization',
'05-back-end-development-and-apis': 'back-end-development-and-apis',
'06-quality-assurance': 'quality-assurance',
'07-scientific-computing-with-python': 'scientific-computing-with-python',
'08-data-analysis-with-python': 'data-analysis-with-python',
'09-information-security': 'information-security',
'10-coding-interview-prep': 'coding-interview-prep',
'11-machine-learning-with-python': 'machine-learning-with-python',
'13-relational-databases': 'relational-database',
'14-responsive-web-design-22': '2022/responsive-web-design',
'15-javascript-algorithms-and-data-structures-22':
'javascript-algorithms-and-data-structures-v8',
'16-the-odin-project': 'the-odin-project',
'17-college-algebra-with-python': 'college-algebra-with-python',
'18-project-euler': 'project-euler',
'19-foundational-c-sharp-with-microsoft':
'foundational-c-sharp-with-microsoft',
'21-a2-english-for-developers': 'a2-english-for-developers',
'22-rosetta-code': 'rosetta-code',
'23-python-for-everybody': 'python-for-everybody',
'24-b1-english-for-developers': 'b1-english-for-developers',
'25-front-end-development': 'full-stack-developer',
'26-a2-professional-spanish': 'a2-professional-spanish',
'27-a2-professional-chinese': 'a2-professional-chinese',
'99-dev-playground': 'dev-playground'
...folderToSuperBlockMap
};
function getSuperBlockFromDir(dir) {

View File

@@ -32,6 +32,43 @@ export enum SuperBlocks {
DevPlayground = 'dev-playground'
}
// Note that this object is used to create folderToSuperBlockMap object
export const superBlockToFolderMap = {
[SuperBlocks.RespWebDesign]: '01-responsive-web-design',
[SuperBlocks.JsAlgoDataStruct]:
'02-javascript-algorithms-and-data-structures',
[SuperBlocks.FrontEndDevLibs]: '03-front-end-development-libraries',
[SuperBlocks.DataVis]: '04-data-visualization',
[SuperBlocks.BackEndDevApis]: '05-back-end-development-and-apis',
[SuperBlocks.QualityAssurance]: '06-quality-assurance',
[SuperBlocks.SciCompPy]: '07-scientific-computing-with-python',
[SuperBlocks.DataAnalysisPy]: '08-data-analysis-with-python',
[SuperBlocks.InfoSec]: '09-information-security',
[SuperBlocks.CodingInterviewPrep]: '10-coding-interview-prep',
[SuperBlocks.MachineLearningPy]: '11-machine-learning-with-python',
[SuperBlocks.RelationalDb]: '13-relational-databases',
[SuperBlocks.RespWebDesignNew]: '14-responsive-web-design-22',
[SuperBlocks.JsAlgoDataStructNew]:
'15-javascript-algorithms-and-data-structures-22',
[SuperBlocks.TheOdinProject]: '16-the-odin-project',
[SuperBlocks.CollegeAlgebraPy]: '17-college-algebra-with-python',
[SuperBlocks.ProjectEuler]: '18-project-euler',
[SuperBlocks.FoundationalCSharp]: '19-foundational-c-sharp-with-microsoft',
[SuperBlocks.A2English]: '21-a2-english-for-developers',
[SuperBlocks.RosettaCode]: '22-rosetta-code',
[SuperBlocks.PythonForEverybody]: '23-python-for-everybody',
[SuperBlocks.B1English]: '24-b1-english-for-developers',
[SuperBlocks.FullStackDeveloper]: '25-front-end-development',
[SuperBlocks.A2Spanish]: '26-a2-professional-spanish',
[SuperBlocks.A2Chinese]: '27-a2-professional-chinese',
[SuperBlocks.DevPlayground]: '99-dev-playground'
};
// Same as superBlockToFolderMap but with the keys and values reversed
export const folderToSuperBlockMap = Object.fromEntries(
Object.entries(superBlockToFolderMap).map(([key, value]) => [value, key])
);
/*
* SuperBlockStages.Upcoming = SHOW_UPCOMING_CHANGES === 'true'
* 'Upcoming' is for development -> not shown on stag or prod anywhere

View File

@@ -11,7 +11,8 @@ import { availableLangs } from '../../shared/config/i18n';
import { getChallengesForLang } from '../../curriculum/get-challenges';
import {
SuperBlocks,
getAuditedSuperBlocks
getAuditedSuperBlocks,
superBlockToFolderMap
} from '../../shared/config/curriculum';
// TODO: re-organise the types to a common 'types' folder that can be shared
@@ -28,38 +29,6 @@ type ChallengeNode = {
challengeType: number;
};
const superBlockFolderMap = {
'responsive-web-design': '01-responsive-web-design',
'javascript-algorithms-and-data-structures':
'02-javascript-algorithms-and-data-structures',
'front-end-development-libraries': '03-front-end-development-libraries',
'data-visualization': '04-data-visualization',
'back-end-development-and-apis': '05-back-end-development-and-apis',
'quality-assurance': '06-quality-assurance',
'scientific-computing-with-python': '07-scientific-computing-with-python',
'data-analysis-with-python': '08-data-analysis-with-python',
'information-security': '09-information-security',
'machine-learning-with-python': '10-machine-learning-with-python',
'coding-interview-prep': '11-coding-interview-prep',
'relational-database': '13-relational-database',
'2022/responsive-web-design': '14-responsive-web-design-22',
'javascript-algorithms-and-data-structures-v8':
'15-javascript-algorithms-and-data-structures-22',
'the-odin-project': '16-the-odin-project',
'college-algebra-with-python': '17-college-algebra-with-python',
'project-euler': '18-project-euler',
'foundational-c-sharp-with-microsoft':
'19-foundational-c-sharp-with-microsoft',
'a2-english-for-developers': '21-a2-english-for-developers',
'rosetta-code': '22-rosetta-code',
'python-for-everybody': '23-python-for-everybody',
'b1-english-for-developers': '24-b1-english-for-developers',
'full-stack-developer': '25-front-end-development',
'a2-professional-spanish': '26-a2-professional-spanish',
'a2-professional-chinese': '27-a2-professional-chinese',
'dev-playground': '99-dev-playground'
};
// Adding types for getChallengesForLang is possible, but not worth the effort
// at this time.
/* eslint-disable @typescript-eslint/no-unsafe-return */
@@ -132,7 +101,7 @@ void (async () => {
// we're not ready to audit the new curriculum yet
(cert !== SuperBlocks.JsAlgoDataStructNew ||
process.env.SHOW_UPCOMING_CHANGES === 'true') &&
file.startsWith(superBlockFolderMap[cert])
file.startsWith(superBlockToFolderMap[cert])
)
);
const noMissingFiles = await auditChallengeFiles(auditedFiles, {

View File

@@ -13,7 +13,7 @@ import { ChallengeContent } from '../../../interfaces/challenge-content';
import SaveChallenge from '../buttons/save-challenge';
import './editor.css';
import { API_LOCATION } from '../../utils/handle-request';
import { superBlockNameMap } from '../../utils/block-name-translator';
import { folderToSuperBlockMap } from '../../../../../../shared/config/curriculum';
const Editor = () => {
const [error, setError] = useState<Error | null>(null);
@@ -91,7 +91,7 @@ const Editor = () => {
</p>
<p>
<Link
to={`${import.meta.env.CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION}/learn/${superBlockNameMap[superblock || '']}/${block || ''}/${
to={`${import.meta.env.CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION}/learn/${folderToSuperBlockMap[superblock || '']}/${block || ''}/${
items.dashedName
}`}
target='_blank'

View File

@@ -1,28 +0,0 @@
export const superBlockNameMap: { [key: string]: string } = {
'01-responsive-web-design': 'responsive-web-design',
'02-javascript-algorithms-and-data-structures':
'javascript-algorithms-and-data-structures',
'03-front-end-development-libraries': 'front-end-development-libraries',
'04-data-visualization': 'data-visualization',
'05-back-end-development-and-apis': 'back-end-development-and-apis',
'06-quality-assurance': 'quality-assurance',
'07-scientific-computing-with-python': 'scientific-computing-with-python',
'08-data-analysis-with-python': 'data-analysis-with-python',
'09-information-security': 'information-security',
'10-coding-interview-prep': 'coding-interview-prep',
'11-machine-learning-with-python': 'machine-learning-with-python',
'13-relational-databases': 'relational-databases',
'14-responsive-web-design-22': '2022/responsive-web-design',
'15-javascript-algorithms-and-data-structures-22':
'javascript-algorithms-and-data-structures-v8',
'16-the-odin-project': 'the-odin-project',
'17-college-algebra-with-python': 'college-algebra-with-python',
'18-project-euler': 'project-euler',
'19-foundational-c-sharp-with-microsoft':
'foundational-c-sharp-with-microsoft',
'21-a2-english-for-developers': 'a2-english-for-developers',
'22-rosetta-code': 'rosetta-code',
'23-python-for-everybody': 'python-for-everybody',
'24-b1-english-for-developers': 'b1-english-for-developers',
'25-front-end-development': 'full-stack-developer'
};

View File

@@ -1,35 +1,8 @@
import { SuperBlocks } from '../../shared/config/curriculum';
import {
SuperBlocks,
superBlockToFolderMap
} from '../../shared/config/curriculum';
export function getSuperBlockSubPath(superBlock: SuperBlocks): string {
const pathMap = {
[SuperBlocks.RespWebDesign]: '01-responsive-web-design',
[SuperBlocks.JsAlgoDataStruct]:
'02-javascript-algorithms-and-data-structures',
[SuperBlocks.FrontEndDevLibs]: '03-front-end-development-libraries',
[SuperBlocks.DataVis]: '04-data-visualization',
[SuperBlocks.BackEndDevApis]: '05-back-end-development-and-apis',
[SuperBlocks.QualityAssurance]: '06-quality-assurance',
[SuperBlocks.SciCompPy]: '07-scientific-computing-with-python',
[SuperBlocks.DataAnalysisPy]: '08-data-analysis-with-python',
[SuperBlocks.InfoSec]: '09-information-security',
[SuperBlocks.CodingInterviewPrep]: '10-coding-interview-prep',
[SuperBlocks.MachineLearningPy]: '11-machine-learning-with-python',
[SuperBlocks.RelationalDb]: '13-relational-databases',
[SuperBlocks.RespWebDesignNew]: '14-responsive-web-design-22',
[SuperBlocks.JsAlgoDataStructNew]:
'15-javascript-algorithms-and-data-structures-22',
[SuperBlocks.TheOdinProject]: '16-the-odin-project',
[SuperBlocks.CollegeAlgebraPy]: '17-college-algebra-with-python',
[SuperBlocks.ProjectEuler]: '18-project-euler',
[SuperBlocks.FoundationalCSharp]: '19-foundational-c-sharp-with-microsoft',
[SuperBlocks.A2English]: '21-a2-english-for-developers',
[SuperBlocks.RosettaCode]: '22-rosetta-code',
[SuperBlocks.PythonForEverybody]: '23-python-for-everybody',
[SuperBlocks.B1English]: '24-b1-english-for-developers',
[SuperBlocks.FullStackDeveloper]: '25-front-end-development',
[SuperBlocks.A2Spanish]: '26-a2-professional-spanish',
[SuperBlocks.A2Chinese]: '27-a2-professional-chinese',
[SuperBlocks.DevPlayground]: '99-dev-playground'
};
return pathMap[superBlock];
return superBlockToFolderMap[superBlock];
}