mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: expose submit types to API (#47293)
* feat: expose submit types to API * fix: clear file name * fix: keep submit types out of versioning
This commit is contained in:
@@ -66,7 +66,7 @@ exports.pathsMap = {
|
||||
[js]: 'js',
|
||||
[jsProject]: 'js'
|
||||
};
|
||||
// determine the component to view for each challenge
|
||||
// determine the component view for each challenge
|
||||
exports.viewTypes = {
|
||||
[html]: 'classic',
|
||||
[js]: 'classic',
|
||||
|
||||
@@ -29,6 +29,12 @@ if (envData.clientLocale == 'english' && !envData.showUpcomingChanges) {
|
||||
).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('there should be an endpoint to request submit types from', () => {
|
||||
fs.existsSync(
|
||||
`${clientStaticPath}/curriculum-data/${VERSION}/submit-types.json`
|
||||
);
|
||||
});
|
||||
|
||||
test('the available-superblocks file should have the correct structure', async () => {
|
||||
const validateAvailableSuperBlocks = availableSuperBlocksValidator();
|
||||
const availableSuperblocks: unknown = JSON.parse(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { mkdirSync, writeFileSync, readFileSync } from 'fs';
|
||||
import { resolve, dirname } from 'path';
|
||||
import { submitTypes } from '../../../client/utils/challenge-types';
|
||||
import { SuperBlocks } from '../../../config/certification-settings';
|
||||
|
||||
type Intro = { [keyValue in SuperBlocks]: IntroProps };
|
||||
@@ -45,15 +46,16 @@ export function buildExtCurriculumData(
|
||||
curriculum: Curriculum
|
||||
): void {
|
||||
const staticFolderPath = resolve(__dirname, '../../../client/static');
|
||||
const versionPath = `${staticFolderPath}/curriculum-data/${ver}`;
|
||||
const dataPath = `${staticFolderPath}/curriculum-data/`;
|
||||
const blockIntroPath = resolve(
|
||||
__dirname,
|
||||
'../../../client/i18n/locales/english/intro.json'
|
||||
);
|
||||
|
||||
mkdirSync(versionPath, { recursive: true });
|
||||
mkdirSync(dataPath, { recursive: true });
|
||||
|
||||
parseCurriculumData();
|
||||
getSubmitTypes();
|
||||
|
||||
function parseCurriculumData() {
|
||||
const superBlockKeys = Object.values(SuperBlocks).filter(x =>
|
||||
@@ -93,7 +95,7 @@ export function buildExtCurriculumData(
|
||||
}
|
||||
|
||||
function writeToFile(fileName: string, data: Record<string, unknown>): void {
|
||||
const filePath = `${versionPath}/${fileName}.json`;
|
||||
const filePath = `${dataPath}/${ver}/${fileName}.json`;
|
||||
mkdirSync(dirname(filePath), { recursive: true });
|
||||
writeFileSync(filePath, JSON.stringify(data, null, 2));
|
||||
}
|
||||
@@ -121,4 +123,11 @@ export function buildExtCurriculumData(
|
||||
|
||||
return superBlocks[superBlock].title;
|
||||
}
|
||||
|
||||
function getSubmitTypes() {
|
||||
writeFileSync(
|
||||
`${dataPath}/submit-types.json`,
|
||||
JSON.stringify(submitTypes, null, 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user