mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: allow filtering by block and challengeId (#63640)
This commit is contained in:
committed by
GitHub
parent
8de1289fa8
commit
4ec96c1a0c
@@ -341,6 +341,7 @@ exports.createSchemaCustomization = ({ actions }) => {
|
||||
superOrder: Int
|
||||
template: String
|
||||
tests: [Test]
|
||||
fields: ChallengeFields
|
||||
title: String
|
||||
transcript: String
|
||||
translationPending: Boolean
|
||||
@@ -467,7 +468,11 @@ exports.createSchemaCustomization = ({ actions }) => {
|
||||
beforeAll: String
|
||||
afterAll: String
|
||||
}
|
||||
|
||||
type ChallengeFields {
|
||||
slug: String
|
||||
blockName: String
|
||||
tests: [Test]
|
||||
}
|
||||
type Nodule {
|
||||
type: String
|
||||
data: JSON
|
||||
|
||||
@@ -334,19 +334,17 @@ export async function parseCurriculumStructure(filter?: Filter) {
|
||||
}
|
||||
|
||||
export async function buildCurriculum(lang: string, filters?: Filter) {
|
||||
// Block validation assumes the entire block is being built, if that's not the
|
||||
// case, skip validation
|
||||
const skipBlockValidation = filters?.challengeId !== undefined;
|
||||
const contentDir = getContentDir(lang);
|
||||
const fccSuperblock = process.env.FCC_SUPERBLOCK;
|
||||
|
||||
const combinedFilters: Filter | undefined = fccSuperblock
|
||||
? { ...filters, superBlock: fccSuperblock }
|
||||
: filters;
|
||||
|
||||
const builder = new SuperblockCreator(
|
||||
getBlockCreator(lang, !isEmpty(combinedFilters))
|
||||
getBlockCreator(lang, skipBlockValidation)
|
||||
);
|
||||
|
||||
const { fullSuperblockList, certifications } =
|
||||
await parseCurriculumStructure(combinedFilters);
|
||||
await parseCurriculumStructure(filters);
|
||||
|
||||
const fullCurriculum: {
|
||||
[key: string]: unknown;
|
||||
|
||||
@@ -28,10 +28,15 @@ export const FCC_CHALLENGE_ID = process.env.FCC_CHALLENGE_ID
|
||||
? process.env.FCC_CHALLENGE_ID.trim()
|
||||
: undefined;
|
||||
|
||||
export const curriculumFilter = {
|
||||
block: process.env.FCC_BLOCK ? process.env.FCC_BLOCK.trim() : undefined,
|
||||
challengeId: FCC_CHALLENGE_ID,
|
||||
superBlock: process.env.FCC_SUPERBLOCK
|
||||
const FCC_BLOCK = process.env.FCC_BLOCK
|
||||
? process.env.FCC_BLOCK.trim()
|
||||
: undefined;
|
||||
const FCC_SUPERBLOCK = process.env.FCC_SUPERBLOCK
|
||||
? process.env.FCC_SUPERBLOCK.trim()
|
||||
: undefined
|
||||
: undefined;
|
||||
|
||||
export const curriculumFilter = {
|
||||
...(FCC_CHALLENGE_ID && { challengeId: FCC_CHALLENGE_ID }),
|
||||
...(FCC_BLOCK && { block: FCC_BLOCK }),
|
||||
...(FCC_SUPERBLOCK && { superBlock: FCC_SUPERBLOCK })
|
||||
};
|
||||
|
||||
@@ -4,6 +4,8 @@ import { promisify } from 'util';
|
||||
|
||||
import { availableLangs } from '../../shared-dist/config/i18n.js';
|
||||
import { buildCurriculum } from './build-curriculum.js';
|
||||
import { curriculumFilter } from './config.js';
|
||||
import type { Filter } from './filter.js';
|
||||
|
||||
const { curriculum: curriculumLangs } = availableLangs;
|
||||
|
||||
@@ -11,11 +13,7 @@ const access = promisify(_access);
|
||||
|
||||
export async function getChallengesForLang(
|
||||
lang: string,
|
||||
filters?: {
|
||||
superBlock?: string;
|
||||
block?: string;
|
||||
challengeId?: string;
|
||||
}
|
||||
filters: Filter = curriculumFilter // default to global curriculum filter, but allow override (e.g. when testing specific blocks)
|
||||
) {
|
||||
const invalidLang = !curriculumLangs.includes(lang);
|
||||
if (invalidLang)
|
||||
|
||||
@@ -15,7 +15,10 @@ import {
|
||||
|
||||
const globalConfigPath = path.resolve(__dirname, '../../../shared-dist/config');
|
||||
|
||||
const isSelectiveBuild = !!process.env.FCC_SUPERBLOCK;
|
||||
const isSelectiveBuild =
|
||||
process.env.FCC_SUPERBLOCK ||
|
||||
process.env.FCC_BLOCK ||
|
||||
process.env.FCC_CHALLENGE_ID;
|
||||
|
||||
void getChallengesForLang('english')
|
||||
.then(result => {
|
||||
|
||||
Reference in New Issue
Block a user