feat(seed): "unpack" and "repack" scripts

add "npm run seed" as alias to "node seed"

unpack tests and solution into HTML file; add titles and help text; style unpacked file

enable running unpacked assert tests in browser

Using browserify, compile "tape", "lodash", jQuery into "unpacked-bundle.js" for use during in-browser unpacked tests

feat(seed): diff after repacking

feat(seed): unpacked tests use Browser TAP chrome dev tool if available
This commit is contained in:
Alex Chaffee
2018-01-19 14:03:17 -05:00
committed by Mrugesh Mohapatra
parent c754880476
commit 590f646263
11 changed files with 698 additions and 217 deletions

24
mongoIds.js Normal file
View File

@@ -0,0 +1,24 @@
import _ from 'lodash';
import { isMongoId } from 'validator';
class MongoIds {
constructor() {
this.knownIds = [];
}
check(id, title) {
if (!isMongoId(id)) {
throw new Error(`Expected a valid ObjectId for ${title}, but got ${id}`);
}
const idIndex = _.findIndex(this.knownIds, existing => id === existing);
if (idIndex !== -1) {
throw new Error(`
All challenges must have a unique id.
The id for ${title} is already assigned
`);
}
this.knownIds = [ ...this.knownIds, id ];
}
}
export default MongoIds;