bajo 2.1.0 → 2.2.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/.github/FUNDING.yml +0 -0
- package/.github/workflows/repo-lockdown.yml +0 -0
- package/.jsdoc.conf.json +0 -0
- package/.mocharc.json +4 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/class/{misc → app}/log.js +8 -2
- package/class/app.js +63 -50
- package/class/bajo.js +43 -211
- package/class/base.js +25 -22
- package/class/helper/bajo.js +55 -53
- package/class/helper/base.js +34 -75
- package/class/{misc → plugin}/err.js +23 -18
- package/class/{misc → plugin}/print.js +7 -16
- package/class/plugin/tools.js +42 -0
- package/class/plugin.js +58 -54
- package/docs/App.html +0 -0
- package/docs/Bajo.html +0 -0
- package/docs/Base.html +0 -0
- package/docs/Err.html +0 -0
- package/docs/Log.html +0 -0
- package/docs/Plugin.html +0 -0
- package/docs/Print.html +0 -0
- package/docs/class_app.js.html +0 -0
- package/docs/class_bajo.js.html +0 -0
- package/docs/class_base.js.html +0 -0
- package/docs/class_helper_bajo.js.html +0 -0
- package/docs/class_helper_base.js.html +0 -0
- package/docs/class_misc_err.js.html +0 -0
- package/docs/class_misc_log.js.html +0 -0
- package/docs/class_misc_print.js.html +0 -0
- package/docs/class_plugin.js.html +0 -0
- package/docs/data/search.json +0 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +0 -0
- package/docs/index.html +0 -0
- package/docs/index.js.html +0 -0
- package/docs/lib_current-loc.js.html +0 -0
- package/docs/lib_formats.js.html +0 -0
- package/docs/lib_import-module.js.html +0 -0
- package/docs/lib_log-levels.js.html +0 -0
- package/docs/lib_parse-args-argv.js.html +0 -0
- package/docs/lib_parse-env.js.html +0 -0
- package/docs/lib_resolve-path.js.html +0 -0
- package/docs/lib_shim.js.html +0 -0
- package/docs/module-Helper_Bajo.html +0 -0
- package/docs/module-Helper_Base.html +0 -0
- package/docs/module-Lib.html +0 -0
- package/docs/scripts/core.js +476 -477
- package/docs/scripts/core.min.js +0 -0
- package/docs/scripts/resize.js +36 -36
- package/docs/scripts/search.js +105 -105
- package/docs/scripts/search.min.js +0 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
- package/docs/scripts/third-party/fuse.js +1 -1
- package/docs/scripts/third-party/hljs-line-num-original.js +282 -285
- package/docs/scripts/third-party/hljs-line-num.js +1 -1
- package/docs/scripts/third-party/hljs-original.js +1195 -1202
- package/docs/scripts/third-party/hljs.js +1 -1
- package/docs/scripts/third-party/popper.js +1 -1
- package/docs/scripts/third-party/tippy.js +1 -1
- package/docs/scripts/third-party/tocbot.js +508 -509
- package/docs/scripts/third-party/tocbot.min.js +0 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/static/home.md +0 -0
- package/docs/static/logo-ecosystem.png +0 -0
- package/docs/static/logo.png +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +0 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
- package/docs/styles/clean-jsdoc-theme-light.css +0 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
- package/docs/styles/clean-jsdoc-theme.min.css +0 -0
- package/extend/bajo/intl/en-US.json +10 -5
- package/extend/bajo/intl/id.json +10 -5
- package/extend/waibuStatic/virtual.json +0 -0
- package/index.js +9 -1
- package/lib/find-deep.js +24 -0
- package/lib/formats.js +0 -0
- package/lib/freeze.js +16 -0
- package/lib/import-module.js +5 -3
- package/lib/index.js +6 -0
- package/lib/log-levels.js +0 -0
- package/package.json +5 -11
- package/test/base.test.js +108 -0
- package/wiki/CHANGES.md +63 -0
- package/wiki/CONFIG.md +0 -0
- package/wiki/CONTRIBUTING.md +0 -0
- package/wiki/DEV_GUIDE.md +0 -0
- package/wiki/ECOSYSTEM.md +0 -0
- package/wiki/GETTING-STARTED.md +1 -1
- package/wiki/USER-GUIDE.md +0 -0
- package/lib/current-loc.js +0 -33
- package/lib/parse-args-argv.js +0 -80
- package/lib/parse-env.js +0 -50
- package/lib/resolve-path.js +0 -24
- package/lib/shim.js +0 -37
package/class/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import lodash from 'lodash'
|
|
2
|
-
import Err from './
|
|
2
|
+
import Err from './plugin/err.js'
|
|
3
3
|
|
|
4
4
|
const { get, isEmpty, cloneDeep, omit, isPlainObject, camelCase } = lodash
|
|
5
5
|
|
|
@@ -14,39 +14,36 @@ const { get, isEmpty, cloneDeep, omit, isPlainObject, camelCase } = lodash
|
|
|
14
14
|
* @class
|
|
15
15
|
*/
|
|
16
16
|
class Plugin {
|
|
17
|
-
/**
|
|
18
|
-
* Package name, the one from package.json
|
|
19
|
-
*
|
|
20
|
-
* @memberof Plugin
|
|
21
|
-
* @constant {string}
|
|
22
|
-
*/
|
|
23
|
-
static pkgName
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Namespace (ns) or plugin's name. Simply the camel cased version of plugin's package name
|
|
27
|
-
*
|
|
28
|
-
* @memberof Plugin
|
|
29
|
-
* @constant {string}
|
|
30
|
-
*/
|
|
31
|
-
static ns
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Plugin alias. Derived plugin must provide its own, unique alias. If it left blank,
|
|
35
|
-
* Bajo will provide this automatically (by using the kebab-cased version of plugin name)
|
|
36
|
-
*
|
|
37
|
-
* @readonly
|
|
38
|
-
* @memberof Plugin
|
|
39
|
-
* @type {string}
|
|
40
|
-
*/
|
|
41
|
-
static alias = ''
|
|
42
|
-
|
|
43
17
|
/**
|
|
44
18
|
* @param {string} pkgName - Package name (the one you use in package.json)
|
|
45
19
|
* @param {Object} app - App instance reference. Usefull to call app method inside a plugin
|
|
46
20
|
*/
|
|
47
21
|
constructor (pkgName, app) {
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Package name, the one from package.json
|
|
24
|
+
*
|
|
25
|
+
* @memberof Plugin
|
|
26
|
+
* @constant {string}
|
|
27
|
+
*/
|
|
28
|
+
this.pkgName = pkgName
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Namespace (ns) or plugin's name. Simply the camel cased version of plugin's package name
|
|
32
|
+
*
|
|
33
|
+
* @memberof Plugin
|
|
34
|
+
* @constant {string}
|
|
35
|
+
*/
|
|
36
|
+
this.ns = camelCase(pkgName)
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Plugin alias. Derived plugin must provide its own, unique alias. If it left blank,
|
|
40
|
+
* Bajo will provide this automatically (by using the kebab-cased version of plugin name)
|
|
41
|
+
*
|
|
42
|
+
* @readonly
|
|
43
|
+
* @memberof Plugin
|
|
44
|
+
* @type {string}
|
|
45
|
+
*/
|
|
46
|
+
this.alias = null
|
|
50
47
|
|
|
51
48
|
/**
|
|
52
49
|
* Reference to app instance
|
|
@@ -79,6 +76,21 @@ class Plugin {
|
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Get package info
|
|
81
|
+
*
|
|
82
|
+
* @method
|
|
83
|
+
* @param {string} [dir] - Package directory. Defaults to the current plugin's package dir
|
|
84
|
+
* @param {Array} [keys=['name', 'version', 'description', 'author', 'license', 'homepage', 'bajo']] - Field keys to be use. Set empty to use all keys.
|
|
85
|
+
*/
|
|
86
|
+
getPkgInfo = (dir, keys = ['name', 'version', 'description', 'author', 'license', 'homepage', 'bajo']) => {
|
|
87
|
+
const { pick, isEmpty } = this.app.lib._
|
|
88
|
+
const { fs } = this.app.lib
|
|
89
|
+
const file = `${dir ?? this.dir.pkg}/package.json`
|
|
90
|
+
const pkg = fs.readJsonSync(file)
|
|
91
|
+
return isEmpty(keys) ? pkg : pick(pkg, keys)
|
|
92
|
+
}
|
|
93
|
+
|
|
82
94
|
/**
|
|
83
95
|
* Get plugin's config value
|
|
84
96
|
*
|
|
@@ -127,43 +139,35 @@ class Plugin {
|
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
/**
|
|
130
|
-
*
|
|
142
|
+
* Translate text and interpolate with given ```args```.
|
|
131
143
|
*
|
|
132
|
-
* @
|
|
133
|
-
*/
|
|
134
|
-
get pkgName () {
|
|
135
|
-
return this.constructor.pkgName
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Getter for plugin's ns
|
|
144
|
+
* Shortcut to {@link App#t} with ns parameter set to this plugin namespace.
|
|
140
145
|
*
|
|
141
|
-
* @
|
|
146
|
+
* @param {string} text - Text to translate
|
|
147
|
+
* @param {...any} params - Variables to interpolate to ```text```
|
|
148
|
+
* @returns {string}
|
|
142
149
|
*/
|
|
143
|
-
|
|
144
|
-
return this.
|
|
150
|
+
t = (text, ...params) => {
|
|
151
|
+
return this.app.t(this.ns, text, ...params)
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
/**
|
|
148
|
-
*
|
|
155
|
+
* Force bind methods to self (```this```)
|
|
149
156
|
*
|
|
150
|
-
* @
|
|
157
|
+
* @param {string[]} names - Method's names
|
|
151
158
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
selfBind (names) {
|
|
160
|
+
for (const name of names) {
|
|
161
|
+
this[name] = this[name].bind(this)
|
|
162
|
+
}
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* Shortcut to {@link App#t} with ns parameter set to this plugin namespace.
|
|
160
|
-
*
|
|
161
|
-
* @param {string} text - Text to translate
|
|
162
|
-
* @param {...any} params - Variables to interpolate to ```text```
|
|
163
|
-
* @returns {string}
|
|
166
|
+
* Dispose internal references
|
|
164
167
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
dispose = () => {
|
|
169
|
+
this.app = null
|
|
170
|
+
this.config = null
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
173
|
|
package/docs/App.html
CHANGED
|
File without changes
|
package/docs/Bajo.html
CHANGED
|
File without changes
|
package/docs/Base.html
CHANGED
|
File without changes
|
package/docs/Err.html
CHANGED
|
File without changes
|
package/docs/Log.html
CHANGED
|
File without changes
|
package/docs/Plugin.html
CHANGED
|
File without changes
|
package/docs/Print.html
CHANGED
|
File without changes
|
package/docs/class_app.js.html
CHANGED
|
File without changes
|
package/docs/class_bajo.js.html
CHANGED
|
File without changes
|
package/docs/class_base.js.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/data/search.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/global.html
CHANGED
|
File without changes
|
package/docs/index.html
CHANGED
|
File without changes
|
package/docs/index.js.html
CHANGED
|
File without changes
|
|
File without changes
|
package/docs/lib_formats.js.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/lib_shim.js.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/docs/module-Lib.html
CHANGED
|
File without changes
|