clique-seeds
Advanced tools
Comparing version 0.0.4 to 0.0.6
{ | ||
"name": "clique-seeds", | ||
"description": "A utility for creating seed data for both the server and client.", | ||
"version": "0.0.4", | ||
"version": "0.0.6", | ||
"author": "Walker Ward <walker.ward1@gmail.com> ()", | ||
@@ -15,3 +15,4 @@ "bugs": { | ||
"chance": "1.0.16", | ||
"common-tags": "1.8.0" | ||
"common-tags": "1.8.0", | ||
"lodash": "4.17.11" | ||
}, | ||
@@ -18,0 +19,0 @@ "ava": { |
@@ -24,2 +24,4 @@ /** | ||
const pick = require('lodash/pick'); | ||
const omit = require('lodash/omit'); | ||
const { stripIndents } = require('common-tags'); | ||
@@ -114,2 +116,18 @@ const Chance = require('chance'); | ||
serialize(recordType) { | ||
const records = this.records[recordType]; | ||
const hasManys = Object.keys(this.records); | ||
const belongsTo = ['rootFolder', ...hasManys.map(o => o.replace(/[s]$/, ''))]; | ||
return records.map((record) => { | ||
record = omit(record, belongsTo); // eslint-disable-line no-param-reassign | ||
return hasManys.reduce((prev, hasMany) => { | ||
if (typeof prev[hasMany] !== 'undefined') { | ||
prev[hasMany] = prev[hasMany].map(o => pick(o, ['id', 'type'])); // eslint-disable-line no-param-reassign | ||
} | ||
return prev; | ||
}, record); | ||
}); | ||
}, | ||
/* ======= End Helper Methods ======= */ | ||
@@ -116,0 +134,0 @@ |
@@ -97,1 +97,14 @@ const test = require('ava'); | ||
}); | ||
test('we can serialize each type', (assert) => { | ||
const seeds = new Seeds(); | ||
const types = Object.keys(seeds.records); | ||
assert.plan(types.length); | ||
seeds.init(); | ||
types.forEach((type) => { | ||
seeds.records[type] = seeds.serialize(type); | ||
assert.true(seeds.records[type].length > 0); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
410914
12
8406
3
1
1
+ Addedlodash@4.17.11
+ Addedlodash@4.17.11(transitive)