UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,474 lines 153 kB
{ "type": "File", "start": 0, "end": 1610, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 54, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1610, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 54, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 48, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 48 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 22, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 22 } }, "local": { "type": "Identifier", "start": 7, "end": 22, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 22 }, "identifierName": "commandLineArgs" }, "name": "commandLineArgs" } } ], "source": { "type": "StringLiteral", "start": 28, "end": 47, "loc": { "start": { "line": 1, "column": 28 }, "end": { "line": 1, "column": 47 } }, "extra": { "rawValue": "command-line-args", "raw": "'command-line-args'" }, "value": "command-line-args" } }, { "type": "ImportDeclaration", "start": 50, "end": 147, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 6, "column": 29 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 61, "end": 86, "loc": { "start": { "line": 4, "column": 2 }, "end": { "line": 4, "column": 27 } }, "imported": { "type": "Identifier", "start": 61, "end": 86, "loc": { "start": { "line": 4, "column": 2 }, "end": { "line": 4, "column": 27 }, "identifierName": "validateSeedersFolderName" }, "name": "validateSeedersFolderName" }, "local": { "type": "Identifier", "start": 61, "end": 86, "loc": { "start": { "line": 4, "column": 2 }, "end": { "line": 4, "column": 27 }, "identifierName": "validateSeedersFolderName" }, "name": "validateSeedersFolderName" } }, { "type": "ImportSpecifier", "start": 90, "end": 116, "loc": { "start": { "line": 5, "column": 2 }, "end": { "line": 5, "column": 28 } }, "imported": { "type": "Identifier", "start": 90, "end": 116, "loc": { "start": { "line": 5, "column": 2 }, "end": { "line": 5, "column": 28 }, "identifierName": "validateSeederTemplatePath" }, "name": "validateSeederTemplatePath" }, "local": { "type": "Identifier", "start": 90, "end": 116, "loc": { "start": { "line": 5, "column": 2 }, "end": { "line": 5, "column": 28 }, "identifierName": "validateSeederTemplatePath" }, "name": "validateSeederTemplatePath" } } ], "source": { "type": "StringLiteral", "start": 125, "end": 146, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 28 } }, "extra": { "rawValue": "../../utils/helpers", "raw": "'../../utils/helpers'" }, "value": "../../utils/helpers" } }, { "type": "ImportDeclaration", "start": 148, "end": 218, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 70 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 157, "end": 176, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 28 } }, "imported": { "type": "Identifier", "start": 157, "end": 176, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 28 }, "identifierName": "promptSeedersFolder" }, "name": "promptSeedersFolder" }, "local": { "type": "Identifier", "start": 157, "end": 176, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 28 }, "identifierName": "promptSeedersFolder" }, "name": "promptSeedersFolder" } }, { "type": "ImportSpecifier", "start": 178, "end": 198, "loc": { "start": { "line": 7, "column": 30 }, "end": { "line": 7, "column": 50 } }, "imported": { "type": "Identifier", "start": 178, "end": 198, "loc": { "start": { "line": 7, "column": 30 }, "end": { "line": 7, "column": 50 }, "identifierName": "promptSeederTemplate" }, "name": "promptSeederTemplate" }, "local": { "type": "Identifier", "start": 178, "end": 198, "loc": { "start": { "line": 7, "column": 30 }, "end": { "line": 7, "column": 50 }, "identifierName": "promptSeederTemplate" }, "name": "promptSeederTemplate" } } ], "source": { "type": "StringLiteral", "start": 206, "end": 217, "loc": { "start": { "line": 7, "column": 58 }, "end": { "line": 7, "column": 69 } }, "extra": { "rawValue": "./prompts", "raw": "'./prompts'" }, "value": "./prompts" } }, { "type": "ImportDeclaration", "start": 219, "end": 272, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 53 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 226, "end": 243, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 24 } }, "local": { "type": "Identifier", "start": 226, "end": 243, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 24 }, "identifierName": "optionDefinitions" }, "name": "optionDefinitions" } } ], "source": { "type": "StringLiteral", "start": 249, "end": 271, "loc": { "start": { "line": 8, "column": 30 }, "end": { "line": 8, "column": 52 } }, "extra": { "rawValue": "./option-definitions", "raw": "'./option-definitions'" }, "value": "./option-definitions" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Get init options from argv\n * @param {string[]} argv cli argv\n * @return {Object} init options\n * @property {string} seedersFolder\n * @property {string} customSeederTemplate\n * @property {boolean} helpWanted\n ", "start": 274, "end": 535, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 17, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "start": 536, "end": 782, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 26, "column": 2 } }, "specifiers": [], "source": null, "declaration": { "type": "VariableDeclaration", "start": 543, "end": 782, "loc": { "start": { "line": 18, "column": 7 }, "end": { "line": 26, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 549, "end": 781, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 26, "column": 1 } }, "id": { "type": "Identifier", "start": 549, "end": 559, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 23 }, "identifierName": "getOptions" }, "name": "getOptions", "leadingComments": null }, "init": { "type": "ArrowFunctionExpression", "start": 562, "end": 781, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 26, "column": 1 } }, "id": { "type": "Identifier", "start": 549, "end": 559, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 23 }, "identifierName": "getOptions" }, "name": "getOptions", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 562, "end": 566, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 30 }, "identifierName": "argv" }, "name": "argv" } ], "body": { "type": "BlockStatement", "start": 570, "end": 781, "loc": { "start": { "line": 18, "column": 34 }, "end": { "line": 26, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 574, "end": 716, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 23, "column": 51 } }, "declarations": [ { "type": "VariableDeclarator", "start": 580, "end": 715, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 23, "column": 50 } }, "id": { "type": "ObjectPattern", "start": 580, "end": 668, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 23, "column": 3 } }, "properties": [ { "type": "ObjectProperty", "start": 586, "end": 599, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 17 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 586, "end": 599, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 17 }, "identifierName": "seedersFolder" }, "name": "seedersFolder" }, "value": { "type": "Identifier", "start": 586, "end": 599, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 17 }, "identifierName": "seedersFolder" }, "name": "seedersFolder" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 605, "end": 641, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 40 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 605, "end": 619, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 18 }, "identifierName": "seederTemplate" }, "name": "seederTemplate" }, "value": { "type": "Identifier", "start": 621, "end": 641, "loc": { "start": { "line": 21, "column": 20 }, "end": { "line": 21, "column": 40 }, "identifierName": "customSeederTemplate" }, "name": "customSeederTemplate" } }, { "type": "ObjectProperty", "start": 647, "end": 663, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 20 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 647, "end": 651, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 8 }, "identifierName": "help" }, "name": "help" }, "value": { "type": "Identifier", "start": 653, "end": 663, "loc": { "start": { "line": 22, "column": 10 }, "end": { "line": 22, "column": 20 }, "identifierName": "helpWanted" }, "name": "helpWanted" } } ] }, "init": { "type": "CallExpression", "start": 671, "end": 715, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 23, "column": 50 } }, "callee": { "type": "Identifier", "start": 671, "end": 686, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 23, "column": 21 }, "identifierName": "commandLineArgs" }, "name": "commandLineArgs" }, "arguments": [ { "type": "Identifier", "start": 687, "end": 704, "loc": { "start": { "line": 23, "column": 22 }, "end": { "line": 23, "column": 39 }, "identifierName": "optionDefinitions" }, "name": "optionDefinitions" }, { "type": "ObjectExpression", "start": 706, "end": 714, "loc": { "start": { "line": 23, "column": 41 }, "end": { "line": 23, "column": 49 } }, "properties": [ { "type": "ObjectProperty", "start": 708, "end": 712, "loc": { "start": { "line": 23, "column": 43 }, "end": { "line": 23, "column": 47 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 708, "end": 712, "loc": { "start": { "line": 23, "column": 43 }, "end": { "line": 23, "column": 47 }, "identifierName": "argv" }, "name": "argv" }, "value": { "type": "Identifier", "start": 708, "end": 712, "loc": { "start": { "line": 23, "column": 43 }, "end": { "line": 23, "column": 47 }, "identifierName": "argv" }, "name": "argv" }, "extra": { "shorthand": true } } ] } ] } } ], "kind": "const" }, { "type": "ReturnStatement", "start": 720, "end": 779, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 25, "column": 61 } }, "argument": { "type": "ObjectExpression", "start": 727, "end": 778, "loc": { "start": { "line": 25, "column": 9 }, "end": { "line": 25, "column": 60 } }, "properties": [ { "type": "ObjectProperty", "start": 729, "end": 742, "loc": { "start": { "line": 25, "column": 11 }, "end": { "line": 25, "column": 24 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 729, "end": 742, "loc": { "start": { "line": 25, "column": 11 }, "end": { "line": 25, "column": 24 }, "identifierName": "seedersFolder" }, "name": "seedersFolder" }, "value": { "type": "Identifier", "start": 729, "end": 742, "loc": { "start": { "line": 25, "column": 11 }, "end": { "line": 25, "column": 24 }, "identifierName": "seedersFolder" }, "name": "seedersFolder" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 744, "end": 764, "loc": { "start": { "line": 25, "column": 26 }, "end": { "line": 25, "column": 46 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 744, "end": 764, "loc": { "start": { "line": 25, "column": 26 }, "end": { "line": 25, "column": 46 }, "identifierName": "customSeederTemplate" }, "name": "customSeederTemplate" }, "value": { "type": "Identifier", "start": 744, "end": 764, "loc": { "start": { "line": 25, "column": 26 }, "end": { "line": 25, "column": 46 }, "identifierName": "customSeederTemplate" }, "name": "customSeederTemplate" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 766, "end": 776, "loc": { "start": { "line": 25, "column": 48 }, "end": { "line": 25, "column": 58 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 766, "end": 776, "loc": { "start": { "line": 25, "column": 48 }, "end": { "line": 25, "column": 58 }, "identifierName": "helpWanted" }, "name": "helpWanted" }, "value": { "type": "Identifier", "start": 766, "end": 776, "loc": { "start": { "line": 25, "column": 48 }, "end": { "line": 25, "column": 58 }, "identifierName": "helpWanted" }, "name": "helpWanted" }, "extra": { "shorthand": true } } ] } } ], "directives": [] } }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Get init options from argv\n * @param {string[]} argv cli argv\n * @return {Object} init options\n * @property {string} seedersFolder\n * @property {string} customSeederTemplate\n * @property {boolean} helpWanted\n ", "start": 274, "end": 535, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 17, "column": 3 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Prompt missing options for init command\n * @param {Object} [options={}] Init command options\n * @param {[type]} options.seedersFolder seeders folder\n * @param {[type]} options.customSeederTemplate custom seeder template\n * @return {Promise} Options without missing\n ", "start": 784, "end": 1088, "loc": { "start": { "line": 28, "column": 0 }, "end": { "line": 34, "column": 3 } } } ] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Get init options from argv\n * @param {string[]} argv cli argv\n * @return {Object} init options\n * @property {string} seedersFolder\n * @property {string} customSeederTemplate\n * @property {boolean} helpWanted\n ", "start": 274, "end": 535, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 17, "column": 3 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Prompt missing options for init command\n * @param {Object} [options={}] Init command options\n * @param {[type]} options.seedersFolder seeders folder\n * @param {[type]} options.customSeederTemplate custom seeder template\n * @return {Promise} Options without missing\n ", "start": 784, "end": 1088, "loc": { "start": { "line": 28, "column": 0 }, "end": { "line": 34, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "start": 1089, "end": 1609, "loc": { "start": { "line": 35, "column": 0 }, "end": { "line": 53, "column": 2 } }, "specifiers": [], "source": null, "declaration": { "type": "VariableDeclaration", "start": 1096, "end": 1609, "loc": { "start": { "line": 35, "column": 7 }, "end": { "line": 53, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 1102, "end": 1608, "loc": { "start": { "line": 35, "column": 13 }, "end": { "line": 53, "column": 1 } }, "id": { "type": "Identifier", "start": 1102, "end": 1122, "loc": { "start": { "line": 35, "column": 13 }, "end": { "line": 35, "column": 33 }, "identifierName": "promptMissingOptions" }, "name": "promptMissingOptions", "leadingComments": null }, "init": { "type": "ArrowFunctionExpression", "start": 1125, "end": 1608, "loc": { "start": { "line": 35, "column": 36 }, "end": { "line": 53, "column": 1 } }, "id": { "type": "Identifier", "start": 1102, "end": 1122, "loc": { "start": { "line": 35, "column": 13 }, "end": { "line": 35, "column": 33 }, "identifierName": "promptMissingOptions" }, "name": "promptMissingOptions", "leadingComments": null }, "generator": false, "expression": false, "async": true, "params": [ { "type": "AssignmentPattern", "start": 1132, "end": 1181, "loc": { "start": { "line": 35, "column": 43 }, "end": { "line": 38, "column": 6 } }, "left": { "type": "ObjectPattern", "start": 1132, "end": 1176, "loc": { "start": { "line": 35, "column": 43 }, "end": { "line": 38, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 1136, "end": 1149, "loc": { "start": { "line": 36, "column": 2 }, "end": { "line": 36, "column": 15 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 1136, "end": 1149, "loc": { "start": { "line": 36, "column": 2 }, "end": { "line": 36, "column": 15 }, "identifierName": "seedersFolder" }, "name": "seedersFolder" }, "value": { "type": "Identifier", "start": 1136, "end": 1149, "loc": { "start": { "line": 36, "column": 2 }, "end": { "line": 36, "column": 15 }, "identifierName": "seedersFolder" }, "name": "seedersFolder" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 1153, "end": 1173, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 37, "column": 22 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 1153, "end": 1173, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 37, "column": 22 }, "identifierName": "customSeederTemplate" }, "name": "customSeederTemplate" }, "value": { "type": "Identifier", "start": 1153, "end": 1173, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 37, "column": 22 }, "identifierName": "customSeederTemplate" }, "name": "customSeederTemplate" }, "extra": { "shorthand": true } } ] }, "right": { "type": "ObjectExpression", "start": 1179, "end": 1181, "loc": { "start": { "line": 38, "column": 4 }, "end": { "line": 38, "column": 6 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 1186, "end": 1608, "loc": { "start": { "line": 38, "column": 11 }, "end": { "line": 53, "column": 1 } }, "body": [ { "type"