Internal helpers called by Bajo and other classes. It should remains hidden and not to be imported by any program.

Methods

(async, static) bootOrder()

Setup plugins boot orders by reading plugin's .bootorder file if provided.

(async, static) bootPlugins()

Iterate through all plugins loaded and do:

  1. build configs
  2. ensure names & aliases uniqueness
  3. ensure dependencies are met
  4. collect hooks
  5. run plugins

(async, static) buildBaseConfig()

Building bajo base config. Mostly dealing with directory setups:

  • determine base directory
  • check whether data directory is valid. If not exist, create one inside app dir
  • ensure data config directory is there
  • ensure tmp dir is there
  • read the list of plugins from .plugins file

(async, static) buildConfigs()

Build configurations

(async, static) buildExtConfig()

Bajo extra config:

  • reading config file
  • merge config with arguments & environments values
  • Set environment (dev or prod)

(async, static) buildPlugins()

Building all plugins:

  • load from app's pluginPkgs
  • iterate through the list and build related plugins
  • making sure main plugin is there. If not, create from template
  • attach these plugins to the app instance

(async, static) checkDependencies()

Ensure dependencies are met

(async, static) checkNameAliases()

Ensure for names and aliases to be unique and no clashes with other plugins

(async, static) collectConfigHandlers()

Collect all config handlers, including the one provided by plugins

(async, static) collectHooks()

Collect and build hooks and push them to the bajo's hook system

(async, static) exitHandler()

Attach plugins exit handlers and make sure the app shutdowns gracefully

(static) findDeep(item, paths) → {string}

Find item deep in paths.

Parameters:
NameTypeDescription
itemstring

Item to find.

pathsArray

Array of path to look for.

Returns:
Type: 
string

(static) freeze(obj, shallowopt)

Freeze object.

Parameters:
NameTypeAttributesDefaultDescription
objObject

Object to freeze.

shallowboolean<optional>
false

If false (default), deep freeze object.

(async, static) importModule(file, optionsopt) → {any}

Import file/module from any loaded plugins.

E.g. your plugin structure looks like this:

|- src
|  |- lib
|  |  |- my-module.js
|- index.js
|- package.json

And this is how to import my-module.js:

const { importModule } = this.app.bajo
const myModule = await importModule('myPlugin:/src/lib/my-module.js')
Parameters:
NameTypeAttributesDefaultDescription
fileTNsPathPairs

File to import.

optionsObject<optional>
{}

Options.

Properties
NameTypeAttributesDefaultDescription
asDefaultImportboolean<optional>
true

If true (default), return default imported module.

asHandlerboolean<optional>

If true, return as a handler.

noCacheboolean<optional>

If true, always import as a fresh copy.

Returns:
Type: 
any

(async, static) run()

Finally, run all plugins

(async, static) runAsApplet()

If app is in applet mode, this little helper should take care plugin's applet boot process

Fires:
  • event:{ns}:beforeAppletRun
  • event:{ns}:afterAppletRun