From a8fc96f42a4d8b325c84bf88065dd2bbb80db439 Mon Sep 17 00:00:00 2001 From: Newton Chung Date: Mon, 11 May 2026 19:27:28 -0700 Subject: [PATCH 1/2] Fix path handling on Build Challenge Map to support Windows --- scripts/build-challenge-map-graphql.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/build-challenge-map-graphql.mjs b/scripts/build-challenge-map-graphql.mjs index 2c7d1ce6a..7b8946fdb 100644 --- a/scripts/build-challenge-map-graphql.mjs +++ b/scripts/build-challenge-map-graphql.mjs @@ -1,5 +1,6 @@ import { writeFile, mkdir } from 'fs/promises'; import { dirname } from 'path'; +import { fileURLToPath } from 'url'; /** * Build challenge map from freeCodeCamp GraphQL Curriculum Database @@ -11,7 +12,9 @@ import { dirname } from 'path'; */ const GRAPHQL_ENDPOINT = 'https://curriculum-db.freecodecamp.org/graphql'; -const OUTPUT_PATH = new URL('../data/challengeMap.json', import.meta.url); +const OUTPUT_PATH = fileURLToPath( + new URL('../data/challengeMap.json', import.meta.url) +); const CHALLENGE_MAP_QUERY = ` query GetChallengeMap { @@ -158,14 +161,14 @@ async function buildChallengeMapFromGraphQL() { const challengeMap = buildChallengeMap(data); // Ensure output directory exists - await mkdir(dirname(OUTPUT_PATH.pathname), { recursive: true }); + await mkdir(dirname(OUTPUT_PATH), { recursive: true }); // Write to file - console.log(`\nšŸ’¾ Writing challenge map to ${OUTPUT_PATH.pathname}...`); + console.log(`\nšŸ’¾ Writing challenge map to ${OUTPUT_PATH}...`); await writeFile(OUTPUT_PATH, JSON.stringify(challengeMap, null, 2)); console.log('āœ… Challenge map successfully generated!\n'); - console.log(` File: ${OUTPUT_PATH.pathname}`); + console.log(` File: ${OUTPUT_PATH}`); console.log(` Size: ${Object.keys(challengeMap).length} challenges`); } catch (err) { console.error('āŒ Error building challenge map:', err); From d106fb8384a2d972f16119ba8785c9d5cba664ce Mon Sep 17 00:00:00 2001 From: Newton Chung Date: Tue, 12 May 2026 13:59:23 -0700 Subject: [PATCH 2/2] Update Outdated Build Challenge Map Comment --- scripts/build-challenge-map-graphql.mjs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/build-challenge-map-graphql.mjs b/scripts/build-challenge-map-graphql.mjs index 7b8946fdb..447ea922a 100644 --- a/scripts/build-challenge-map-graphql.mjs +++ b/scripts/build-challenge-map-graphql.mjs @@ -8,7 +8,20 @@ import { fileURLToPath } from 'url'; * This script fetches the complete curriculum structure from the GraphQL API * and generates a flat lookup map for challenge resolution. * - * Output format: { challengeId: { certification, block, name } } + * Output format: + * { + * "challengeId": { + * "superblocks": ["superblock-dashed-name", ...], + * "blocks": ["block-dashed-name", ...], + * "name": "Challenge Title" + * } + * } + * + * Notes: + * - Challenges may appear in multiple superblocks/blocks; the script records + * all occurrences as arrays. Consumers that need a single canonical + * superblock/block (e.g., dashboard grouping) should use the first array + * element as the canonical value. */ const GRAPHQL_ENDPOINT = 'https://curriculum-db.freecodecamp.org/graphql';