MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / createProject

Function createProject

tools/challenge-helper-scripts/create-project.ts:58–144  ·  view source on GitHub ↗
(projectArgs: CreateProjectArgs)

Source from the content-addressed store, hash-verified

56}
57
58async function createProject(projectArgs: CreateProjectArgs) {
59 if (!projectArgs.title) {
60 projectArgs.title = projectArgs.block;
61 }
62
63 const order = projectArgs.order;
64 const chapter = projectArgs.chapter;
65 const module = projectArgs.module;
66 const position = projectArgs.position;
67
68 const superblockFilename = (
69 superBlockToFilename as Record<SuperBlocks, string>
70 )[projectArgs.superBlock];
71
72 if (chapterBasedSuperBlocks.includes(projectArgs.superBlock)) {
73 if (!chapter || !module || typeof position == 'undefined') {
74 throw Error(
75 'Missing one of the following arguments: chapter, module, position'
76 );
77 }
78 void updateChapterModuleSuperblockStructure(
79 projectArgs.block,
80 // Convert human-friendly (1-based) position to 0-based index for insertion.
81 { order: position - 1, chapter, module },
82 superblockFilename
83 );
84 } else {
85 if (typeof order == 'undefined') {
86 throw Error('Missing argument: order');
87 }
88 void updateSimpleSuperblockStructure(
89 projectArgs.block,
90 { order },
91 superblockFilename
92 );
93 }
94
95 void updateIntroJson(
96 projectArgs.superBlock,
97 projectArgs.block,
98 projectArgs.title
99 );
100
101 const challengeId = new ObjectId();
102
103 if (projectArgs.blockLabel === BlockLabel.quiz) {
104 if (projectArgs.questionCount == null) {
105 throw new Error(
106 'Property `questionCount` is null when creating new Quiz Challenge'
107 );
108 }
109 await createMetaJson(
110 projectArgs.superBlock,
111 projectArgs.block,
112 projectArgs.title,
113 projectArgs.helpCategory,
114 challengeId
115 );

Callers 1

create-project.tsFile · 0.85

Calls 6

createFirstChallengeFunction · 0.85
updateIntroJsonFunction · 0.70
createMetaJsonFunction · 0.70
createQuizChallengeFunction · 0.70

Tested by

no test coverage detected