mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor(challenge-helpers): use new superBlockToFolderMap directly (#60794)
This commit is contained in:
@@ -5,9 +5,11 @@ import { prompt } from 'inquirer';
|
|||||||
import { format } from 'prettier';
|
import { format } from 'prettier';
|
||||||
import ObjectID from 'bson-objectid';
|
import ObjectID from 'bson-objectid';
|
||||||
|
|
||||||
import { SuperBlocks } from '../../shared/config/curriculum';
|
import {
|
||||||
|
SuperBlocks,
|
||||||
|
superBlockToFolderMap
|
||||||
|
} from '../../shared/config/curriculum';
|
||||||
import { createStepFile, validateBlockName } from './utils';
|
import { createStepFile, validateBlockName } from './utils';
|
||||||
import { getSuperBlockSubPath } from './fs-utils';
|
|
||||||
import { Meta } from './helpers/project-metadata';
|
import { Meta } from './helpers/project-metadata';
|
||||||
|
|
||||||
const helpCategories = [
|
const helpCategories = [
|
||||||
@@ -141,7 +143,7 @@ async function createFirstChallenge(
|
|||||||
superBlock: SuperBlocks,
|
superBlock: SuperBlocks,
|
||||||
block: string
|
block: string
|
||||||
): Promise<ObjectID> {
|
): Promise<ObjectID> {
|
||||||
const superBlockSubPath = getSuperBlockSubPath(superBlock);
|
const superBlockSubPath = superBlockToFolderMap[superBlock];
|
||||||
const newChallengeDir = path.resolve(
|
const newChallengeDir = path.resolve(
|
||||||
__dirname,
|
__dirname,
|
||||||
`../../curriculum/challenges/english/${superBlockSubPath}/${block}`
|
`../../curriculum/challenges/english/${superBlockSubPath}/${block}`
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import { prompt } from 'inquirer';
|
|||||||
import { format } from 'prettier';
|
import { format } from 'prettier';
|
||||||
import ObjectID from 'bson-objectid';
|
import ObjectID from 'bson-objectid';
|
||||||
|
|
||||||
import { SuperBlocks } from '../../shared/config/curriculum';
|
import {
|
||||||
|
SuperBlocks,
|
||||||
|
superBlockToFolderMap
|
||||||
|
} from '../../shared/config/curriculum';
|
||||||
import { createQuizFile, validateBlockName } from './utils';
|
import { createQuizFile, validateBlockName } from './utils';
|
||||||
import { getSuperBlockSubPath } from './fs-utils';
|
|
||||||
import { Meta } from './helpers/project-metadata';
|
import { Meta } from './helpers/project-metadata';
|
||||||
|
|
||||||
const helpCategories = [
|
const helpCategories = [
|
||||||
@@ -135,7 +137,7 @@ async function createQuizChallenge(
|
|||||||
title: string,
|
title: string,
|
||||||
questionCount: number
|
questionCount: number
|
||||||
): Promise<ObjectID> {
|
): Promise<ObjectID> {
|
||||||
const superBlockSubPath = getSuperBlockSubPath(superBlock);
|
const superBlockSubPath = superBlockToFolderMap[superBlock];
|
||||||
const newChallengeDir = path.resolve(
|
const newChallengeDir = path.resolve(
|
||||||
__dirname,
|
__dirname,
|
||||||
`../../curriculum/challenges/english/${superBlockSubPath}/${block}`
|
`../../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];
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user