fix(scripts): fix unpack and repack scripts for the new challenge schema

This commit is contained in:
ValeraS
2018-07-10 17:21:07 +03:00
committed by Kristofer Koishigawa
parent 2edb306ca1
commit 52ed7cfa7e
3 changed files with 319 additions and 143 deletions

View File

@ -4,12 +4,15 @@ Joi.objectId = require('joi-objectid')(Joi);
const schema = Joi.object().keys({
block: Joi.string(),
blockId: Joi.objectId(),
challengeType: Joi.number().min(0).max(9).required(),
challengeType: Joi.number()
.min(0)
.max(9)
.required(),
checksum: Joi.number(),
dashedName: Joi.string(),
description: Joi.array().items(
Joi.string().allow('')
).required(),
description: Joi.array()
.items(Joi.string().allow(''))
.required(),
fileName: Joi.string(),
files: Joi.object().pattern(
/(jsx?|html|css|sass)$/,
@ -17,14 +20,8 @@ const schema = Joi.object().keys({
key: Joi.string(),
ext: Joi.string(),
name: Joi.string(),
head: [
Joi.array().items(Joi.string().allow('')),
Joi.string().allow('')
],
tail: [
Joi.array().items(Joi.string().allow('')),
Joi.string().allow('')
],
head: [Joi.array().items(Joi.string().allow('')), Joi.string().allow('')],
tail: [Joi.array().items(Joi.string().allow('')), Joi.string().allow('')],
contents: [
Joi.array().items(Joi.string().allow('')),
Joi.string().allow('')
@ -49,9 +46,8 @@ const schema = Joi.object().keys({
crossDomain: Joi.bool()
})
),
solutions: Joi.array().items(
Joi.string().optional()
),
releasedOn: Joi.string().allow(''),
solutions: Joi.array().items(Joi.string().optional()),
superBlock: Joi.string(),
superOrder: Joi.number(),
suborder: Joi.number(),
@ -59,7 +55,9 @@ const schema = Joi.object().keys({
// public challenges
Joi.object().keys({
text: Joi.string().required(),
testString: Joi.string().allow('').required()
testString: Joi.string()
.allow('')
.required()
}),
// our tests used in certification verification
Joi.object().keys({
@ -69,7 +67,14 @@ const schema = Joi.object().keys({
),
template: Joi.string(),
time: Joi.string().allow(''),
title: Joi.string().required()
title: Joi.string().required(),
translations: Joi.object().pattern(
/\w+(-\w+)*/,
Joi.object().keys({
title: Joi.string(),
description: Joi.array().items(Joi.string().allow(''))
})
)
});
exports.validateChallenge = function validateChallenge(challenge) {