bajo 1.2.8 → 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.
Files changed (167) hide show
  1. package/.jsdoc.conf.json +6 -3
  2. package/README.md +8 -148
  3. package/class/app.js +113 -0
  4. package/{boot/class/bajo-core.js → class/bajo.js} +449 -37
  5. package/{boot/class/error.js → class/base/err.js} +29 -3
  6. package/class/base/log.js +205 -0
  7. package/class/base/plugin.js +177 -0
  8. package/class/base/print.js +272 -0
  9. package/class/helper/bajo.js +344 -0
  10. package/class/helper/plugin.js +169 -0
  11. package/{boot/class/bajo-plugin.js → class/plugin.js} +60 -3
  12. package/docs/App.html +3 -0
  13. package/docs/Bajo.html +15 -0
  14. package/docs/BasePlugin.html +5 -0
  15. package/docs/Err.html +3 -0
  16. package/docs/Log.html +3 -0
  17. package/docs/Plugin.html +3 -0
  18. package/docs/Print.html +3 -0
  19. package/docs/bitcoin.jpeg +0 -0
  20. package/docs/class_app.js.html +116 -0
  21. package/docs/class_bajo.js.html +1100 -0
  22. package/docs/class_base_err.js.html +99 -0
  23. package/docs/class_base_log.js.html +208 -0
  24. package/docs/class_base_plugin.js.html +180 -0
  25. package/docs/class_base_print.js.html +275 -0
  26. package/docs/class_helper_bajo.js.html +347 -0
  27. package/docs/class_helper_plugin.js.html +172 -0
  28. package/docs/class_plugin.js.html +121 -0
  29. package/docs/data/search.json +1 -0
  30. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  31. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  32. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  33. package/docs/global.html +3 -0
  34. package/docs/index.html +3 -0
  35. package/docs/lib_create-method.js.html +42 -0
  36. package/docs/lib_formats.js.html +68 -0
  37. package/docs/lib_log-levels.js.html +28 -0
  38. package/docs/lib_resolve-path.js.html +30 -0
  39. package/docs/lib_shim.js.html +35 -0
  40. package/docs/module-class_helper_bajo.html +3 -0
  41. package/docs/module-class_helper_plugin.html +3 -0
  42. package/docs/module-lib_create-method.html +3 -0
  43. package/docs/module-lib_formats.html +3 -0
  44. package/docs/module-lib_log-levels.html +3 -0
  45. package/docs/module-lib_resolve-path.html +3 -0
  46. package/docs/module-lib_shim.html +3 -0
  47. package/docs/scripts/core.js +726 -0
  48. package/docs/scripts/core.min.js +23 -0
  49. package/docs/scripts/resize.js +90 -0
  50. package/docs/scripts/search.js +265 -0
  51. package/docs/scripts/search.min.js +6 -0
  52. package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
  53. package/docs/scripts/third-party/fuse.js +9 -0
  54. package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
  55. package/docs/scripts/third-party/hljs-line-num.js +1 -0
  56. package/docs/scripts/third-party/hljs-original.js +5171 -0
  57. package/docs/scripts/third-party/hljs.js +1 -0
  58. package/docs/scripts/third-party/popper.js +5 -0
  59. package/docs/scripts/third-party/tippy.js +1 -0
  60. package/docs/scripts/third-party/tocbot.js +672 -0
  61. package/docs/scripts/third-party/tocbot.min.js +1 -0
  62. package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
  63. package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
  64. package/docs/styles/clean-jsdoc-theme-light.css +482 -0
  65. package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  66. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  67. package/docs/styles/clean-jsdoc-theme.min.css +1 -0
  68. package/docs/tutorial-contribution.html +3 -0
  69. package/docs/tutorial-ecosystem.html +3 -0
  70. package/docs/tutorial-getting-started.html +13 -0
  71. package/docs/tutorial-plugin-dev.html +3 -0
  72. package/docs/tutorial-user-guide.html +3 -0
  73. package/lib/create-method.js +39 -0
  74. package/{boot/lib → lib}/formats.js +28 -0
  75. package/lib/log-levels.js +25 -0
  76. package/{boot/lib → lib}/parse-args-argv.js +1 -1
  77. package/{boot/lib → lib}/resolve-path.js +12 -0
  78. package/{boot/lib → lib}/shim.js +10 -0
  79. package/misc-docs/bitcoin.jpeg +0 -0
  80. package/misc-docs/contribution.md +20 -0
  81. package/{docs → misc-docs}/ecosystem.md +41 -12
  82. package/misc-docs/getting-started.md +142 -0
  83. package/misc-docs/plugin-dev.md +0 -0
  84. package/misc-docs/toc.json +17 -0
  85. package/misc-docs/user-guide.md +1 -0
  86. package/package.json +14 -12
  87. package/bajoBook/book/doc/.metadata.json +0 -28
  88. package/bajoBook/book/doc/How-to-Make-a-Paper-Boat-564x400@2x.jpg +0 -0
  89. package/bajoBook/book/doc/pages/guides/definition.md +0 -7
  90. package/bajoBook/book/doc/pages/guides/intro.md +0 -3
  91. package/bajoBook/book/doc/pages/guides/setup.md +0 -22
  92. package/bajoBook/book/reference/.metadata.json +0 -152
  93. package/bajoBook/book/reference/concept-leadership-business-with-paper-boats.jpg +0 -0
  94. package/bajoBook/book/reference/pages/configuration/configuration-file.md +0 -52
  95. package/bajoBook/book/reference/pages/helper/break-ns-path.md +0 -24
  96. package/bajoBook/book/reference/pages/helper/build-collections.md +0 -19
  97. package/bajoBook/book/reference/pages/helper/call-helper-or-handler.md +0 -35
  98. package/bajoBook/book/reference/pages/helper/current-loc.md +0 -28
  99. package/bajoBook/book/reference/pages/helper/dayjs.md +0 -13
  100. package/bajoBook/book/reference/pages/helper/defaults-deep.md +0 -29
  101. package/bajoBook/book/reference/pages/helper/dump.md +0 -32
  102. package/bajoBook/book/reference/pages/helper/each-plugins.md +0 -24
  103. package/bajoBook/book/reference/pages/helper/envs.md +0 -11
  104. package/bajoBook/book/reference/pages/helper/error.md +0 -29
  105. package/bajoBook/book/reference/pages/helper/fatal.md +0 -18
  106. package/bajoBook/book/reference/pages/helper/freeze.md +0 -13
  107. package/bajoBook/book/reference/pages/helper/generate-id.md +0 -36
  108. package/bajoBook/book/reference/pages/helper/get-config.md +0 -27
  109. package/bajoBook/book/reference/pages/helper/get-global-module-dir.md +0 -13
  110. package/bajoBook/book/reference/pages/helper/get-helper.md +0 -13
  111. package/bajoBook/book/reference/pages/helper/get-item-by-name.md +0 -13
  112. package/bajoBook/book/reference/pages/helper/get-key-by-value.md +0 -13
  113. package/bajoBook/book/reference/pages/helper/get-module-dir.md +0 -13
  114. package/bajoBook/book/reference/pages/helper/get-plugin-data-dir.md +0 -13
  115. package/bajoBook/book/reference/pages/helper/get-plugin-name.md +0 -13
  116. package/bajoBook/book/reference/pages/helper/get-plugin.md +0 -13
  117. package/bajoBook/book/reference/pages/helper/import-module.md +0 -13
  118. package/bajoBook/book/reference/pages/helper/import-pkg.md +0 -13
  119. package/bajoBook/book/reference/pages/helper/is-empty-dir.md +0 -13
  120. package/bajoBook/book/reference/pages/helper/is-log-in-range.md +0 -13
  121. package/bajoBook/book/reference/pages/helper/is-set.md +0 -13
  122. package/bajoBook/book/reference/pages/helper/is-valid-app.md +0 -13
  123. package/bajoBook/book/reference/pages/helper/is-valid-plugin.md +0 -13
  124. package/bajoBook/book/reference/pages/helper/log-levels.md +0 -13
  125. package/bajoBook/book/reference/pages/helper/log.md +0 -13
  126. package/bajoBook/book/reference/pages/helper/paginate.md +0 -13
  127. package/bajoBook/book/reference/pages/helper/pascal-case.md +0 -13
  128. package/bajoBook/book/reference/pages/helper/print.md +0 -13
  129. package/bajoBook/book/reference/pages/helper/read-config.md +0 -13
  130. package/bajoBook/book/reference/pages/helper/read-json.md +0 -13
  131. package/bajoBook/book/reference/pages/helper/resolve-path.md +0 -13
  132. package/bajoBook/book/reference/pages/helper/resolve-tpl-path.md +0 -13
  133. package/bajoBook/book/reference/pages/helper/run-hook.md +0 -13
  134. package/bajoBook/book/reference/pages/helper/save-as-download.md +0 -13
  135. package/bajoBook/book/reference/pages/helper/titleize.md +0 -13
  136. package/bajoBook/book/reference/pages/helper/white-space.md +0 -13
  137. package/boot/class/app.js +0 -67
  138. package/boot/class/bajo-core/boot-order.js +0 -35
  139. package/boot/class/bajo-core/boot-plugins.js +0 -17
  140. package/boot/class/bajo-core/build-config.js +0 -85
  141. package/boot/class/bajo-core/build-plugins.js +0 -44
  142. package/boot/class/bajo-core/collect-config-handlers.js +0 -20
  143. package/boot/class/bajo-core/exit-handler.js +0 -53
  144. package/boot/class/bajo-core/run-as-applet.js +0 -26
  145. package/boot/class/bajo-plugin/attach-method.js +0 -14
  146. package/boot/class/bajo-plugin/build-config.js +0 -15
  147. package/boot/class/bajo-plugin/check-clash.js +0 -18
  148. package/boot/class/bajo-plugin/check-dependency.js +0 -39
  149. package/boot/class/bajo-plugin/collect-hooks.js +0 -31
  150. package/boot/class/bajo-plugin/run.js +0 -23
  151. package/boot/class/log.js +0 -90
  152. package/boot/class/plugin.js +0 -79
  153. package/boot/class/print.js +0 -153
  154. package/boot/lib/create-method.js +0 -33
  155. package/boot/lib/log-levels.js +0 -1
  156. package/test/method/isSet.js +0 -43
  157. /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
  158. /package/{bajo → extend/bajo}/intl/id.json +0 -0
  159. /package/{waibuStatic → extend/waibuStatic}/virtual.json +0 -0
  160. /package/{boot/index.js → index.js} +0 -0
  161. /package/{boot/lib → lib}/current-loc.js +0 -0
  162. /package/{boot/lib → lib}/dayjs.js +0 -0
  163. /package/{boot/lib → lib}/import-module.js +0 -0
  164. /package/{boot/lib → lib}/omitted-plugin-keys.js +0 -0
  165. /package/{boot/lib → lib}/parse-env.js +0 -0
  166. /package/{boot/lib → lib}/read-all-configs.js +0 -0
  167. /package/{docs/hook.md → misc-docs/.hook.md} +0 -0
