UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,533 lines 542 kB
{ "type": "File", "start": 0, "end": 3363, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 122, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 3363, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 122, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 20, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 20 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 9, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 9 } }, "local": { "type": "Identifier", "start": 7, "end": 9, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 9 }, "identifierName": "fs" }, "name": "fs" } } ], "source": { "type": "StringLiteral", "start": 15, "end": 19, "loc": { "start": { "line": 1, "column": 15 }, "end": { "line": 1, "column": 19 } }, "extra": { "rawValue": "fs", "raw": "'fs'" }, "value": "fs" } }, { "type": "ImportDeclaration", "start": 21, "end": 45, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 24 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 28, "end": 32, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 11 } }, "local": { "type": "Identifier", "start": 28, "end": 32, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 11 }, "identifierName": "path" }, "name": "path" } } ], "source": { "type": "StringLiteral", "start": 38, "end": 44, "loc": { "start": { "line": 2, "column": 17 }, "end": { "line": 2, "column": 23 } }, "extra": { "rawValue": "path", "raw": "'path'" }, "value": "path" } }, { "type": "ImportDeclaration", "start": 46, "end": 79, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 33 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 53, "end": 61, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 15 } }, "local": { "type": "Identifier", "start": 53, "end": 61, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 15 }, "identifierName": "findRoot" }, "name": "findRoot" } } ], "source": { "type": "StringLiteral", "start": 67, "end": 78, "loc": { "start": { "line": 3, "column": 21 }, "end": { "line": 3, "column": 32 } }, "extra": { "rawValue": "find-root", "raw": "'find-root'" }, "value": "find-root" } }, { "type": "ImportDeclaration", "start": 81, "end": 207, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 10, "column": 21 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 92, "end": 118, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 28 } }, "imported": { "type": "Identifier", "start": 92, "end": 118, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 28 }, "identifierName": "defaultUserGeneratorConfig" }, "name": "defaultUserGeneratorConfig" }, "local": { "type": "Identifier", "start": 92, "end": 118, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 28 }, "identifierName": "defaultUserGeneratorConfig" }, "name": "defaultUserGeneratorConfig" } }, { "type": "ImportSpecifier", "start": 122, "end": 142, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 22 } }, "imported": { "type": "Identifier", "start": 122, "end": 142, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 22 }, "identifierName": "systemSeederTemplate" }, "name": "systemSeederTemplate" }, "local": { "type": "Identifier", "start": 122, "end": 142, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 22 }, "identifierName": "systemSeederTemplate" }, "name": "systemSeederTemplate" } }, { "type": "ImportSpecifier", "start": 146, "end": 166, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 22 } }, "imported": { "type": "Identifier", "start": 146, "end": 166, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 22 }, "identifierName": "systemConfigTemplate" }, "name": "systemConfigTemplate" }, "local": { "type": "Identifier", "start": 146, "end": 166, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 22 }, "identifierName": "systemConfigTemplate" }, "name": "systemConfigTemplate" } }, { "type": "ImportSpecifier", "start": 170, "end": 184, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 16 } }, "imported": { "type": "Identifier", "start": 170, "end": 184, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 16 }, "identifierName": "configFilename" }, "name": "configFilename" }, "local": { "type": "Identifier", "start": 170, "end": 184, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 16 }, "identifierName": "configFilename" }, "name": "configFilename" } } ], "source": { "type": "StringLiteral", "start": 193, "end": 206, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 20 } }, "extra": { "rawValue": "./constants", "raw": "'./constants'" }, "value": "./constants" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Get the user project root path\n * @return {string}\n ", "start": 209, "end": 270, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 15, "column": 3 } } } ] }, { "type": "VariableDeclaration", "start": 271, "end": 371, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 19, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 277, "end": 370, "loc": { "start": { "line": 16, "column": 6 }, "end": { "line": 19, "column": 1 } }, "id": { "type": "Identifier", "start": 277, "end": 291, "loc": { "start": { "line": 16, "column": 6 }, "end": { "line": 16, "column": 20 }, "identifierName": "getProjectRoot" }, "name": "getProjectRoot", "leadingComments": null }, "init": { "type": "ArrowFunctionExpression", "start": 294, "end": 370, "loc": { "start": { "line": 16, "column": 23 }, "end": { "line": 19, "column": 1 } }, "id": { "type": "Identifier", "start": 277, "end": 291, "loc": { "start": { "line": 16, "column": 6 }, "end": { "line": 16, "column": 20 }, "identifierName": "getProjectRoot" }, "name": "getProjectRoot", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 300, "end": 370, "loc": { "start": { "line": 16, "column": 29 }, "end": { "line": 19, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 304, "end": 337, "loc": { "start": { "line": 17, "column": 2 }, "end": { "line": 17, "column": 35 } }, "declarations": [ { "type": "VariableDeclarator", "start": 310, "end": 336, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 34 } }, "id": { "type": "Identifier", "start": 310, "end": 320, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 18 }, "identifierName": "workingDir" }, "name": "workingDir" }, "init": { "type": "CallExpression", "start": 323, "end": 336, "loc": { "start": { "line": 17, "column": 21 }, "end": { "line": 17, "column": 34 } }, "callee": { "type": "MemberExpression", "start": 323, "end": 334, "loc": { "start": { "line": 17, "column": 21 }, "end": { "line": 17, "column": 32 } }, "object": { "type": "Identifier", "start": 323, "end": 330, "loc": { "start": { "line": 17, "column": 21 }, "end": { "line": 17, "column": 28 }, "identifierName": "process" }, "name": "process" }, "property": { "type": "Identifier", "start": 331, "end": 334, "loc": { "start": { "line": 17, "column": 29 }, "end": { "line": 17, "column": 32 }, "identifierName": "cwd" }, "name": "cwd" }, "computed": false }, "arguments": [] } } ], "kind": "const" }, { "type": "ReturnStatement", "start": 340, "end": 368, "loc": { "start": { "line": 18, "column": 2 }, "end": { "line": 18, "column": 30 } }, "argument": { "type": "CallExpression", "start": 347, "end": 367, "loc": { "start": { "line": 18, "column": 9 }, "end": { "line": 18, "column": 29 } }, "callee": { "type": "Identifier", "start": 347, "end": 355, "loc": { "start": { "line": 18, "column": 9 }, "end": { "line": 18, "column": 17 }, "identifierName": "findRoot" }, "name": "findRoot" }, "arguments": [ { "type": "Identifier", "start": 356, "end": 366, "loc": { "start": { "line": 18, "column": 18 }, "end": { "line": 18, "column": 28 }, "identifierName": "workingDir" }, "name": "workingDir" } ] } } ], "directives": [] } }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Get the user project root path\n * @return {string}\n ", "start": 209, "end": 270, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 15, "column": 3 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * mongoose-data-seed config\n * @type {Object}\n * @property {Function} clean\n * @property {Function} getConfigFromPackageJson\n * @property {Function} getUserGeneratorConfig\n * @property {Function} update\n * @property {Function} loadUserConfig\n * @property {String} projectRoot\n * @property {String} userConfigFilename\n * @property {String} userConfigFilepath\n * @property {String} userSeedersFolderName\n * @property {String} userSeedersFolderPath\n * @property {boolean} userConfigExists\n * @property {String} seederTemplate\n * @property {String} configTemplate\n ", "start": 373, "end": 956, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 37, "column": 3 } } } ] }, { "type": "Identifier", "start": 957, "end": 3320, "loc": { "start": { "line": 38, "column": 0 }, "end": { "line": 117, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 963, "end": 3319, "loc": { "start": { "line": 38, "column": 6 }, "end": { "line": 117, "column": 1 } }, "id": { "type": "Identifier", "start": 963, "end": 969, "loc": { "start": { "line": 38, "column": 6 }, "end": { "line": 38, "column": 12 }, "identifierName": "config" }, "name": "config", "leadingComments": null }, "init": { "type": "ObjectExpression", "start": 972, "end": 3319, "loc": { "start": { "line": 38, "column": 15 }, "end": { "line": 117, "column": 1 } }, "properties": [ { "type": "ObjectMethod", "start": 1010, "end": 1356, "loc": { "start": { "line": 42, "column": 2 }, "end": { "line": 53, "column": 3 } }, "method": true, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1010, "end": 1015, "loc": { "start": { "line": 42, "column": 2 }, "end": { "line": 42, "column": 7 }, "identifierName": "clean" }, "name": "clean", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1018, "end": 1356, "loc": { "start": { "line": 42, "column": 10 }, "end": { "line": 53, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 1024, "end": 1047, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 27 } }, "expression": { "type": "UnaryExpression", "start": 1024, "end": 1046, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 26 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 1031, "end": 1046, "loc": { "start": { "line": 43, "column": 11 }, "end": { "line": 43, "column": 26 } }, "object": { "type": "ThisExpression", "start": 1031, "end": 1035, "loc": { "start": { "line": 43, "column": 11 }, "end": { "line": 43, "column": 15 } } }, "property": { "type": "Identifier", "start": 1036, "end": 1046, "loc": { "start": { "line": 43, "column": 16 }, "end": { "line": 43, "column": 26 }, "identifierName": "workingDir" }, "name": "workingDir" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, { "type": "ExpressionStatement", "start": 1052, "end": 1076, "loc": { "start": { "line": 44, "column": 4 }, "end": { "line": 44, "column": 28 } }, "expression": { "type": "UnaryExpression", "start": 1052, "end": 1075, "loc": { "start": { "line": 44, "column": 4 }, "end": { "line": 44, "column": 27 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 1059, "end": 1075, "loc": { "start": { "line": 44, "column": 11 }, "end": { "line": 44, "column": 27 } }, "object": { "type": "ThisExpression", "start": 1059, "end": 1063, "loc": { "start": { "line": 44, "column": 11 }, "end": { "line": 44, "column": 15 } } }, "property": { "type": "Identifier", "start": 1064, "end": 1075, "loc": { "start": { "line": 44, "column": 16 }, "end": { "line": 44, "column": 27 }, "identifierName": "projectRoot" }, "name": "projectRoot" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, { "type": "ExpressionStatement", "start": 1081, "end": 1112, "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 35 } }, "expression": { "type": "UnaryExpression", "start": 1081, "end": 1111, "loc": { "start": { "line": 45, "column": 4 }, "end": { "line": 45, "column": 34 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 1088, "end": 1111, "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 34 } }, "object": { "type": "ThisExpression", "start": 1088, "end": 1092, "loc": { "start": { "line": 45, "column": 11 }, "end": { "line": 45, "column": 15 } } }, "property": { "type": "Identifier", "start": 1093, "end": 1111, "loc": { "start": { "line": 45, "column": 16 }, "end": { "line": 45, "column": 34 }, "identifierName": "userConfigFilename" }, "name": "userConfigFilename" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, { "type": "ExpressionStatement", "start": 1117, "end": 1148, "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 46, "column": 35 } }, "expression": { "type": "UnaryExpression", "start": 1117, "end": 1147, "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 46, "column": 34 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 1124, "end": 1147, "loc": { "start": { "line": 46, "column": 11 }, "end": { "line": 46, "column": 34 } }, "object": { "type": "ThisExpression", "start": 1124, "end": 1128, "loc": { "start": { "line": 46, "column": 11 }, "end": { "line": 46, "column": 15 } } }, "property": { "type": "Identifier", "start": 1129, "end": 1147, "loc": { "start": { "line": 46, "column": 16 }, "end": { "line": 46, "column": 34 }, "identifierName": "userConfigFilepath" }, "name": "userConfigFilepath" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, { "type": "ExpressionStatement", "start": 1153, "end": 1187, "loc": { "start": { "line": 47, "column": 4 }, "end": { "line": 47, "column": 38 } }, "expression": { "type": "UnaryExpression", "start": 1153, "end": 1186, "loc": { "start": { "line": 47, "column": 4 }, "end": { "line": 47, "column": 37 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 1160, "end": 1186, "loc": { "start": { "line": 47, "column": 11 }, "end": { "line": 47, "column": 37 } }, "object": { "type": "ThisExpression", "start": 1160, "end": 1164, "loc": { "start": { "line": 47, "column": 11 }, "end": { "line": 47, "column": 15 } } }, "property": { "type": "Identifier", "start": 1165, "end": 1186, "loc": { "start": { "line": 47, "column": 16 }, "end": { "line": 47, "column": 37 }, "identifierName": "userSeedersFolderName" }, "name": "userSeedersFolderName" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, { "type": "ExpressionStatement", "start": 1192, "end": 1226, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 48, "column": 38 } }, "expression": { "type": "UnaryExpression", "start": 1192, "end": 1225, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 48, "column": 37 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 1199, "end": 1225, "loc": { "start": { "line": 48, "column": 11 }, "end": { "line": 48, "column": 37 } }, "object": { "type": "ThisExpression", "start": 1199, "end": 1203, "loc": { "start": { "line": 48, "column": 11 }, "end": { "line": 48, "column": 15 } } }, "property": { "type": "Identifier", "start": 1204, "end": 1225, "loc": { "start": { "line": 48, "column": 16 }, "end": { "line": 48, "column": 37 }, "identifierName": "userSeedersFolderPath" }, "name": "userSeedersFolderPath" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, { "type": "ExpressionStatement", "start": 1231, "end": 1260, "loc": { "start": { "line": 49, "column": 4 }, "end": { "line": 49, "column": 33 } }, "expression": { "type": "UnaryExpression", "start": 1231, "end": 1259, "loc": { "start": { "line": 49, "column": 4 }, "end": { "line": 49, "column": 32 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 1238, "end": 1259, "loc": { "start": { "line": 49, "column": 11 }, "end": { "line": 49, "column": 32 } }, "object": { "type": "ThisExpression", "start": 1238, "end": 1242, "loc": { "start": { "line": 49, "column": 11 }, "end": { "line": 49, "column": 15 } } }, "property": { "type": "Identifier", "start": 1243, "end": 1259, "loc": { "start": { "line": 49, "column": 16 }, "end": { "line": 49, "column": 32 }, "identifierName": "userConfigExists" }, "name": "userConfigExists" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, { "type": "ExpressionStatement", "start": 1265, "end": 1288, "loc": { "start": { "line": 50, "column": 4 }, "end": { "line": 50, "column": 27 } }, "expression": { "type": "UnaryExpression", "start": 1265, "end": 1287, "loc": { "start": { "l