feat: react challenges (#16099)
* chore(packages): Update redux utils * feat(Panes): Invert control of panes map creation * feat(Modern): Add view * feat(Panes): Decouple panes from Challenges * fix(Challenges): Decouple challenge views from panes map * fix(Challenge/views): PanesMap => mapStateToPanesMap This clarifies what these functions are doing * fix(Challenges): Add view type * fix(Panes): Remove unneeded panes container * feat(Panes): Invert control of pane content render This decouples the Panes from the content they render, allowing for greater flexibility. * feat(Modern): Add side panel This is common between modern and classic * feat(seed): Array to string file content * fix(files): Modern files should be polyvinyls * feat(Modern): Create editors per file * fix(seed/React): Incorrect keyfile name * feat(Modern): Highligh jsx correctly This adds highlighting for jsx. Unfortunately, this disables linting for non-javascript files as jshint will only work for those * feat(rechallenge): Add jsx ext to babel transformer * feat(seed): Normalize challenge files head/tail/content * refactor(rechallenge/build): Rename function * fix(code-storage): Pull in files from localStorage * feat(Modern/React): Add Enzyme to test runner This enables testing of React challenges * feat(Modern): Add submission type * refactor(Panes): Rename panes map update action
This commit is contained in:
committed by
Quincy Larson
parent
8b9be0242a
commit
dced96da8e
@@ -1,8 +1,4 @@
|
||||
import cond from 'lodash/cond';
|
||||
import identity from 'lodash/identity';
|
||||
import matchesProperty from 'lodash/matchesProperty';
|
||||
import stubTrue from 'lodash/stubTrue';
|
||||
import conforms from 'lodash/conforms';
|
||||
import _ from 'lodash';
|
||||
|
||||
import * as babel from 'babel-core';
|
||||
import presetEs2015 from 'babel-preset-es2015';
|
||||
@@ -14,7 +10,8 @@ import loopProtect from 'loop-protect';
|
||||
|
||||
import {
|
||||
transformHeadTailAndContents,
|
||||
setContent
|
||||
setContent,
|
||||
setExt
|
||||
} from '../../common/utils/polyvinyl.js';
|
||||
import castToObservable from '../../common/app/utils/cast-to-observable.js';
|
||||
|
||||
@@ -30,12 +27,12 @@ loopProtect.hit = function hit(line) {
|
||||
|
||||
// const sourceReg =
|
||||
// /(<!-- fcc-start-source -->)([\s\S]*?)(?=<!-- fcc-end-source -->)/g;
|
||||
const HTML$JSReg = /html|js/;
|
||||
const console$logReg = /(?:\b)console(\.log\S+)/g;
|
||||
const NBSPReg = new RegExp(String.fromCharCode(160), 'g');
|
||||
|
||||
const testHTMLJS = conforms({ ext: (ext) => HTML$JSReg.test(ext) });
|
||||
const testJS = matchesProperty('ext', 'js');
|
||||
const isJS = _.matchesProperty('ext', 'js');
|
||||
const testHTMLJS = _.overSome(isJS, _.matchesProperty('ext', 'html'));
|
||||
const testJS$JSX = _.overSome(isJS, _.matchesProperty('ext', 'jsx'));
|
||||
|
||||
// if shouldProxyConsole then we change instances of console log
|
||||
// to `window.__console.log`
|
||||
@@ -51,7 +48,7 @@ export function proxyLoggerTransformer(file) {
|
||||
);
|
||||
}
|
||||
|
||||
export const addLoopProtect = cond([
|
||||
export const addLoopProtect = _.cond([
|
||||
[
|
||||
testHTMLJS,
|
||||
function(file) {
|
||||
@@ -63,33 +60,33 @@ export const addLoopProtect = cond([
|
||||
return setContent(loopProtect(file.contents), file);
|
||||
}
|
||||
],
|
||||
[ stubTrue, identity ]
|
||||
[ _.stubTrue, _.identity ]
|
||||
]);
|
||||
export const replaceNBSP = cond([
|
||||
export const replaceNBSP = _.cond([
|
||||
[
|
||||
testHTMLJS,
|
||||
function(file) {
|
||||
return setContent(
|
||||
file.contents.replace(NBSPReg, ' '),
|
||||
file.contents.replace(NBSPReg, ' '),
|
||||
file
|
||||
);
|
||||
);
|
||||
}
|
||||
],
|
||||
[ stubTrue, identity ]
|
||||
[ _.stubTrue, _.identity ]
|
||||
]);
|
||||
|
||||
export const babelTransformer = cond([
|
||||
export const babelTransformer = _.cond([
|
||||
[
|
||||
testJS,
|
||||
testJS$JSX,
|
||||
function(file) {
|
||||
const result = babel.transform(file.contents, babelOptions);
|
||||
return setContent(
|
||||
result.code,
|
||||
file
|
||||
);
|
||||
return _.flow(
|
||||
_.partial(setContent, result.code),
|
||||
_.partial(setExt, 'js')
|
||||
)(file);
|
||||
}
|
||||
],
|
||||
[ stubTrue, identity ]
|
||||
[ _.stubTrue, _.identity ]
|
||||
]);
|
||||
|
||||
export const _transformers = [
|
||||
|
Reference in New Issue
Block a user