bajo 1.2.9 → 2.0.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/.jsdoc.conf.json +6 -3
- package/README.md +8 -148
- package/class/app.js +113 -0
- package/{boot/class/bajo-core.js → class/bajo.js} +448 -35
- package/{boot/class/error.js → class/base/err.js} +29 -3
- package/class/base/log.js +205 -0
- package/class/base/plugin.js +177 -0
- package/class/base/print.js +272 -0
- package/class/helper/bajo.js +344 -0
- package/class/helper/plugin.js +169 -0
- package/{boot/class/bajo-plugin.js → class/plugin.js} +60 -3
- package/docs/App.html +3 -0
- package/docs/Bajo.html +15 -0
- package/docs/BasePlugin.html +5 -0
- package/docs/Err.html +3 -0
- package/docs/Log.html +3 -0
- package/docs/Plugin.html +3 -0
- package/docs/Print.html +3 -0
- package/docs/bitcoin.jpeg +0 -0
- package/docs/class_app.js.html +116 -0
- package/docs/class_bajo.js.html +1100 -0
- package/docs/class_base_err.js.html +99 -0
- package/docs/class_base_log.js.html +208 -0
- package/docs/class_base_plugin.js.html +180 -0
- package/docs/class_base_print.js.html +275 -0
- package/docs/class_helper_bajo.js.html +347 -0
- package/docs/class_helper_plugin.js.html +172 -0
- package/docs/class_plugin.js.html +121 -0
- package/docs/data/search.json +1 -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 +3 -0
- package/docs/index.html +3 -0
- package/docs/lib_create-method.js.html +42 -0
- package/docs/lib_formats.js.html +68 -0
- package/docs/lib_log-levels.js.html +28 -0
- package/docs/lib_resolve-path.js.html +30 -0
- package/docs/lib_shim.js.html +35 -0
- package/docs/module-class_helper_bajo.html +3 -0
- package/docs/module-class_helper_plugin.html +3 -0
- package/docs/module-lib_create-method.html +3 -0
- package/docs/module-lib_formats.html +3 -0
- package/docs/module-lib_log-levels.html +3 -0
- package/docs/module-lib_resolve-path.html +3 -0
- package/docs/module-lib_shim.html +3 -0
- package/docs/scripts/core.js +726 -0
- package/docs/scripts/core.min.js +23 -0
- package/docs/scripts/resize.js +90 -0
- package/docs/scripts/search.js +265 -0
- package/docs/scripts/search.min.js +6 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/scripts/third-party/fuse.js +9 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/scripts/third-party/hljs-original.js +5171 -0
- package/docs/scripts/third-party/hljs.js +1 -0
- package/docs/scripts/third-party/popper.js +5 -0
- package/docs/scripts/third-party/tippy.js +1 -0
- package/docs/scripts/third-party/tocbot.js +672 -0
- package/docs/scripts/third-party/tocbot.min.js +1 -0
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/tutorial-contribution.html +3 -0
- package/docs/tutorial-ecosystem.html +3 -0
- package/docs/tutorial-getting-started.html +13 -0
- package/docs/tutorial-plugin-dev.html +3 -0
- package/docs/tutorial-user-guide.html +3 -0
- package/lib/create-method.js +39 -0
- package/{boot/lib → lib}/formats.js +28 -0
- package/{boot/lib → lib}/log-levels.js +16 -0
- package/{boot/lib → lib}/parse-args-argv.js +1 -1
- package/{boot/lib → lib}/resolve-path.js +12 -0
- package/{boot/lib → lib}/shim.js +10 -0
- package/misc-docs/bitcoin.jpeg +0 -0
- package/misc-docs/contribution.md +20 -0
- package/{docs → misc-docs}/ecosystem.md +41 -12
- package/misc-docs/getting-started.md +142 -0
- package/misc-docs/plugin-dev.md +0 -0
- package/misc-docs/toc.json +17 -0
- package/misc-docs/user-guide.md +1 -0
- package/package.json +14 -13
- package/bajoBook/book/doc/.metadata.json +0 -28
- package/bajoBook/book/doc/How-to-Make-a-Paper-Boat-564x400@2x.jpg +0 -0
- package/bajoBook/book/doc/pages/guides/definition.md +0 -7
- package/bajoBook/book/doc/pages/guides/intro.md +0 -3
- package/bajoBook/book/doc/pages/guides/setup.md +0 -22
- package/bajoBook/book/reference/.metadata.json +0 -152
- package/bajoBook/book/reference/concept-leadership-business-with-paper-boats.jpg +0 -0
- package/bajoBook/book/reference/pages/configuration/configuration-file.md +0 -52
- package/bajoBook/book/reference/pages/helper/break-ns-path.md +0 -24
- package/bajoBook/book/reference/pages/helper/build-collections.md +0 -19
- package/bajoBook/book/reference/pages/helper/call-helper-or-handler.md +0 -35
- package/bajoBook/book/reference/pages/helper/current-loc.md +0 -28
- package/bajoBook/book/reference/pages/helper/dayjs.md +0 -13
- package/bajoBook/book/reference/pages/helper/defaults-deep.md +0 -29
- package/bajoBook/book/reference/pages/helper/dump.md +0 -32
- package/bajoBook/book/reference/pages/helper/each-plugins.md +0 -24
- package/bajoBook/book/reference/pages/helper/envs.md +0 -11
- package/bajoBook/book/reference/pages/helper/error.md +0 -29
- package/bajoBook/book/reference/pages/helper/fatal.md +0 -18
- package/bajoBook/book/reference/pages/helper/freeze.md +0 -13
- package/bajoBook/book/reference/pages/helper/generate-id.md +0 -36
- package/bajoBook/book/reference/pages/helper/get-config.md +0 -27
- package/bajoBook/book/reference/pages/helper/get-global-module-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-helper.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-item-by-name.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-key-by-value.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-module-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin-data-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin-name.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin.md +0 -13
- package/bajoBook/book/reference/pages/helper/import-module.md +0 -13
- package/bajoBook/book/reference/pages/helper/import-pkg.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-empty-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-log-in-range.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-set.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-valid-app.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-valid-plugin.md +0 -13
- package/bajoBook/book/reference/pages/helper/log-levels.md +0 -13
- package/bajoBook/book/reference/pages/helper/log.md +0 -13
- package/bajoBook/book/reference/pages/helper/paginate.md +0 -13
- package/bajoBook/book/reference/pages/helper/pascal-case.md +0 -13
- package/bajoBook/book/reference/pages/helper/print.md +0 -13
- package/bajoBook/book/reference/pages/helper/read-config.md +0 -13
- package/bajoBook/book/reference/pages/helper/read-json.md +0 -13
- package/bajoBook/book/reference/pages/helper/resolve-path.md +0 -13
- package/bajoBook/book/reference/pages/helper/resolve-tpl-path.md +0 -13
- package/bajoBook/book/reference/pages/helper/run-hook.md +0 -13
- package/bajoBook/book/reference/pages/helper/save-as-download.md +0 -13
- package/bajoBook/book/reference/pages/helper/titleize.md +0 -13
- package/bajoBook/book/reference/pages/helper/white-space.md +0 -13
- package/boot/class/app.js +0 -67
- package/boot/class/bajo-core/boot-order.js +0 -35
- package/boot/class/bajo-core/boot-plugins.js +0 -17
- package/boot/class/bajo-core/build-config.js +0 -86
- package/boot/class/bajo-core/build-plugins.js +0 -44
- package/boot/class/bajo-core/collect-config-handlers.js +0 -20
- package/boot/class/bajo-core/exit-handler.js +0 -53
- package/boot/class/bajo-core/run-as-applet.js +0 -26
- package/boot/class/bajo-plugin/attach-method.js +0 -14
- package/boot/class/bajo-plugin/build-config.js +0 -15
- package/boot/class/bajo-plugin/check-clash.js +0 -18
- package/boot/class/bajo-plugin/check-dependency.js +0 -39
- package/boot/class/bajo-plugin/collect-hooks.js +0 -31
- package/boot/class/bajo-plugin/run.js +0 -23
- package/boot/class/log.js +0 -96
- package/boot/class/plugin.js +0 -79
- package/boot/class/print.js +0 -153
- package/boot/lib/create-method.js +0 -33
- package/test/method/isSet.js +0 -43
- /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
- /package/{bajo → extend/bajo}/intl/id.json +0 -0
- /package/{waibuStatic → extend/waibuStatic}/virtual.json +0 -0
- /package/{boot/index.js → index.js} +0 -0
- /package/{boot/lib → lib}/current-loc.js +0 -0
- /package/{boot/lib → lib}/dayjs.js +0 -0
- /package/{boot/lib → lib}/import-module.js +0 -0
- /package/{boot/lib → lib}/omitted-plugin-keys.js +0 -0
- /package/{boot/lib → lib}/parse-env.js +0 -0
- /package/{boot/lib → lib}/read-all-configs.js +0 -0
- /package/{docs/hook.md → misc-docs/.hook.md} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Before we go any further, below are some terminologies I use throughout these documentations:
|
|
6
|
+
|
|
7
|
+
- ```<bajo-base-dir>```: project directory is where you write all your codes
|
|
8
|
+
- ```<bajo-data-dir>```: data directory, defaults to ```<bajo-base-dir>/data``` if not specifically stated
|
|
9
|
+
- ```<bajo-tmp-dir>```: temp directory, defaults to OS temporary directory
|
|
10
|
+
- ```<package>```: plugin package name as normally showed on npm listing
|
|
11
|
+
- ```<plugin>```: plugin name, which is camel cased version of package name
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Open your terminal and type:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ npm install bajo
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Fire up!
|
|
22
|
+
|
|
23
|
+
Create a new empty directory, this will be your project directory or your ```<bajo-base-dir>```. Now goto your newly created directory, and type:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
$ npm init
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You'll be asked to name your project etc. **IMPORTANT**: don't forget to mark your project as ES6 project by setting ```type``` key in your ```package.json``` to ```module```.
|
|
30
|
+
|
|
31
|
+
After completing those steps, move on the the next one: crating bajo bootstrap.
|
|
32
|
+
|
|
33
|
+
Inside your ```<bajo-base-dir>```, create the ```index.js``` file and put these lines below:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import bajo from 'bajo'
|
|
37
|
+
await bajo()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A bajo app **ALWAYS** needs a data directory to put configuration files, etc. This
|
|
41
|
+
could be located inside or outside your ```<bajo-base-dir>```.
|
|
42
|
+
|
|
43
|
+
Lets assume you're going to put your data directory inside your ```<bajo-base-dir>```. So please
|
|
44
|
+
create a new directory called ```data``` first. After that, just type in your terminal:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
$ node index.js --dir-data=data
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or you could utilize ```dotenv``` by creating ```.env``` file in the same directory as ```index.js```, and put this inside:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
DIR_DATA = ./data
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Now you can omit calling node with arguments, you just need to type:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
$ node index.js
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
### General rules
|
|
65
|
+
|
|
66
|
+
- All configuration files must be placed in ```<bajo-data-dir>/config/``` subfolder
|
|
67
|
+
- Config files should be named after its plugin name
|
|
68
|
+
- File format should be in ```.json``` or ```.js``` format
|
|
69
|
+
- If ```.js``` file is used, it should be in ES6 format and should export either plain javascript object or a function (sync or async both supported)
|
|
70
|
+
- If it returns a function, this function will be called within its plugin scope and should return a plain js object
|
|
71
|
+
- Other formats (```.yml```, ```.yaml``` and ```.toml```) can also be used by installing [bajoConfig](https://github.com/ardhi/bajo-config) plugin
|
|
72
|
+
- Order of importance: ```.js``` > ```.json``` > ```.yml``` > ```.yaml``` > ```.toml```
|
|
73
|
+
|
|
74
|
+
### Main configuration File
|
|
75
|
+
|
|
76
|
+
It should be named ```bajo.json``` with following keys:
|
|
77
|
+
|
|
78
|
+
| Key | Type | Required | Default | Description |
|
|
79
|
+
| --- | ---- | -------- | ------- | ----------- |
|
|
80
|
+
| ```env``` | ```string``` | no | ```dev``` | App environment: ```dev``` or ```prod``` |
|
|
81
|
+
| ```log``` | ```object``` | no || Logger setting |
|
|
82
|
+
| ```dateFormat``` | ```string``` | no | ```YYYY-MM-DDTHH:MM:ss.SSS[Z]```| Date format accoding to [dayjs](https://github.com/iamkun/dayjs) |
|
|
83
|
+
| ```applet``` | ```boolean``` | no | ```false``` | Set to ```true``` if you want to show log even in [applet mode](#applet-mode) |
|
|
84
|
+
| ```level``` | ```string``` | no || Set one of these: ```trace```, ```debug```, ```info```, ```warn```, ```error```, ```fatal``` and ```silent```. If it isn't set, it will auto selected based on environment |
|
|
85
|
+
| ```lang``` | ```string``` | no || Language to use. If not set, it will be auto detected |
|
|
86
|
+
| ```exitHandler``` | ```boolean``` | no | ```true``` | Set to ```false``` if you want your app **NOT** to exit gracefully |
|
|
87
|
+
|
|
88
|
+
### Installed Plugins
|
|
89
|
+
|
|
90
|
+
Plugins are what make Bajo Framework so great and flexible: they extends app features!
|
|
91
|
+
|
|
92
|
+
To use plugins:
|
|
93
|
+
|
|
94
|
+
1. Install with ```npm install <package>```
|
|
95
|
+
2. Optionally create ```<bajo-data-dir>/config/<plugin>.json``` to customize plugin settings
|
|
96
|
+
3. Open/create ```<bajo-data-dir>/config/.plugins``` and put ```<package>``` in it, line by line
|
|
97
|
+
|
|
98
|
+
Example below will load ```bajoConfig```, ```bajoExtra``` and ```bajoTemplate```:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
bajo-config
|
|
102
|
+
bajo-extra
|
|
103
|
+
bajo-template
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If you later decide to NOT load one or more plugins from your app, you just need to remove those from ```.plugins``` file or put ```#``` hash mark in front of package name and restart your app.
|
|
107
|
+
|
|
108
|
+
> **Warning**: please do not confuse between ```<package>``` and ```<plugin>```. Plugin package is the name of JS package listed on npm, while plugin name is the name of a plugin - a camel cased version of plugin package
|
|
109
|
+
|
|
110
|
+
### Configuration Overrides
|
|
111
|
+
|
|
112
|
+
You can override ANY settings on ANY configuration files with dotenv variables and program's argument switches easily.
|
|
113
|
+
|
|
114
|
+
Order of importance: dotenv variable > args switches > config files
|
|
115
|
+
|
|
116
|
+
#### dotenv
|
|
117
|
+
|
|
118
|
+
- Create/open ```<bajo-base-dir>/.env```
|
|
119
|
+
- Use ```__``` (double underscores) as the replacement of the dot in object
|
|
120
|
+
- ```DIR__DATA```: Set ```<bajo-data-dir>``` data directory
|
|
121
|
+
- ```DIR__TMP```: Set ```<bajo-tmp-dir>``` temp directory
|
|
122
|
+
- For every key in ```bajo.json```, use its snake cased, upper cased version, e.g:
|
|
123
|
+
- ```env``` => ```ENV```
|
|
124
|
+
- ```log.dateFormat``` => ```LOG__DATE_FORMAT```
|
|
125
|
+
- ```exitHandler``` => ```EXIT_HANDLER```
|
|
126
|
+
- To override plugins config, prepend every key in plugin config with snake cased, upper cased version of the plugin name followed by a dot, e.g:
|
|
127
|
+
- ```key``` in ```myPlugin``` => ```MY_PLUGIN.KEY```
|
|
128
|
+
- ```key.subKey.subSubKey``` in ```myPlugin``` => ```MY_PLUGIN.KEY__SUB_KEY__SUB_SUB_KEY```
|
|
129
|
+
|
|
130
|
+
#### Program argument switches
|
|
131
|
+
- Use switches, e.g: ```node index.js --xxx=one --yyy=two```
|
|
132
|
+
- Every switches must be prefixed with ```--```
|
|
133
|
+
- Use ```-``` as the replacement of the dot in object
|
|
134
|
+
- ```--dir-data```: Set ```<bajo-data-dir>``` data directory
|
|
135
|
+
- ```--dir-tmp```: Set ```<bajo-tmp-dir>``` temp directory
|
|
136
|
+
- For every key in ```bajo.json```, add prefix ```--``` e.g:
|
|
137
|
+
- ```env``` => ```--env=prod```
|
|
138
|
+
- ```log.dateFormat``` => ```--log-dateFormat=xxx```
|
|
139
|
+
- ```exitHandler``` => ```--exitHandler```
|
|
140
|
+
- To override plugins config, prepend every key in plugin config with the plugin name followed by a ```:```, e.g:
|
|
141
|
+
- ```key``` in ```myPlugin``` => ```--myPlugin:key```
|
|
142
|
+
- ```key.subKey.subSubKey``` in ```myPlugin``` => ```--myPlugin:key-subKey-subSubKey```
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"getting-started": {
|
|
3
|
+
"title": "Getting Started"
|
|
4
|
+
},
|
|
5
|
+
"user-guide": {
|
|
6
|
+
"title": "User Guide"
|
|
7
|
+
},
|
|
8
|
+
"plugin-dev": {
|
|
9
|
+
"title": "Plugin Development"
|
|
10
|
+
},
|
|
11
|
+
"ecosystem": {
|
|
12
|
+
"title": "Ecosystem"
|
|
13
|
+
},
|
|
14
|
+
"contribution": {
|
|
15
|
+
"title": "Contribution"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# User Guide
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bajo",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A framework to build a giant monstrous app rapidly",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build-doc": "jsdoc -c .jsdoc.conf.json",
|
|
8
8
|
"test": "mocha"
|
|
@@ -27,31 +27,32 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"add-filename-increment": "^1.0.0",
|
|
29
29
|
"aneka": "^0.1.4",
|
|
30
|
-
"chalk": "^5.
|
|
30
|
+
"chalk": "^5.6.0",
|
|
31
31
|
"dayjs": "^1.11.13",
|
|
32
32
|
"deep-freeze-strict": "^1.1.1",
|
|
33
33
|
"delay": "^6.0.0",
|
|
34
|
-
"dotenv": "^
|
|
34
|
+
"dotenv": "^17.2.1",
|
|
35
35
|
"dotenv-parse-variables": "^2.0.0",
|
|
36
36
|
"empty-dir": "^3.0.0",
|
|
37
37
|
"fast-glob": "^3.3.3",
|
|
38
38
|
"flat": "^6.0.1",
|
|
39
|
-
"fs-extra": "^11.
|
|
39
|
+
"fs-extra": "^11.3.1",
|
|
40
40
|
"get-global-path": "^0.0.1",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"ms": "^2.1.3",
|
|
43
|
-
"nanoid": "^5.
|
|
43
|
+
"nanoid": "^5.1.5",
|
|
44
44
|
"omit-deep": "^0.3.0",
|
|
45
|
-
"ora": "^8.
|
|
45
|
+
"ora": "^8.2.0",
|
|
46
46
|
"outmatch": "^1.0.0",
|
|
47
|
-
"semver": "^7.
|
|
47
|
+
"semver": "^7.7.2",
|
|
48
48
|
"sprintf-js": "^1.1.3",
|
|
49
|
-
"yargs": "^
|
|
49
|
+
"yargs": "^18.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@faker-js/faker": "^
|
|
53
|
-
"chai": "^
|
|
54
|
-
"clean-jsdoc-theme": "^4.
|
|
55
|
-
"
|
|
52
|
+
"@faker-js/faker": "^9.9.0",
|
|
53
|
+
"chai": "^6.0.0",
|
|
54
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
55
|
+
"docdash": "^2.0.2",
|
|
56
|
+
"sinon": "^21.0.0"
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"book": {
|
|
3
|
-
"title": "Bajo Framework - User Guides",
|
|
4
|
-
"description": "Getting started for new user, the basics and advanced topics",
|
|
5
|
-
"author": "Ardhi Lukianto <ardhi@lukianto.com>",
|
|
6
|
-
"meta": {
|
|
7
|
-
"externalLink": {
|
|
8
|
-
"Github": "https://github.com/ardhi/bajo",
|
|
9
|
-
"NPM": "https://www.npmjs.com/package/bajo"
|
|
10
|
-
},
|
|
11
|
-
"coverImage": "How-to-Make-a-Paper-Boat-564x400@2x.jpg"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"pages": {
|
|
15
|
-
"guides": {
|
|
16
|
-
"level": "1"
|
|
17
|
-
},
|
|
18
|
-
"guides/definition": {
|
|
19
|
-
"level": "1.1"
|
|
20
|
-
},
|
|
21
|
-
"guides/intro": {
|
|
22
|
-
"level": "1.2"
|
|
23
|
-
},
|
|
24
|
-
"guides/setup": {
|
|
25
|
-
"level": "1.3"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
Binary file
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Instalation & Setup
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Installation is quite straight forward; in your app project directory, enter following command:
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
$ npm install bajo-book
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Then in your data directory, find ```config``` folder and add the package in ```bajo.json``` file:
|
|
12
|
-
|
|
13
|
-
```json
|
|
14
|
-
{
|
|
15
|
-
"log": {
|
|
16
|
-
"level": "debug"
|
|
17
|
-
},
|
|
18
|
-
"plugins": ["bajo-db", "bajo-web", "bajo-web-mpa", "bajo-web-static", "bajo-book"]
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
After app restart, all books found in plugins will be rebuilt and displayed as web pages in ```/book``` mountpoint (or any prefix you've put in ```bajoBook.json```)
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"book": {
|
|
3
|
-
"title": "Bajo Framework - Reference",
|
|
4
|
-
"description": "Framework reference, API and developer related documentation",
|
|
5
|
-
"author": "Ardhi Lukianto <ardhi@lukianto.com>",
|
|
6
|
-
"meta": {
|
|
7
|
-
"externalLink": {
|
|
8
|
-
"Github": "https://github.com/ardhi/bajo",
|
|
9
|
-
"NPM": "https://www.npmjs.com/package/bajo"
|
|
10
|
-
},
|
|
11
|
-
"coverImage": "concept-leadership-business-with-paper-boats.jpg",
|
|
12
|
-
"coverImageAttr": "<a href=\"https://www.freepik.com/free-photo/concept-leadership-business-with-paper-boats_40312961.htm#page=2&query=paper%20boat&position=45&from_view=search&track=ais\">Image by atlascompany</a> on Freepik"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"pages": {
|
|
16
|
-
"configuration": {
|
|
17
|
-
"level": "1"
|
|
18
|
-
},
|
|
19
|
-
"configuration/configuration-file": {
|
|
20
|
-
"level": "1.1"
|
|
21
|
-
},
|
|
22
|
-
"helper": {
|
|
23
|
-
"level": "2"
|
|
24
|
-
},
|
|
25
|
-
"helper/break-ns-path": {
|
|
26
|
-
"level": "2.1"
|
|
27
|
-
},
|
|
28
|
-
"helper/build-collections": {
|
|
29
|
-
"level": "2.2"
|
|
30
|
-
},
|
|
31
|
-
"helper/call-helper-or-handler": {
|
|
32
|
-
"level": "2.3"
|
|
33
|
-
},
|
|
34
|
-
"helper/current-loc": {
|
|
35
|
-
"level": "2.4"
|
|
36
|
-
},
|
|
37
|
-
"helper/dayjs": {
|
|
38
|
-
"level": "2.5"
|
|
39
|
-
},
|
|
40
|
-
"helper/defaults-deep": {
|
|
41
|
-
"level": "2.6"
|
|
42
|
-
},
|
|
43
|
-
"helper/dump": {
|
|
44
|
-
"level": "2.7"
|
|
45
|
-
},
|
|
46
|
-
"helper/each-plugins": {
|
|
47
|
-
"level": "2.8"
|
|
48
|
-
},
|
|
49
|
-
"helper/envs": {
|
|
50
|
-
"level": "2.9"
|
|
51
|
-
},
|
|
52
|
-
"helper/error": {
|
|
53
|
-
"level": "2.10"
|
|
54
|
-
},
|
|
55
|
-
"helper/fatal": {
|
|
56
|
-
"level": "2.11"
|
|
57
|
-
},
|
|
58
|
-
"helper/freeze": {
|
|
59
|
-
"level": "2.12"
|
|
60
|
-
},
|
|
61
|
-
"helper/generate-id": {
|
|
62
|
-
"level": "2.13"
|
|
63
|
-
},
|
|
64
|
-
"helper/get-config": {
|
|
65
|
-
"level": "2.14"
|
|
66
|
-
},
|
|
67
|
-
"helper/get-global-module-dir": {
|
|
68
|
-
"level": "2.15"
|
|
69
|
-
},
|
|
70
|
-
"helper/get-helper": {
|
|
71
|
-
"level": "2.16"
|
|
72
|
-
},
|
|
73
|
-
"helper/get-item-by-name": {
|
|
74
|
-
"level": "2.17"
|
|
75
|
-
},
|
|
76
|
-
"helper/get-key-by-value": {
|
|
77
|
-
"level": "2.18"
|
|
78
|
-
},
|
|
79
|
-
"helper/get-module-dir": {
|
|
80
|
-
"level": "2.19"
|
|
81
|
-
},
|
|
82
|
-
"helper/get-plugin": {
|
|
83
|
-
"level": "2.20"
|
|
84
|
-
},
|
|
85
|
-
"helper/get-plugin-data-dir": {
|
|
86
|
-
"level": "2.21"
|
|
87
|
-
},
|
|
88
|
-
"helper/get-plugin-name": {
|
|
89
|
-
"level": "2.22"
|
|
90
|
-
},
|
|
91
|
-
"helper/import-module": {
|
|
92
|
-
"level": "2.23"
|
|
93
|
-
},
|
|
94
|
-
"helper/import-pkg": {
|
|
95
|
-
"level": "2.24"
|
|
96
|
-
},
|
|
97
|
-
"helper/is-empty-dir": {
|
|
98
|
-
"level": "2.25"
|
|
99
|
-
},
|
|
100
|
-
"helper/is-log-in-range": {
|
|
101
|
-
"level": "2.26"
|
|
102
|
-
},
|
|
103
|
-
"helper/is-set": {
|
|
104
|
-
"level": "2.27"
|
|
105
|
-
},
|
|
106
|
-
"helper/is-valid-app": {
|
|
107
|
-
"level": "2.28"
|
|
108
|
-
},
|
|
109
|
-
"helper/is-valid-plugin": {
|
|
110
|
-
"level": "2.29"
|
|
111
|
-
},
|
|
112
|
-
"helper/log": {
|
|
113
|
-
"level": "2.30"
|
|
114
|
-
},
|
|
115
|
-
"helper/log-levels": {
|
|
116
|
-
"level": "2.31"
|
|
117
|
-
},
|
|
118
|
-
"helper/paginate": {
|
|
119
|
-
"level": "2.32"
|
|
120
|
-
},
|
|
121
|
-
"helper/pascal-case": {
|
|
122
|
-
"level": "2.33"
|
|
123
|
-
},
|
|
124
|
-
"helper/print": {
|
|
125
|
-
"level": "2.34"
|
|
126
|
-
},
|
|
127
|
-
"helper/read-config": {
|
|
128
|
-
"level": "2.35"
|
|
129
|
-
},
|
|
130
|
-
"helper/read-json": {
|
|
131
|
-
"level": "2.36"
|
|
132
|
-
},
|
|
133
|
-
"helper/resolve-path": {
|
|
134
|
-
"level": "2.37"
|
|
135
|
-
},
|
|
136
|
-
"helper/resolve-tpl-path": {
|
|
137
|
-
"level": "2.38"
|
|
138
|
-
},
|
|
139
|
-
"helper/run-hook": {
|
|
140
|
-
"level": "2.39"
|
|
141
|
-
},
|
|
142
|
-
"helper/save-as-download": {
|
|
143
|
-
"level": "2.40"
|
|
144
|
-
},
|
|
145
|
-
"helper/titleize": {
|
|
146
|
-
"level": "2.41"
|
|
147
|
-
},
|
|
148
|
-
"helper/white-space": {
|
|
149
|
-
"level": "2.42"
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
Binary file
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
Configuration file should be placed inside app data directory: ```<data dir>/config/bajo.json```. Supported format: **.json** and **.js** file. If you use ```bajo-config```, you can also write config
|
|
2
|
-
file in YAML or TOML format. But we recommend to stick with good old JSON file.
|
|
3
|
-
|
|
4
|
-
The following table lists all keys used to control running app:
|
|
5
|
-
|
|
6
|
-
| Key | Type | Default | Description |
|
|
7
|
-
| --- | ---- | ------- | ----------- |
|
|
8
|
-
| ```dir``` | object |||
|
|
9
|
-
| ```base``` | string | _Autodetect_ | Your app base directory. _Readonly_ |
|
|
10
|
-
| ```pkg``` | string | _Autodetect_ | **bajo** package directory. _Readonly_ |
|
|
11
|
-
| ```data``` | string | ```data``` sub directory under ```dir.base``` | Your data directory. Can be anywhere in your file system |
|
|
12
|
-
| ```tmp``` | string | Sub directory ```bajo``` in your default OS temp directory | Temp directory. Can be anywhere in your file system |
|
|
13
|
-
| ```log``` | object |||
|
|
14
|
-
| ```level``` | string | ```debug``` | Log level. Choices: **trace**, **debug**, **info**, **warn**, **error**, **fatal**, **silent** |
|
|
15
|
-
| ```dateFormat``` | string | ```YYYY-MM-DDTHH:MM:ss.SSS[Z]``` | Using Pino format |
|
|
16
|
-
| ```tool``` | boolean | ```false``` | If _true_ log will still be shown even when app is running in **sidetool** mode |
|
|
17
|
-
| ```lang``` | string | ```en-US``` | Language used |
|
|
18
|
-
| ```env``` | string | ```dev``` | Running environment: **prod** for production, **dev** for development |
|
|
19
|
-
| ```plugins``` | array | ```['app']``` | List of plugins used by your app |
|
|
20
|
-
| ```exitHandler``` | boolean | ```true``` | If _true_, error will be handled automatically |
|
|
21
|
-
|
|
22
|
-
#### Example
|
|
23
|
-
|
|
24
|
-
Using JSON file:
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"dir": {
|
|
29
|
-
"data": "/home/me/app/data"
|
|
30
|
-
},
|
|
31
|
-
"log": {
|
|
32
|
-
"level": "trace"
|
|
33
|
-
},
|
|
34
|
-
"lang": "id"
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Using JS file:
|
|
39
|
-
|
|
40
|
-
```javascript
|
|
41
|
-
async function () {
|
|
42
|
-
return {
|
|
43
|
-
dir: {
|
|
44
|
-
data: '/home/me/app/data'
|
|
45
|
-
},
|
|
46
|
-
log: {
|
|
47
|
-
level: 'trace'
|
|
48
|
-
},
|
|
49
|
-
lang: 'id'
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
```
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: function breakNsPath()
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Bajo uses this common format ```<ns>:<path>``` everywhere to describe a path (variable, function name, etc) belongs to what namespace/plugin. This function helps you to get the right **ns** and **path** pair by validating named namespace.
|
|
6
|
-
|
|
7
|
-
###### Parameters:
|
|
8
|
-
|
|
9
|
-
| Name | Type | Default Value | Description |
|
|
10
|
-
| ---- | ---- | ------------- | ----------- |
|
|
11
|
-
| ```item``` | string | ```''``` | ```<ns>:<path>``` pair |
|
|
12
|
-
|
|
13
|
-
###### Returns:
|
|
14
|
-
|
|
15
|
-
```array``` of **ns** and **path**
|
|
16
|
-
|
|
17
|
-
#### Example
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
...
|
|
21
|
-
const { breakNsPath } = this.bajo.helper
|
|
22
|
-
console.log(breakNsPath('bajoWeb:/my/path'))
|
|
23
|
-
// ['bajoWeb', '/my/path']
|
|
24
|
-
```
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: async function buildCollections()
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
A function helper to collect and format data from a plugin's config entries.
|
|
6
|
-
|
|
7
|
-
###### Parameters:
|
|
8
|
-
|
|
9
|
-
| Name | Type | Default Value | Description |
|
|
10
|
-
| ---- | ---- | ------------- | ----------- |
|
|
11
|
-
| ```options``` | object | ```{}``` ||
|
|
12
|
-
| ```plugin``` | string | _Autodetect_ | Plugin name from which collections are gathered |
|
|
13
|
-
| ```handler``` | function || Extraction function handler. _Required_ |
|
|
14
|
-
| ```dupChecks``` | array | ```[]``` | Array of keys to check for duplications. If none is provided, ignore duplication checks |
|
|
15
|
-
| ```container``` | string | ```connections``` | Plugin's config key used as container |
|
|
16
|
-
|
|
17
|
-
###### Returns:
|
|
18
|
-
|
|
19
|
-
```array```
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: async function callHelperOrHandler()
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Helper that call a function based on 1st parameter supplied:
|
|
6
|
-
|
|
7
|
-
- if it a function (handler), than it will be call it right away.
|
|
8
|
-
- if it a string and a valid helper name, it will call its underlaying function.
|
|
9
|
-
|
|
10
|
-
Any other parameters will be passed through as its arguments
|
|
11
|
-
|
|
12
|
-
###### Parameters:
|
|
13
|
-
|
|
14
|
-
| Name | Type | Default Value | Description |
|
|
15
|
-
| ---- | ---- | ------------- | ----------- |
|
|
16
|
-
| ```nameOrFn``` | string or function || see above |
|
|
17
|
-
| ```...args``` | ```any``` || rest parameter |
|
|
18
|
-
|
|
19
|
-
###### Returns:
|
|
20
|
-
|
|
21
|
-
```any```
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#### Example
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
...
|
|
28
|
-
const { callHelperOrHandler } = this.bajo.helper
|
|
29
|
-
|
|
30
|
-
const add = (a, b) => a + b
|
|
31
|
-
const newId = 'bajo:generateId'
|
|
32
|
-
|
|
33
|
-
console.log(await callHelperOrHandler(add, 5, 6)) // returns: 11
|
|
34
|
-
console.log(await callHelperOrHandler(newId)) // returns: '<generated id>'
|
|
35
|
-
```
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: function currentLoc()
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
In ES 6, there is no *__dirname* nor *__filename*. This helper simply provides a simple way to get what you want
|
|
6
|
-
|
|
7
|
-
###### Parameters:
|
|
8
|
-
|
|
9
|
-
| Name | Type | Default Value | Description |
|
|
10
|
-
| ---- | ---- | ------------- | ----------- |
|
|
11
|
-
| ```meta``` ||| imported meta |
|
|
12
|
-
|
|
13
|
-
###### Returns:
|
|
14
|
-
|
|
15
|
-
```object``` of
|
|
16
|
-
- ```dir```: current script directory
|
|
17
|
-
- ```file```: current script file
|
|
18
|
-
- ```__dirname```: alias of ```dir```
|
|
19
|
-
- ```__filename```: alias of ```file```
|
|
20
|
-
|
|
21
|
-
#### Example
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
...
|
|
25
|
-
const { currentLoc } = this.bajo.helper
|
|
26
|
-
const { dir, file } = currentLoc(import.meta)
|
|
27
|
-
console.log(dir) // prints: '/home/me/apps/current/dir'
|
|
28
|
-
```
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: function defaultsDeep()
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Similar to lodash's [defaultsDeep](https://lodash.com/docs/4.17.15#defaultsDeep), but without mutating the source object, and no merging of arrays.
|
|
6
|
-
|
|
7
|
-
Based on [@nodeutils/defaults-deep](https://github.com/nodeutils/defaults-deep), customized to work
|
|
8
|
-
in Bajo environment
|
|
9
|
-
|
|
10
|
-
###### Parameters:
|
|
11
|
-
|
|
12
|
-
| Name | Type | Default Value | Description |
|
|
13
|
-
| ---- | ---- | ------------- | ----------- |
|
|
14
|
-
| ```...args``` | ...object || rest parameter of objects |
|
|
15
|
-
|
|
16
|
-
###### Returns:
|
|
17
|
-
|
|
18
|
-
```object``` of merged argument's objects
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#### Example
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
...
|
|
25
|
-
const { defaultsDeep } = this.bajo.helper
|
|
26
|
-
const a = { one: 1, two: 2 }
|
|
27
|
-
const b = { one: 'one', three: 'three' }
|
|
28
|
-
console.log(defaultsDeep(b, a)) // returns: { one: 'one', two: 2, three: 'three' }
|
|
29
|
-
```
|