mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-10-24 02:07:00 +08:00
fix: validate upcoming changes better (#49219)
* fix: mark new JS projects as upcoming changes * fix: verify all non-cert superblocks have metas * fix: remove special handling of new JS challenges
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Build a Caesars Cipher Project",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"usesMultifileEditor": false,
|
||||
"order": 17,
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +13,3 @@
|
||||
"Build a Caesars Cipher"
|
||||
]
|
||||
]}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Build a Cash Register Project",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"usesMultifileEditor": false,
|
||||
"order": 14,
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +13,3 @@
|
||||
"Build a Cash Register"
|
||||
]
|
||||
]}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Build a Palindrome Checker Project",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"usesMultifileEditor": false,
|
||||
"order": 3,
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +13,3 @@
|
||||
"Build a Palindrome Checker"
|
||||
]
|
||||
]}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Build a Roman Numeral Converter Project",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"usesMultifileEditor": false,
|
||||
"order": 6,
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +13,3 @@
|
||||
"Build a Roman Numeral Converter"
|
||||
]
|
||||
]}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Build a Telephone Number Validator Project",
|
||||
"isUpcomingChange": false,
|
||||
"isUpcomingChange": true,
|
||||
"usesMultifileEditor": false,
|
||||
"order": 10,
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +13,3 @@
|
||||
"Build a Telephone Number Validator"
|
||||
]
|
||||
]}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
const assert = require('assert');
|
||||
const yaml = require('js-yaml');
|
||||
const { findIndex, isEmpty } = require('lodash');
|
||||
const { findIndex } = require('lodash');
|
||||
const readDirP = require('readdirp');
|
||||
const { helpCategoryMap } = require('../client/utils/challenge-types');
|
||||
const { showUpcomingChanges } = require('../config/env.json');
|
||||
@@ -151,9 +150,6 @@ exports.getChallengesForLang = async function getChallengesForLang(lang) {
|
||||
{ type: 'directories', depth: 0 },
|
||||
buildSuperBlocks
|
||||
);
|
||||
Object.entries(curriculum).forEach(([name, superBlock]) => {
|
||||
assert(!isEmpty(superBlock.blocks), `superblock ${name} has no blocks`);
|
||||
});
|
||||
const cb = (file, curriculum) => buildChallenges(file, curriculum, lang);
|
||||
// fill the scaffold with the challenges
|
||||
return walk(
|
||||
@@ -166,11 +162,15 @@ exports.getChallengesForLang = async function getChallengesForLang(lang) {
|
||||
|
||||
async function buildBlocks({ basename: blockName }, curriculum, superBlock) {
|
||||
const metaPath = path.resolve(META_DIR, `${blockName}/meta.json`);
|
||||
const isCertification = !fs.existsSync(metaPath);
|
||||
if (isCertification && superBlock !== 'certifications')
|
||||
throw Error(
|
||||
`superblock ${superBlock} is missing meta.json for ${blockName}`
|
||||
);
|
||||
|
||||
if (fs.existsSync(metaPath)) {
|
||||
// try to read the file, if the meta path does not exist it should be a certification.
|
||||
// As they do not have meta files.
|
||||
|
||||
if (isCertification) {
|
||||
curriculum['certifications'].blocks[blockName] = { challenges: [] };
|
||||
} else {
|
||||
const blockMeta = JSON.parse(fs.readFileSync(metaPath));
|
||||
|
||||
const { isUpcomingChange } = blockMeta;
|
||||
@@ -186,8 +186,6 @@ async function buildBlocks({ basename: blockName }, curriculum, superBlock) {
|
||||
const blockInfo = { meta: blockMeta, challenges: [] };
|
||||
curriculum[superBlock].blocks[blockName] = blockInfo;
|
||||
}
|
||||
} else {
|
||||
curriculum['certifications'].blocks[blockName] = { challenges: [] };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,14 +219,6 @@ async function buildChallenges({ path: filePath }, curriculum, lang) {
|
||||
}
|
||||
const { meta } = challengeBlock;
|
||||
const isCert = path.extname(filePath) === '.yml';
|
||||
// TODO: there's probably a better way, but this makes sure we don't build any
|
||||
// of the new curriculum when we don't want it.
|
||||
if (
|
||||
!showUpcomingChanges &&
|
||||
meta?.superBlock === '2022/javascript-algorithms-and-data-structures'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const createChallenge = generateChallengeCreator(CHALLENGES_DIR, lang);
|
||||
const challenge = isCert
|
||||
? await createCertification(CHALLENGES_DIR, filePath, lang)
|
||||
|
||||
Reference in New Issue
Block a user