UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,916 lines (1,915 loc) 4.76 MB
{ "type": "File", "start": 0, "end": 23222, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 840, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 23222, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 840, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 23, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 23 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 11, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 11 } }, "local": { "type": "Identifier", "start": 7, "end": 11, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 11 }, "identifierName": "test" }, "name": "test" } } ], "source": { "type": "StringLiteral", "start": 17, "end": 22, "loc": { "start": { "line": 1, "column": 17 }, "end": { "line": 1, "column": 22 } }, "extra": { "rawValue": "ava", "raw": "'ava'" }, "value": "ava" } }, { "type": "ImportDeclaration", "start": 24, "end": 50, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 26 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 31, "end": 36, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 12 } }, "local": { "type": "Identifier", "start": 31, "end": 36, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 12 }, "identifierName": "sinon" }, "name": "sinon" } } ], "source": { "type": "StringLiteral", "start": 42, "end": 49, "loc": { "start": { "line": 2, "column": 18 }, "end": { "line": 2, "column": 25 } }, "extra": { "rawValue": "sinon", "raw": "'sinon'" }, "value": "sinon" } }, { "type": "ImportDeclaration", "start": 51, "end": 75, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 24 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 58, "end": 62, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 11 } }, "local": { "type": "Identifier", "start": 58, "end": 62, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 11 }, "identifierName": "path" }, "name": "path" } } ], "source": { "type": "StringLiteral", "start": 68, "end": 74, "loc": { "start": { "line": 3, "column": 17 }, "end": { "line": 3, "column": 23 } }, "extra": { "rawValue": "path", "raw": "'path'" }, "value": "path" } }, { "type": "ImportDeclaration", "start": 77, "end": 128, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 51 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 84, "end": 91, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 14 } }, "local": { "type": "Identifier", "start": 84, "end": 91, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 14 }, "identifierName": "Subject" }, "name": "Subject" } } ], "source": { "type": "StringLiteral", "start": 97, "end": 127, "loc": { "start": { "line": 5, "column": 20 }, "end": { "line": 5, "column": 50 } }, "extra": { "rawValue": "../../__mocks__/rxjs-subject", "raw": "'../../__mocks__/rxjs-subject'" }, "value": "../../__mocks__/rxjs-subject" } }, { "type": "ImportDeclaration", "start": 129, "end": 238, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 10, "column": 28 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 136, "end": 138, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 9 } }, "local": { "type": "Identifier", "start": 136, "end": 138, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 9 }, "identifierName": "fs" }, "name": "fs" } }, { "type": "ImportSpecifier", "start": 144, "end": 165, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 23 } }, "imported": { "type": "Identifier", "start": 144, "end": 165, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 23 }, "identifierName": "alreadyExistsFilename" }, "name": "alreadyExistsFilename" }, "local": { "type": "Identifier", "start": 144, "end": 165, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 23 }, "identifierName": "alreadyExistsFilename" }, "name": "alreadyExistsFilename" } }, { "type": "ImportSpecifier", "start": 169, "end": 186, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 19 } }, "imported": { "type": "Identifier", "start": 169, "end": 186, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 19 }, "identifierName": "alreadyExistsPath" }, "name": "alreadyExistsPath" }, "local": { "type": "Identifier", "start": 169, "end": 186, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 19 }, "identifierName": "alreadyExistsPath" }, "name": "alreadyExistsPath" } }, { "type": "ImportSpecifier", "start": 190, "end": 208, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 20 } }, "imported": { "type": "Identifier", "start": 190, "end": 208, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 20 }, "identifierName": "throwableMkdirPath" }, "name": "throwableMkdirPath" }, "local": { "type": "Identifier", "start": 190, "end": 208, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 20 }, "identifierName": "throwableMkdirPath" }, "name": "throwableMkdirPath" } } ], "source": { "type": "StringLiteral", "start": 217, "end": 237, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 27 } }, "extra": { "rawValue": "../../__mocks__/fs", "raw": "'../../__mocks__/fs'" }, "value": "../../__mocks__/fs" } }, { "type": "ImportDeclaration", "start": 239, "end": 293, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 54 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 246, "end": 251, "loc": { "start": { "line": 11, "column": 7 }, "end": { "line": 11, "column": 12 } }, "local": { "type": "Identifier", "start": 246, "end": 251, "loc": { "start": { "line": 11, "column": 7 }, "end": { "line": 11, "column": 12 }, "identifierName": "memFs" }, "name": "memFs" } }, { "type": "ImportSpecifier", "start": 255, "end": 260, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 21 } }, "imported": { "type": "Identifier", "start": 255, "end": 260, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 21 }, "identifierName": "store" }, "name": "store" }, "local": { "type": "Identifier", "start": 255, "end": 260, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 21 }, "identifierName": "store" }, "name": "store" } } ], "source": { "type": "StringLiteral", "start": 268, "end": 292, "loc": { "start": { "line": 11, "column": 29 }, "end": { "line": 11, "column": 53 } }, "extra": { "rawValue": "../../__mocks__/mem-fs", "raw": "'../../__mocks__/mem-fs'" }, "value": "../../__mocks__/mem-fs" } }, { "type": "ImportDeclaration", "start": 294, "end": 378, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 14, "column": 39 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 301, "end": 312, "loc": { "start": { "line": 12, "column": 7 }, "end": { "line": 12, "column": 18 } }, "local": { "type": "Identifier", "start": 301, "end": 312, "loc": { "start": { "line": 12, "column": 7 }, "end": { "line": 12, "column": 18 }, "identifierName": "memFsEditor" }, "name": "memFsEditor" } }, { "type": "ImportSpecifier", "start": 318, "end": 337, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 21 } }, "imported": { "type": "Identifier", "start": 318, "end": 320, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 4 }, "identifierName": "fs" }, "name": "fs" }, "local": { "type": "Identifier", "start": 324, "end": 337, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 21 }, "identifierName": "memFsEditorFs" }, "name": "memFsEditorFs" } } ], "source": { "type": "StringLiteral", "start": 346, "end": 377, "loc": { "start": { "line": 14, "column": 7 }, "end": { "line": 14, "column": 38 } }, "extra": { "rawValue": "../../__mocks__/mem-fs-editor", "raw": "'../../__mocks__/mem-fs-editor'" }, "value": "../../__mocks__/mem-fs-editor" } }, { "type": "ImportDeclaration", "start": 380, "end": 460, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 16, "column": 80 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 389, "end": 415, "loc": { "start": { "line": 16, "column": 9 }, "end": { "line": 16, "column": 35 } }, "imported": { "type": "Identifier", "start": 389, "end": 415, "loc": { "start": { "line": 16, "column": 9 }, "end": { "line": 16, "column": 35 }, "identifierName": "defaultUserGeneratorConfig" }, "name": "defaultUserGeneratorConfig" }, "local": { "type": "Identifier", "start": 389, "end": 415, "loc": { "start": { "line": 16, "column": 9 }, "end": { "line": 16, "column": 35 }, "identifierName": "defaultUserGeneratorConfig" }, "name": "defaultUserGeneratorConfig" } }, { "type": "ImportSpecifier", "start": 417, "end": 437, "loc": { "start": { "line": 16, "column": 37 }, "end": { "line": 16, "column": 57 } }, "imported": { "type": "Identifier", "start": 417, "end": 437, "loc": { "start": { "line": 16, "column": 37 }, "end": { "line": 16, "column": 57 }, "identifierName": "systemSeederTemplate" }, "name": "systemSeederTemplate" }, "local": { "type": "Identifier", "start": 417, "end": 437, "loc": { "start": { "line": 16, "column": 37 }, "end": { "line": 16, "column": 57 }, "identifierName": "systemSeederTemplate" }, "name": "systemSeederTemplate" } } ], "source": { "type": "StringLiteral", "start": 445, "end": 459, "loc": { "start": { "line": 16, "column": 65 }, "end": { "line": 16, "column": 79 } }, "extra": { "rawValue": "../constants", "raw": "'../constants'" }, "value": "../constants" } }, { "type": "ImportDeclaration", "start": 461, "end": 527, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 17, "column": 66 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 470, "end": 481, "loc": { "start": { "line": 17, "column": 9 }, "end": { "line": 17, "column": 20 } }, "imported": { "type": "Identifier", "start": 470, "end": 481, "loc": { "start": { "line": 17, "column": 9 }, "end": { "line": 17, "column": 20 }, "identifierName": "mockImports" }, "name": "mockImports" }, "local": { "type": "Identifier", "start": 470, "end": 481, "loc": { "start": { "line": 17, "column": 9 }, "end": { "line": 17, "column": 20 }, "identifierName": "mockImports" }, "name": "mockImports" } }, { "type": "ImportSpecifier", "start": 483, "end": 495, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 34 } }, "imported": { "type": "Identifier", "start": 483, "end": 495, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 34 }, "identifierName": "resetImports" }, "name": "resetImports" }, "local": { "type": "Identifier", "start": 483, "end": 495, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 34 }, "identifierName": "resetImports" }, "name": "resetImports" } } ], "source": { "type": "StringLiteral", "start": 503, "end": 526, "loc": { "start": { "line": 17, "column": 42 }, "end": { "line": 17, "column": 65 } }, "extra": { "rawValue": "../utils/test-helpers", "raw": "'../utils/test-helpers'" }, "value": "../utils/test-helpers" } }, { "type": "ImportDeclaration", "start": 529, "end": 576, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 47 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 536, "end": 550, "loc": { "start": { "line": 19, "column": 7 }, "end": { "line": 19, "column": 21 } }, "local": { "type": "Identifier", "start": 536, "end": 550, "loc": { "start": { "line": 19, "column": 7 }, "end": { "line": 19, "column": 21 }, "identifierName": "InstallerError" }, "name": "InstallerError" } } ], "source": { "type": "StringLiteral", "start": 556, "end": 575, "loc": { "start": { "line": 19, "column": 27 }, "end": { "line": 19, "column": 46 } }, "extra": { "rawValue": "./installer-error", "raw": "'./installer-error'" }, "value": "./installer-error" } }, { "type": "ImportDeclaration", "start": 578, "end": 652, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 21, "column": 74 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 585, "end": 594, "loc": { "start": { "line": 21, "column": 7 }, "end": { "line": 21, "column": 16 } }, "local": { "type": "Identifier", "start": 585, "end": 594, "loc": { "start": { "line": 21, "column": 7 }, "end": { "line": 21, "column": 16 }, "identifierName": "Installer" }, "name": "Installer" } }, { "type": "ImportSpecifier", "start": 598, "end": 630, "loc": { "start": { "line": 21, "column": 20 }, "end": { "line": 21, "column": 52 } }, "imported": { "type": "Identifier", "start": 598, "end": 611, "loc": { "start": { "line": 21, "column": 20 }, "end": { "line": 21, "column": 33 }, "identifierName": "__RewireAPI__" }, "name": "__RewireAPI__" }, "local": { "type": "Identifier", "start": 615, "end": 630, "loc": { "start": { "line": 21, "column": 37 }, "end": { "line": 21, "column": 52 }, "identifierName": "moduleRewireAPI" }, "name": "moduleRewireAPI" } } ], "source": { "type": "StringLiteral", "start": 638, "end": 651, "loc": { "start": { "line": 21, "column": 60 }, "end": { "line": 21, "column": 73 } }, "extra": { "rawValue": "./installer", "raw": "'./installer'" }, "value": "./installer" } }, { "type": "VariableDeclaration", "start": 654, "end": 754, "loc": { "start": { "line": 23, "column": 0 }, "end": { "line": 26, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 660, "end": 753, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 26, "column": 1 } }, "id": { "type": "Identifier", "start": 660, "end": 668, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 23, "column": 14 }, "identifierName": "helpData" }, "name": "helpData" }, "init": { "type": "ObjectExpression", "start": 671, "end": 753, "loc": { "start": { "line": 23, "column": 17 }, "end": { "line": 26, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 675, "end": 706, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 24, "column": 33 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 675, "end": 688, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 24, "column": 15 }, "identifierName": "seedersFolder" }, "name": "seedersFolder" }, "value": { "type": "StringLiteral", "start": 690, "end": 706, "loc": { "start": { "line": 24, "column": 17 }, "end": { "line": 24, "column": 33 } }, "extra": { "rawValue": "seeders-folder", "raw": "'seeders-folder'" }, "value": "seeders-folder" } }, { "type": "ObjectProperty", "start": 710, "end": 750, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 25, "column": 42 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 710, "end": 730, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 25, "column": 22 }, "identifierName": "customSeederTemplate" }, "name": "customSeederTemplate" }, "value": { "type": "StringLiteral", "start": 732, "end": 750, "loc": { "start": { "line": 25, "column": 24 }, "end": { "line": 25, "column": 42 } }, "extra": { "rawValue": "some-template.js", "raw": "'some-template.js'" }, "value": "some-template.js" } } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 756, "end": 999, "loc": { "start": { "line": 28, "column": 0 }, "end": { "line": 34, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 762, "end": 998, "loc": { "start": { "line": 28, "column": 6 }, "end": { "line": 34, "column": 1 } }, "id": { "type": "Identifier", "start": 762, "end": 775, "loc": { "start": { "line": 28, "column": 6 }, "end": { "line": 28, "column": 19 }, "identifierName": "defaultConfig" }, "name": "defaultConfig" }, "init": { "type": "ObjectExpression", "start": 778, "end": 998, "loc": { "start": { "line": 28, "column": 22 }, "end": { "line": 34, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 782, "end": 810, "loc": { "start": { "line": 29, "column": 2 }, "end": { "line": 29, "column": 30 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 782, "end": 793, "loc": { "start": { "line": 29, "column": 2 }, "end": { "line": 29, "column": 13 }, "identifierName": "projectRoot" }, "name": "projectRoot" }, "value": { "type": "StringLiteral", "start": 795, "end": 810, "loc": { "start": { "line": 29, "column": 15 }, "end": { "line": 29, "column": 30 } }, "extra": { "rawValue": "/project/root", "raw": "'/project/root'" }, "value": "/project/root" } }, { "type": "ObjectProperty", "start": 814, "end": 836, "loc": { "start": { "line": 30, "column": 2 }, "end": { "line": 30, "column": 24 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 814, "end": 830, "loc": { "start": { "line": 30, "column": 2 }, "end": { "line": 30, "column": 18 }, "identifierName": "userConfigExists" }, "name": "userConfigExists" }, "value": { "type": "BooleanLiteral", "start": 832, "end": 836, "loc": { "start": { "line": 30, "column": 20 }, "end": { "line": 30, "column": 24 } }, "value": true } }, { "type": "ObjectProperty", "start": 840, "end": 880, "loc": { "start": { "line": 31, "column": 2 }, "end": { "line": 31, "column": 42 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 840, "end": 858, "loc": { "start": { "line": 31, "column": 2 }, "end": { "line": 31, "column": 20 }, "identifierName": "userConfigFilename" }, "name": "userConfigFilename" }, "value": { "type": "StringLiteral", "start": 860, "end": 880, "loc": { "start": { "line": 31, "column": 22 }, "end": { "line": 31, "column": 42 } }, "extra": { "rawValue": "config-filename.js", "raw": "'config-filename.js'" }, "value": "config-filename.js" } }, { "type": "ObjectProperty", "start": 884, "end": 938, "loc": { "start": { "line": 32, "column": 2 }, "end": { "line": 32, "column": 56 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 884, "end": 902, "loc": { "start": { "line": 32, "column": 2 }, "end": { "line": 32, "column": 20 }, "identifierName": "userConfigFilepath" }, "name": "userConfigFilepath" }, "value": { "type": "StringLiteral", "start": 904, "end": 938, "loc": { "start": { "line": 32, "column": 22 }, "end": { "line": 32, "column": 56 } }, "extra": { "rawValue": "/project/root/config-filename.js", "raw": "'/project/root/config-filename.js'" }, "value": "/project/root/config-filename.js" } }, { "type": "ObjectProperty", "start": 942, "end": 995, "loc": { "start": { "line": 33, "column": 2 }, "end": { "line": 33, "column": 55 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 942, "end": 956, "loc": { "start": { "line": 33, "column": 2 }, "end": { "line": 33, "column": 16 }, "identifierName": "configTemplate" }, "name": "configTemplate" }, "value": { "type": "StringLiteral", "start": 958, "end": 995, "loc": { "start": { "line": 33, "column": 18 }, "end": { "line": 33, "column": 55 } }, "extra": { "rawValue": "/template/folder/config-template.js", "raw": "'/template/folder/config-template.js'" }, "value": "/template/folder/config-template.js" } } ] } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 1001, "end": 1325, "loc": { "start": { "line": 36, "column": 0 }, "end": { "line": 50, "column": 3 } }, "expression": { "type": "CallExpression", "start": 1001, "end": 1324, "loc": { "start": { "line": 36, "column": 0 }, "end": { "line": 50, "column": 2 } }, "callee": { "type": "MemberExpression", "start": 1001, "end": 1016, "loc": { "start": { "line": 36, "column": 0 }, "end": { "line": 36, "column": 15 } }, "object": { "type": "Identifier", "start": 1001, "end": 1005, "loc": { "start": { "line": 36, "column": 0 }, "end": { "line": 36, "column": 4 }, "identifierName": "test" }, "name": "test" }, "property": { "type": "Identifier", "start": 1006, "end": 1016, "loc": { "start": { "line": 36, "column": 5 }, "end": { "line": 36, "column": 15 }, "identifierName": "beforeEach" }, "name": "beforeEach" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 1017, "end": 1031, "loc": { "start": { "line": 36, "column": 16 }, "end": { "line": 36, "column": 30 } }, "extra": { "rawValue": "mock imports", "raw": "'mock imports'" }, "value": "mock imports" }, { "type": "ArrowFunctionExpression", "start": 1033, "end": 1323, "loc": { "start": { "line": 36, "column": 32 }, "end": { "line": 50, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1033, "end": 1034, "loc": { "start": { "line": 36, "column": 32 }, "end": { "line": 36, "column": 33 }, "identifierName": "t" }, "name": "t" } ], "body": { "type": "BlockStatement", "start": 1038, "end": 1323, "loc": { "start": { "line": 36, "column": 37 }, "end": { "line": 50, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 1042, "end": 1251, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 45, "column": 4 } }, "declarations": [ { "type": "VariableDeclarator", "start": 1048, "end": 1250, "loc": { "start": { "line": 37, "column": 8 }, "end": { "line": 45, "column": 3 } }, "id": { "type": "Identifier", "start": 1048, "end": 1053, "loc": {