refactor(curriculum): move helpCategory to block meta.json file (#50265)

* refactor: move helpCategory to block meta

* fix: test?
This commit is contained in:
Tom
2023-05-04 01:46:58 -05:00
committed by GitHub
parent 45d2ffa676
commit d02bb663c4
135 changed files with 1647 additions and 1488 deletions

View File

@@ -10,7 +10,12 @@ import { createStepFile } from './utils';
import { getSuperBlockSubPath } from './fs-utils';
import { Meta } from './helpers/project-metadata';
const helpCategories = ['HTML-CSS', 'JavaScript', 'Python'] as const;
const helpCategories = [
'HTML-CSS',
'JavaScript',
'Backend Development',
'Python'
] as const;
type BlockInfo = {
title: string;
@@ -42,10 +47,16 @@ async function createProject(
title = block;
}
void updateIntroJson(superBlock, block, title);
void updateHelpCategoryMap(block, helpCategory);
const challengeId = await createFirstChallenge(superBlock, block);
void createMetaJson(superBlock, block, title, order, challengeId);
void createMetaJson(
superBlock,
block,
title,
helpCategory,
order,
challengeId
);
// TODO: remove once we stop relying on markdown in the client.
void createIntroMD(superBlock, block, title);
}
@@ -71,24 +82,11 @@ async function updateIntroJson(
);
}
async function updateHelpCategoryMap(block: string, helpCategory: string) {
const helpCategoryPath = path.resolve(
__dirname,
'../../client/utils/help-category-map.json'
);
const helpMap = await parseJson<Record<string, string>>(helpCategoryPath);
helpMap[block] = helpCategory;
void withTrace(
fs.writeFile,
helpCategoryPath,
format(JSON.stringify(helpMap), { parser: 'json' })
);
}
async function createMetaJson(
superBlock: SuperBlocks,
block: string,
title: string,
helpCategory: string,
order: number,
challengeId: ObjectID
) {
@@ -96,6 +94,7 @@ async function createMetaJson(
const newMeta = await parseJson<Meta>('./base-meta.json');
newMeta.name = title;
newMeta.dashedName = block;
newMeta.helpCategory = helpCategory;
newMeta.order = order;
newMeta.superOrder = Object.values(SuperBlocks).indexOf(superBlock) + 1;
newMeta.superBlock = superBlock;