const fs = require('fs-extra'); const path = require('path'); const { omit, findLastIndex } = require('lodash'); const YAML = require('js-yaml'); const { dasherize } = require('./utils'); const { getChallenges } = require('./getChallenges'); const blackListedFieldNames = [ 'betaSolutions', 'betaTests', 'hints', 'MDNlinks', 'null', 'rawSolutions', 'react', 'reactRedux', 'redux', 'releasedOn', 'translations', 'type' ]; getChallenges().forEach(block => { const { name, order, challenges, time = '', superBlock, superOrder, template = '', required = [], ...restBlock } = block; const blockDashedName = dasherize(name); const blockMeta = { name, dashedName: blockDashedName, order, time, template, required, superBlock, superOrder, challengeOrder: challenges.map(({ id, title }) => [id, title]), ...restBlock }; const superOrderPrefix = `0${superOrder}`; const outputDir = path.resolve( __dirname, `./challenges/english/${superOrderPrefix}-${superBlock}/${blockDashedName}` ); fs.ensureDirSync(outputDir); challenges.forEach(challenge => { const { description: oldDescription = [], files = {}, tests = [], solutions = [], ...restChallenge } = challenge; const challengeMeta = omit(restChallenge, blackListedFieldNames); const challengeFileName = `${dasherize(challenge.title)}.english.md`; let description = ''; let instructions = ''; const hrIndex = findLastIndex(oldDescription, el => (/^