bajo 2.0.1 → 2.0.2

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.
Files changed (101) hide show
  1. package/.github/FUNDING.yml +13 -0
  2. package/.github/workflows/repo-lockdown.yml +24 -0
  3. package/.jsdoc.conf.json +7 -6
  4. package/LICENSE +1 -1
  5. package/README.md +50 -18
  6. package/class/app.js +376 -54
  7. package/class/bajo.js +228 -149
  8. package/class/base.js +106 -0
  9. package/class/helper/bajo.js +135 -84
  10. package/class/helper/{plugin.js → base.js} +96 -22
  11. package/class/{base → misc}/err.js +44 -14
  12. package/class/misc/log.js +212 -0
  13. package/class/misc/print.js +264 -0
  14. package/class/plugin.js +120 -68
  15. package/docs/App.html +23 -1
  16. package/docs/Bajo.html +2 -9
  17. package/docs/Base.html +3 -0
  18. package/docs/Err.html +3 -1
  19. package/docs/Log.html +5 -1
  20. package/docs/Plugin.html +1 -1
  21. package/docs/Print.html +1 -1
  22. package/docs/class_app.js.html +378 -56
  23. package/docs/class_bajo.js.html +230 -151
  24. package/docs/class_base.js.html +109 -0
  25. package/docs/class_helper_bajo.js.html +138 -87
  26. package/docs/class_helper_base.js.html +246 -0
  27. package/docs/class_misc_err.js.html +129 -0
  28. package/docs/class_misc_log.js.html +210 -0
  29. package/docs/class_misc_print.js.html +267 -0
  30. package/docs/class_plugin.js.html +122 -70
  31. package/docs/data/search.json +1 -1
  32. package/docs/global.html +4 -1
  33. package/docs/index.html +2 -2
  34. package/docs/index.js.html +35 -0
  35. package/docs/lib_current-loc.js.html +36 -0
  36. package/docs/lib_formats.js.html +8 -8
  37. package/docs/lib_import-module.js.html +59 -0
  38. package/docs/lib_log-levels.js.html +17 -7
  39. package/docs/lib_parse-args-argv.js.html +83 -0
  40. package/docs/lib_parse-env.js.html +53 -0
  41. package/docs/lib_resolve-path.js.html +3 -6
  42. package/docs/lib_shim.js.html +8 -3
  43. package/docs/module-Helper_Bajo.html +3 -0
  44. package/docs/module-Helper_Base.html +3 -0
  45. package/docs/module-Lib.html +15 -0
  46. package/docs/static/home.md +32 -0
  47. package/docs/static/logo-ecosystem.png +0 -0
  48. package/docs/static/logo.png +0 -0
  49. package/extend/bajo/intl/en-US.json +8 -2
  50. package/extend/bajo/intl/id.json +8 -2
  51. package/index.js +22 -2
  52. package/lib/current-loc.js +24 -2
  53. package/lib/formats.js +6 -6
  54. package/lib/import-module.js +29 -0
  55. package/lib/log-levels.js +15 -5
  56. package/lib/parse-args-argv.js +20 -12
  57. package/lib/parse-env.js +18 -7
  58. package/lib/resolve-path.js +1 -4
  59. package/lib/shim.js +6 -1
  60. package/package.json +4 -7
  61. package/wiki/CONFIG.md +30 -0
  62. package/wiki/CONTRIBUTING.md +5 -0
  63. package/wiki/DEV_GUIDE.md +3 -0
  64. package/wiki/ECOSYSTEM.md +93 -0
  65. package/wiki/GETTING-STARTED.md +356 -0
  66. package/wiki/USER-GUIDE.md +256 -0
  67. package/class/base/log.js +0 -205
  68. package/class/base/plugin.js +0 -168
  69. package/class/base/print.js +0 -272
  70. package/docs/BasePlugin.html +0 -5
  71. package/docs/class_base_err.js.html +0 -99
  72. package/docs/class_base_log.js.html +0 -208
  73. package/docs/class_base_plugin.js.html +0 -180
  74. package/docs/class_base_print.js.html +0 -275
  75. package/docs/class_helper_plugin.js.html +0 -172
  76. package/docs/lib_create-method.js.html +0 -42
  77. package/docs/module-class_helper_bajo.html +0 -3
  78. package/docs/module-class_helper_plugin.html +0 -3
  79. package/docs/module-lib_create-method.html +0 -3
  80. package/docs/module-lib_formats.html +0 -3
  81. package/docs/module-lib_log-levels.html +0 -3
  82. package/docs/module-lib_resolve-path.html +0 -3
  83. package/docs/module-lib_shim.html +0 -3
  84. package/docs/tutorial-contribution.html +0 -3
  85. package/docs/tutorial-ecosystem.html +0 -3
  86. package/docs/tutorial-getting-started.html +0 -13
  87. package/docs/tutorial-plugin-dev.html +0 -3
  88. package/docs/tutorial-user-guide.html +0 -3
  89. package/lib/create-method.js +0 -39
  90. package/lib/dayjs.js +0 -8
  91. package/lib/omitted-plugin-keys.js +0 -3
  92. package/lib/read-all-configs.js +0 -19
  93. package/misc-docs/.hook.md +0 -11
  94. package/misc-docs/bitcoin.jpeg +0 -0
  95. package/misc-docs/contribution.md +0 -20
  96. package/misc-docs/ecosystem.md +0 -94
  97. package/misc-docs/getting-started.md +0 -142
  98. package/misc-docs/plugin-dev.md +0 -0
  99. package/misc-docs/toc.json +0 -17
  100. package/misc-docs/user-guide.md +0 -1
  101. /package/docs/{bitcoin.jpeg → static/bitcoin.jpeg} +0 -0
@@ -1,142 +0,0 @@
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
- | &nbsp;&nbsp;```dateFormat``` | ```string``` | no | ```YYYY-MM-DDTHH:MM:ss.SSS[Z]```| Date format accoding to [dayjs](https://github.com/iamkun/dayjs) |
83
- | &nbsp;&nbsp;```applet``` | ```boolean``` | no | ```false``` | Set to ```true``` if you want to show log even in [applet mode](#applet-mode) |
84
- | &nbsp;&nbsp;```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
@@ -1,17 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- # User Guide
File without changes