Repository: freeCodeCamp/freeCodeCamp
File: tools/challenge-helper-scripts/create-project.ts (TypeScript)

Code before:
      blockLayout
    );
    // TODO: remove once we stop relying on markdown in the client.
  }
  void createIntroMD(superBlock, block, title, blockType!);
  if (superBlock === SuperBlocks.FullStackDeveloper) {
    await updateFullStackJson(chapter!, module!, block, position!);
  }
}

async function updateFullStackJson(
  chapterName: string,
  moduleName: string,
  block: string,
  position: number
) {
  const fullStackText = await fs.readFile(
    '../../curriculum/superblock-structure/full-stack.json',
    { encoding: 'utf-8' }
  );
  const fullStackData = JSON.parse(fullStackText) as FullStackData;

  const chapterExists =
    fullStackData['chapters'].findIndex(
      (chapter: FullStackChapter) => chapter.dashedName === chapterName
    ) !== -1;
  if (!chapterExists) {
    // Inserts the chapter, module and block if the chapter is missing
    const newChapter = {
      dashedName: chapterName,
      modules: [{ dashedName: moduleName, blocks: [{ dashedName: block }] }]
    };
    fullStackData['chapters'].push(newChapter);
  } else {
    // Chapter is present; is module present
    // Get the index of the correct chapter
    const chapterIndex = fullStackData['chapters'].findIndex(
      (chapter: FullStackChapter) => chapter.dashedName === chapterName
    );
    const moduleExists =
      fullStackData['chapters'][chapterIndex]['modules'].findIndex(
        (module: FullStackModule) => module.dashedName === moduleName
      ) !== -1;

    if (!moduleExists) {
      // Insert the new module and block
      fullStackData['chapters'][chapterIndex]['modules'].push({
        dashedName: moduleName,
        blocks: [{ dashedName: block }]
      });
    } else {

Review comment (suggestion):
```suggestion
  const chapterExists = fullStackData['chapters'].some(
    (chapter: FullStackChapter) => chapter.dashedName === chapterName
  );
```

Code after:
    }
    const challengeId = await createQuizChallenge(
      projectArgs.block,
      projectArgs.title,
      projectArgs.questionCount
    );
    void createMetaJson(
      projectArgs.superBlock,
      projectArgs.block,
      projectArgs.title,
      projectArgs.helpCategory,
      challengeId
    );
  } else {
    const challengeId = await createFirstChallenge(projectArgs.block);
    void createMetaJson(
      projectArgs.superBlock,
      projectArgs.block,
      projectArgs.title,
      projectArgs.helpCategory,
      challengeId,
      projectArgs.order,
      projectArgs.blockType,
      projectArgs.blockLayout
    );
    // TODO: remove once we stop relying on markdown in the client.
  }

  if (
    (projectArgs.superBlock === SuperBlocks.FullStackDeveloper &&
      projectArgs.blockType) == null
  ) {
    throw new Error('Missing argument: blockType when updating intro markdown');
  }

  void createIntroMD(
    projectArgs.superBlock,
    projectArgs.block,
    projectArgs.title
  );
}

async function updateIntroJson(
  superBlock: SuperBlocks,
  block: string,
  title: string
) {
  const introJsonPath = path.resolve(
    __dirname,
    '../../client/i18n/locales/english/intro.json'
  );