@@ -1,32 +0,0 @@
1
- ---
2
- title: function dump()
3
- ---
4
-
5
- A ```console.log``` with untruncated, deep objects. Doesn't return anything, instead prints arguments as nested, deep object.
6
-
7
- ###### Parameters:
8
-
9
- | Name | Type | Default Value | Description |
10
- | ---- | ---- | ------------- | ----------- |
11
- | ```...args``` | ...object || rest parameter of objects |
12
-
13
- ###### Returns:
14
-
15
- ```void```
16
-
17
- #### Example
18
-
19
- ```javascript
20
- ...
21
- const { dump } = this.bajo.helper
22
- const value = {
23
- level1: {
24
- level2: {
25
- level3: {
26
- level4: 'this is a test'
27
- }
28
- }
29
- }
30
- }
31
- dump(value)
32
- ```
@@ -1,24 +0,0 @@
1
- ---
2
- title: async function eachPlugins()
3
- ---
4
-
5
- Walk through all loaded plugins and execute the callback handler.
6
-
7
- ###### Parameters:
8
-
9
- | Name | Type | Default Value | Description |
10
- | ---- | ---- | ------------- | ----------- |
11
- | ```handler``` | async function || callback handler. _Required_ |
12
- | ```options``` | object |||
13
- |     ```key``` | string | ```name``` | Key of Bajo's config object that will be used as the key of returned object |
14
- |     ```glob``` | string/object || see above |
15
- |     ```ns``` | string | _Autodetect_ | If not set, it defaults to calling plugin |
16
- |     ```extend``` | string || see above |
17
- |     ```extendHandler``` | function | ```handler``` | see above |
18
- |     ```useBajo``` | boolean | ```false``` | weather to scan **bajo** package dir too |
19
-
20
- ###### Returns:
21
-
22
- ```object```
23
-
24
- #### Example
@@ -1,11 +0,0 @@
1
- ---
2
- title: object envs
3
- ---
4
-
5
- Variable of object holding all available environtments
6
-
7
- #### Example
8
-
9
- ```javascript
10
- const { envs } = this.bajo.helper
11
- console.log(envs) // prints: { dev: 'development', prod: 'production' }
@@ -1,29 +0,0 @@
1
- ---
2
- title: function error()
3
- ---
4
-
5
- A shortcut to create an instance of Error with message and optionally rest parameter within a single line.
6
-
7
- Message can hold ```sprintf``` token. If it does, use rest parameter to replace its token.
8
-
9
- If last parameter is a plain object, it will be used as error payload.
10
-
11
- ###### Parameters:
12
-
13
- | Name | Type | Default Value | Description |
14
- | ---- | ---- | ------------- | ----------- |
15
- | ```message``` | string || Error message. _Required_ |
16
- | ```...args``` | ...any || see above |
17
-
18
- ###### Returns:
19
-
20
- ```object``` new instance of node's Error
21
-
22
- #### Example
23
-
24
- ```javascript
25
- ...
26
- const { error } = this.bajo.helper
27
- const payload = { statusCode: 500, details: [{ field: 'username', error: 'Required' }] }
28
- throw error('This is a %s error, it should also hold some payloads', 'fatal', payload)
29
- ```
@@ -1,18 +0,0 @@
1
- ---
2
- title: function fatal()
3
- ---
4
-
5
- Basically the same as [error()](2.9-error.md), with two extras:
6
-
7
- - prints error on screen
8
- - terminate running program with exit code 1
9
-
10
- ###### Parameters:
11
-
12
- | Name | Type | Default Value | Description |
13
- | ---- | ---- | ------------- | ----------- |
14
- | ```...args``` | ...any || any arguments provided here will be passed through **error()** |
15
-
16
- ###### Returns:
17
-
18
- ```void```
@@ -1,13 +0,0 @@
1
- ---
2
- title: function freeze()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,36 +0,0 @@
1
- ---
2
- title: function generateId()
3
- ---
4
-
5
- ID generator based on [nanoid](https://github.com/ai/nanoid).
6
-
7
- By default, ```options.pattern``` is set to ```abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789``` so that resulted ID will be a full alphanumeric characters with the length of ```options.length``` (default: ```21```)
8
-
9
- If ```options.pattern``` is an object:
10
-
11
- - ```pattern```: characters to use
12
- - ```lowerCase```: if ```true```, only use lowercase
13
- - ```upperCase```: if ```true```, only use uppercase
14
-
15
- ```lowerCase``` and ```upperCase``` is mutually exclusive, first one win.
16
-
17
- ###### Parameters:
18
-
19
- | Name | Type | Default Value | Description |
20
- | ---- | ---- | ------------- | ----------- |
21
- | ```options``` | object |||
22
- |     ```pattern``` | string or object | all alphanumeric characters | see above |
23
- |     ```length``` | integer | ```21``` | length of generated ID |
24
- |     ```returnInstance``` | boolean | ```false``` | Set ```true``` to return a nanoid instance |
25
-
26
- ###### Returns:
27
-
28
- ```string``` or ```object```
29
-
30
- #### Example
31
-
32
- ```javascript
33
- ...
34
- const { generateId } = this.bajo.helper
35
- console.log(generateId()) // returns: <randomly generated characters>
36
- ```
@@ -1,27 +0,0 @@
1
- ---
2
- title: function getConfig()
3
- ---
4
-
5
- Get configuration object of **bajo** or its **plugin**
6
-
7
- ###### Parameters:
8
-
9
- | Name | Type | Default&nbsp;Value | Description |
10
- | ---- | ---- | ------------- | ----------- |
11
- | ```name``` | string | ```bajo``` | A valid plugin name |
12
- | ```options``` | object |||
13
- | &nbsp;&nbsp;&nbsp;&nbsp;```full``` | boolean | ```false``` | If ```true```, returns ALL config objects belonging to named plugin. Otherwise, returns only subset of objects that can be changed through configuration file |
14
- | &nbsp;&nbsp;&nbsp;&nbsp;```clone``` | boolean | ```false``` | If ```true```, returns cloned object |
15
-
16
- ###### Returns:
17
-
18
- ```object```
19
-
20
- #### Example
21
-
22
- ```javascript
23
- ...
24
- const { getConfig } = this.bajo.helper
25
- const cfg = getConfig('bajoLogger')
26
- console.log(cfg)
27
- ```
@@ -1,13 +0,0 @@
1
- ---
2
- title: function getGlobalModuleDir()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function getHelper()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: async function getItemByName()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function getKeyByValue()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function getModuleDir()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function getPluginDataDir()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function getPluginName()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function getPlugin()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: async function importModule()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: async function importPkg()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: async function isEmptyDir()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function isLogInRange()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function isSet()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function isValidApp()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function isValidPlugin()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: object logLevels
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: object log
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function paginate()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function pascalCase()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: object print
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: async function readConfig()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function readJson()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function resolvePath()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function resolveTplPath()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: async function runHook()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: async function saveAsDownload()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: function titleize()
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
@@ -1,13 +0,0 @@
1
- ---
2
- title: array whiteSpace
3
- ---
4
-
5
- ###### Parameters:
6
-
7
- | Name | Type | Default Value | Description |
8
- | ---- | ---- | ------------- | ----------- |
9
-
10
- ###### Returns:
11
-
12
-
13
- #### Example
package/boot/class/app.js DELETED
@@ -1,67 +0,0 @@
1
- import util from 'util'
2
- import lodash from 'lodash'
3
- import BajoCore from './bajo-core.js'
4
- import resolvePath from '../lib/resolve-path.js'
5
- import parseArgsArgv from '../lib/parse-args-argv.js'
6
- import parseEnv from '../lib/parse-env.js'
7
- import buildPlugins from './bajo-core/build-plugins.js'
8
- import { buildBaseConfig, buildExtConfig } from './bajo-core/build-config.js'
9
- import collectConfigHandlers from './bajo-core/collect-config-handlers.js'
10
- import bootOrder from './bajo-core/boot-order.js'
11
- import bootPlugins from './bajo-core/boot-plugins.js'
12
- import exitHandler from './bajo-core/exit-handler.js'
13
- import runAsApplet from './bajo-core/run-as-applet.js'
14
-
15
- const { last } = lodash
16
-
17
- class App {
18
- constructor (cwd) {
19
- if (!cwd) cwd = process.cwd()
20
- const l = last(process.argv)
21
- if (l.startsWith('--cwd')) {
22
- const parts = l.split('=')
23
- cwd = parts[1]
24
- }
25
- this.dir = resolvePath(cwd)
26
- process.env.APPDIR = this.dir
27
- }
28
-
29
- addPlugin = (plugin) => {
30
- if (this[plugin.name]) throw new Error(`Plugin '${plugin.name}' added already`)
31
- this[plugin.name] = plugin
32
- }
33
-
34
- dump = (...args) => {
35
- const terminate = last(args) === true
36
- if (terminate) args.pop()
37
- for (const arg of args) {
38
- const result = util.inspect(arg, false, null, true)
39
- console.log(result)
40
- }
41
- if (terminate) process.kill(process.pid, 'SIGINT')
42
- }
43
-
44
- boot = async () => {
45
- // argv/args
46
- const { args, argv } = await parseArgsArgv.call(this.app) ?? {}
47
- this.argv = argv
48
- this.args = args
49
- this.env = parseEnv() ?? {}
50
-
51
- const bajo = new BajoCore(this)
52
- await buildBaseConfig.call(bajo)
53
- await buildPlugins.call(bajo)
54
- await collectConfigHandlers.call(bajo)
55
- await buildExtConfig.call(bajo)
56
- await bootOrder.call(bajo)
57
- await bootPlugins.call(bajo)
58
- await exitHandler.call(bajo)
59
- // boot complete
60
- const elapsed = new Date() - bajo.runAt
61
- bajo.log.info('bootCompleted%s', bajo.lib.aneka.secToHms(elapsed, true))
62
- await bajo.runHook('bajo:afterBootComplete')
63
- if (bajo.applet) await runAsApplet.call(bajo)
64
- }
65
- }
66
-
67
- export default App