mongoose-data-seed
Version:
Seed mongodb with data using mongoose models
1,542 lines (1,541 loc) • 390 kB
JSON
{
"type": "File",
"start": 0,
"end": 2243,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 101,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2243,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 101,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"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": "path"
},
"name": "path"
}
}
],
"source": {
"type": "StringLiteral",
"start": 17,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 23
}
},
"extra": {
"rawValue": "path",
"raw": "'path'"
},
"value": "path"
}
},
{
"type": "ImportDeclaration",
"start": 25,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 27
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 32,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 32,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "memFs"
},
"name": "memFs"
}
}
],
"source": {
"type": "StringLiteral",
"start": 43,
"end": 51,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 26
}
},
"extra": {
"rawValue": "mem-fs",
"raw": "'mem-fs'"
},
"value": "mem-fs"
}
},
{
"type": "ImportDeclaration",
"start": 53,
"end": 88,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 35
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 60,
"end": 66,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 13
}
},
"local": {
"type": "Identifier",
"start": 60,
"end": 66,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "editor"
},
"name": "editor"
}
}
],
"source": {
"type": "StringLiteral",
"start": 72,
"end": 87,
"loc": {
"start": {
"line": 3,
"column": 19
},
"end": {
"line": 3,
"column": 34
}
},
"extra": {
"rawValue": "mem-fs-editor",
"raw": "'mem-fs-editor'"
},
"value": "mem-fs-editor"
}
},
{
"type": "ImportDeclaration",
"start": 89,
"end": 115,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 26
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 96,
"end": 101,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 96,
"end": 101,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 12
},
"identifierName": "chalk"
},
"name": "chalk"
}
}
],
"source": {
"type": "StringLiteral",
"start": 107,
"end": 114,
"loc": {
"start": {
"line": 4,
"column": 18
},
"end": {
"line": 4,
"column": 25
}
},
"extra": {
"rawValue": "chalk",
"raw": "'chalk'"
},
"value": "chalk"
}
},
{
"type": "ImportDeclaration",
"start": 117,
"end": 227,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 10,
"column": 26
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 128,
"end": 149,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 23
}
},
"imported": {
"type": "Identifier",
"start": 128,
"end": 149,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 23
},
"identifierName": "getFolderNameFromPath"
},
"name": "getFolderNameFromPath"
},
"local": {
"type": "Identifier",
"start": 128,
"end": 149,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 23
},
"identifierName": "getFolderNameFromPath"
},
"name": "getFolderNameFromPath"
}
},
{
"type": "ImportSpecifier",
"start": 153,
"end": 172,
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 8,
"column": 21
}
},
"imported": {
"type": "Identifier",
"start": 153,
"end": 172,
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 8,
"column": 21
},
"identifierName": "normalizeSeederName"
},
"name": "normalizeSeederName"
},
"local": {
"type": "Identifier",
"start": 153,
"end": 172,
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 8,
"column": 21
},
"identifierName": "normalizeSeederName"
},
"name": "normalizeSeederName"
}
},
{
"type": "ImportSpecifier",
"start": 176,
"end": 199,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 25
}
},
"imported": {
"type": "Identifier",
"start": 176,
"end": 199,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 25
},
"identifierName": "normalizeSeederFileName"
},
"name": "normalizeSeederFileName"
},
"local": {
"type": "Identifier",
"start": 176,
"end": 199,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 25
},
"identifierName": "normalizeSeederFileName"
},
"name": "normalizeSeederFileName"
}
}
],
"source": {
"type": "StringLiteral",
"start": 208,
"end": 226,
"loc": {
"start": {
"line": 10,
"column": 7
},
"end": {
"line": 10,
"column": 25
}
},
"extra": {
"rawValue": "../utils/helpers",
"raw": "'../utils/helpers'"
},
"value": "../utils/helpers"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Seeder Generator\n *\n * Generate a new seeder\n ",
"start": 229,
"end": 284,
"loc": {
"start": {
"line": 12,
"column": 0
},
"end": {
"line": 16,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 285,
"end": 2242,
"loc": {
"start": {
"line": 17,
"column": 0
},
"end": {
"line": 100,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 300,
"end": 2242,
"loc": {
"start": {
"line": 17,
"column": 15
},
"end": {
"line": 100,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 306,
"end": 321,
"loc": {
"start": {
"line": 17,
"column": 21
},
"end": {
"line": 17,
"column": 36
},
"identifierName": "SeederGenerator"
},
"name": "SeederGenerator",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 322,
"end": 2242,
"loc": {
"start": {
"line": 17,
"column": 37
},
"end": {
"line": 100,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 326,
"end": 507,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 22,
"column": 3
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 326,
"end": 337,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 18,
"column": 13
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "ObjectPattern",
"start": 338,
"end": 385,
"loc": {
"start": {
"line": 18,
"column": 14
},
"end": {
"line": 18,
"column": 61
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 340,
"end": 344,
"loc": {
"start": {
"line": 18,
"column": 16
},
"end": {
"line": 18,
"column": 20
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 340,
"end": 344,
"loc": {
"start": {
"line": 18,
"column": 16
},
"end": {
"line": 18,
"column": 20
},
"identifierName": "name"
},
"name": "name"
},
"value": {
"type": "Identifier",
"start": 340,
"end": 344,
"loc": {
"start": {
"line": 18,
"column": 16
},
"end": {
"line": 18,
"column": 20
},
"identifierName": "name"
},
"name": "name"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 346,
"end": 360,
"loc": {
"start": {
"line": 18,
"column": 22
},
"end": {
"line": 18,
"column": 36
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 346,
"end": 360,
"loc": {
"start": {
"line": 18,
"column": 22
},
"end": {
"line": 18,
"column": 36
},
"identifierName": "seederTemplate"
},
"name": "seederTemplate"
},
"value": {
"type": "Identifier",
"start": 346,
"end": 360,
"loc": {
"start": {
"line": 18,
"column": 22
},
"end": {
"line": 18,
"column": 36
},
"identifierName": "seederTemplate"
},
"name": "seederTemplate"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 362,
"end": 383,
"loc": {
"start": {
"line": 18,
"column": 38
},
"end": {
"line": 18,
"column": 59
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 362,
"end": 383,
"loc": {
"start": {
"line": 18,
"column": 38
},
"end": {
"line": 18,
"column": 59
},
"identifierName": "userSeedersFolderPath"
},
"name": "userSeedersFolderPath"
},
"value": {
"type": "Identifier",
"start": 362,
"end": 383,
"loc": {
"start": {
"line": 18,
"column": 38
},
"end": {
"line": 18,
"column": 59
},
"identifierName": "userSeedersFolderPath"
},
"name": "userSeedersFolderPath"
},
"extra": {
"shorthand": true
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start": 387,
"end": 507,
"loc": {
"start": {
"line": 18,
"column": 63
},
"end": {
"line": 22,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 393,
"end": 454,
"loc": {
"start": {
"line": 19,
"column": 4
},
"end": {
"line": 19,
"column": 65
}
},
"expression": {
"type": "CallExpression",
"start": 393,
"end": 453,
"loc": {
"start": {
"line": 19,
"column": 4
},
"end": {
"line": 19,
"column": 64
}
},
"callee": {
"type": "MemberExpression",
"start": 393,
"end": 410,
"loc": {
"start": {
"line": 19,
"column": 4
},
"end": {
"line": 19,
"column": 21
}
},
"object": {
"type": "ThisExpression",
"start": 393,
"end": 397,
"loc": {
"start": {
"line": 19,
"column": 4
},
"end": {
"line": 19,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 398,
"end": 410,
"loc": {
"start": {
"line": 19,
"column": 9
},
"end": {
"line": 19,
"column": 21
},
"identifierName": "_initOptions"
},
"name": "_initOptions"
},
"computed": false
},
"arguments": [
{
"type": "ObjectExpression",
"start": 411,
"end": 452,
"loc": {
"start": {
"line": 19,
"column": 22
},
"end": {
"line": 19,
"column": 63
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 413,
"end": 427,
"loc": {
"start": {
"line": 19,
"column": 24
},
"end": {
"line": 19,
"column": 38
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 413,
"end": 427,
"loc": {
"start": {
"line": 19,
"column": 24
},
"end": {
"line": 19,
"column": 38
},
"identifierName": "seederTemplate"
},
"name": "seederTemplate"
},
"value": {
"type": "Identifier",
"start": 413,
"end": 427,
"loc": {
"start": {
"line": 19,
"column": 24
},
"end": {
"line": 19,
"column": 38
},
"identifierName": "seederTemplate"
},
"name": "seederTemplate"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 429,
"end": 450,
"loc": {
"start": {
"line": 19,
"column": 40
},
"end": {
"line": 19,
"column": 61
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 429,
"end": 450,
"loc": {
"start": {
"line": 19,
"column": 40
},
"end": {
"line": 19,
"column": 61
},
"identifierName": "userSeedersFolderPath"
},
"name": "userSeedersFolderPath"
},
"value": {
"type": "Identifier",
"start": 429,
"end": 450,
"loc": {
"start": {
"line": 19,
"column": 40
},
"end": {
"line": 19,
"column": 61
},
"identifierName": "userSeedersFolderPath"
},
"name": "userSeedersFolderPath"
},
"extra": {
"shorthand": true
}
}
]
}
]
}
},
{
"type": "ExpressionStatement",
"start": 459,
"end": 477,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 22
}
},
"expression": {
"type": "CallExpression",
"start": 459,
"end": 476,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 21
}
},
"callee": {
"type": "MemberExpression",
"start": 459,
"end": 474,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 459,
"end": 463,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 464,
"end": 474,
"loc": {
"start": {
"line": 20,
"column": 9
},
"end": {
"line": 20,
"column": 19
},
"identifierName": "_initMemFs"
},
"name": "_initMemFs"
},
"computed": false
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 482,
"end": 503,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 25
}
},
"expression": {
"type": "CallExpression",
"start": 482,
"end": 502,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 24
}
},
"callee": {
"type": "MemberExpression",
"start": 482,
"end": 496,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 18
}
},
"object": {
"type": "ThisExpression",
"start": 482,
"end": 486,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 487,
"end": 496,
"loc": {
"start": {
"line": 21,
"column": 9
},
"end": {
"line": 21,
"column": 18
},
"identifierName": "_initName"
},
"name": "_initName"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 497,
"end": 501,
"loc": {
"start": {
"line": 21,
"column": 19
},
"end": {
"line": 21,
"column": 23
},
"identifierName": "name"
},
"name": "name"
}
]
}
}
],
"directives": [],
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * generate the new seeder\n ",
"start": 511,
"end": 549,
"loc": {
"start": {
"line": 24,
"column": 2
},
"end": {
"line": 26,
"column": 5
}
}
}
]
},
{
"type": "ClassMethod",
"start": 552,
"end": 728,
"loc": {
"start": {
"line": 27,
"column": 2
},
"end": {
"line": 35,
"column": 3
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 558,
"end": 566,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 16
},
"identifierName": "generate"
},
"name": "generate"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start": 569,
"end": 728,
"loc": {
"start": {
"line": 27,
"column": 19
},
"end": {
"line": 35,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 575,
"end": 611,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 28,
"column": 40
}
},
"expression": {
"type": "CallExpression",
"start": 575,
"end": 610,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 28,
"column": 39
}
},
"callee": {
"type": "MemberExpression",
"start": 575,
"end": 608,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 28,
"column": 37
}
},
"object": {
"type": "ThisExpression",
"start": 575,
"end": 579,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 28,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 580,
"end": 608,
"loc": {
"start": {
"line": 28,
"column": 9
},
"end": {
"line": 28,
"column": 37
},
"identifierName": "_validateSeederFileNotExists"
},
"name": "_validateSeederFileNotExists"
},
"computed": false
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 617,
"end": 644,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 31
}
},
"expression": {
"type": "CallExpression",
"start": 617,
"end": 643,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 30
}
},
"callee": {
"type": "MemberExpression",
"start": 617,
"end": 641,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 617,
"end": 621,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 622,
"end": 641,
"loc": {
"start": {
"line": 30,
"column": 9
},
"end": {
"line": 30,
"column": 28
},
"identifierName": "_copySeederTemplate"
},
"name": "_copySeederTemplate"
},
"computed": false
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 650,
"end": 683,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"column": 37
}
},
"expression": {
"type": "AwaitExpression",
"start": 650,
"end": 682,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"column": 36
}
},
"argument": {
"type": "CallExpression",
"start": 656,
"end": 682,
"loc": {
"start": {
"line": 32,
"column": 10
},
"end": {
"line": 32,
"column": 36
}
},
"callee": {
"type": "MemberExpression",
"start": 656,
"end": 680,
"loc": {
"start": {
"line": 32,
"column": 10
},
"end": {
"line": 32,
"column": 34
}
},
"object": {
"type": "ThisExpression",
"start": 656,
"end": 660,
"loc": {
"start": {
"line": 32,
"column": 10
},
"end": {
"line": 32,
"column": 14
}
}
},
"property": {
"type": "Identifier",
"start": 661,
"end": 680,
"loc": {
"start": {
"line": 32,
"column": 15
},
"end": {
"line": 32,
"column": 34
},
"identifierName": "_commitMemFsChanges"
},
"name": "_commitMemFsChanges"
},
"computed": false
},
"arguments": []
}
}
},
{
"type": "ReturnStatement",
"start": 689,
"end": 724,
"loc": {
"start": {
"line": 34,
"column": 4
},
"end": {
"line": 34,
"column": 39
}
},
"argument": {
"type": "MemberExpression",
"start": 696,
"end": 723,
"loc": {
"start": {
"line": 34,
"column": 11