From a788426514fd9d03a8f38a89e004a22fa05887e8 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 23 Jan 2017 13:29:54 -0500 Subject: [PATCH 01/12] updated dependencies --- package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 49bfe5f..c87661b 100644 --- a/package.json +++ b/package.json @@ -46,14 +46,14 @@ "dependencies": { "adm-zip": "^0.4.7", "async-array-methods": "^2.1.0", - "babel-core": "~6.20.0", - "babel-helpers": "~6.16.0", - "babel-runtime": "^6.18.0", + "babel-core": "~6.22.1", + "babel-helpers": "~6.22.0", + "babel-runtime": "~6.22.0", "chalk": "^1.1.3", "chance": "^1.0.4", "cli-table": "~0.3.1", "commander": "^2.9.0", - "couchbase-promises": "~2.2.0", + "couchbase-promises": "~3.0.1", "cson": "^4.0.0", "csv-parse": "^1.1.7", "csv-stringify": "^1.0.4", @@ -71,7 +71,7 @@ "ora": "~0.4.1", "perfy": "~1.1.2", "request": "^2.78.0", - "set-cookie-parser": "^1.0.2", + "set-cookie-parser": "~2.0.0", "to-js": "^0.0.6", "update-notifier": "^1.0.2", "yamljs": "^0.2.8" @@ -79,21 +79,21 @@ "devDependencies": { "ava": "^0.16.0", "ava-spec": "github:tjbenton/ava-spec", - "babel-cli": "^6.18.0", + "babel-cli": "~6.22.2", "babel-plugin-array-includes": "~2.0.3", - "babel-plugin-external-helpers": "~6.18.0", - "babel-plugin-transform-runtime": "~6.15.0", - "babel-preset-latest": "^6.16.0", - "babel-preset-stage-0": "^6.16.0", + "babel-plugin-external-helpers": "~6.22.0", + "babel-plugin-transform-runtime": "~6.22.0", + "babel-preset-latest": "~6.22.0", + "babel-preset-stage-0": "~6.22.0", "coveralls": "^2.11.15", "docs-core": "0.0.0-alpha-6.1", "docs-theme-default": "0.0.0-alpha-6.1", "get-stream": "~3.0.0", - "joi": "~10.0.5", + "joi": "~10.2.0", "jsondiffpatch": "~0.2.4", "lint-rules": "github:ma-shop/lint-rules", "nixt": "~0.5.0", - "nyc": "~9.0.1", + "nyc": "~10.1.2", "proxyquire": "~1.7.10", "test-console": "~1.0.0" }, From a4a36a7b3ed79507538fa9b3bb2af3069beafad8 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 24 Jan 2017 12:26:46 -0500 Subject: [PATCH 02/12] fixed models spinner to be correct --- app/models.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models.js b/app/models.js index 5134427..76f238d 100644 --- a/app/models.js +++ b/app/models.js @@ -30,8 +30,6 @@ export default class Models extends Base { this.registered_models = []; // holds the paths that have already been added this.prepared = false; - - this.progress = this.spinner('Models'); } ///# @name prepare @@ -109,7 +107,7 @@ export default class Models extends Base { } async registerModels(models, dependency = false) { - this.progress.start(); + this.progress = this.progress || this.spinner('Models').start(); // if models weren't passed in then don't do anything if (!models) { return; @@ -192,6 +190,8 @@ export default class Models extends Base { if (this.models.length === this.registered_models.length) { this.progress.stop(); + // unset progress so when it's run again it works correctly + // this.progress = null; } return this; } From 737caaa3a2df2c08963c4e073060f01b9fe0553d Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Tue, 24 Jan 2017 14:18:21 -0500 Subject: [PATCH 03/12] bugfix `parseModelDependencies` Fixes a bug where if two files required the same dependency the second model passed would have it's dependencies removed which causes issues when trying to make the document generation smarter. --- app/models.js | 2 +- test/models.test.js | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/models.js b/app/models.js index 76f238d..fb53f25 100644 --- a/app/models.js +++ b/app/models.js @@ -236,7 +236,7 @@ export default class Models extends Base { } // get list of files, flatten the array of files and filter files for valid input formats: yaml - const files = this.filterModelFiles(await utils.findFiles(model.data.dependencies)); + const files = to.flatten(await utils.findFiles(model.data.dependencies)); if (!files.length) { model.data.dependencies = []; diff --git a/test/models.test.js b/test/models.test.js index 4c63299..760c755 100644 --- a/test/models.test.js +++ b/test/models.test.js @@ -68,7 +68,6 @@ test('without args', async (t) => { prepared: is.boolean(), registered_models: is.array().length(0), spinners: is.object().required(), - progress: is.object().required(), }; const { error } = is.validate(t.context, expected); if (error) { @@ -258,7 +257,6 @@ test.group('parseModelDependencies', models(async (t, file) => { t.plan(0); } else { const length = t.context.models.length; - t.plan(length * 2 + 1); t.is(length, to.unique(t.context.registered_models).length); } @@ -278,11 +276,7 @@ test.group('parseModelDependencies', models(async (t, file) => { } else { t.truthy(dependency.is_dependency); } - if ( - dependency.data && - dependency.data.dependencies && - dependency.data.dependencies.length - ) { + if (dependency.data.dependencies.length) { check(dependency.data.dependencies); } } From ec50dd289c734954ebe45dcecaecbfd7fa74e4b2 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Wed, 25 Jan 2017 13:49:42 -0500 Subject: [PATCH 04/12] updated to exit if lint fails --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 34cf31f..b2098bc 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ post-coverage: # The command the ci server runs ci: - make lint build-source-maps -i + make lint || exit 1 # if the tests fail then it will exit with an error make coverage || exit 1 # show the coverage report From 0a8541aba9b685ffc50ff2f808691140c8b28a9e Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 26 Jan 2017 12:27:57 -0500 Subject: [PATCH 05/12] bugfix for memory leak --- app/models.js | 5 ++-- .../contacts/validation/contacts.model.js | 2 +- .../ecommerce/validation/orders.model.js | 2 +- .../ecommerce/validation/products.model.js | 2 +- .../ecommerce/validation/reviews.model.js | 2 +- .../ecommerce/validation/users.model.js | 2 +- .../models/flat/validation/products.model.js | 2 +- .../models/flat/validation/users.model.js | 2 +- .../validation/airline_reviews.model.js | 2 +- .../flight-data/validation/airlines.model.js | 2 +- .../validation/airport_airlines.model.js | 2 +- .../validation/airport_frequencies.model.js | 2 +- .../validation/airport_navaids.model.js | 2 +- .../validation/airport_reviews.model.js | 2 +- .../validation/airport_runways.model.js | 2 +- .../flight-data/validation/airports.model.js | 2 +- .../flight-data/validation/codes.model.js | 2 +- .../validation/continents.model.js | 2 +- .../flight-data/validation/countries.model.js | 2 +- .../validation/frequencies.model.js | 2 +- .../flight-data/validation/navaids.model.js | 2 +- .../flight-data/validation/regions.model.js | 2 +- .../flight-data/validation/routes.model.js | 2 +- .../flight-data/validation/runways.model.js | 2 +- .../flight-data/validation/users.model.js | 2 +- .../music/validation/countries.model.js | 11 +-------- .../music/validation/playlists.model.js | 2 +- .../models/music/validation/tracks.model.js | 2 +- .../models/music/validation/users.model.js | 2 +- .../models/simple/validation/users.model.js | 2 +- .../social/validation/addresses.model.js | 2 +- .../models/social/validation/auth.model.js | 2 +- .../social/validation/chat_messages.model.js | 2 +- .../models/social/validation/chats.model.js | 2 +- .../models/social/validation/emails.model.js | 2 +- .../models/social/validation/friends.model.js | 2 +- .../models/social/validation/likes.model.js | 2 +- .../models/social/validation/phones.model.js | 2 +- .../models/social/validation/posts.model.js | 2 +- .../social/validation/user_addresses.model.js | 2 +- .../social/validation/user_emails.model.js | 2 +- .../social/validation/user_phones.model.js | 2 +- .../models/social/validation/users.model.js | 2 +- .../zip-input/validation/users.model.js | 24 +------------------ test/models.test.js | 4 +++- 45 files changed, 48 insertions(+), 78 deletions(-) diff --git a/app/models.js b/app/models.js index fb53f25..9b3f1aa 100644 --- a/app/models.js +++ b/app/models.js @@ -216,7 +216,7 @@ export default class Models extends Base { parseModelSeed(model, this.options.seed); // add this models inputs to the main inputs object - this.inputs = to.extend(this.inputs || {}, await inputs); + this.inputs = Object.assign(this.inputs || {}, await inputs); await dependencies; return model; } @@ -260,7 +260,7 @@ export async function parseModelInputs(model) { !model.data.inputs || !model.data.inputs.length ) { - model.data.inputs = {}; + model.data.inputs = []; return {}; } @@ -286,7 +286,6 @@ export async function parseModelInputs(model) { return file; }); - model.data.inputs = inputs; return inputs; } diff --git a/test/fixtures/models/contacts/validation/contacts.model.js b/test/fixtures/models/contacts/validation/contacts.model.js index d6ff215..40f8b55 100644 --- a/test/fixtures/models/contacts/validation/contacts.model.js +++ b/test/fixtures/models/contacts/validation/contacts.model.js @@ -13,7 +13,7 @@ module.exports = is.object({ min: 200, max: 400, count: is.number().min(200).max(400), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), dependencies: is.array().length(0), }, properties: { diff --git a/test/fixtures/models/ecommerce/validation/orders.model.js b/test/fixtures/models/ecommerce/validation/orders.model.js index 49d0863..1f6be20 100644 --- a/test/fixtures/models/ecommerce/validation/orders.model.js +++ b/test/fixtures/models/ecommerce/validation/orders.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 600, count: is.number().min(300).max(600), dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { _id: utils.check('string', 'The document id', { post_build: is.func(), }), diff --git a/test/fixtures/models/ecommerce/validation/products.model.js b/test/fixtures/models/ecommerce/validation/products.model.js index 746fc5a..1a23c12 100644 --- a/test/fixtures/models/ecommerce/validation/products.model.js +++ b/test/fixtures/models/ecommerce/validation/products.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 500, count: is.number().min(100).max(500), dependencies: is.array().length(0), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { _id: utils.check('string', 'The document id', { post_build: is.func(), }), diff --git a/test/fixtures/models/ecommerce/validation/reviews.model.js b/test/fixtures/models/ecommerce/validation/reviews.model.js index bc5bb4e..53977f6 100644 --- a/test/fixtures/models/ecommerce/validation/reviews.model.js +++ b/test/fixtures/models/ecommerce/validation/reviews.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 1000, count: is.number().min(500).max(1000), dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { _id: utils.check('string', 'The document id', { post_build: is.func(), }), diff --git a/test/fixtures/models/ecommerce/validation/users.model.js b/test/fixtures/models/ecommerce/validation/users.model.js index 40cafeb..34f5f14 100644 --- a/test/fixtures/models/ecommerce/validation/users.model.js +++ b/test/fixtures/models/ecommerce/validation/users.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 500, count: is.number().min(200).max(500), dependencies: is.array().length(0), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flat/validation/products.model.js b/test/fixtures/models/flat/validation/products.model.js index 9d2dd21..944ea40 100644 --- a/test/fixtures/models/flat/validation/products.model.js +++ b/test/fixtures/models/flat/validation/products.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 500, count: is.number().min(100).max(500), dependencies: is.array().length(0), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { _id: utils.check('string', 'The document id', { post_build: is.func(), }), diff --git a/test/fixtures/models/flat/validation/users.model.js b/test/fixtures/models/flat/validation/users.model.js index 9938b19..e1b8532 100644 --- a/test/fixtures/models/flat/validation/users.model.js +++ b/test/fixtures/models/flat/validation/users.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 400, count: is.number().min(100).max(400), dependencies: is.array().length(0), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { user_id: utils.check('integer', 'The users id', { build: is.func(), }), diff --git a/test/fixtures/models/flight-data/validation/airline_reviews.model.js b/test/fixtures/models/flight-data/validation/airline_reviews.model.js index 2b287d0..5e9cdf8 100644 --- a/test/fixtures/models/flight-data/validation/airline_reviews.model.js +++ b/test/fixtures/models/flight-data/validation/airline_reviews.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), pre_build: is.func(), }, diff --git a/test/fixtures/models/flight-data/validation/airlines.model.js b/test/fixtures/models/flight-data/validation/airlines.model.js index 4f25ca7..a3a7ee5 100644 --- a/test/fixtures/models/flight-data/validation/airlines.model.js +++ b/test/fixtures/models/flight-data/validation/airlines.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), post_build: is.func(), }, diff --git a/test/fixtures/models/flight-data/validation/airport_airlines.model.js b/test/fixtures/models/flight-data/validation/airport_airlines.model.js index 707f0c3..889d69f 100644 --- a/test/fixtures/models/flight-data/validation/airport_airlines.model.js +++ b/test/fixtures/models/flight-data/validation/airport_airlines.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/airport_frequencies.model.js b/test/fixtures/models/flight-data/validation/airport_frequencies.model.js index acc600f..976b5b4 100644 --- a/test/fixtures/models/flight-data/validation/airport_frequencies.model.js +++ b/test/fixtures/models/flight-data/validation/airport_frequencies.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/airport_navaids.model.js b/test/fixtures/models/flight-data/validation/airport_navaids.model.js index ce3177a..4b06db3 100644 --- a/test/fixtures/models/flight-data/validation/airport_navaids.model.js +++ b/test/fixtures/models/flight-data/validation/airport_navaids.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/airport_reviews.model.js b/test/fixtures/models/flight-data/validation/airport_reviews.model.js index ac19c3c..f9405af 100644 --- a/test/fixtures/models/flight-data/validation/airport_reviews.model.js +++ b/test/fixtures/models/flight-data/validation/airport_reviews.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), pre_build: is.func(), }, diff --git a/test/fixtures/models/flight-data/validation/airport_runways.model.js b/test/fixtures/models/flight-data/validation/airport_runways.model.js index b5e1934..a7b2aaa 100644 --- a/test/fixtures/models/flight-data/validation/airport_runways.model.js +++ b/test/fixtures/models/flight-data/validation/airport_runways.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/airports.model.js b/test/fixtures/models/flight-data/validation/airports.model.js index 9b0579b..ad00eef 100644 --- a/test/fixtures/models/flight-data/validation/airports.model.js +++ b/test/fixtures/models/flight-data/validation/airports.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), post_build: is.func(), }, diff --git a/test/fixtures/models/flight-data/validation/codes.model.js b/test/fixtures/models/flight-data/validation/codes.model.js index a6cee52..53ec5a1 100644 --- a/test/fixtures/models/flight-data/validation/codes.model.js +++ b/test/fixtures/models/flight-data/validation/codes.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/continents.model.js b/test/fixtures/models/flight-data/validation/continents.model.js index d1656bf..4161091 100644 --- a/test/fixtures/models/flight-data/validation/continents.model.js +++ b/test/fixtures/models/flight-data/validation/continents.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/countries.model.js b/test/fixtures/models/flight-data/validation/countries.model.js index 13ae226..bf245b4 100644 --- a/test/fixtures/models/flight-data/validation/countries.model.js +++ b/test/fixtures/models/flight-data/validation/countries.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/frequencies.model.js b/test/fixtures/models/flight-data/validation/frequencies.model.js index cf44e2c..61ac355 100644 --- a/test/fixtures/models/flight-data/validation/frequencies.model.js +++ b/test/fixtures/models/flight-data/validation/frequencies.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/navaids.model.js b/test/fixtures/models/flight-data/validation/navaids.model.js index 2e4329f..0925301 100644 --- a/test/fixtures/models/flight-data/validation/navaids.model.js +++ b/test/fixtures/models/flight-data/validation/navaids.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), post_build: is.func(), }, diff --git a/test/fixtures/models/flight-data/validation/regions.model.js b/test/fixtures/models/flight-data/validation/regions.model.js index 21c104c..28bfac0 100644 --- a/test/fixtures/models/flight-data/validation/regions.model.js +++ b/test/fixtures/models/flight-data/validation/regions.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/routes.model.js b/test/fixtures/models/flight-data/validation/routes.model.js index 6ea00f1..97f739a 100644 --- a/test/fixtures/models/flight-data/validation/routes.model.js +++ b/test/fixtures/models/flight-data/validation/routes.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/runways.model.js b/test/fixtures/models/flight-data/validation/runways.model.js index f8c8edd..9e3bb21 100644 --- a/test/fixtures/models/flight-data/validation/runways.model.js +++ b/test/fixtures/models/flight-data/validation/runways.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(0), - inputs: is.object().length(1), + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/flight-data/validation/users.model.js b/test/fixtures/models/flight-data/validation/users.model.js index 74d9ab5..b805447 100644 --- a/test/fixtures/models/flight-data/validation/users.model.js +++ b/test/fixtures/models/flight-data/validation/users.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 10000, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), pre_build: is.func(), post_build: is.func(), diff --git a/test/fixtures/models/music/validation/countries.model.js b/test/fixtures/models/music/validation/countries.model.js index a027be1..76d3679 100644 --- a/test/fixtures/models/music/validation/countries.model.js +++ b/test/fixtures/models/music/validation/countries.model.js @@ -13,16 +13,7 @@ module.exports = is.object({ min: 0, max: 0, count: 1, - inputs: { - countries: is.array() - .items({ - name: is.string(), - iso_2: is.string().uppercase().length(2), - iso_3: is.string().uppercase().length(3), - iso_m49: is.number(), - }) - .length(247), - }, + inputs: is.array().items(is.string()).length(1), dependencies: is.array().length(0), pre_run: is.func(), pre_build: is.func(), diff --git a/test/fixtures/models/music/validation/playlists.model.js b/test/fixtures/models/music/validation/playlists.model.js index 62b2863..cccdd18 100644 --- a/test/fixtures/models/music/validation/playlists.model.js +++ b/test/fixtures/models/music/validation/playlists.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 1000, count: is.number().min(500).max(1000), dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { _id: utils.check('string', 'The document id', { post_build: is.func(), }), diff --git a/test/fixtures/models/music/validation/tracks.model.js b/test/fixtures/models/music/validation/tracks.model.js index 98f7932..9150426 100644 --- a/test/fixtures/models/music/validation/tracks.model.js +++ b/test/fixtures/models/music/validation/tracks.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 800, count: is.number().min(500).max(800), dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { _id: utils.check('string', 'The document id', { post_build: is.func(), }), diff --git a/test/fixtures/models/music/validation/users.model.js b/test/fixtures/models/music/validation/users.model.js index 428a041..0218237 100644 --- a/test/fixtures/models/music/validation/users.model.js +++ b/test/fixtures/models/music/validation/users.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 600, count: is.number().min(400).max(600), dependencies: is.array().length(0), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { _id: utils.check('string', 'The document id', { post_build: is.func(), }), diff --git a/test/fixtures/models/simple/validation/users.model.js b/test/fixtures/models/simple/validation/users.model.js index 9ef1a5f..b0137b9 100644 --- a/test/fixtures/models/simple/validation/users.model.js +++ b/test/fixtures/models/simple/validation/users.model.js @@ -13,7 +13,7 @@ module.exports = is.object({ max: 100, count: is.number().min(50).max(100), dependencies: is.array().length(0), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), }, properties: { id: { diff --git a/test/fixtures/models/social/validation/addresses.model.js b/test/fixtures/models/social/validation/addresses.model.js index 2ad54e4..8e9751f 100644 --- a/test/fixtures/models/social/validation/addresses.model.js +++ b/test/fixtures/models/social/validation/addresses.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/auth.model.js b/test/fixtures/models/social/validation/auth.model.js index b04cdac..904828a 100644 --- a/test/fixtures/models/social/validation/auth.model.js +++ b/test/fixtures/models/social/validation/auth.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/chat_messages.model.js b/test/fixtures/models/social/validation/chat_messages.model.js index abe12e7..69d0911 100644 --- a/test/fixtures/models/social/validation/chat_messages.model.js +++ b/test/fixtures/models/social/validation/chat_messages.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), pre_build: is.func(), }, diff --git a/test/fixtures/models/social/validation/chats.model.js b/test/fixtures/models/social/validation/chats.model.js index 8781c9e..80b649c 100644 --- a/test/fixtures/models/social/validation/chats.model.js +++ b/test/fixtures/models/social/validation/chats.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/emails.model.js b/test/fixtures/models/social/validation/emails.model.js index 6ba7782..1cd9245 100644 --- a/test/fixtures/models/social/validation/emails.model.js +++ b/test/fixtures/models/social/validation/emails.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/friends.model.js b/test/fixtures/models/social/validation/friends.model.js index 1a78718..4f4a2e2 100644 --- a/test/fixtures/models/social/validation/friends.model.js +++ b/test/fixtures/models/social/validation/friends.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/likes.model.js b/test/fixtures/models/social/validation/likes.model.js index 4926035..a877734 100644 --- a/test/fixtures/models/social/validation/likes.model.js +++ b/test/fixtures/models/social/validation/likes.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/phones.model.js b/test/fixtures/models/social/validation/phones.model.js index 3756614..8cdd2c3 100644 --- a/test/fixtures/models/social/validation/phones.model.js +++ b/test/fixtures/models/social/validation/phones.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/posts.model.js b/test/fixtures/models/social/validation/posts.model.js index 5ffa8e8..f3c396f 100644 --- a/test/fixtures/models/social/validation/posts.model.js +++ b/test/fixtures/models/social/validation/posts.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(1), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/user_addresses.model.js b/test/fixtures/models/social/validation/user_addresses.model.js index 5857e89..2a05002 100644 --- a/test/fixtures/models/social/validation/user_addresses.model.js +++ b/test/fixtures/models/social/validation/user_addresses.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/user_emails.model.js b/test/fixtures/models/social/validation/user_emails.model.js index cb450db..5afbe65 100644 --- a/test/fixtures/models/social/validation/user_emails.model.js +++ b/test/fixtures/models/social/validation/user_emails.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/user_phones.model.js b/test/fixtures/models/social/validation/user_phones.model.js index b471937..59ec5c3 100644 --- a/test/fixtures/models/social/validation/user_phones.model.js +++ b/test/fixtures/models/social/validation/user_phones.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1, dependencies: is.array().items(is.string()).length(2), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/social/validation/users.model.js b/test/fixtures/models/social/validation/users.model.js index 8f57d13..4fdffa7 100644 --- a/test/fixtures/models/social/validation/users.model.js +++ b/test/fixtures/models/social/validation/users.model.js @@ -14,7 +14,7 @@ module.exports = is.object({ max: 0, count: 1000, dependencies: is.array().length(0), - inputs: is.object().length(0), + inputs: is.array().items(is.string()).length(0), pre_run: is.func(), }, properties: { diff --git a/test/fixtures/models/zip-input/validation/users.model.js b/test/fixtures/models/zip-input/validation/users.model.js index f7d692e..be9850a 100644 --- a/test/fixtures/models/zip-input/validation/users.model.js +++ b/test/fixtures/models/zip-input/validation/users.model.js @@ -14,29 +14,7 @@ module.exports = is.object({ max: 500, count: is.number().min(100).max(500), dependencies: is.array().length(0), - inputs: { - address: { - types: is.array().items(is.string()).length(3) - }, - email: { - types: is.array().items(is.string()).length(3) - }, - phone: { - types: is.array().items(is.string()).length(8) - }, - countries: is.array() - .items({ - code: is.string().uppercase(), - name: is.string().regex(/[A-Z].+/), - }).length(247), - regions: is.array() - .items({ - code: is.string().regex(/[A-Z0-9-]{4,}/), - name: is.string(), - iso_country: is.string().uppercase(), - }) - .length(3999), - }, + inputs: is.array().items(is.string()).length(1), pre_run: is.func(), pre_build: is.func(), }, diff --git a/test/models.test.js b/test/models.test.js index 760c755..80249b7 100644 --- a/test/models.test.js +++ b/test/models.test.js @@ -309,7 +309,9 @@ test.group('parseModelInputs', models(async (t, file) => { const actual = await parseModelInputs(model); - const tests = [ t.context.inputs, actual, model.data.inputs ]; + t.is(to.type(model.data.inputs), 'array'); + + const tests = [ t.context.inputs, actual ]; for (let item of tests) { const { error } = is.object(expected).validate(item); From db91e2a79b1a57949933f526d9984fff0efbc056 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 27 Jan 2017 11:42:17 -0500 Subject: [PATCH 06/12] added `resolveDependants` This adds an array of model files that are dependent on each model --- app/models.js | 22 +++++++++++++++++++ .../contacts/validation/contacts.model.js | 1 + .../ecommerce/validation/orders.model.js | 1 + .../ecommerce/validation/products.model.js | 1 + .../ecommerce/validation/reviews.model.js | 1 + .../ecommerce/validation/users.model.js | 1 + .../models/flat/validation/products.model.js | 1 + .../models/flat/validation/users.model.js | 1 + .../validation/airline_reviews.model.js | 1 + .../flight-data/validation/airlines.model.js | 1 + .../validation/airport_airlines.model.js | 1 + .../validation/airport_frequencies.model.js | 1 + .../validation/airport_navaids.model.js | 1 + .../validation/airport_reviews.model.js | 1 + .../validation/airport_runways.model.js | 1 + .../flight-data/validation/airports.model.js | 1 + .../flight-data/validation/codes.model.js | 1 + .../validation/continents.model.js | 1 + .../flight-data/validation/countries.model.js | 1 + .../validation/frequencies.model.js | 1 + .../flight-data/validation/navaids.model.js | 1 + .../flight-data/validation/regions.model.js | 1 + .../flight-data/validation/routes.model.js | 1 + .../flight-data/validation/runways.model.js | 1 + .../flight-data/validation/users.model.js | 1 + .../music/validation/countries.model.js | 1 + .../music/validation/playlists.model.js | 1 + .../models/music/validation/tracks.model.js | 1 + .../models/music/validation/users.model.js | 1 + .../models/simple/validation/users.model.js | 1 + .../social/validation/addresses.model.js | 1 + .../models/social/validation/auth.model.js | 1 + .../social/validation/chat_messages.model.js | 1 + .../models/social/validation/chats.model.js | 1 + .../models/social/validation/emails.model.js | 1 + .../models/social/validation/friends.model.js | 1 + .../models/social/validation/likes.model.js | 1 + .../models/social/validation/phones.model.js | 1 + .../models/social/validation/posts.model.js | 1 + .../social/validation/user_addresses.model.js | 1 + .../social/validation/user_emails.model.js | 1 + .../social/validation/user_phones.model.js | 1 + .../models/social/validation/users.model.js | 1 + .../zip-input/validation/users.model.js | 1 + 44 files changed, 65 insertions(+) diff --git a/app/models.js b/app/models.js index 9b3f1aa..7a5cbdb 100644 --- a/app/models.js +++ b/app/models.js @@ -187,6 +187,7 @@ export default class Models extends Base { // update the models order this.models = resolveDependenciesOrder(this.models); + this.models = resolveDependants(this.models); if (this.models.length === this.registered_models.length) { this.progress.stop(); @@ -480,3 +481,24 @@ export function resolveDependenciesOrder(models = []) { return resolver.sort().map((file) => models[order[file]]); } + + +/// @name resolveDependenciesOf +/// @description Figures out which models use the model as a dependency +/// @arg {array} models [[]] - The models to loop over +/// @returns {array} - The models are returned with the `dependants` +export function resolveDependants(models = []) { + return models.map((model) => { + model.dependants = models.reduce((prev, next) => { + if ( + model.file !== next.file && + next.data.dependencies.includes(model.file) + ) { + prev.push(next.file); + } + return prev; + }, []); + + return model; + }); +} diff --git a/test/fixtures/models/contacts/validation/contacts.model.js b/test/fixtures/models/contacts/validation/contacts.model.js index 40f8b55..86c75e9 100644 --- a/test/fixtures/models/contacts/validation/contacts.model.js +++ b/test/fixtures/models/contacts/validation/contacts.model.js @@ -6,6 +6,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), type: 'object', key: '_id', seed: 0, diff --git a/test/fixtures/models/ecommerce/validation/orders.model.js b/test/fixtures/models/ecommerce/validation/orders.model.js index 1f6be20..6fe7dba 100644 --- a/test/fixtures/models/ecommerce/validation/orders.model.js +++ b/test/fixtures/models/ecommerce/validation/orders.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/ecommerce/validation/products.model.js b/test/fixtures/models/ecommerce/validation/products.model.js index 1a23c12..67f0d2b 100644 --- a/test/fixtures/models/ecommerce/validation/products.model.js +++ b/test/fixtures/models/ecommerce/validation/products.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/ecommerce/validation/reviews.model.js b/test/fixtures/models/ecommerce/validation/reviews.model.js index 53977f6..30226b1 100644 --- a/test/fixtures/models/ecommerce/validation/reviews.model.js +++ b/test/fixtures/models/ecommerce/validation/reviews.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/ecommerce/validation/users.model.js b/test/fixtures/models/ecommerce/validation/users.model.js index 34f5f14..557efd0 100644 --- a/test/fixtures/models/ecommerce/validation/users.model.js +++ b/test/fixtures/models/ecommerce/validation/users.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flat/validation/products.model.js b/test/fixtures/models/flat/validation/products.model.js index 944ea40..b619245 100644 --- a/test/fixtures/models/flat/validation/products.model.js +++ b/test/fixtures/models/flat/validation/products.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flat/validation/users.model.js b/test/fixtures/models/flat/validation/users.model.js index e1b8532..aba998d 100644 --- a/test/fixtures/models/flat/validation/users.model.js +++ b/test/fixtures/models/flat/validation/users.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: 'user_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airline_reviews.model.js b/test/fixtures/models/flight-data/validation/airline_reviews.model.js index 5e9cdf8..2095819 100644 --- a/test/fixtures/models/flight-data/validation/airline_reviews.model.js +++ b/test/fixtures/models/flight-data/validation/airline_reviews.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airlines.model.js b/test/fixtures/models/flight-data/validation/airlines.model.js index a3a7ee5..ec64121 100644 --- a/test/fixtures/models/flight-data/validation/airlines.model.js +++ b/test/fixtures/models/flight-data/validation/airlines.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airport_airlines.model.js b/test/fixtures/models/flight-data/validation/airport_airlines.model.js index 889d69f..4c7e643 100644 --- a/test/fixtures/models/flight-data/validation/airport_airlines.model.js +++ b/test/fixtures/models/flight-data/validation/airport_airlines.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airport_frequencies.model.js b/test/fixtures/models/flight-data/validation/airport_frequencies.model.js index 976b5b4..03802db 100644 --- a/test/fixtures/models/flight-data/validation/airport_frequencies.model.js +++ b/test/fixtures/models/flight-data/validation/airport_frequencies.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airport_navaids.model.js b/test/fixtures/models/flight-data/validation/airport_navaids.model.js index 4b06db3..f25b36c 100644 --- a/test/fixtures/models/flight-data/validation/airport_navaids.model.js +++ b/test/fixtures/models/flight-data/validation/airport_navaids.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airport_reviews.model.js b/test/fixtures/models/flight-data/validation/airport_reviews.model.js index f9405af..9c2f35f 100644 --- a/test/fixtures/models/flight-data/validation/airport_reviews.model.js +++ b/test/fixtures/models/flight-data/validation/airport_reviews.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airport_runways.model.js b/test/fixtures/models/flight-data/validation/airport_runways.model.js index a7b2aaa..c015052 100644 --- a/test/fixtures/models/flight-data/validation/airport_runways.model.js +++ b/test/fixtures/models/flight-data/validation/airport_runways.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/airports.model.js b/test/fixtures/models/flight-data/validation/airports.model.js index ad00eef..389ae41 100644 --- a/test/fixtures/models/flight-data/validation/airports.model.js +++ b/test/fixtures/models/flight-data/validation/airports.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/codes.model.js b/test/fixtures/models/flight-data/validation/codes.model.js index 53ec5a1..25b1192 100644 --- a/test/fixtures/models/flight-data/validation/codes.model.js +++ b/test/fixtures/models/flight-data/validation/codes.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/continents.model.js b/test/fixtures/models/flight-data/validation/continents.model.js index 4161091..cc415d7 100644 --- a/test/fixtures/models/flight-data/validation/continents.model.js +++ b/test/fixtures/models/flight-data/validation/continents.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/countries.model.js b/test/fixtures/models/flight-data/validation/countries.model.js index bf245b4..5bd01c7 100644 --- a/test/fixtures/models/flight-data/validation/countries.model.js +++ b/test/fixtures/models/flight-data/validation/countries.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/frequencies.model.js b/test/fixtures/models/flight-data/validation/frequencies.model.js index 61ac355..fe7df55 100644 --- a/test/fixtures/models/flight-data/validation/frequencies.model.js +++ b/test/fixtures/models/flight-data/validation/frequencies.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/navaids.model.js b/test/fixtures/models/flight-data/validation/navaids.model.js index 0925301..8227e17 100644 --- a/test/fixtures/models/flight-data/validation/navaids.model.js +++ b/test/fixtures/models/flight-data/validation/navaids.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/regions.model.js b/test/fixtures/models/flight-data/validation/regions.model.js index 28bfac0..b787688 100644 --- a/test/fixtures/models/flight-data/validation/regions.model.js +++ b/test/fixtures/models/flight-data/validation/regions.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/routes.model.js b/test/fixtures/models/flight-data/validation/routes.model.js index 97f739a..5657373 100644 --- a/test/fixtures/models/flight-data/validation/routes.model.js +++ b/test/fixtures/models/flight-data/validation/routes.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/runways.model.js b/test/fixtures/models/flight-data/validation/runways.model.js index 9e3bb21..f8e1e20 100644 --- a/test/fixtures/models/flight-data/validation/runways.model.js +++ b/test/fixtures/models/flight-data/validation/runways.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/flight-data/validation/users.model.js b/test/fixtures/models/flight-data/validation/users.model.js index b805447..47ed704 100644 --- a/test/fixtures/models/flight-data/validation/users.model.js +++ b/test/fixtures/models/flight-data/validation/users.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/music/validation/countries.model.js b/test/fixtures/models/music/validation/countries.model.js index 76d3679..4440ac9 100644 --- a/test/fixtures/models/music/validation/countries.model.js +++ b/test/fixtures/models/music/validation/countries.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/music/validation/playlists.model.js b/test/fixtures/models/music/validation/playlists.model.js index cccdd18..1cd6301 100644 --- a/test/fixtures/models/music/validation/playlists.model.js +++ b/test/fixtures/models/music/validation/playlists.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/music/validation/tracks.model.js b/test/fixtures/models/music/validation/tracks.model.js index 9150426..b5a04f0 100644 --- a/test/fixtures/models/music/validation/tracks.model.js +++ b/test/fixtures/models/music/validation/tracks.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/music/validation/users.model.js b/test/fixtures/models/music/validation/users.model.js index 0218237..4147ed7 100644 --- a/test/fixtures/models/music/validation/users.model.js +++ b/test/fixtures/models/music/validation/users.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/simple/validation/users.model.js b/test/fixtures/models/simple/validation/users.model.js index b0137b9..4950ab6 100644 --- a/test/fixtures/models/simple/validation/users.model.js +++ b/test/fixtures/models/simple/validation/users.model.js @@ -6,6 +6,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: 'id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/addresses.model.js b/test/fixtures/models/social/validation/addresses.model.js index 8e9751f..b02fa1e 100644 --- a/test/fixtures/models/social/validation/addresses.model.js +++ b/test/fixtures/models/social/validation/addresses.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/auth.model.js b/test/fixtures/models/social/validation/auth.model.js index 904828a..9ba3d89 100644 --- a/test/fixtures/models/social/validation/auth.model.js +++ b/test/fixtures/models/social/validation/auth.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/chat_messages.model.js b/test/fixtures/models/social/validation/chat_messages.model.js index 69d0911..3fec34e 100644 --- a/test/fixtures/models/social/validation/chat_messages.model.js +++ b/test/fixtures/models/social/validation/chat_messages.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/chats.model.js b/test/fixtures/models/social/validation/chats.model.js index 80b649c..01e1805 100644 --- a/test/fixtures/models/social/validation/chats.model.js +++ b/test/fixtures/models/social/validation/chats.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/emails.model.js b/test/fixtures/models/social/validation/emails.model.js index 1cd9245..5974d76 100644 --- a/test/fixtures/models/social/validation/emails.model.js +++ b/test/fixtures/models/social/validation/emails.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/friends.model.js b/test/fixtures/models/social/validation/friends.model.js index 4f4a2e2..c6315c2 100644 --- a/test/fixtures/models/social/validation/friends.model.js +++ b/test/fixtures/models/social/validation/friends.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/likes.model.js b/test/fixtures/models/social/validation/likes.model.js index a877734..fce8f0f 100644 --- a/test/fixtures/models/social/validation/likes.model.js +++ b/test/fixtures/models/social/validation/likes.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/phones.model.js b/test/fixtures/models/social/validation/phones.model.js index 8cdd2c3..4dfeffe 100644 --- a/test/fixtures/models/social/validation/phones.model.js +++ b/test/fixtures/models/social/validation/phones.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/posts.model.js b/test/fixtures/models/social/validation/posts.model.js index f3c396f..6ba02b6 100644 --- a/test/fixtures/models/social/validation/posts.model.js +++ b/test/fixtures/models/social/validation/posts.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/user_addresses.model.js b/test/fixtures/models/social/validation/user_addresses.model.js index 2a05002..f74afe2 100644 --- a/test/fixtures/models/social/validation/user_addresses.model.js +++ b/test/fixtures/models/social/validation/user_addresses.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/user_emails.model.js b/test/fixtures/models/social/validation/user_emails.model.js index 5afbe65..0fd102a 100644 --- a/test/fixtures/models/social/validation/user_emails.model.js +++ b/test/fixtures/models/social/validation/user_emails.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/user_phones.model.js b/test/fixtures/models/social/validation/user_phones.model.js index 59ec5c3..0f4c52c 100644 --- a/test/fixtures/models/social/validation/user_phones.model.js +++ b/test/fixtures/models/social/validation/user_phones.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/social/validation/users.model.js b/test/fixtures/models/social/validation/users.model.js index 4fdffa7..d32c5db 100644 --- a/test/fixtures/models/social/validation/users.model.js +++ b/test/fixtures/models/social/validation/users.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { diff --git a/test/fixtures/models/zip-input/validation/users.model.js b/test/fixtures/models/zip-input/validation/users.model.js index be9850a..6c280aa 100644 --- a/test/fixtures/models/zip-input/validation/users.model.js +++ b/test/fixtures/models/zip-input/validation/users.model.js @@ -7,6 +7,7 @@ module.exports = is.object({ file: is.string(), root: is.string(), is_dependency: is.boolean(), + dependants: is.array(), key: '_id', seed: 0, data: { From 558e2d2eabe99b73c6d970abafb8763998c34458 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 27 Jan 2017 12:05:43 -0500 Subject: [PATCH 07/12] added `events-async` --- app/logger.js | 6 +++++- package.json | 1 + test/base.test.js | 12 ++++++++++++ test/models.test.js | 8 +++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/logger.js b/app/logger.js index f2191b8..7922d53 100644 --- a/app/logger.js +++ b/app/logger.js @@ -6,14 +6,18 @@ symbols.warn = symbols.warning; symbols.ok = symbols.okay = symbols.success; import ora from 'ora'; import formatSeconds from 'format-seconds'; +import Emitter from 'events-async'; + /// @name Logger /// @description /// This is the main logger for the application -export default class Logger { +export default class Logger extends Emitter { ///# @name constructor ///# @arg {object} options [{ log: true, verbose: false, timestamp: true }] constructor(options = {}) { + super(); + this.setMaxListeners(50); this.options = to.extend({ log: true, verbose: false, diff --git a/package.json b/package.json index c87661b..9adb1f9 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "dependency-resolver": "~2.0.1", "es6-promise-pool": "^2.4.4", "es6-promisify": "^5.0.0", + "events-async": "~1.0.0", "faker": "^3.1.0", "find-root": "~1.0.0", "format-seconds": "~0.3.1", diff --git a/test/base.test.js b/test/base.test.js index e8ebc1e..a7adfc8 100644 --- a/test/base.test.js +++ b/test/base.test.js @@ -9,6 +9,12 @@ const test = ava.group('base:'); test('without args', (t) => { const base = new Base(); t.deepEqual(base, { + // inherited from events-async + domain: null, + _events: {}, + _eventsCount: 0, + _maxListeners: 50, + options: { root: process.cwd(), log: true, @@ -32,6 +38,12 @@ test('without args', (t) => { test('with args', (t) => { const base = new Base({ log: false }); t.deepEqual(base, { + // inherited from events-async + domain: null, + _events: {}, + _eventsCount: 0, + _maxListeners: 50, + options: { root: process.cwd(), log: false, diff --git a/test/models.test.js b/test/models.test.js index 80249b7..360336f 100644 --- a/test/models.test.js +++ b/test/models.test.js @@ -49,9 +49,15 @@ test.beforeEach((t) => { }); -test('without args', async (t) => { +test('without args', (t) => { t.context.options.log = true; const expected = { + // inherited from events-async + domain: null, + _events: {}, + _eventsCount: 0, + _maxListeners: 50, + options: { root: models_root, log: true, From 8ee11e3fd8309013fc27416ab58e33368e618482 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Fri, 27 Jan 2017 12:17:08 -0500 Subject: [PATCH 08/12] Created a `Documents` class that runs the models in a more efficient way --- app/documents.js | 119 +++++++++++++++++++++++++++++++++++++++-- app/index.js | 27 +++------- test/documents.test.js | 3 +- test/index.test.js | 14 ++--- 4 files changed, 130 insertions(+), 33 deletions(-) diff --git a/app/documents.js b/app/documents.js index 34090f7..09ba210 100644 --- a/app/documents.js +++ b/app/documents.js @@ -1,3 +1,9 @@ +let exit = false; +process.on('SIGINT', () => { + exit = true; + process.exit(2); +}); + import faker from 'faker'; import Chance from 'chance'; import Base from './base'; @@ -6,13 +12,111 @@ import { set, get } from 'lodash'; import to from 'to-js'; //// -/// @name Document -/// @page api/document +/// @name Documents +/// @page api/documents //// +/// @name Documents +/// @description This class is used to generate all the documents for the passed models +export default class Documents extends Base { + constructor(options = {}, documents = {}, globals = {}, inputs = {}) { + super(options); + this.options = to.extend({ count: 0 }, this.options); + this.documents = documents; + this.globals = globals; + this.inputs = inputs; + this.total = 0; + } + + ///# @name build + ///# @description + ///# This takes an array of models and builds them + ///# @arg {array} models - Array of models + ///# @returns {array} of documents + ///# @async + build(models) { + models = to.clone(models); + const todo = models.map((model) => model.file); + const result = []; + + function finished(dependencies) { + for (let file of dependencies) { + for (let model of models) { + if (model.file === file && !model.complete) { + return false; + } + } + } + + return true; + } + + this.on('run', () => { + // don't run again if the program should exit + if (exit) return; + for (let model of models) { + const index = todo.indexOf(model.file); + if (index > -1 && finished(model.data.dependencies)) { + todo.splice(index, 1); + const document = this.document(model); + + if (!model.is_dependency) { + result.push(document); + } + } + if (model.complete && finished(model.dependants)) { + // if the model is no longer needed then remove it + delete this.documents[model.name]; + } + } + + if (!todo.length) { + this.emit('finished'); + } + }); + + this.emit('run'); + + return new Promise((resolve, reject) => { + this.once('error', (err) => { + reject(err); + }); + this.once('finished', () => { + Promise.all(result).then((res) => { + this.inputs = {}; + resolve(res); + }); + }); + }); + } + + document(model) { + const document = new Document(this.options, this.documents, this.globals, this.inputs); + return document.build(model) + .then(() => { + let result; + if (!model.is_dependency) { + result = this.emit('data', this.documents[model.name], model); + } + // update the total documents number + this.total += this.documents[model.name].length; + model.complete = true; + this.emit('run'); + return result; + }) + .catch((err) => { + exit = true; + process.exit(2); + this.emit('error', err); + }); + } +} + + + /// @name Document /// @description This is used to generate documents based off a model -export default class Document extends Base { +export class Document extends Base { constructor(options = {}, documents = {}, globals = {}, inputs = {}) { super(options); this.options = to.extend({ count: 0 }, this.options); @@ -59,12 +163,19 @@ export default class Document extends Base { spinner.start(); const delay = (duration) => new Promise((resolve) => setTimeout(resolve, duration)); await pool(model.data.count, async (i) => { // loop over each model and execute in order of dependency + // don't anymore if the program should exit + if (exit) return; + + update(); // this allows the spinner to actually update the count and doesn't affect performance much const doc = await this.buildDocument(model, i); update(); await delay(0); this.documents[model.name].push(doc); - }, this.options.spinners ? 75 : 1000); + }, this.options.spinners ? 75 : 1000) + .catch((err) => { + spinner.fail(err); + }); this.runData(model.data.post_run, model); diff --git a/app/index.js b/app/index.js index b76b22e..df9d586 100644 --- a/app/index.js +++ b/app/index.js @@ -1,10 +1,9 @@ import Models from './models'; -import { map } from 'async-array-methods'; import Output from './output/index'; import Base from './base'; import to from 'to-js'; import { uniqueId } from 'lodash'; -import Document from './documents'; +import Documents from './documents'; import { success } from 'log-symbols'; /// @name Fakeit @@ -53,27 +52,17 @@ export default class Fakeit extends Base { output.prepare(); await model.registerModels(models); - - const document = new Document(this.options, this.documents, this.globals, model.inputs); - - let result = []; - - for (let obj of to.flatten(model.models)) { - const value = await document.build(obj); - if (!obj.is_dependency) { - result.push(value); - } - } - - result = await Promise.all(result); - await output.preparing; - result = await map(result, (data) => output.output(data)); + + const documents = new Documents(this.options, this.documents, this.globals, model.inputs); + delete model.inputs; + let result = documents.build(model.models); + documents.on('data', (data) => output.output(data)); + result = await result; await output.finalize(); const time = this.timeEnd(label); - const total = to.reduce(document.documents, (prev, { value }) => prev + value.length, 0); if (this.options.verbose) { - console.log(`${success} Finished generating ${total} documents in ${time}`); + console.log(`${success} Finished generating ${documents.total} documents in ${time}`); } return result; diff --git a/test/documents.test.js b/test/documents.test.js index f444dbd..3bd6c50 100644 --- a/test/documents.test.js +++ b/test/documents.test.js @@ -1,9 +1,10 @@ /* eslint-disable no-undefined */ -import Document, { +import { transformValueToType, getPaths, typeToValue, + Document, } from '../dist/documents.js'; /* istanbul ignore next : needed to test models */ const Model = require('../dist/models.js').default; diff --git a/test/index.test.js b/test/index.test.js index e31c17e..c0a5bf8 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -96,21 +96,17 @@ generate.group('supports globs', (test) => { const actual = await t.context.fakeit.generate('ecommerce/**/*.yaml', t.context.defaults); t.is(actual.length, 4); - - const doc_types = actual.map((item) => to.object(item)[0].doc_type); - const documents = [ 'Products', 'Users', 'Reviews', 'Orders' ]; - t.deepEqual(to.keys(t.context.fakeit.documents), documents); - t.deepEqual(doc_types, documents.map((doc) => doc.toLowerCase().slice(0, -1))); + const doc_types = actual.map((item) => to.object(item)[0].doc_type).sort(); + t.deepEqual(doc_types, [ 'product', 'user', 'review', 'order' ].sort()); }); test('ecommerce/**/@(o|p)*.yaml', async (t) => { t.context.defaults.output = 'return'; const actual = await t.context.fakeit.generate('ecommerce/**/@(orders|products).yaml', t.context.defaults); - // expect 3 documents because orders requires `products.yaml`, and `users.yaml` - t.deepEqual(to.keys(t.context.fakeit.documents), [ 'Products', 'Users', 'Orders' ]); + // only the files that were passed should be returned which should be `products`, and `orders` - const doc_types = actual.map((item) => to.object(item)[0].doc_type); - t.deepEqual(doc_types, [ 'product', 'order' ]); + const doc_types = actual.map((item) => to.object(item)[0].doc_type).sort(); + t.deepEqual(doc_types, [ 'order', 'product' ]); }); }); From aeed92cf8b5e1cdf040da01ba31aa65cb2aa0f86 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Thu, 2 Feb 2017 18:45:28 -0500 Subject: [PATCH 09/12] pr fixes --- app/documents.js | 3 ++- app/models.js | 5 +++-- package.json | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/documents.js b/app/documents.js index 09ba210..fd96498 100644 --- a/app/documents.js +++ b/app/documents.js @@ -64,8 +64,9 @@ export default class Documents extends Base { result.push(document); } } + + // if the model is complete and it's dependants are also completed is no longer needed then remove it if (model.complete && finished(model.dependants)) { - // if the model is no longer needed then remove it delete this.documents[model.name]; } } diff --git a/app/models.js b/app/models.js index 7a5cbdb..ec7f3ee 100644 --- a/app/models.js +++ b/app/models.js @@ -191,8 +191,6 @@ export default class Models extends Base { if (this.models.length === this.registered_models.length) { this.progress.stop(); - // unset progress so when it's run again it works correctly - // this.progress = null; } return this; } @@ -489,9 +487,12 @@ export function resolveDependenciesOrder(models = []) { /// @returns {array} - The models are returned with the `dependants` export function resolveDependants(models = []) { return models.map((model) => { + // loop over each model and find out which other models depend on the current model model.dependants = models.reduce((prev, next) => { if ( + // the next file in the loop doesn't matche the current models file model.file !== next.file && + // the next models dependencies includes the current models files next.data.dependencies.includes(model.file) ) { prev.push(next.file); diff --git a/package.json b/package.json index 9adb1f9..0ebe99e 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "dependency-resolver": "~2.0.1", "es6-promise-pool": "^2.4.4", "es6-promisify": "^5.0.0", - "events-async": "~1.0.0", + "events-async": "github:tjbenton/events-async#temp", "faker": "^3.1.0", "find-root": "~1.0.0", "format-seconds": "~0.3.1", @@ -119,7 +119,7 @@ "test/utils.js" ], "failFast": true, - "concurrency": 5, + "concurrency": 1, "babel": "inherit" }, "nyc": { From 414a7c1745af5593b20122c0d2636b36ee5ccd47 Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 6 Feb 2017 14:14:32 -0500 Subject: [PATCH 10/12] if the model that's passed is `flight-data` make it run serial This is to improve performance on all tests since the flight-data tests are the most cpu intensive. It increases the speed of the tests, and decreases the cpu usage --- test/utils.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/utils.js b/test/utils.js index c18b7f8..4e662da 100644 --- a/test/utils.js +++ b/test/utils.js @@ -125,6 +125,11 @@ module.exports.models = function(settings) { // eslint-disable-next-line no-underscore-dangle const schema_keys = schema.isJoi ? _.map(schema._inner.children, 'key') : to.keys(schema); + + if (model.indexOf('flight-data') >= 0) { + test = test.serial; + } + test(model, function(t) { // eslint-disable-line // run the call back with the `t` assertion object and the current model var result = cb(t, model); From 8d01b4111f8cd075399d92da1eeb18131060a64b Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 6 Feb 2017 15:41:14 -0500 Subject: [PATCH 11/12] updated to `events-async@1.1.0` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ebe99e..42e7d23 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "dependency-resolver": "~2.0.1", "es6-promise-pool": "^2.4.4", "es6-promisify": "^5.0.0", - "events-async": "github:tjbenton/events-async#temp", + "events-async": "~1.1.0", "faker": "^3.1.0", "find-root": "~1.0.0", "format-seconds": "~0.3.1", From a93a1359eaa833ec20f1581726677b8e425e4f2a Mon Sep 17 00:00:00 2001 From: Tyler Benton Date: Mon, 6 Feb 2017 15:52:20 -0500 Subject: [PATCH 12/12] fixed error with `make lint` on node v4 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b2098bc..a53a99a 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ watch: # lint test files lint: - eslint 'app' 'test' + command -v eslint >/dev/null 2>&1 && eslint 'app' 'test' || ./node_modules/lint-rules/node_modules/.bin/eslint 'app' 'test'; # run unit tests test: