Home Reference Source Test

Function

Static Public Summary
public

Get the command name of a given alias

public

Get the function of a given command

public

exit(error: Error)

Exit mongoose-data-seed.

public

async generateSeeder(name: string): Promise

Generate a new seeder.

public

Get the command and the arguments from the cli

public

Get folder name from given path.

public

Get object with selected keys from a given object.

public

Get generate options from argv

public

Get init options from argv

public

Get run options from argv or prompts

public

help()

Prints the generate command user-guide

public

async help()

Prints the help

public

help()

Prints the install command user-guide

public

help()

Prints the run command user-guide

public

async index(argv: stringp[]): Promise

mongoose-data-seed generate command

public

async index(argv: stringp[]): Promise

mongoose-data-seed init command

public

async index(argv: stringp[]): Promise

mongoose-data-seed run command

public

isAlias(command: string): Boolean

Whether a given command is an alias

public

Normalize seeder filename.

public

Normalize seeder name.

public

Prompt missing options for init command

public

async run(options: Object): Promise

Run seeders

public

runCommand(command: string, argv: string): *

Run command

public

async runinstaller(options: Object): Promise

Run the installer

public

Validate generate command options

public

Validate seeder template path.

public

Validate seeders folder name.

public

Validate user config.

Static Public

public aliasToCommand(alias: string): string source

import {aliasToCommand} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Get the command name of a given alias

Params:

NameTypeAttributeDescription
alias string

Return:

string

public commandToFunction(command: string): Function source

import {commandToFunction} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Get the function of a given command

Params:

NameTypeAttributeDescription
command string

command name

Return:

Function

command function

public exit(error: Error) source

Exit mongoose-data-seed.

Params:

NameTypeAttributeDescription
error Error
  • optional

Exit with error when supplied.

public async generateSeeder(name: string): Promise source

Generate a new seeder.

Params:

NameTypeAttributeDescription
name string

seeder name

Return:

Promise

public getCommandAndArgvFromCli(): Object source

import {getCommandAndArgvFromCli} from 'mongoose-data-seed/src/lib/commands/helpers.js'

Get the command and the arguments from the cli

Return:

Object

Return Properties:

NameTypeAttributeDescription
command string

command name

argv string[]

command arguments

public getFolderNameFromPath(path: string): string source

import {getFolderNameFromPath} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Get folder name from given path.

Params:

NameTypeAttributeDescription
path string

path

Return:

string

folder name

public getObjectWithSelectedKeys(obj: Object, keys: string[]): Object source

import {getObjectWithSelectedKeys} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Get object with selected keys from a given object.

Params:

NameTypeAttributeDescription
obj Object

Object

keys string[]

Keys to get from the given object.

Return:

Object

new object with the selected keys.

public getOptions(argv: string[]): Object source

Get generate options from argv

Params:

NameTypeAttributeDescription
argv string[]

cli argv

Return:

Object

run options

Return Properties:

NameTypeAttributeDescription
seederName string
helpWanted boolean

public getOptions(argv: string[]): Object source

Get init options from argv

Params:

NameTypeAttributeDescription
argv string[]

cli argv

Return:

Object

init options

Return Properties:

NameTypeAttributeDescription
seedersFolder string
customSeederTemplate string
helpWanted boolean

public getOptions(argv: string[]): Object source

Get run options from argv or prompts

Params:

NameTypeAttributeDescription
argv string[]

cli argv

Return:

Object

run options

Return Properties:

NameTypeAttributeDescription
selectedSeeders string[]
dropDatabase boolean
helpWanted boolean

public help() source

Prints the generate command user-guide

public async help() source

Prints the help

public help() source

Prints the install command user-guide

public help() source

Prints the run command user-guide

public async index(argv: stringp[]): Promise source

mongoose-data-seed generate command

Params:

NameTypeAttributeDescription
argv stringp[]

cli arguments

Return:

Promise

public async index(argv: stringp[]): Promise source

mongoose-data-seed init command

Params:

NameTypeAttributeDescription
argv stringp[]

cli arguments

Return:

Promise

public async index(argv: stringp[]): Promise source

mongoose-data-seed run command

Params:

NameTypeAttributeDescription
argv stringp[]

cli arguments

Return:

Promise

public isAlias(command: string): Boolean source

Whether a given command is an alias

Params:

NameTypeAttributeDescription
command string

Return:

Boolean

public normalizeSeederFileName(name: string): string source

import {normalizeSeederFileName} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Normalize seeder filename.

Params:

NameTypeAttributeDescription
name string

seeder name

Return:

string

normalized seeder filename

public normalizeSeederName(name: string): string source

import {normalizeSeederName} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Normalize seeder name.

Params:

NameTypeAttributeDescription
name string

seeder name

Return:

string

normalized seeder name

public async promptMissingOptions(options: Object): Promise source

import {promptMissingOptions} from 'mongoose-data-seed/src/lib/commands/init/options.js'

Prompt missing options for init command

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Init command options

options.seedersFolder [type]

seeders folder

options.customSeederTemplate [type]

custom seeder template

Return:

Promise

Options without missing

public async run(options: Object): Promise source

Run seeders

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Options

options.selectedSeeders string[]
  • optional
  • default: []

Selected seeders to run. When empty, run all seeders.

options.dropDatabase boolean
  • optional
  • default: false

Drop database before running?

Return:

Promise

public runCommand(command: string, argv: string): * source

Run command

Params:

NameTypeAttributeDescription
command string

command name

argv string

command arguments

Return:

*

public async runinstaller(options: Object): Promise source

Run the installer

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

installer options

options.seedersFolder string
options.seedersTemplate string

Return:

Promise

public validateOptions(options: Object) source

Validate generate command options

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Options

options.seederName string

seeder name to generate

options.helpWanted boolean

help wanted?

Throw:

Error

throw error when options are not valid.

public validateSeederTemplatePath(name: string): boolean source

import {validateSeederTemplatePath} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Validate seeder template path.

Params:

NameTypeAttributeDescription
name string

path

Return:

boolean

public validateSeedersFolderName(name: string): boolean source

import {validateSeedersFolderName} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Validate seeders folder name.

Params:

NameTypeAttributeDescription
name string

folder name

Return:

boolean

public validateUserConfig() source

import {validateUserConfig} from 'mongoose-data-seed/src/lib/utils/helpers.js'

Validate user config.

Throw:

Error

throw error when user config is not valid.