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

Code before:
  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 {
      const moduleIndex = fullStackData['chapters'][chapterIndex][
        'modules'
      ].findIndex(
        (module: FullStackModule) => module.dashedName === moduleName
      );

Review comment (suggestion):
```suggestion
      modules: [{ dashedName: moduleName, blocks: [{ dashedName: block }] }],
      comingSoon: true
```
It should start out life as "comingSoon".

Code after:
    );
    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'
  );
  const newIntro = await parseJson<IntroJson>(introJsonPath);
  newIntro[superBlock].blocks[block] = {
    title,
    intro: [title, '']
  };