diff --git a/curriculum/package-lock.json b/curriculum/package-lock.json index 73fbf66039..be8305ed72 100644 --- a/curriculum/package-lock.json +++ b/curriculum/package-lock.json @@ -1309,6 +1309,42 @@ "to-fast-properties": "^2.0.0" } }, + "@hapi/hoek": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.0.tgz", + "integrity": "sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==", + "dev": true + }, + "@hapi/topo": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.0.0.tgz", + "integrity": "sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw==", + "dev": true, + "requires": { + "@hapi/hoek": "^9.0.0" + } + }, + "@sideway/address": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.1.tgz", + "integrity": "sha512-+I5aaQr3m0OAmMr7RQ3fR9zx55sejEYR2BFJaxL+zT3VM2611X0SHvPWIbAUBZVTn/YzYKbV8gJ2oT/QELknfQ==", + "dev": true, + "requires": { + "@hapi/hoek": "^9.0.0" + } + }, + "@sideway/formula": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sideway/formula/-/formula-3.0.0.tgz", + "integrity": "sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==", + "dev": true + }, + "@sideway/pinpoint": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", + "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", + "dev": true + }, "@types/hast": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.1.tgz", @@ -4779,12 +4815,6 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, - "hoek": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-5.0.4.tgz", - "integrity": "sha512-Alr4ZQgoMlnere5FZJsIyfIjORBqZll5POhDsF4q64dPuJR6rNxXdDxtHSQq8OXRurhmx+PWYEE8bXRROY8h0w==", - "dev": true - }, "homedir-polyfill": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", @@ -5163,15 +5193,6 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "isemail": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/isemail/-/isemail-3.2.0.tgz", - "integrity": "sha512-zKqkK+O+dGqevc93KNsbZ/TqTUFd46MwWjYOoMrjIMZ51eU7DtQG3Wmd9SQQT7i7RVnuTPEiYEWHU3MSbxC1Tg==", - "dev": true, - "requires": { - "punycode": "2.x.x" - } - }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -5191,20 +5212,22 @@ "dev": true }, "joi": { - "version": "13.7.0", - "resolved": "https://registry.npmjs.org/joi/-/joi-13.7.0.tgz", - "integrity": "sha512-xuY5VkHfeOYK3Hdi91ulocfuFopwgbSORmIwzcwHKESQhC7w1kD5jaVSPnqDxS2I8t3RZ9omCKAxNwXN5zG1/Q==", + "version": "17.4.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-17.4.0.tgz", + "integrity": "sha512-F4WiW2xaV6wc1jxete70Rw4V/VuMd6IN+a5ilZsxG4uYtUXWu2kq9W5P2dz30e7Gmw8RCbY/u/uk+dMPma9tAg==", "dev": true, "requires": { - "hoek": "5.x.x", - "isemail": "3.x.x", - "topo": "3.x.x" + "@hapi/hoek": "^9.0.0", + "@hapi/topo": "^5.0.0", + "@sideway/address": "^4.1.0", + "@sideway/formula": "^3.0.0", + "@sideway/pinpoint": "^2.0.0" } }, "joi-objectid": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/joi-objectid/-/joi-objectid-2.0.0.tgz", - "integrity": "sha1-VlSVc6Zrp5Xc9rniJt5fOy027Do=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/joi-objectid/-/joi-objectid-3.0.1.tgz", + "integrity": "sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ==", "dev": true }, "js-tokens": { @@ -7915,23 +7938,6 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "dev": true }, - "topo": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/topo/-/topo-3.0.3.tgz", - "integrity": "sha512-IgpPtvD4kjrJ7CRA3ov2FhWQADwv+Tdqbsf1ZnPUSAtCJ9e1Z44MmoSGDXGk4IppoZA7jd/QRkNddlLJWlUZsQ==", - "dev": true, - "requires": { - "hoek": "6.x.x" - }, - "dependencies": { - "hoek": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", - "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==", - "dev": true - } - } - }, "tough-cookie": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", diff --git a/curriculum/package.json b/curriculum/package.json index 7b65a51fcf..4ba9d718b1 100644 --- a/curriculum/package.json +++ b/curriculum/package.json @@ -25,7 +25,6 @@ "delete-step": "cross-env CALLING_DIR=$INIT_CWD node ../tools/challenge-helper-scripts/delete-step", "lint": "gulp lint", "reorder-steps": "cross-env CALLING_DIR=$INIT_CWD node ../tools/challenge-helper-scripts/reorder-steps", - "pretest": "cd ../client && npm run build:workers", "test": "mocha --delay --reporter progress --bail", "pretest:full-output": "npm run pretest", "test:full-output": "cross-env FULL_OUTPUT=true mocha --delay --reporter progress" @@ -48,8 +47,8 @@ "css": "3.0.0", "gulp": "4.0.2", "invariant": "2.2.4", - "joi": "13.7.0", - "joi-objectid": "2.0.0", + "joi": "^17.4.0", + "joi-objectid": "^3.0.1", "js-yaml": "4.0.0", "jsdom": "16.5.3", "live-server": "1.2.1", diff --git a/curriculum/schema/challengeSchema.js b/curriculum/schema/challengeSchema.js index 86fe38b517..dacfc70998 100644 --- a/curriculum/schema/challengeSchema.js +++ b/curriculum/schema/challengeSchema.js @@ -11,7 +11,7 @@ const fileJoi = Joi.object().keys({ name: Joi.string(), editableRegionBoundaries: [Joi.array().items(Joi.number())], path: Joi.string(), - error: Joi.empty(), + error: Joi.valid(null), head: Joi.string().allow(''), tail: Joi.string().allow(''), seed: Joi.string().allow(''), @@ -33,7 +33,7 @@ const schema = Joi.object() // TODO: require this only for normal challenges, not certs dashedName: Joi.string().regex(slugRE), description: Joi.when('challengeType', { - is: Joi.only([challengeTypes.step, challengeTypes.video]), + is: [challengeTypes.step, challengeTypes.video], then: Joi.string().allow(''), otherwise: Joi.string().required() }), @@ -45,7 +45,7 @@ const schema = Joi.object() indexjsx: fileJoi }), guideUrl: Joi.string().uri({ scheme: 'https' }), - helpCategory: Joi.only(['JavaScript', 'HTML-CSS', 'Python']), + helpCategory: Joi.valid('JavaScript', 'HTML-CSS', 'Python'), videoUrl: Joi.string().allow(''), forumTopicId: Joi.number(), helpRoom: Joi.string(), @@ -106,5 +106,5 @@ const schema = Joi.object() .xor('helpCategory', 'isPrivate'); exports.challengeSchemaValidator = () => { - return challenge => Joi.validate(challenge, schema); + return challenge => schema.validate(challenge); }; diff --git a/curriculum/test/utils/mongoIds.js b/curriculum/test/utils/mongoIds.js index ee5e42d469..3148581acd 100644 --- a/curriculum/test/utils/mongoIds.js +++ b/curriculum/test/utils/mongoIds.js @@ -10,7 +10,7 @@ class MongoIds { } check(id, title) { try { - Joi.validate(id, schema); + schema.validate(id); } catch { throw new Error(`Expected a valid ObjectId for ${title}, but got ${id}`); }