Skip to content

Commit f412196

Browse files
authored
refactor: move superblock folder maps to config (freeCodeCamp#60714)
1 parent 4912a0a commit f412196

File tree

6 files changed

+50
-126
lines changed

6 files changed

+50
-126
lines changed

curriculum/utils.js

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const path = require('path');
22
const {
33
generateSuperBlockList,
4-
SuperBlocks
4+
SuperBlocks,
5+
folderToSuperBlockMap
56
} = require('../shared/config/curriculum');
67

78
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
@@ -59,35 +60,7 @@ function getSuperOrder(superblock) {
5960

6061
const directoryToSuperblock = {
6162
'00-certifications': 'certifications', // treating certifications as a superblock for simplicity
62-
'01-responsive-web-design': 'responsive-web-design',
63-
'02-javascript-algorithms-and-data-structures':
64-
'javascript-algorithms-and-data-structures',
65-
'03-front-end-development-libraries': 'front-end-development-libraries',
66-
'04-data-visualization': 'data-visualization',
67-
'05-back-end-development-and-apis': 'back-end-development-and-apis',
68-
'06-quality-assurance': 'quality-assurance',
69-
'07-scientific-computing-with-python': 'scientific-computing-with-python',
70-
'08-data-analysis-with-python': 'data-analysis-with-python',
71-
'09-information-security': 'information-security',
72-
'10-coding-interview-prep': 'coding-interview-prep',
73-
'11-machine-learning-with-python': 'machine-learning-with-python',
74-
'13-relational-databases': 'relational-database',
75-
'14-responsive-web-design-22': '2022/responsive-web-design',
76-
'15-javascript-algorithms-and-data-structures-22':
77-
'javascript-algorithms-and-data-structures-v8',
78-
'16-the-odin-project': 'the-odin-project',
79-
'17-college-algebra-with-python': 'college-algebra-with-python',
80-
'18-project-euler': 'project-euler',
81-
'19-foundational-c-sharp-with-microsoft':
82-
'foundational-c-sharp-with-microsoft',
83-
'21-a2-english-for-developers': 'a2-english-for-developers',
84-
'22-rosetta-code': 'rosetta-code',
85-
'23-python-for-everybody': 'python-for-everybody',
86-
'24-b1-english-for-developers': 'b1-english-for-developers',
87-
'25-front-end-development': 'full-stack-developer',
88-
'26-a2-professional-spanish': 'a2-professional-spanish',
89-
'27-a2-professional-chinese': 'a2-professional-chinese',
90-
'99-dev-playground': 'dev-playground'
63+
...folderToSuperBlockMap
9164
};
9265

9366
function getSuperBlockFromDir(dir) {

shared/config/curriculum.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,43 @@ export enum SuperBlocks {
3232
DevPlayground = 'dev-playground'
3333
}
3434

35+
// Note that this object is used to create folderToSuperBlockMap object
36+
export const superBlockToFolderMap = {
37+
[SuperBlocks.RespWebDesign]: '01-responsive-web-design',
38+
[SuperBlocks.JsAlgoDataStruct]:
39+
'02-javascript-algorithms-and-data-structures',
40+
[SuperBlocks.FrontEndDevLibs]: '03-front-end-development-libraries',
41+
[SuperBlocks.DataVis]: '04-data-visualization',
42+
[SuperBlocks.BackEndDevApis]: '05-back-end-development-and-apis',
43+
[SuperBlocks.QualityAssurance]: '06-quality-assurance',
44+
[SuperBlocks.SciCompPy]: '07-scientific-computing-with-python',
45+
[SuperBlocks.DataAnalysisPy]: '08-data-analysis-with-python',
46+
[SuperBlocks.InfoSec]: '09-information-security',
47+
[SuperBlocks.CodingInterviewPrep]: '10-coding-interview-prep',
48+
[SuperBlocks.MachineLearningPy]: '11-machine-learning-with-python',
49+
[SuperBlocks.RelationalDb]: '13-relational-databases',
50+
[SuperBlocks.RespWebDesignNew]: '14-responsive-web-design-22',
51+
[SuperBlocks.JsAlgoDataStructNew]:
52+
'15-javascript-algorithms-and-data-structures-22',
53+
[SuperBlocks.TheOdinProject]: '16-the-odin-project',
54+
[SuperBlocks.CollegeAlgebraPy]: '17-college-algebra-with-python',
55+
[SuperBlocks.ProjectEuler]: '18-project-euler',
56+
[SuperBlocks.FoundationalCSharp]: '19-foundational-c-sharp-with-microsoft',
57+
[SuperBlocks.A2English]: '21-a2-english-for-developers',
58+
[SuperBlocks.RosettaCode]: '22-rosetta-code',
59+
[SuperBlocks.PythonForEverybody]: '23-python-for-everybody',
60+
[SuperBlocks.B1English]: '24-b1-english-for-developers',
61+
[SuperBlocks.FullStackDeveloper]: '25-front-end-development',
62+
[SuperBlocks.A2Spanish]: '26-a2-professional-spanish',
63+
[SuperBlocks.A2Chinese]: '27-a2-professional-chinese',
64+
[SuperBlocks.DevPlayground]: '99-dev-playground'
65+
};
66+
67+
// Same as superBlockToFolderMap but with the keys and values reversed
68+
export const folderToSuperBlockMap = Object.fromEntries(
69+
Object.entries(superBlockToFolderMap).map(([key, value]) => [value, key])
70+
);
71+
3572
/*
3673
* SuperBlockStages.Upcoming = SHOW_UPCOMING_CHANGES === 'true'
3774
* 'Upcoming' is for development -> not shown on stag or prod anywhere

tools/challenge-auditor/index.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { availableLangs } from '../../shared/config/i18n';
1111
import { getChallengesForLang } from '../../curriculum/get-challenges';
1212
import {
1313
SuperBlocks,
14-
getAuditedSuperBlocks
14+
getAuditedSuperBlocks,
15+
superBlockToFolderMap
1516
} from '../../shared/config/curriculum';
1617

1718
// TODO: re-organise the types to a common 'types' folder that can be shared
@@ -28,38 +29,6 @@ type ChallengeNode = {
2829
challengeType: number;
2930
};
3031

31-
const superBlockFolderMap = {
32-
'responsive-web-design': '01-responsive-web-design',
33-
'javascript-algorithms-and-data-structures':
34-
'02-javascript-algorithms-and-data-structures',
35-
'front-end-development-libraries': '03-front-end-development-libraries',
36-
'data-visualization': '04-data-visualization',
37-
'back-end-development-and-apis': '05-back-end-development-and-apis',
38-
'quality-assurance': '06-quality-assurance',
39-
'scientific-computing-with-python': '07-scientific-computing-with-python',
40-
'data-analysis-with-python': '08-data-analysis-with-python',
41-
'information-security': '09-information-security',
42-
'machine-learning-with-python': '10-machine-learning-with-python',
43-
'coding-interview-prep': '11-coding-interview-prep',
44-
'relational-database': '13-relational-database',
45-
'2022/responsive-web-design': '14-responsive-web-design-22',
46-
'javascript-algorithms-and-data-structures-v8':
47-
'15-javascript-algorithms-and-data-structures-22',
48-
'the-odin-project': '16-the-odin-project',
49-
'college-algebra-with-python': '17-college-algebra-with-python',
50-
'project-euler': '18-project-euler',
51-
'foundational-c-sharp-with-microsoft':
52-
'19-foundational-c-sharp-with-microsoft',
53-
'a2-english-for-developers': '21-a2-english-for-developers',
54-
'rosetta-code': '22-rosetta-code',
55-
'python-for-everybody': '23-python-for-everybody',
56-
'b1-english-for-developers': '24-b1-english-for-developers',
57-
'full-stack-developer': '25-front-end-development',
58-
'a2-professional-spanish': '26-a2-professional-spanish',
59-
'a2-professional-chinese': '27-a2-professional-chinese',
60-
'dev-playground': '99-dev-playground'
61-
};
62-
6332
// Adding types for getChallengesForLang is possible, but not worth the effort
6433
// at this time.
6534
/* eslint-disable @typescript-eslint/no-unsafe-return */
@@ -132,7 +101,7 @@ void (async () => {
132101
// we're not ready to audit the new curriculum yet
133102
(cert !== SuperBlocks.JsAlgoDataStructNew ||
134103
process.env.SHOW_UPCOMING_CHANGES === 'true') &&
135-
file.startsWith(superBlockFolderMap[cert])
104+
file.startsWith(superBlockToFolderMap[cert])
136105
)
137106
);
138107
const noMissingFiles = await auditChallengeFiles(auditedFiles, {

tools/challenge-editor/client/src/components/editor/editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ChallengeContent } from '../../../interfaces/challenge-content';
1313
import SaveChallenge from '../buttons/save-challenge';
1414
import './editor.css';
1515
import { API_LOCATION } from '../../utils/handle-request';
16-
import { superBlockNameMap } from '../../utils/block-name-translator';
16+
import { folderToSuperBlockMap } from '../../../../../../shared/config/curriculum';
1717

1818
const Editor = () => {
1919
const [error, setError] = useState<Error | null>(null);
@@ -91,7 +91,7 @@ const Editor = () => {
9191
</p>
9292
<p>
9393
<Link
94-
to={`${import.meta.env.CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION}/learn/${superBlockNameMap[superblock || '']}/${block || ''}/${
94+
to={`${import.meta.env.CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION}/learn/${folderToSuperBlockMap[superblock || '']}/${block || ''}/${
9595
items.dashedName
9696
}`}
9797
target='_blank'

tools/challenge-editor/client/src/utils/block-name-translator.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
1-
import { SuperBlocks } from '../../shared/config/curriculum';
1+
import {
2+
SuperBlocks,
3+
superBlockToFolderMap
4+
} from '../../shared/config/curriculum';
25

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

0 commit comments

Comments
 (0)