BasePlugin

This is the base class of bajo's plugin system.

Constructor

new BasePlugin(pkgName, app)

Parameters:
NameTypeDescription
pkgNamestring

Package name (the one you use in package.json)

appObject

App instance reference. Usefull to call app method inside a plugin

Members

alias :string

Getter for plugin's alias

Type:
  • string

app :Object

Reference to app instance

Type:
  • Object

config :Object

Config object

Type:
  • Object

lib :TLib

Property to give you direct access to the most commonly used 3rd party library in a bajo based app. No manual import necessary, always available, everywhere, anytime!

Example:

const { camelCase, kebabCase } = this.lib._
console.log(camelCase('Elit commodo sit et aliqua'))
Type:
  • TLib

name :string

Getter for plugin's name

Type:
  • string

pkgName :string

Getter for plugin's package name

Type:
  • string

(static, readonly) alias :string

Plugin alias. Derived plugin must provide its own, unique alias. If it left blank, Bajo will provide this automatically

Type:
  • string

(static, constant) pkgName :string

Package name, the one from package.json

Type:
  • string

(static, constant) pluginName :string

Plugin name. Simply the camel cased version of plugin's package name

Type:
  • string

Methods

error(msg, …argsopt) → {Object}

Create an instance of Err object

Parameters:
NameTypeAttributesDescription
msgmsg

Error message

argsany<optional>
<repeatable>

Argument variables you might want to add to the error object

Returns:

Err instance

Type: 
Object

fatal(msg, …argsopt)

Create an instance of Err object, display it on screen and then force terminate the app process

Parameters:
NameTypeAttributesDescription
msgmsg

Error message

argsany<optional>
<repeatable>

Argument variables you might want to add to the error object

getConfig(pathopt, optionsopt) → {Object}

Get plugin's config value

Parameters:
NameTypeAttributesDefaultDescription
pathstring<optional>

dot separated config path (think of lodash's 'get'). If not provided, the full config will be given

optionsObject<optional>
{}

Options

Properties
NameTypeAttributesDefaultDescription
defValueany<optional>
{}

Default value to use if returned object is undefined

omitArray.<string><optional>
[]

Omit these keys from returned object

noCloneboolean<optional>
false

Set true to NOT clone returned object

Returns:

Returned object. If no path provided, the whole config object is returned

Type: 
Object

initLog()

Initialize log. Please refer to Log class for more info

initPrint(optionsopt)

Initialize print engine. Please refer to Print class for more info

Parameters:
NameTypeAttributesDescription
optionsObject<optional>

Print options

Type Definitions

TLib

Type:
  • Object
Properties
NameTypeDescription
_Object

Access to lodash

fsObject

Access to fs-extra

fastGlobObject

Access to fast-glob

sprintfObject

Access to sprintf

anekaObject

Access to aneka

outmatchObject

Access to outmatch

dayjsObject

Access to dayjs with utc & customParseFormat plugin already applied