refactor(challenge-helpers): use new superBlockToFolderMap directly (#60794)

This commit is contained in:
Tom
2025-06-10 07:43:04 -05:00
committed by GitHub
parent fc7d2ac761
commit c32eb093d2
4 changed files with 10 additions and 29 deletions
@@ -5,9 +5,11 @@ import { prompt } from 'inquirer';
import { format } from 'prettier';
import ObjectID from 'bson-objectid';
import { SuperBlocks } from '../../shared/config/curriculum';
import {
SuperBlocks,
superBlockToFolderMap
} from '../../shared/config/curriculum';
import { createStepFile, validateBlockName } from './utils';
import { getSuperBlockSubPath } from './fs-utils';
import { Meta } from './helpers/project-metadata';
const helpCategories = [
@@ -141,7 +143,7 @@ async function createFirstChallenge(
superBlock: SuperBlocks,
block: string
): Promise<ObjectID> {
const superBlockSubPath = getSuperBlockSubPath(superBlock);
const superBlockSubPath = superBlockToFolderMap[superBlock];
const newChallengeDir = path.resolve(
__dirname,
`../../curriculum/challenges/english/${superBlockSubPath}/${block}`
@@ -5,9 +5,11 @@ import { prompt } from 'inquirer';
import { format } from 'prettier';
import ObjectID from 'bson-objectid';
import { SuperBlocks } from '../../shared/config/curriculum';
import {
SuperBlocks,
superBlockToFolderMap
} from '../../shared/config/curriculum';
import { createQuizFile, validateBlockName } from './utils';
import { getSuperBlockSubPath } from './fs-utils';
import { Meta } from './helpers/project-metadata';
const helpCategories = [
@@ -135,7 +137,7 @@ async function createQuizChallenge(
title: string,
questionCount: number
): Promise<ObjectID> {
const superBlockSubPath = getSuperBlockSubPath(superBlock);
const superBlockSubPath = superBlockToFolderMap[superBlock];
const newChallengeDir = path.resolve(
__dirname,
`../../curriculum/challenges/english/${superBlockSubPath}/${block}`
@@ -1,15 +0,0 @@
import fs from 'fs/promises';
import path from 'path';
import { SuperBlocks } from '../../shared/config/curriculum';
import { getSuperBlockSubPath } from './fs-utils';
describe('getSuperBlockSubPath', () => {
it('should return sub-paths that exist', async () => {
const subPaths = Object.values(SuperBlocks).map(getSuperBlockSubPath);
const paths = subPaths.map(sub =>
path.resolve(__dirname, '../../curriculum/challenges/english', sub)
);
await Promise.all(paths.map(path => fs.access(path)));
});
});
@@ -1,8 +0,0 @@
import {
SuperBlocks,
superBlockToFolderMap
} from '../../shared/config/curriculum';
export function getSuperBlockSubPath(superBlock: SuperBlocks): string {
return superBlockToFolderMap[superBlock];
}