feat(next): BREAKING New curriculum package
This commit is contained in:
8
client/package-lock.json
generated
8
client/package-lock.json
generated
@ -904,6 +904,14 @@
|
||||
"prop-types": "^15.5.7"
|
||||
}
|
||||
},
|
||||
"@freecodecamp/curriculum": {
|
||||
"version": "0.0.0-next.1",
|
||||
"resolved": "https://registry.npmjs.org/@freecodecamp/curriculum/-/curriculum-0.0.0-next.1.tgz",
|
||||
"integrity": "sha512-DGJTEguAS67h8Nb9etpjJNvp1Ceh6flTVWXMavlnpnaiTqGpb7Yb+vn22nM94JFAuwHLGxUIVj0mpuL2WF2Vdw==",
|
||||
"requires": {
|
||||
"invariant": "^2.2.4"
|
||||
}
|
||||
},
|
||||
"@freecodecamp/gatsby-source-filesystem": {
|
||||
"version": "2.0.1-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@freecodecamp/gatsby-source-filesystem/-/gatsby-source-filesystem-2.0.1-beta.3.tgz",
|
||||
|
@ -13,7 +13,7 @@
|
||||
"@fortawesome/free-regular-svg-icons": "^5.2.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.2.0",
|
||||
"@fortawesome/react-fontawesome": "0.0.20",
|
||||
"@freecodecamp/curriculum": "^3.2.1",
|
||||
"@freecodecamp/curriculum": "0.0.0-next.1",
|
||||
"@freecodecamp/gatsby-source-filesystem": "^2.0.1-beta.3",
|
||||
"@freecodecamp/react-bootstrap": "^0.32.3",
|
||||
"@reach/router": "^1.1.1",
|
||||
|
@ -1,3 +1,4 @@
|
||||
*
|
||||
!dist/*.js
|
||||
!dist/challenges/**/*.json
|
||||
!lib.js
|
||||
!utils.js
|
||||
!getChallenges.js
|
@ -1,26 +1,10 @@
|
||||
const path = require('path');
|
||||
const { findIndex } = require('lodash');
|
||||
const invariant = require('invariant');
|
||||
const readDirP = require('readdirp-walk');
|
||||
|
||||
const { parseMarkdown } = require('../tools/challenge-md-parser');
|
||||
|
||||
const supportedLangs = ['english'];
|
||||
|
||||
function validateLang(lang) {
|
||||
invariant(lang, 'Please provide a language');
|
||||
invariant(
|
||||
supportedLangs.includes(lang),
|
||||
`${lang} is not supported
|
||||
|
||||
Supported languages: ${JSON.stringify(supportedLangs, null, 2)}
|
||||
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
exports.getChallengesForLang = function getChallengesForLang(lang) {
|
||||
validateLang(lang);
|
||||
let curriculum = {};
|
||||
return new Promise(resolve =>
|
||||
readDirP({ root: path.resolve(__dirname, `./challenges/${lang}`) })
|
||||
@ -87,4 +71,3 @@ function getBlockNameFromPath(filePath) {
|
||||
const [, block] = filePath.split('/');
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
const gulp = require('gulp');
|
||||
const babel = require('gulp-babel');
|
||||
const rename = require('gulp-rename');
|
||||
|
||||
gulp.task('babel-getChallenges', () =>
|
||||
gulp.src('./getChallenges.js')
|
||||
.pipe(babel({
|
||||
presets: ['env']
|
||||
}))
|
||||
.pipe(gulp.dest('dist'))
|
||||
);
|
||||
|
||||
gulp.task('babel', ['babel-getChallenges'], () =>
|
||||
gulp.src('./package-entry.js')
|
||||
.pipe(rename('./index.js'))
|
||||
.pipe(babel({
|
||||
presets: ['env']
|
||||
}))
|
||||
.pipe(gulp.dest('dist/'))
|
||||
);
|
33
curriculum/lib.js
Normal file
33
curriculum/lib.js
Normal file
@ -0,0 +1,33 @@
|
||||
const invariant = require('invariant');
|
||||
|
||||
const { getChallengesForLang } = require('./getChallenges');
|
||||
const { supportedLangs } = require('./utils');
|
||||
|
||||
const promises = supportedLangs.map(lang => getChallengesForLang(lang));
|
||||
const curricula = Promise.all(promises).then(allLangCurriculum =>
|
||||
allLangCurriculum.reduce(
|
||||
(map, current, i) => ({ ...map, [supportedLangs[i]]: current }),
|
||||
{}
|
||||
)
|
||||
);
|
||||
|
||||
function validateLang(lang) {
|
||||
invariant(lang, 'Please provide a language');
|
||||
invariant(
|
||||
supportedLangs.includes(lang),
|
||||
`${lang} is not supported
|
||||
|
||||
Supported languages: ${JSON.stringify(supportedLangs, null, 2)}
|
||||
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
async function getCurriculum(lang) {
|
||||
validateLang(lang);
|
||||
const allCurriculum = await curricula;
|
||||
const requested = allCurriculum[lang];
|
||||
return requested;
|
||||
}
|
||||
|
||||
exports.getChallengesForLang = getCurriculum;
|
5614
curriculum/package-lock.json
generated
5614
curriculum/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -3,24 +3,22 @@
|
||||
"description": "freeCodeCamp's curriculum seed files",
|
||||
"license": "(BSD-3-Clause AND CC-BY-SA-4.0)",
|
||||
"author": "freeCodeCamp <team@freecodecamp.org>",
|
||||
"homepage": "https://github.com/freeCodeCamp/curriculum#readme",
|
||||
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/freeCodeCamp/curriculum.git"
|
||||
"url": "https://github.com/freeCodeCamp/freeCodeCamp.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/freeCodeCamp/curriculum/issues"
|
||||
"url": "https://github.com/freeCodeCamp/freeCodeCamp/issues"
|
||||
},
|
||||
"version": "3.2.1",
|
||||
"main": "getChallenges.js",
|
||||
"version": "0.0.0-next.1",
|
||||
"main": "lib.js",
|
||||
"scripts": {
|
||||
"build": "gulp babel",
|
||||
"precommit": "lint-staged",
|
||||
"commit": "git-cz",
|
||||
"commitmsg": "commitlint -e",
|
||||
"format": "prettier --write es5 './**/*.{js,json}' && npm run lint",
|
||||
"lint": "eslint ./**/*.js --fix",
|
||||
"prepack": "npm run build",
|
||||
"repack": "babel-node ./repack.js",
|
||||
"semantic-release": "semantic-release",
|
||||
"test": "babel-node ./test-challenges.js | tap-spec",
|
||||
@ -62,9 +60,6 @@
|
||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"fs-extra": "^6.0.1",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^7.0.1",
|
||||
"gulp-rename": "^1.3.0",
|
||||
"husky": "^0.14.3",
|
||||
"joi": "^13.3.0",
|
||||
"joi-objectid": "^2.0.0",
|
||||
|
@ -4,4 +4,7 @@ exports.dasherize = function dasherize(name) {
|
||||
.replace(/\s/g, '-')
|
||||
.replace(/[^a-z0-9\-\.]/gi, '')
|
||||
.replace(/\:/g, '');
|
||||
}
|
||||
};
|
||||
|
||||
const supportedLangs = ['english'];
|
||||
exports.supportedLangs = supportedLangs;
|
||||
|
Reference in New Issue
Block a user