bajo 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/class/_helper.js +4 -6
- package/class/app.js +3 -3
- package/class/bajo.js +71 -56
- package/docs/App.html +2 -2
- package/docs/Bajo.html +2 -2
- package/docs/Cache.html +1 -1
- package/docs/class__helper.js.html +5 -6
- package/docs/class_app.js.html +8 -5
- package/docs/class_bajo.js.html +100 -62
- package/docs/class_cache.js.html +2 -0
- package/docs/data/search.json +1 -1
- package/docs/global.html +1 -1
- package/docs/lib_freeze.js.html +38 -3
- package/docs/module-Helper.html +1 -1
- package/docs/module-Lib.html +1 -1
- package/lib/freeze.js +38 -3
- package/package.json +9 -13
- package/test/bajo.test.js +0 -1
- package/wiki/CHANGES.md +12 -0
package/class/_helper.js
CHANGED
|
@@ -15,7 +15,6 @@ import localizedFormat from 'dayjs/plugin/localizedFormat.js'
|
|
|
15
15
|
import weekOfYear from 'dayjs/plugin/weekOfYear.js'
|
|
16
16
|
import freeze from '../lib/freeze.js'
|
|
17
17
|
import findDeep from '../lib/find-deep.js'
|
|
18
|
-
import omitDeep from 'omit-deep'
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Internal helpers called by Bajo and other classes. It should remains
|
|
@@ -160,8 +159,7 @@ export const lib = {
|
|
|
160
159
|
dayjs,
|
|
161
160
|
aneka,
|
|
162
161
|
freeze,
|
|
163
|
-
findDeep
|
|
164
|
-
omitDeep
|
|
162
|
+
findDeep
|
|
165
163
|
}
|
|
166
164
|
|
|
167
165
|
/**
|
|
@@ -281,12 +279,12 @@ export async function collectConfigHandlers () {
|
|
|
281
279
|
export async function buildExtConfig () {
|
|
282
280
|
// config merging
|
|
283
281
|
const { defaultsDeep, includes } = this.app.lib.aneka
|
|
284
|
-
const { parseObject
|
|
285
|
-
const { isEmpty, get, isString, without } = this.app.lib._
|
|
282
|
+
const { parseObject } = this.app.lib
|
|
283
|
+
const { isEmpty, get, isString, without, omit } = this.app.lib._
|
|
286
284
|
|
|
287
285
|
let resp = get(this, `app.options.config.${this.ns}`, {})
|
|
288
286
|
if (isEmpty(resp)) resp = await this.readAllConfigs(`${this.dir.data}/config/${this.ns}`)
|
|
289
|
-
resp =
|
|
287
|
+
resp = omit(pick(resp, ['log', 'exitHandler', 'env', 'runtime']), omitted)
|
|
290
288
|
const envs = this.app.envs
|
|
291
289
|
this.config = defaultsDeep({}, this.config, resp, defConfig)
|
|
292
290
|
// language
|
package/class/app.js
CHANGED
|
@@ -106,9 +106,9 @@ class App {
|
|
|
106
106
|
/**
|
|
107
107
|
* Config handlers.
|
|
108
108
|
*
|
|
109
|
-
* By default, there are two built-in handlers available: ```.js```
|
|
110
|
-
* and ```.
|
|
111
|
-
* lets you to use ```.
|
|
109
|
+
* By default, there are two built-in handlers available: ```.js```, ```.json```
|
|
110
|
+
* and ```.yml/.yaml```. Use plugins to add more, e.g {@link https://github.com/ardhi/bajo-config|bajo-config}
|
|
111
|
+
* lets you to use ```.toml```.
|
|
112
112
|
*
|
|
113
113
|
* @type {TAppConfigHandler[]}
|
|
114
114
|
*/
|
package/class/bajo.js
CHANGED
|
@@ -4,15 +4,14 @@ import increment from 'add-filename-increment'
|
|
|
4
4
|
import fs from 'fs-extra'
|
|
5
5
|
import path from 'path'
|
|
6
6
|
import os from 'os'
|
|
7
|
-
import emptyDir from 'empty-dir'
|
|
8
7
|
import lodash from 'lodash'
|
|
9
8
|
import { createRequire } from 'module'
|
|
10
|
-
import getGlobalPath from 'get-global-path'
|
|
11
9
|
import fastGlob from 'fast-glob'
|
|
12
10
|
import querystring from 'querystring'
|
|
13
11
|
import importModule from '../lib/import-module.js'
|
|
14
12
|
import logLevels from '../lib/log-levels.js'
|
|
15
13
|
import { types as formatTypes, formats } from '../lib/formats.js'
|
|
14
|
+
import * as yaml from 'js-yaml'
|
|
16
15
|
import aneka from 'aneka'
|
|
17
16
|
import {
|
|
18
17
|
buildBaseConfig,
|
|
@@ -30,10 +29,10 @@ const {
|
|
|
30
29
|
isFunction, map, isObject,
|
|
31
30
|
trim, filter, isEmpty, orderBy, pullAt, find, camelCase,
|
|
32
31
|
cloneDeep, isPlainObject, isArray, isString, omit, keys, indexOf,
|
|
33
|
-
last, get, has, values,
|
|
32
|
+
last, get, has, values, pick
|
|
34
33
|
} = lodash
|
|
35
34
|
|
|
36
|
-
const { resolvePath } = aneka
|
|
35
|
+
const { resolvePath, getGlobalModuleDir } = aneka
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* Name based ```{ns}:{path}``` format.
|
|
@@ -78,7 +77,9 @@ class Bajo extends Plugin {
|
|
|
78
77
|
// by defaualt, only these config formats below are supported.
|
|
79
78
|
app.configHandlers = [
|
|
80
79
|
{ ns: 'bajo', ext: '.js', readHandler: this.fromJs },
|
|
81
|
-
{ ns: 'bajo', ext: '.json', readHandler: this.fromJson, writeHandler: this.toJson }
|
|
80
|
+
{ ns: 'bajo', ext: '.json', readHandler: this.fromJson, writeHandler: this.toJson },
|
|
81
|
+
{ ns: 'bajo', ext: '.yaml', readHandler: this.fromYaml, writeHandler: this.toYaml },
|
|
82
|
+
{ ns: 'bajo', ext: '.yml', readHandler: this.fromYml, writeHandler: this.toYml }
|
|
82
83
|
]
|
|
83
84
|
|
|
84
85
|
this.hooks = []
|
|
@@ -499,34 +500,6 @@ class Bajo extends Plugin {
|
|
|
499
500
|
return value
|
|
500
501
|
}
|
|
501
502
|
|
|
502
|
-
/**
|
|
503
|
-
* Get NPM global module directory.
|
|
504
|
-
*
|
|
505
|
-
* @method
|
|
506
|
-
* @param {string} [pkgName] - If provided, return this package global directory. Otherwise the npm global module directory.
|
|
507
|
-
* @param {boolean} [silent=true] - Set to ```false``` to throw exception in case of error. Otherwise silently returns undefined.
|
|
508
|
-
* @returns {string}
|
|
509
|
-
*/
|
|
510
|
-
getGlobalModuleDir = (pkgName, silent = true) => {
|
|
511
|
-
let nodeModulesDir = process.env.BAJO_GLOBAL_MODULE_DIR
|
|
512
|
-
if (!nodeModulesDir) {
|
|
513
|
-
const npmPath = getGlobalPath('npm')
|
|
514
|
-
if (!npmPath) {
|
|
515
|
-
if (silent) return
|
|
516
|
-
throw this.error('cantLocateNpmGlobalDir', { code: 'BAJO_CANT_LOCATE_NPM_GLOBAL_DIR' })
|
|
517
|
-
}
|
|
518
|
-
nodeModulesDir = dropRight(resolvePath(npmPath).split('/'), 1).join('/')
|
|
519
|
-
process.env.BAJO_GLOBAL_MODULE_DIR = nodeModulesDir
|
|
520
|
-
}
|
|
521
|
-
if (!pkgName) return nodeModulesDir
|
|
522
|
-
const dir = `${nodeModulesDir}/${pkgName}`
|
|
523
|
-
if (!fs.existsSync(dir)) {
|
|
524
|
-
if (silent) return
|
|
525
|
-
throw this.error('cantLocateGlobalDir%s', pkgName, { code: 'BAJO_CANT_LOCATE_MODULE_GLOBAL_DIR' })
|
|
526
|
-
}
|
|
527
|
-
return dir
|
|
528
|
-
}
|
|
529
|
-
|
|
530
503
|
/**
|
|
531
504
|
* Get class method by name.
|
|
532
505
|
*
|
|
@@ -543,22 +516,21 @@ class Bajo extends Plugin {
|
|
|
543
516
|
}
|
|
544
517
|
|
|
545
518
|
/**
|
|
546
|
-
* Get module directory
|
|
519
|
+
* Get module directory.
|
|
547
520
|
*
|
|
548
521
|
* @method
|
|
549
522
|
* @param {string} pkgName - Package name to find.
|
|
550
|
-
* @param {
|
|
523
|
+
* @param {boolean} [withGlobalDir=true] - Whether to include the global module directory.
|
|
551
524
|
* @returns {string} Return absolute package directory.
|
|
552
525
|
*/
|
|
553
|
-
getModuleDir = (pkgName, base) => {
|
|
526
|
+
getModuleDir = (pkgName, base, withGlobalDir = true) => {
|
|
554
527
|
const { findDeep } = this.app.lib
|
|
555
528
|
if (pkgName === 'main') return resolvePath(this.app.dir)
|
|
556
529
|
if (base === 'main') base = this.app.dir
|
|
557
530
|
else if (this && this.app && this.app[base]) base = this.app[base].pkgName
|
|
558
531
|
const pkgPath = pkgName + '/package.json'
|
|
559
532
|
const paths = require.resolve.paths(pkgPath)
|
|
560
|
-
|
|
561
|
-
paths.unshift(gdir)
|
|
533
|
+
if (withGlobalDir) paths.push(getGlobalModuleDir())
|
|
562
534
|
paths.unshift(resolvePath(path.join(this.app.dir, 'node_modules')))
|
|
563
535
|
let dir = findDeep(pkgPath, paths)
|
|
564
536
|
if (base && !dir) dir = findDeep(`${base}/node_modules/${pkgPath}`, paths)
|
|
@@ -643,21 +615,6 @@ class Bajo extends Plugin {
|
|
|
643
615
|
return values(result)
|
|
644
616
|
}
|
|
645
617
|
|
|
646
|
-
/**
|
|
647
|
-
* Check whether a directory is empty or not. More info please {@link https://github.com/gulpjs/empty-dir|check here}.
|
|
648
|
-
*
|
|
649
|
-
* @method
|
|
650
|
-
* @async
|
|
651
|
-
* @param {(string|TNsPathPairs)} dir - Directory to check.
|
|
652
|
-
* @param {function} filterFn - Filter function to filter out files that cause false positives.
|
|
653
|
-
* @returns {boolean}
|
|
654
|
-
*/
|
|
655
|
-
isEmptyDir = async (dir, filterFn) => {
|
|
656
|
-
dir = resolvePath(this.app.getPluginFile(dir))
|
|
657
|
-
await fs.exists(dir)
|
|
658
|
-
return await emptyDir(dir, filterFn)
|
|
659
|
-
}
|
|
660
|
-
|
|
661
618
|
/**
|
|
662
619
|
* Check whether log level is within log's app current level.
|
|
663
620
|
*
|
|
@@ -750,7 +707,7 @@ class Bajo extends Plugin {
|
|
|
750
707
|
}
|
|
751
708
|
|
|
752
709
|
/**
|
|
753
|
-
* Read and parse file as config object. Supported types: ```.js``` and ```.
|
|
710
|
+
* Read and parse file as config object. Supported types: ```.js```, ```.json``` and ```.yml/.yaml```.
|
|
754
711
|
* More supports can be added using plugin. {@link https://github.com/ardhi/bajo-config|bajo-config} gives you additional supports for ```.yml```, ```.yaml``` and ```.toml``` file.
|
|
755
712
|
*
|
|
756
713
|
* If file extension is ```.*```, it will be auto detected and parsed accordingly
|
|
@@ -845,7 +802,7 @@ class Bajo extends Plugin {
|
|
|
845
802
|
ext = ext.toLowerCase()
|
|
846
803
|
if (['.js', '.json'].includes(ext)) {
|
|
847
804
|
const item = find(this.app.configHandlers, { ext })
|
|
848
|
-
return await output(await item.readHandler.call(this.app[
|
|
805
|
+
return await output(await item.readHandler.call(this.app[ns], file, parserOpts))
|
|
849
806
|
}
|
|
850
807
|
if (!['', '.*'].includes(ext)) {
|
|
851
808
|
const item = find(this.app.configHandlers, { ext })
|
|
@@ -870,7 +827,8 @@ class Bajo extends Plugin {
|
|
|
870
827
|
if (!ignoreError) throw this.error('cantParse%s', f, { code: 'BAJO_CONFIG_NO_PARSER' })
|
|
871
828
|
continue
|
|
872
829
|
}
|
|
873
|
-
|
|
830
|
+
const _ns = ['.js', '.json'].includes(ext) ? ns : item.ns
|
|
831
|
+
config = await item.readHandler.call(this.app[_ns], f, parserOpts)
|
|
874
832
|
if (!isEmpty(config)) break
|
|
875
833
|
}
|
|
876
834
|
return await output(config)
|
|
@@ -924,6 +882,32 @@ class Bajo extends Plugin {
|
|
|
924
882
|
return JSON.parse(content)
|
|
925
883
|
}
|
|
926
884
|
|
|
885
|
+
/**
|
|
886
|
+
* Parse YAML text
|
|
887
|
+
*
|
|
888
|
+
* @method
|
|
889
|
+
* @param {string} text - Text to be parsed
|
|
890
|
+
* @param {object} options - Options object
|
|
891
|
+
* @returns {object} Parsed object
|
|
892
|
+
*/
|
|
893
|
+
fromYaml = (text, options = {}) => {
|
|
894
|
+
const { fs } = this.app.lib
|
|
895
|
+
const content = options.readFromFile ? fs.readFileSync(text, 'utf8') : text
|
|
896
|
+
return yaml.load(content)
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Parse YML text. Alias for fromYaml.
|
|
901
|
+
*
|
|
902
|
+
* @method
|
|
903
|
+
* @param {string} text - Text to be parsed
|
|
904
|
+
* @param {object} options - Options object
|
|
905
|
+
* @returns {object} Parsed object
|
|
906
|
+
*/
|
|
907
|
+
fromYml = (text, options = {}) => {
|
|
908
|
+
return this.fromYaml(text, options)
|
|
909
|
+
}
|
|
910
|
+
|
|
927
911
|
/**
|
|
928
912
|
* Convert data to JSON string.
|
|
929
913
|
*
|
|
@@ -943,6 +927,37 @@ class Bajo extends Plugin {
|
|
|
943
927
|
return content
|
|
944
928
|
}
|
|
945
929
|
|
|
930
|
+
/**
|
|
931
|
+
* Convert object to YAML string
|
|
932
|
+
*
|
|
933
|
+
* @method
|
|
934
|
+
* @param {object} object - Object to be converted
|
|
935
|
+
* @param {object} options - Options object
|
|
936
|
+
* @returns {string} YAML string
|
|
937
|
+
*/
|
|
938
|
+
toYaml = (object, options = {}) => {
|
|
939
|
+
const { omit } = this.app.lib._
|
|
940
|
+
const { fs } = this.app.lib
|
|
941
|
+
const content = yaml.dump(object, omit(options, ['writeToFile']))
|
|
942
|
+
if (options.writeToFile) {
|
|
943
|
+
fs.writeFileSync(options.saveAsFile, content, 'utf8')
|
|
944
|
+
return
|
|
945
|
+
}
|
|
946
|
+
return content
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Convert object to YML string. Alias for toYaml.
|
|
951
|
+
*
|
|
952
|
+
* @method
|
|
953
|
+
* @param {object} object - Object to be converted
|
|
954
|
+
* @param {object} options - Options object
|
|
955
|
+
* @returns {string} YML string
|
|
956
|
+
*/
|
|
957
|
+
toYml = (object, options = {}) => {
|
|
958
|
+
return this.toYaml(object, options)
|
|
959
|
+
}
|
|
960
|
+
|
|
946
961
|
/**
|
|
947
962
|
* Read all config files from path.
|
|
948
963
|
*
|
package/docs/App.html
CHANGED
|
@@ -16,9 +16,9 @@ console.log(this.args) // it should print: ['arg1', 'arg2']
|
|
|
16
16
|
// }
|
|
17
17
|
</code></pre></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Object</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line199">line 199</a></li></ul></dd></div><div class="details-item-container"><dt class="tag-see bold">See</dt><dd class="tag-see"><ul><li>module:Lib.parseArgsArgv</li></ul></dd></div></dl><h3 class="name has-anchor" id="baseClass"><span class="type-signature"></span>baseClass<span class="type-signature"></span></h3><div class="description"><p>All plugin's base class are saved here as key-value pairs with plugin name as its key. The special key <code>Base</code> && <code>Tools</code> is for <a href="Base.html">Base</a> & <a href="Tools.html">Tools</a> class so anytime you want to create your own plugin, just use something like this:</p><pre class="prettyprint source lang-javascript"><code>class MyPlugin extends this.app.baseClass.Base {
|
|
18
18
|
... your class
|
|
19
|
-
}</code></pre></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line150">line 150</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="boxen"><span class="type-signature"></span>boxen<span class="type-signature"></span></h3><div class="description"><p>Placeholder for boxen that will get imported from <code>bajoCli</code> later during boot process.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line224">line 224</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="configHandlers"><span class="type-signature"></span>configHandlers<span class="type-signature"> :Array.<<a href="global.html#TAppConfigHandler">TAppConfigHandler</a>></span></h3><div class="description"><p>Config handlers.</p><p>By default, there are two built-in handlers available: <code>.js</code> and <code>.
|
|
19
|
+
}</code></pre></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line150">line 150</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="boxen"><span class="type-signature"></span>boxen<span class="type-signature"></span></h3><div class="description"><p>Placeholder for boxen that will get imported from <code>bajoCli</code> later during boot process.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line224">line 224</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="configHandlers"><span class="type-signature"></span>configHandlers<span class="type-signature"> :Array.<<a href="global.html#TAppConfigHandler">TAppConfigHandler</a>></span></h3><div class="description"><p>Config handlers.</p><p>By default, there are two built-in handlers available: <code>.js</code>, <code>.json</code> and <code>.yml/.yaml</code>. Use plugins to add more, e.g <a href="https://github.com/ardhi/bajo-config">bajo-config</a> lets you to use <code>.toml</code>.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Array.<<a href="global.html#TAppConfigHandler">TAppConfigHandler</a>></span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line115">line 115</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="envVars"><span class="type-signature"></span>envVars<span class="type-signature"> :Object</span></h3><div class="description"><p>Environment variables. Support dotenv (<code>.env</code>) file too!</p><ul><li>Underscore (<code>_</code>) translates key to camel-cased one</li><li>Double underscores (<code>__</code>) breaks the key into object keys</li><li>While dot (<code>.</code>) is used as namespace separator. If no namespace found, it is saved under <code>_</code> key.</li></ul><p>Values are also parsed automatically using <a href="https://github.com/ladjs/dotenv-parse-variables">dotenv-parse-variables</a>.</p><p>Example:</p><ul><li><code>MY_KEY=secret</code> → <code>{ _: { myKey: 'secret' } }</code></li><li><code>MY_KEY__SUB_KEY=supersecret</code> → <code>{ _: { myKey: { subKey: 'supersecret' } } }</code></li><li><code>MY_NS.MY_NAME=John</code> → <code>{ myNs: { myName: 'John' } }</code></li></ul></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Object</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line219">line 219</a></li></ul></dd></div><div class="details-item-container"><dt class="tag-see bold">See</dt><dd class="tag-see"><ul><li>module:Lib.parseEnv</li></ul></dd></div></dl><h3 class="name has-anchor" id="lib"><span class="type-signature"></span>lib<span class="type-signature"> :TAppLib</span></h3><div class="description"><p>Gives you direct access to the most commonly used 3rd party library in a Bajo based app. No manual import necessary, always available, anywhere, anytime!</p><p>Example:</p><pre class="prettyprint source lang-javascript"><code>const { camelCase, kebabCase } = this.app.lib._
|
|
20
20
|
console.log(camelCase('Elit commodo sit et aliqua'))
|
|
21
|
-
</code></pre></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">TAppLib</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line129">line 129</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="log"><span class="type-signature"></span>log<span class="type-signature"> :<a href="Log.html">Log</a></span></h3><div class="description"><p>Instance of system log.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type"><a href="Log.html">Log</a></span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line138">line 138</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="options"><span class="type-signature"></span>options<span class="type-signature"> :Object</span></h3><div class="description"><p>Copy of provided options.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Object</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line58">line 58</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="pluginPkgs"><span class="type-signature"></span>pluginPkgs<span class="type-signature"> :Array</span></h3><div class="description"><p>Plugin's package names container. This is the list of plugins to load. It is read from <code>package.json</code> and <code>.plugins</code> file by default, but you can override it by providing <code>options.plugins</code> at constructor.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Array</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line96">line 96</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="runAt"><span class="type-signature"></span>runAt<span class="type-signature"> :Date</span></h3><div class="description"><p>Date/time when your app start.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Date</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line82">line 82</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="startPlugin"><span class="type-signature"></span>startPlugin<span class="type-signature"></span></h3><div class="description"><p>Start a plugin.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line577">line 577</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="stopPlugin"><span class="type-signature"></span>stopPlugin<span class="type-signature"></span></h3><div class="description"><p>Stop a plugin.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line587">line 587</a></li></ul></dd></div></dl><h3 class="name has-anchor" id=".this.envs"><span class="type-signature">(static, constant) </span>this.envs<span class="type-signature"> :<a href="global.html#TAppEnv">TAppEnv</a></span></h3><div class="description"><p>App environments.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type"><a href="global.html#TAppEnv">TAppEnv</a></span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line75">line 75</a></li></ul></dd></div></dl><h3 class="name has-anchor" id=".this.mainNs"><span class="type-signature">(static, constant) </span>this.mainNs<span class="type-signature"> :string</span></h3><div class="description"><p>Your main namespace. And yes, you suppose to NOT CHANGE this.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">string</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-default bold">Default Value</dt><dd class="tag-default"><ul><li data-skip-pre-process="true">'main'</li></ul></dd></div><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line67">line 67</a></li></ul></dd></div></dl><h2 id="methods" class="subsection-title has-anchor">Methods</h2><h3 class="name has-anchor" id="addPlugin"><span class="type-signature"></span>addPlugin<span class="signature">(plugin, baseClass<span class="signature-attributes">opt</span>)</span></h3><div class="description"><p>Add and save plugin and it's base class definition (if provided).</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>plugin</code></td><td class="type"><span class="param-type">TPlugin</span></td><td class="attributes"></td><td class="description last"><p>A valid bajo plugin.</p></td></tr><tr><td class="name"><code>baseClass</code></td><td class="type"><span class="param-type">Object</span></td><td class="attributes"><optional><br></td><td class="description last"><p>Base class definition.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line245">line 245</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="boot"><span class="type-signature">(async) </span>boot<span class="signature">()</span><span class="type-signature"> → {<a href="App.html">App</a>}</span></h3><div class="description"><p>Boot process:</p><ul><li>Parsing program arguments, options and environment values</li><li>Create <a href="Bajo.html">Bajo</a> instance & initialize it</li><li>Run in applet mode if <code>-a</code> or <code>--applet</code> is given</li></ul><p>After boot process is completed, event <code>bajo:afterBootCompleted</code> is emitted.</p><p>If app mode is <code>applet</code>, it runs your choosen applet instead.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line409">line 409</a></li></ul></dd></div></dl><div class="method-member-container flex w-100 overflow-auto mt-20"><strong>Fires:</strong><ul><li>bajo:afterBootCompleted</li></ul></div><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type"><a href="App.html">App</a></span></dd></dl></div><h3 class="name has-anchor" id="dump"><span class="type-signature"></span>dump<span class="signature">(…args)</span></h3><div class="description"><p>Dumping variable on screen. Like <code>console.log</code> with configurable options. Useful for quick debugging and testing. You can also use it to dump variables in production without worrying about performance because it is using Bajo's built-in cache to store the result of util's inspect, so it will only be processed once for each unique variable.</p><p>Any argument passed to this method will be displayed on screen. If the last argument is a boolean <code>true</code>, app will quit rightaway after dumping.</p><p>If you have <code>bajoCli</code> plugin installed, variables will be displayed in a nice box using <code>boxen</code> package. Otherwise, it will fallback to <code>console.log</code> with util's inspect result.</p><p>To have more control on how the variable is displayed, you can set options in Bajo's config under <code>dump</code> key. See <a href="Bajo.html#config">Bajo#config</a> for details.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>args</code></td><td class="type"><span class="param-type">any</span></td><td class="attributes"><repeatable><br></td><td class="description last"><p>Variables to dump.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line373">line 373</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="exit"><span class="type-signature"></span>exit<span class="signature">(signal<span class="signature-attributes">opt</span>)</span></h3><div class="description"><p>Terminate the app and back to console.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th>Default</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>signal</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"><optional><br></td><td class="default">SIGINT</td><td class="description last"><p>Signal to send.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line455">line 455</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="getAllNs"><span class="type-signature"></span>getAllNs<span class="signature">()</span><span class="type-signature"> → {Array.<string>}</span></h3><div class="description"><p>Get all loaded plugin namespaces.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line257">line 257</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Array.<string></span></dd></dl></div><h3 class="name has-anchor" id="getAllPlugins"><span class="type-signature"></span>getAllPlugins<span class="signature">()</span><span class="type-signature"> → {Array.<TPlugin>}</span></h3><div class="description"><p>Get all plugins loaded plugins.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line279">line 279</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Array.<TPlugin></span></dd></dl></div><h3 class="name has-anchor" id="getPlugin"><span class="type-signature"></span>getPlugin<span class="signature">(name, silent<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h3><div class="description"><p>Get plugin by its namespace.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>name</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"></td><td class="description last"><p>Plugin name/namespace or alias.</p></td></tr><tr><td class="name"><code>silent</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="description last"><p>If <code>true</code>, silently return undefined even on error.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line291">line 291</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><div class="param-desc"><p>Plugin object.</p></div><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Object</span></dd></dl></div><h3 class="name has-anchor" id="getPluginDataDir"><span class="type-signature"></span>getPluginDataDir<span class="signature">(name, ensureDir<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span></h3><div class="description"><p>Get plugin data directory</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th>Default</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>name</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"></td><td class="default"></td><td class="description last"><p>Plugin name (namespace) or alias.</p></td></tr><tr><td class="name"><code>ensureDir</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="default">true</td><td class="description last"><p>Set <code>true</code> (default) to ensure directory is existed.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line319">line 319</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">string</span></dd></dl></div><h3 class="name has-anchor" id="getPluginFile"><span class="type-signature"></span>getPluginFile<span class="signature">(file)</span><span class="type-signature"> → {string}</span></h3><div class="description"><p>Resolve file path from:</p><ul><li>local/absolute file</li><li>TNsPath (<code>myPlugin:/path/to/file.txt</code>)</li><li>file under node_modules, e.g. <code>myPlugin:node_modules/some-package/file.txt</code></li></ul></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>file</code></td><td class="type"><span class="param-type">string</span></td><td class="description last"><p>File path, see above for supported types.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line338">line 338</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><div class="param-desc"><p>Resolved file path.</p></div><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">string</span></dd></dl></div><h3 class="name has-anchor" id="getPlugins"><span class="type-signature"></span>getPlugins<span class="signature">(nss<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array.<TPlugin>}</span></h3><div class="description"><p>Get loaded plugins.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>nss</code></td><td class="type"><span class="param-type">Array.<string></span></td><td class="attributes"><optional><br></td><td class="description last"><p>Array of namespaces. If empty, it returns all loaded plugins.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line268">line 268</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Array.<TPlugin></span></dd></dl></div><h3 class="name has-anchor" id="loadIntl"><span class="type-signature"></span>loadIntl<span class="signature">(ns)</span></h3><div class="description"><p>Load internationalization & languages files for particular plugin.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>ns</code></td><td class="type"><span class="param-type">string</span></td><td class="description last"><p>Plugin name.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line466">line 466</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="t"><span class="type-signature"></span>t<span class="signature">(ns, text, …params)</span><span class="type-signature"> → {string}</span></h3><div class="description"><p>Translate text and interpolate with given <code>args</code>.</p><p>There is a shortcut to this method attached on all plugins. You'll normally call that shorcut instead of this method, because it is bound to plugin's name already</p><pre class="prettyprint source lang-javascript"><code>... within your main plugin
|
|
21
|
+
</code></pre></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">TAppLib</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line129">line 129</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="log"><span class="type-signature"></span>log<span class="type-signature"> :<a href="Log.html">Log</a></span></h3><div class="description"><p>Instance of system log.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type"><a href="Log.html">Log</a></span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line138">line 138</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="options"><span class="type-signature"></span>options<span class="type-signature"> :Object</span></h3><div class="description"><p>Copy of provided options.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Object</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line58">line 58</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="pluginPkgs"><span class="type-signature"></span>pluginPkgs<span class="type-signature"> :Array</span></h3><div class="description"><p>Plugin's package names container. This is the list of plugins to load. It is read from <code>package.json</code> and <code>.plugins</code> file by default, but you can override it by providing <code>options.plugins</code> at constructor.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Array</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line96">line 96</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="runAt"><span class="type-signature"></span>runAt<span class="type-signature"> :Date</span></h3><div class="description"><p>Date/time when your app start.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">Date</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line82">line 82</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="startPlugin"><span class="type-signature"></span>startPlugin<span class="type-signature"></span></h3><div class="description"><p>Start a plugin.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line580">line 580</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="stopPlugin"><span class="type-signature"></span>stopPlugin<span class="type-signature"></span></h3><div class="description"><p>Stop a plugin.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line590">line 590</a></li></ul></dd></div></dl><h3 class="name has-anchor" id=".this.envs"><span class="type-signature">(static, constant) </span>this.envs<span class="type-signature"> :<a href="global.html#TAppEnv">TAppEnv</a></span></h3><div class="description"><p>App environments.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type"><a href="global.html#TAppEnv">TAppEnv</a></span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line75">line 75</a></li></ul></dd></div></dl><h3 class="name has-anchor" id=".this.mainNs"><span class="type-signature">(static, constant) </span>this.mainNs<span class="type-signature"> :string</span></h3><div class="description"><p>Your main namespace. And yes, you suppose to NOT CHANGE this.</p></div><div class="member-item-container flex"><strong>Type:</strong><ul><li><span class="param-type">string</span></li></ul></div><dl class="details"><div class="details-item-container"><dt class="tag-default bold">Default Value</dt><dd class="tag-default"><ul><li data-skip-pre-process="true">'main'</li></ul></dd></div><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line67">line 67</a></li></ul></dd></div></dl><h2 id="methods" class="subsection-title has-anchor">Methods</h2><h3 class="name has-anchor" id="addPlugin"><span class="type-signature"></span>addPlugin<span class="signature">(plugin, baseClass<span class="signature-attributes">opt</span>)</span></h3><div class="description"><p>Add and save plugin and it's base class definition (if provided).</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>plugin</code></td><td class="type"><span class="param-type">TPlugin</span></td><td class="attributes"></td><td class="description last"><p>A valid bajo plugin.</p></td></tr><tr><td class="name"><code>baseClass</code></td><td class="type"><span class="param-type">Object</span></td><td class="attributes"><optional><br></td><td class="description last"><p>Base class definition.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line245">line 245</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="boot"><span class="type-signature">(async) </span>boot<span class="signature">()</span><span class="type-signature"> → {<a href="App.html">App</a>}</span></h3><div class="description"><p>Boot process:</p><ul><li>Parsing program arguments, options and environment values</li><li>Create <a href="Bajo.html">Bajo</a> instance & initialize it</li><li>Run in applet mode if <code>-a</code> or <code>--applet</code> is given</li></ul><p>After boot process is completed, event <code>bajo:afterBootCompleted</code> is emitted.</p><p>If app mode is <code>applet</code>, it runs your choosen applet instead.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line409">line 409</a></li></ul></dd></div></dl><div class="method-member-container flex w-100 overflow-auto mt-20"><strong>Fires:</strong><ul><li>bajo:afterBootCompleted</li></ul></div><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type"><a href="App.html">App</a></span></dd></dl></div><h3 class="name has-anchor" id="dump"><span class="type-signature"></span>dump<span class="signature">(…args)</span></h3><div class="description"><p>Dumping variable on screen. Like <code>console.log</code> with configurable options. Useful for quick debugging and testing. You can also use it to dump variables in production without worrying about performance because it is using Bajo's built-in cache to store the result of util's inspect, so it will only be processed once for each unique variable.</p><p>Any argument passed to this method will be displayed on screen. If the last argument is a boolean <code>true</code>, app will quit rightaway after dumping.</p><p>If you have <code>bajoCli</code> plugin installed, variables will be displayed in a nice box using <code>boxen</code> package. Otherwise, it will fallback to <code>console.log</code> with util's inspect result.</p><p>To have more control on how the variable is displayed, you can set options in Bajo's config under <code>dump</code> key. See <a href="Bajo.html#config">Bajo#config</a> for details.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>args</code></td><td class="type"><span class="param-type">any</span></td><td class="attributes"><repeatable><br></td><td class="description last"><p>Variables to dump.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line373">line 373</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="exit"><span class="type-signature"></span>exit<span class="signature">(signal<span class="signature-attributes">opt</span>)</span></h3><div class="description"><p>Terminate the app and back to console.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th>Default</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>signal</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"><optional><br></td><td class="default">SIGINT</td><td class="description last"><p>Signal to send.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line455">line 455</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="getAllNs"><span class="type-signature"></span>getAllNs<span class="signature">()</span><span class="type-signature"> → {Array.<string>}</span></h3><div class="description"><p>Get all loaded plugin namespaces.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line257">line 257</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Array.<string></span></dd></dl></div><h3 class="name has-anchor" id="getAllPlugins"><span class="type-signature"></span>getAllPlugins<span class="signature">()</span><span class="type-signature"> → {Array.<TPlugin>}</span></h3><div class="description"><p>Get all plugins loaded plugins.</p></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line279">line 279</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Array.<TPlugin></span></dd></dl></div><h3 class="name has-anchor" id="getConfigFormats"><span class="type-signature"></span>getConfigFormats<span class="signature">(noDot<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array.<string>}</span></h3><div class="description"><p>Helper method to list all supported config formats.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>noDot</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="description last"><p>If <code>true</code>, it will return the list without dot prefix.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line569">line 569</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Array.<string></span></dd></dl></div><h3 class="name has-anchor" id="getPlugin"><span class="type-signature"></span>getPlugin<span class="signature">(name, silent<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h3><div class="description"><p>Get plugin by its namespace.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>name</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"></td><td class="description last"><p>Plugin name/namespace or alias.</p></td></tr><tr><td class="name"><code>silent</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="description last"><p>If <code>true</code>, silently return undefined even on error.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line291">line 291</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><div class="param-desc"><p>Plugin object.</p></div><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Object</span></dd></dl></div><h3 class="name has-anchor" id="getPluginDataDir"><span class="type-signature"></span>getPluginDataDir<span class="signature">(name, ensureDir<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span></h3><div class="description"><p>Get plugin data directory</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th>Default</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>name</code></td><td class="type"><span class="param-type">string</span></td><td class="attributes"></td><td class="default"></td><td class="description last"><p>Plugin name (namespace) or alias.</p></td></tr><tr><td class="name"><code>ensureDir</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="default">true</td><td class="description last"><p>Set <code>true</code> (default) to ensure directory is existed.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line319">line 319</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">string</span></dd></dl></div><h3 class="name has-anchor" id="getPluginFile"><span class="type-signature"></span>getPluginFile<span class="signature">(file)</span><span class="type-signature"> → {string}</span></h3><div class="description"><p>Resolve file path from:</p><ul><li>local/absolute file</li><li>TNsPath (<code>myPlugin:/path/to/file.txt</code>)</li><li>file under node_modules, e.g. <code>myPlugin:node_modules/some-package/file.txt</code></li></ul></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>file</code></td><td class="type"><span class="param-type">string</span></td><td class="description last"><p>File path, see above for supported types.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line338">line 338</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><div class="param-desc"><p>Resolved file path.</p></div><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">string</span></dd></dl></div><h3 class="name has-anchor" id="getPlugins"><span class="type-signature"></span>getPlugins<span class="signature">(nss<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array.<TPlugin>}</span></h3><div class="description"><p>Get loaded plugins.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th>Attributes</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>nss</code></td><td class="type"><span class="param-type">Array.<string></span></td><td class="attributes"><optional><br></td><td class="description last"><p>Array of namespaces. If empty, it returns all loaded plugins.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line268">line 268</a></li></ul></dd></div></dl><div class="method-member-container mt-20"><strong>Returns:</strong><dl class="param-type"><dt>Type: </dt><dd><span class="param-type">Array.<TPlugin></span></dd></dl></div><h3 class="name has-anchor" id="loadIntl"><span class="type-signature"></span>loadIntl<span class="signature">(ns)</span></h3><div class="description"><p>Load internationalization & languages files for particular plugin.</p></div><div class="method-member-container flex flex-col w-100 overflow-auto mt-20"><strong>Parameters:</strong><table class="params"><thead><tr><th>Name</th><th>Type</th><th class="last">Description</th></tr></thead><tbody><tr><td class="name"><code>ns</code></td><td class="type"><span class="param-type">string</span></td><td class="description last"><p>Plugin name.</p></td></tr></tbody></table></div><dl class="details"><div class="details-item-container"><dt class="tag-source bold">Source</dt><dd class="tag-source"><ul><li><a href="class_app.js.html">class/app.js</a>, <a href="class_app.js.html#line466">line 466</a></li></ul></dd></div></dl><h3 class="name has-anchor" id="t"><span class="type-signature"></span>t<span class="signature">(ns, text, …params)</span><span class="type-signature"> → {string}</span></h3><div class="description"><p>Translate text and interpolate with given <code>args</code>.</p><p>There is a shortcut to this method attached on all plugins. You'll normally call that shorcut instead of this method, because it is bound to plugin's name already</p><pre class="prettyprint source lang-javascript"><code>... within your main plugin
|
|
22
22
|
const translated = this.app.t('main', 'My cute cat is %s', 'purring')
|
|
23
23
|
// or
|
|
24
24
|
const translated = this.t('My cute cat is %s', 'purring')
|