Options
All
  • Public
  • Public/Protected
  • All
Menu

Base class for the generators

Hierarchy

Index

Constructors

constructor

Properties

appname

appname: string

args

args: __type

config

config: Storage

description

description: string

env

env: object

Type declaration

  • error: function
    • error(...e: Error[]): void
    • Parameters

      • Rest ...e: Error[]

      Returns void

fs

fs: MemFsEditor

options

options: __type

resolved

resolved: string

user

user: object

Type declaration

  • git: object
    • email: function
      • email(): string
      • Retrieves user's email from Git in the global scope or the project scope (it'll take what Git will use in the current context)

        Returns string

        configured git email or undefined

    • name: function
      • name(): string
      • Retrieves user's name from Git in the global scope or the project scope (it'll take what Git will use in the current context)

        Returns string

        configured git name or undefined

  • github: object
    • username: function
      • username(): Promise<string>
      • Retrieves GitHub's username from the GitHub API

        Returns Promise<string>

        Resolved with the GitHub username or rejected if unable to get the information

Static Protected ERROR_REQUIRED

ERROR_REQUIRED: "This field is required" = "This field is required"

Common message for required files

type

{string}

Static Protected ERROR_SPECIAL_CHARACTER

ERROR_SPECIAL_CHARACTER: "This field only could contains [a-zA-Z0-9_] characters, without spaces or special characters" = "This field only could contains [a-zA-Z0-9_] characters, without spaces or special characters"

Common message for special characters

type

{string}

Static defaultMaxListeners

defaultMaxListeners: number

Static Protected options

options: object

Shared options for all the generators

type

{{}}

Type declaration

Methods

Private _addToConfig

  • _addToConfig(config: any): void
  • Add properties to the config. The properties will be saved in the .yo-rc file

    Parameters

    • config: any

    Returns void

Private _getAllOptions

  • _getAllOptions(): object

Private _getOption

  • _getOption(key: any): any

Private _setOption

  • _setOption(key: any, value: any): void
  • Set a shared option

    Parameters

    • key: any
    • value: any

    Returns void

Private _validateNonEmpty

  • _validateNonEmpty(toValidate: any): boolean
  • Validate a field is not null or empty

    Parameters

    • toValidate: any

    Returns boolean

Private _validateSpecial

  • _validateSpecial(toValidate: any): boolean
  • Validate special characters

    Parameters

    • toValidate: any

    Returns boolean

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

argument

  • argument(name: string, config: ArgumentConfig): this
  • Parameters

    • name: string
    • config: ArgumentConfig

    Returns this

argumentsHelp

  • argumentsHelp(): string
  • Returns string

bowerInstall

  • bowerInstall(component?: string | string[], options?: object, spawnOptions?: object): Promise<void>
  • Receives a list of components and an options object to install through bower.

    The installation will automatically run during the run loop install phase.

    Parameters

    • Optional component: string | string[]

      Components to install

    • Optional options: object

      Options to pass to dargs as arguments

    • Optional spawnOptions: object

      Options to pass child_process.spawn.

    Returns Promise<void>

    Resolved if install successful, rejected otherwise

composeWith

  • composeWith(namespace: string, options: object, settings?: object): this
  • Parameters

    • namespace: string
    • options: object
      • [name: string]: any
    • Optional settings: object
      • link: "weak" | "strong"
      • local: string

    Returns this

desc

  • desc(description: string): this
  • Parameters

    • description: string

    Returns this

destinationPath

  • destinationPath(...path: string[]): string
  • Parameters

    • Rest ...path: string[]

    Returns string

destinationRoot

  • destinationRoot(rootPath?: string): string
  • Parameters

    • Optional rootPath: string

    Returns string

determineAppname

  • determineAppname(): string
  • Returns string

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

help

  • help(): string
  • Returns string

installDependencies

  • installDependencies(options?: InstallOptions): Promise<void>
  • Runs npm and bower, in sequence, in the generated directory and prints a message to let the user know.

    example

    this.installDependencies({ bower: true, npm: true }).then(() => console.log('Everything is ready!'));

    example

    this.installDependencies({ yarn: {force: true}, npm: false }).then(() => console.log('Everything is ready!'));

    Parameters

    • Optional options: InstallOptions

    Returns Promise<void>

    Resolved if install successful, rejected otherwise

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

log

  • log(message?: string, context?: any): void
  • Parameters

    • Optional message: string
    • Optional context: any

    Returns void

npmInstall

  • npmInstall(pkgs?: string | string[], options?: object, spawnOptions?: object): Promise<void>
  • Receives a list of packages and an options object to install through npm.

    The installation will automatically run during the run loop install phase.

    Parameters

    • Optional pkgs: string | string[]

      Packages to install

    • Optional options: object

      Options to pass to dargs as arguments

    • Optional spawnOptions: object

      Options to pass child_process.spawn.

    Returns Promise<void>

    Resolved if install successful, rejected otherwise

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

option

  • option(name: string, config: OptionConfig): this
  • Parameters

    • name: string
    • config: OptionConfig

    Returns this

optionsHelp

  • optionsHelp(): string
  • Returns string

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prompt

  • Parameters

    Returns Promise<Answers>

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

registerTransformStream

  • registerTransformStream(stream: __type | Array<__type>): this
  • Parameters

    • stream: __type | Array<__type>

    Returns this

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rootGeneratorName

  • rootGeneratorName(): string
  • Returns string

rootGeneratorVersion

  • rootGeneratorVersion(): string
  • Returns string

run

  • run(cb?: Callback): this
  • Parameters

    • Optional cb: Callback

    Returns this

runInstall

  • runInstall(installer: string, paths?: string | string[], options?: object, spawnOptions?: object): Promise<void>
  • Combine package manager cmd line arguments and run the install command.

    During the install step, every command will be scheduled to run once, on the run loop. This means you can use Promise.then to log information, but don't return it or mix it with this.async as it'll dead lock the process.

    Parameters

    Returns Promise<void>

    Resolved if install successful, rejected otherwise

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

sourceRoot

  • sourceRoot(rootPath?: string): string
  • Parameters

    • Optional rootPath: string

    Returns string

spawnCommand

  • spawnCommand(command: string, args: string[], opt?: __type): any
  • Parameters

    • command: string
    • args: string[]
    • Optional opt: __type

    Returns any

spawnCommandSync

  • spawnCommandSync(command: string, args: string[], opt?: __type): any
  • Parameters

    • command: string
    • args: string[]
    • Optional opt: __type

    Returns any

templatePath

  • templatePath(...path: string[]): string
  • Parameters

    • Rest ...path: string[]

    Returns string

usage

  • usage(): string
  • Returns string

yarnInstall

  • yarnInstall(pkgs?: string | string[], options?: object, spawnOptions?: object): Promise<void>
  • Receives a list of packages and an options object to install through npm.

    The installation will automatically run during the run loop install phase.

    Parameters

    • Optional pkgs: string | string[]

      Packages to install

    • Optional options: object

      Options to pass to dargs as arguments

    • Optional spawnOptions: object

      Options to pass child_process.spawn.

    Returns Promise<void>

    Resolved if install successful, rejected otherwise

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc