bajo 2.21.1 → 2.22.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 +1 -1
- package/class/app.js +139 -115
- package/class/bajo.js +96 -89
- package/class/base.js +25 -9
- package/class/cache.js +32 -19
- package/class/err.js +11 -9
- package/class/log.js +102 -52
- package/class/plugin.js +45 -35
- package/class/print.js +45 -44
- package/class/tools.js +7 -1
- package/docs/App.html +1 -23
- package/docs/Bajo.html +1 -6
- package/docs/Base.html +1 -1
- package/docs/Cache.html +1 -1
- package/docs/Err.html +2 -2
- package/docs/Log.html +4 -4
- package/docs/Plugin.html +1 -1
- package/docs/Print.html +1 -1
- package/docs/Tools.html +1 -1
- package/docs/class_app.js.html +141 -117
- package/docs/class_bajo.js.html +98 -91
- package/docs/class_base.js.html +27 -11
- package/docs/class_cache.js.html +34 -21
- package/docs/class_err.js.html +13 -11
- package/docs/class_log.js.html +104 -54
- package/docs/class_plugin.js.html +47 -37
- package/docs/class_print.js.html +47 -46
- package/docs/class_tools.js.html +9 -3
- package/docs/data/search.json +1 -1
- package/docs/global.html +1 -1
- package/docs/index.html +1 -1
- package/docs/index.js.html +8 -4
- package/docs/{class__helper.js.html → lib_helper.js.html} +208 -96
- package/docs/lib_hook.js.html +231 -0
- package/docs/module-Helper.html +8 -1
- package/docs/module-Hook.html +3 -0
- package/docs/module-Lib.html +1 -8
- package/index.js +1 -1
- package/{class/_helper.js → lib/helper.js} +206 -94
- package/lib/hook.js +228 -0
- package/package.json +1 -1
- package/wiki/CHANGES.md +6 -0
- package/docs/class_helper_bajo.js.html +0 -398
- package/docs/class_helper_base.js.html +0 -246
- package/docs/class_misc_err.js.html +0 -129
- package/docs/class_misc_log.js.html +0 -210
- package/docs/class_misc_print.js.html +0 -267
- package/docs/lib_current-loc.js.html +0 -36
- package/docs/lib_find-deep.js.html +0 -27
- package/docs/lib_formats.js.html +0 -68
- package/docs/lib_freeze.js.html +0 -54
- package/docs/lib_import-module.js.html +0 -61
- package/docs/lib_index.js.html +0 -9
- package/docs/lib_log-levels.js.html +0 -38
- package/docs/lib_parse-args-argv.js.html +0 -83
- package/docs/lib_parse-env.js.html +0 -53
- package/docs/lib_resolve-path.js.html +0 -27
- package/docs/lib_shim.js.html +0 -40
- package/docs/module-Helper_Bajo.html +0 -3
- package/docs/module-Helper_Base.html +0 -3
- package/lib/find-deep.js +0 -24
- package/lib/formats.js +0 -65
- package/lib/freeze.js +0 -51
- package/lib/import-module.js +0 -58
- package/lib/index.js +0 -6
- package/lib/log-levels.js +0 -35
package/docs/module-Lib.html
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
<!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Module: Lib</title><!--[if lt IE 9]>
|
|
2
2
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
3
|
-
<![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">Bajo API</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="App.html">App</a></div><div class="sidebar-section-children"><a href="Bajo.html">Bajo</a></div><div class="sidebar-section-children"><a href="Base.html">Base</a></div><div class="sidebar-section-children"><a href="Cache.html">Cache</a></div><div class="sidebar-section-children"><a href="Err.html">Err</a></div><div class="sidebar-section-children"><a href="Log.html">Log</a></div><div class="sidebar-section-children"><a href="Plugin.html">Plugin</a></div><div class="sidebar-section-children"><a href="Print.html">Print</a></div><div class="sidebar-section-children"><a href="Tools.html">Tools</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-events"><div>Events</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#event:bajo:afterAll%257Bmethod%257D">bajo:afterAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBootComplete">bajo:afterBootComplete</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBuildCollection">bajo:afterBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterCollectHooks">bajo:afterCollectHooks</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeAll%257Bmethod%257D">bajo:beforeAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeBuildCollection">bajo:beforeBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:after%257Bmethod%257D">{ns}:after{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:beforeAppletRun">{ns}:beforeAppletRun</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:before%257Bmethod%257D">{ns}:before{method}</a></div><div class="sidebar-section-children"><a href="module-Helper%257Bns%257D_afterAppletRun.html">Helper{ns}:afterAppletRun</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Helper.html">Helper</a></div><div class="sidebar-section-children"><a href="module-Lib.html">Lib</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#TAppConfigHandler">TAppConfigHandler</a></div><div class="sidebar-section-children"><a href="global.html#TAppEnv">TAppEnv</a></div><div class="sidebar-section-children"><a href="global.html#TBajoDataType">TBajoDataType</a></div><div class="sidebar-section-children"><a href="global.html#TBajoFormatResult">TBajoFormatResult</a></div><div class="sidebar-section-children"><a href="global.html#TBajoFormatType">TBajoFormatType</a></div><div class="sidebar-section-children"><a href="global.html#TLogJson">TLogJson</a></div><div class="sidebar-section-children"><a href="global.html#TLogLevels">TLogLevels</a></div><div class="sidebar-section-children"><a href="global.html#TNsPathPairs">TNsPathPairs</a></div><div class="sidebar-section-children"><a href="global.html#TNsPathResult">TNsPathResult</a></div><div class="sidebar-section-children"><a href="global.html#TPrintOptions">TPrintOptions</a></div><div class="sidebar-section-children"><a href="global.html#boot">boot</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section><header></header><article><div class="container-overview"><div class="description"><p>External helpers you can use by importing its file directly</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="lib_index.js.html">lib/index.js</a>, <a href="lib_index.js.html#line1">line 1</a></li></ul></dd></div></dl></div><h2 id="methods" class="subsection-title has-anchor">Methods</h2><h3 class="name has-anchor" id=".findDeep"><span class="type-signature">(static) </span>findDeep<span class="signature">(item, paths)</span><span class="type-signature"> → {string}</span></h3><div class="description"><p>Find item deep in paths.</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>item</code></td><td class="type"><span class="param-type">string</span></td><td class="description last"><p>Item to find.</p></td></tr><tr><td class="name"><code>paths</code></td><td class="type"><span class="param-type">Array</span></td><td class="description last"><p>Array of path to look for.</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="lib_find-deep.js.html">lib/find-deep.js</a>, <a href="lib_find-deep.js.html#line12">line 12</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=".freeze"><span class="type-signature">(static) </span>freeze<span class="signature">(obj, shallow<span class="signature-attributes">opt</span>)</span></h3><div class="description"><p>Freeze object.</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>obj</code></td><td class="type"><span class="param-type">Object</span></td><td class="attributes"></td><td class="default"></td><td class="description last"><p>Object to freeze.</p></td></tr><tr><td class="name"><code>shallow</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="default">false</td><td class="description last"><p>If <code>false</code> (default), deep freeze object.</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="lib_freeze.js.html">lib/freeze.js</a>, <a href="lib_freeze.js.html#line12">line 12</a></li></ul></dd></div></dl><h3 class="name has-anchor" id=".importModule"><span class="type-signature">(async, static) </span>importModule<span class="signature">(file, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {any}</span></h3><div class="description"><p>Import file/module from any loaded plugins.</p><p>E.g. your plugin structure looks like this:</p><pre class="prettyprint source"><code>|- src
|
|
4
|
-
| |- lib
|
|
5
|
-
| | |- my-module.js
|
|
6
|
-
|- index.js
|
|
7
|
-
|- package.json
|
|
8
|
-
</code></pre><p>And this is how to import <code>my-module.js</code>:</p><pre class="prettyprint source lang-javascript"><code>const { importModule } = this.app.bajo
|
|
9
|
-
const myModule = await importModule('myPlugin:/src/lib/my-module.js')
|
|
10
|
-
</code></pre></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>file</code></td><td class="type"><span class="param-type"><a href="global.html#TNsPathPairs">TNsPathPairs</a></span></td><td class="attributes"></td><td class="default"></td><td class="description last"><p>File to import.</p></td></tr><tr><td class="name"><code>options</code></td><td class="type"><span class="param-type">Object</span></td><td class="attributes"><optional><br></td><td class="default">{}</td><td class="description last"><p>Options.</p><h6>Properties</h6><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>asDefaultImport</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>If <code>true</code> (default), return default imported module.</p></td></tr><tr><td class="name"><code>asHandler</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="default"></td><td class="description last"><p>If <code>true</code>, return as a handler.</p></td></tr><tr><td class="name"><code>noCache</code></td><td class="type"><span class="param-type">boolean</span></td><td class="attributes"><optional><br></td><td class="default"></td><td class="description last"><p>If <code>true</code>, always import as a fresh copy.</p></td></tr></tbody></table></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="lib_import-module.js.html">lib/import-module.js</a>, <a href="lib_import-module.js.html#line37">line 37</a></li></ul></dd></div><div class="details-item-container"><dt class="tag-see bold">See</dt><dd class="tag-see"><ul><li><a href="Bajo.html#importModule">Bajo#importModule</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">any</span></dd></dl></div></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">Bajo API</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="App.html">App</a></div><div class="sidebar-section-children"><a href="Bajo.html">Bajo</a></div><div class="sidebar-section-children"><a href="Base.html">Base</a></div><div class="sidebar-section-children"><a href="Cache.html">Cache</a></div><div class="sidebar-section-children"><a href="Err.html">Err</a></div><div class="sidebar-section-children"><a href="Log.html">Log</a></div><div class="sidebar-section-children"><a href="Plugin.html">Plugin</a></div><div class="sidebar-section-children"><a href="Print.html">Print</a></div><div class="sidebar-section-children"><a href="Tools.html">Tools</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-events"><div>Events</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#event:bajo:afterAll%257Bmethod%257D">bajo:afterAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBootComplete">bajo:afterBootComplete</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBuildCollection">bajo:afterBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterCollectHooks">bajo:afterCollectHooks</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeAll%257Bmethod%257D">bajo:beforeAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeBuildCollection">bajo:beforeBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:after%257Bmethod%257D">{ns}:after{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:beforeAppletRun">{ns}:beforeAppletRun</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:before%257Bmethod%257D">{ns}:before{method}</a></div><div class="sidebar-section-children"><a href="module-Helper%257Bns%257D_afterAppletRun.html">Helper{ns}:afterAppletRun</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Helper.html">Helper</a></div><div class="sidebar-section-children"><a href="module-Lib.html">Lib</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#TAppConfigHandler">TAppConfigHandler</a></div><div class="sidebar-section-children"><a href="global.html#TAppEnv">TAppEnv</a></div><div class="sidebar-section-children"><a href="global.html#TBajoDataType">TBajoDataType</a></div><div class="sidebar-section-children"><a href="global.html#TBajoFormatResult">TBajoFormatResult</a></div><div class="sidebar-section-children"><a href="global.html#TBajoFormatType">TBajoFormatType</a></div><div class="sidebar-section-children"><a href="global.html#TLogJson">TLogJson</a></div><div class="sidebar-section-children"><a href="global.html#TLogLevels">TLogLevels</a></div><div class="sidebar-section-children"><a href="global.html#TNsPathPairs">TNsPathPairs</a></div><div class="sidebar-section-children"><a href="global.html#TNsPathResult">TNsPathResult</a></div><div class="sidebar-section-children"><a href="global.html#TPrintOptions">TPrintOptions</a></div><div class="sidebar-section-children"><a href="global.html#boot">boot</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
|
|
3
|
+
<![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">Bajo API</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="App.html">App</a></div><div class="sidebar-section-children"><a href="Bajo.html">Bajo</a></div><div class="sidebar-section-children"><a href="Base.html">Base</a></div><div class="sidebar-section-children"><a href="Cache.html">Cache</a></div><div class="sidebar-section-children"><a href="Err.html">Err</a></div><div class="sidebar-section-children"><a href="Log.html">Log</a></div><div class="sidebar-section-children"><a href="Plugin.html">Plugin</a></div><div class="sidebar-section-children"><a href="Print.html">Print</a></div><div class="sidebar-section-children"><a href="Tools.html">Tools</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-events"><div>Events</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#event:bajo:afterAll%257Bmethod%257D">bajo:afterAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBuildCollection">bajo:afterBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterCollectHooks">bajo:afterCollectHooks</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeAll%257Bmethod%257D">bajo:beforeAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeBuildCollection">bajo:beforeBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:after%257Bmethod%257D">{ns}:after{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:beforeAppletRun">{ns}:beforeAppletRun</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:before%257Bmethod%257D">{ns}:before{method}</a></div><div class="sidebar-section-children"><a href="module-Helper%257Bns%257D_afterAppletRun.html">Helper{ns}:afterAppletRun</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Helper.html">Helper</a></div><div class="sidebar-section-children"><a href="module-Lib.html">Lib</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#boot">boot</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section><header></header><article><div class="container-overview"><div class="description"><p>External helpers you can use by importing its file directly</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="lib_helper.js.html">lib/helper.js</a>, <a href="lib_helper.js.html#line694">line 694</a></li></ul></dd></div></dl></div></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">Bajo API</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="App.html">App</a></div><div class="sidebar-section-children"><a href="Bajo.html">Bajo</a></div><div class="sidebar-section-children"><a href="Base.html">Base</a></div><div class="sidebar-section-children"><a href="Cache.html">Cache</a></div><div class="sidebar-section-children"><a href="Err.html">Err</a></div><div class="sidebar-section-children"><a href="Log.html">Log</a></div><div class="sidebar-section-children"><a href="Plugin.html">Plugin</a></div><div class="sidebar-section-children"><a href="Print.html">Print</a></div><div class="sidebar-section-children"><a href="Tools.html">Tools</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-events"><div>Events</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#event:bajo:afterAll%257Bmethod%257D">bajo:afterAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterBuildCollection">bajo:afterBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:afterCollectHooks">bajo:afterCollectHooks</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeAll%257Bmethod%257D">bajo:beforeAll{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:bajo:beforeBuildCollection">bajo:beforeBuildCollection</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:after%257Bmethod%257D">{ns}:after{method}</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:beforeAppletRun">{ns}:beforeAppletRun</a></div><div class="sidebar-section-children"><a href="global.html#event:%257Bns%257D:before%257Bmethod%257D">{ns}:before{method}</a></div><div class="sidebar-section-children"><a href="module-Helper%257Bns%257D_afterAppletRun.html">Helper{ns}:afterAppletRun</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Helper.html">Helper</a></div><div class="sidebar-section-children"><a href="module-Lib.html">Lib</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#boot">boot</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Print from '
|
|
2
|
-
import Log from '
|
|
1
|
+
import Print from '../class/print.js'
|
|
2
|
+
import Log from '../class/log.js'
|
|
3
3
|
import os from 'os'
|
|
4
4
|
import fs from 'fs-extra'
|
|
5
5
|
import lodash from 'lodash'
|
|
@@ -13,8 +13,12 @@ import utc from 'dayjs/plugin/utc.js'
|
|
|
13
13
|
import customParseFormat from 'dayjs/plugin/customParseFormat.js'
|
|
14
14
|
import localizedFormat from 'dayjs/plugin/localizedFormat.js'
|
|
15
15
|
import weekOfYear from 'dayjs/plugin/weekOfYear.js'
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const { resolvePath } = aneka
|
|
17
|
+
const {
|
|
18
|
+
isFunction, isPlainObject, cloneDeep, merge, forOwn, groupBy, find, reduce, map,
|
|
19
|
+
trim, keys, intersection, each, camelCase, get, orderBy, pick, values, set,
|
|
20
|
+
without, uniq, isEmpty
|
|
21
|
+
} = lodash
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Internal helpers called by Bajo and other classes. It should remains
|
|
@@ -23,11 +27,6 @@ import findDeep from '../lib/find-deep.js'
|
|
|
23
27
|
* @module Helper
|
|
24
28
|
*/
|
|
25
29
|
|
|
26
|
-
const {
|
|
27
|
-
merge, forOwn, groupBy, find, reduce, map, trim, keys, intersection, each,
|
|
28
|
-
camelCase, get, orderBy, isFunction, isPlainObject, pick, values, set, without, uniq, isEmpty
|
|
29
|
-
} = lodash
|
|
30
|
-
|
|
31
30
|
const omitted = ['spawn', 'cwd', 'name', 'alias', 'applet', 'a', 'plugins']
|
|
32
31
|
|
|
33
32
|
const defConfig = {
|
|
@@ -104,7 +103,7 @@ const defMain = `async function factory (pkgName) {
|
|
|
104
103
|
export default factory
|
|
105
104
|
`
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
function outmatchNs (source, pattern) {
|
|
108
107
|
const { breakNsPath } = this.bajo
|
|
109
108
|
const [src, subSrc] = source.split(':')
|
|
110
109
|
if (!subSrc) return pattern === src
|
|
@@ -117,7 +116,7 @@ export function outmatchNs (source, pattern) {
|
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
function parseObject (obj, options = {}) {
|
|
121
120
|
const me = this
|
|
122
121
|
const { ns = 'bajo', lang } = options
|
|
123
122
|
options.translator = {
|
|
@@ -138,7 +137,8 @@ dayjs.extend(localizedFormat)
|
|
|
138
137
|
dayjs.extend(weekOfYear)
|
|
139
138
|
|
|
140
139
|
/**
|
|
141
|
-
* @typedef {Object}
|
|
140
|
+
* @typedef {Object} TLib
|
|
141
|
+
* @memberof App
|
|
142
142
|
* @property {Object} _ Access to {@link https://lodash.com|lodash}.
|
|
143
143
|
* @property {Object} fs Access to {@link https://github.com/jprichardson/node-fs-extra|fs-extra}.
|
|
144
144
|
* @property {Object} fastGlob Access to {@link https://github.com/mrmlnc/fast-glob|fast-glob}.
|
|
@@ -159,7 +159,9 @@ export const lib = {
|
|
|
159
159
|
dayjs,
|
|
160
160
|
aneka,
|
|
161
161
|
freeze,
|
|
162
|
-
findDeep
|
|
162
|
+
findDeep,
|
|
163
|
+
outmatchNs,
|
|
164
|
+
parseObject
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
/**
|
|
@@ -172,7 +174,6 @@ export const lib = {
|
|
|
172
174
|
*
|
|
173
175
|
* @async
|
|
174
176
|
* @method
|
|
175
|
-
* @memberof module:Helper
|
|
176
177
|
*/
|
|
177
178
|
export async function buildBaseConfig () {
|
|
178
179
|
// dirs
|
|
@@ -214,7 +215,6 @@ export async function buildBaseConfig () {
|
|
|
214
215
|
* - attach these plugins to the app instance
|
|
215
216
|
*
|
|
216
217
|
* @async
|
|
217
|
-
* @memberof module:Helper
|
|
218
218
|
*/
|
|
219
219
|
export async function buildPlugins () {
|
|
220
220
|
const { resolvePath } = this.app.lib.aneka
|
|
@@ -248,7 +248,6 @@ export async function buildPlugins () {
|
|
|
248
248
|
* Collect all config handlers, including the one provided by plugins
|
|
249
249
|
*
|
|
250
250
|
* @async
|
|
251
|
-
* @memberof module:Helper
|
|
252
251
|
*/
|
|
253
252
|
export async function collectConfigHandlers () {
|
|
254
253
|
for (const pkg of this.app.pluginPkgs) {
|
|
@@ -274,7 +273,6 @@ export async function collectConfigHandlers () {
|
|
|
274
273
|
* - Set environment (```dev``` or ```prod```)
|
|
275
274
|
*
|
|
276
275
|
* @async
|
|
277
|
-
* @memberof module:Helper
|
|
278
276
|
*/
|
|
279
277
|
export async function buildExtConfig () {
|
|
280
278
|
// config merging
|
|
@@ -325,7 +323,6 @@ export async function buildExtConfig () {
|
|
|
325
323
|
* Setup plugins boot orders by reading plugin's ```.bootorder``` file if provided.
|
|
326
324
|
*
|
|
327
325
|
* @async
|
|
328
|
-
* @memberof module:Helper
|
|
329
326
|
*/
|
|
330
327
|
export async function bootOrder () {
|
|
331
328
|
const { freeze } = this.app.lib
|
|
@@ -354,7 +351,6 @@ export async function bootOrder () {
|
|
|
354
351
|
* Build configurations
|
|
355
352
|
*
|
|
356
353
|
* @async
|
|
357
|
-
* @memberof module:Helper
|
|
358
354
|
*/
|
|
359
355
|
export async function buildConfigs () {
|
|
360
356
|
this.bajo.log.debug('readConfigs')
|
|
@@ -369,7 +365,6 @@ export async function buildConfigs () {
|
|
|
369
365
|
* Ensure for names and aliases to be unique and no clashes with other plugins
|
|
370
366
|
*
|
|
371
367
|
* @async
|
|
372
|
-
* @memberof module:Helper
|
|
373
368
|
*/
|
|
374
369
|
export async function checkNameAliases () {
|
|
375
370
|
this.bajo.log.debug('checkAliasNameClash')
|
|
@@ -389,7 +384,6 @@ export async function checkNameAliases () {
|
|
|
389
384
|
* Ensure dependencies are met
|
|
390
385
|
*
|
|
391
386
|
* @async
|
|
392
|
-
* @memberof module:Helper
|
|
393
387
|
*/
|
|
394
388
|
export async function checkDependencies () {
|
|
395
389
|
const { join } = this.bajo
|
|
@@ -425,8 +419,6 @@ export async function checkDependencies () {
|
|
|
425
419
|
* Collect and build hooks and push them to the bajo's hook system
|
|
426
420
|
*
|
|
427
421
|
* @async
|
|
428
|
-
* @memberof module:Helper
|
|
429
|
-
* @fires bajo:afterCollectHooks
|
|
430
422
|
*/
|
|
431
423
|
export async function collectHooks () {
|
|
432
424
|
const { eachPlugins, runHook, isLogInRange, importModule } = this.bajo
|
|
@@ -470,15 +462,6 @@ export async function collectHooks () {
|
|
|
470
462
|
})
|
|
471
463
|
}
|
|
472
464
|
|
|
473
|
-
/**
|
|
474
|
-
* Run after hooks are collected
|
|
475
|
-
*
|
|
476
|
-
* @global
|
|
477
|
-
* @event bajo:afterCollectHooks
|
|
478
|
-
* @param {Object[]} hooks - Array of hook objects
|
|
479
|
-
* @see {@tutorial hook}
|
|
480
|
-
* @see module:Helper/Base.collectHooks
|
|
481
|
-
*/
|
|
482
465
|
await runHook('bajo:afterCollectHooks', this.bajo.hooks)
|
|
483
466
|
me.bajo.log.debug('collected%s%d', this.t('hooks'), me.bajo.hooks.length)
|
|
484
467
|
}
|
|
@@ -487,11 +470,14 @@ export async function collectHooks () {
|
|
|
487
470
|
* Finally, run all plugins
|
|
488
471
|
*
|
|
489
472
|
* @async
|
|
490
|
-
* @
|
|
491
|
-
* @
|
|
492
|
-
* @
|
|
493
|
-
* @
|
|
494
|
-
* @
|
|
473
|
+
* @see module:Hook~bajo:beforeAllInit
|
|
474
|
+
* @see module:Hook~{ns}:beforeInit
|
|
475
|
+
* @see module:Hook~{ns}:afterInit
|
|
476
|
+
* @see module:Hook~bajo:afterAllInit
|
|
477
|
+
* @see module:Hook~bajo:beforeAllStart
|
|
478
|
+
* @see module:Hook~{ns}:beforeStart
|
|
479
|
+
* @see module:Hook~{ns}:afterStart
|
|
480
|
+
* @see module:Hook~bajo:afterAllStart
|
|
495
481
|
*/
|
|
496
482
|
export async function run () {
|
|
497
483
|
const me = this
|
|
@@ -500,49 +486,14 @@ export async function run () {
|
|
|
500
486
|
const methods = ['init']
|
|
501
487
|
if (!me.applet) methods.push('start')
|
|
502
488
|
for (const method of methods) {
|
|
503
|
-
/**
|
|
504
|
-
* Run before all ```{method}``` executed. Accepted ```{method}```: ```Init``` or ```Start```
|
|
505
|
-
*
|
|
506
|
-
* @global
|
|
507
|
-
* @event bajo:beforeAll{method}
|
|
508
|
-
* @param {string} method - Accepted methods: ```Init```, ```Start```
|
|
509
|
-
* @see module:Helper/Base.run
|
|
510
|
-
*/
|
|
511
489
|
await runHook(`bajo:${camelCase(`before all ${method}`)}`)
|
|
512
490
|
await eachPlugins(async function () {
|
|
513
491
|
const { ns } = this
|
|
514
|
-
/**
|
|
515
|
-
* Run before ```{method}``` is executed within ```{ns}``` context
|
|
516
|
-
*
|
|
517
|
-
* - ```{ns}``` - namespace
|
|
518
|
-
* - ```{method}``` - Accepted methods: ```Init``` or ```Start```
|
|
519
|
-
*
|
|
520
|
-
* @global
|
|
521
|
-
* @event {ns}:before{method}
|
|
522
|
-
* @see module:Helper/Base.run
|
|
523
|
-
*/
|
|
524
492
|
await runHook(`${ns}:${camelCase(`before ${method}`)}`)
|
|
525
493
|
await me[ns][method]()
|
|
526
|
-
/**
|
|
527
|
-
* Run after ```{method}``` is executed within ```{ns}``` context
|
|
528
|
-
*
|
|
529
|
-
* - ```{ns}``` - namespace
|
|
530
|
-
* - ```{method}``` - Accepted methods: ```Init``` or ```Start```
|
|
531
|
-
*
|
|
532
|
-
* @global
|
|
533
|
-
* @event {ns}:after{method}
|
|
534
|
-
* @see module:Helper/Base.run
|
|
535
|
-
*/
|
|
536
494
|
await runHook(`${ns}:${camelCase(`after ${method}`)}`)
|
|
537
495
|
if (method === 'start') freeze(me[ns].config)
|
|
538
496
|
})
|
|
539
|
-
/**
|
|
540
|
-
* Run after all ```{method}``` executed. Accepted ```{method}```: ```Init``` or ```Start```
|
|
541
|
-
*
|
|
542
|
-
* @global
|
|
543
|
-
* @event bajo:afterAll{method}
|
|
544
|
-
* @see module:Helper/Base.run
|
|
545
|
-
*/
|
|
546
497
|
await runHook(`bajo:${camelCase(`after all ${method}`)}`)
|
|
547
498
|
}
|
|
548
499
|
if (me.bajo.config.log.level === 'trace') {
|
|
@@ -562,7 +513,6 @@ export async function run () {
|
|
|
562
513
|
* 5. {@link module:Helper/Base.run|run plugins}
|
|
563
514
|
*
|
|
564
515
|
* @async
|
|
565
|
-
* @memberof module:Helper
|
|
566
516
|
*/
|
|
567
517
|
export async function bootPlugins () {
|
|
568
518
|
await buildConfigs.call(this.app)
|
|
@@ -576,7 +526,6 @@ export async function bootPlugins () {
|
|
|
576
526
|
* Attach plugins exit handlers and make sure the app shutdowns gracefully
|
|
577
527
|
*
|
|
578
528
|
* @async
|
|
579
|
-
* @memberof module:Helper
|
|
580
529
|
*/
|
|
581
530
|
export async function exitHandler () {
|
|
582
531
|
if (!this.config.exitHandler) return
|
|
@@ -641,7 +590,6 @@ export async function exitHandler () {
|
|
|
641
590
|
* @async
|
|
642
591
|
* @fires {ns}:beforeAppletRun
|
|
643
592
|
* @fires {ns}:afterAppletRun
|
|
644
|
-
* @memberof module:Helper
|
|
645
593
|
*/
|
|
646
594
|
export async function runAsApplet () {
|
|
647
595
|
const { isString, map, find } = this.app.lib._
|
|
@@ -665,26 +613,190 @@ export async function runAsApplet () {
|
|
|
665
613
|
const applet = find(this.app.applets, a => (a.ns === ns || a.alias === ns))
|
|
666
614
|
if (!applet) this.print.fatal('notFound%s%s', this.app.t('applet'), name)
|
|
667
615
|
|
|
668
|
-
/**
|
|
669
|
-
* Run before applet is run. ```[ns]``` is applet's namespace
|
|
670
|
-
*
|
|
671
|
-
* @global
|
|
672
|
-
* @event {ns}:beforeAppletRun
|
|
673
|
-
* @param {...any} params
|
|
674
|
-
* @see {@tutorial hook}
|
|
675
|
-
* @see module:Helper/Bajo.runAsApplet
|
|
676
|
-
*/
|
|
677
616
|
await this.runHook(`${applet.ns}:beforeAppletRun`, ...this.app.args)
|
|
678
617
|
await this.app.bajoCli.runApplet(applet, path, ...this.app.args)
|
|
679
|
-
/**
|
|
680
|
-
* Run after applet is run. ```[ns]``` is applet's namespace
|
|
681
|
-
*
|
|
682
|
-
* @global
|
|
683
|
-
* @event {ns}:afterAppletRun
|
|
684
|
-
* @param {...any} params
|
|
685
|
-
* @see {@tutorial hook}
|
|
686
|
-
* @see module:Helper/Bajo.runAsApplet
|
|
687
|
-
* @memberof module:Helper
|
|
688
|
-
*/
|
|
689
618
|
await this.runHook(`${applet.ns}:afterAppletRun`, ...this.app.args)
|
|
690
619
|
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Import file/module from any loaded plugins.
|
|
623
|
+
*
|
|
624
|
+
* E.g. your plugin structure looks like this:
|
|
625
|
+
* ```
|
|
626
|
+
* |- src
|
|
627
|
+
* | |- lib
|
|
628
|
+
* | | |- my-module.js
|
|
629
|
+
* |- index.js
|
|
630
|
+
* |- package.json
|
|
631
|
+
* ```
|
|
632
|
+
*
|
|
633
|
+
* And this is how to import ```my-module.js```:
|
|
634
|
+
* ```javascript
|
|
635
|
+
* const { importModule } = this.app.bajo
|
|
636
|
+
* const myModule = await importModule('myPlugin:/src/lib/my-module.js')
|
|
637
|
+
* ```
|
|
638
|
+
*
|
|
639
|
+
* @method
|
|
640
|
+
* @async
|
|
641
|
+
* @param {TNsPathPairs} file File to import.
|
|
642
|
+
* @param {Object} [options={}] Options.
|
|
643
|
+
* @param {boolean} [options.asDefaultImport=true] If ```true``` (default), return default imported module.
|
|
644
|
+
* @param {boolean} [options.asHandler] If ```true```, return as a {@link HandlerType|handler}.
|
|
645
|
+
* @param {boolean} [options.noCache] If ```true```, always import as a fresh copy.
|
|
646
|
+
* @returns {any}
|
|
647
|
+
* @see Bajo#importModule
|
|
648
|
+
*/
|
|
649
|
+
export async function importModule (file, { asDefaultImport = true, asHandler, noCache } = {}) {
|
|
650
|
+
const load = async (file, asDefaultImport, noCache = false) => {
|
|
651
|
+
file = resolvePath(file, true)
|
|
652
|
+
if (noCache) file += `?_=${Date.now()}`
|
|
653
|
+
const imported = await import(file)
|
|
654
|
+
if (asDefaultImport) return imported.default
|
|
655
|
+
return imported
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (this) file = this.app.getPluginFile(file)
|
|
659
|
+
if (!fs.existsSync(file)) return
|
|
660
|
+
let mod = await load(file, asDefaultImport, noCache)
|
|
661
|
+
if (!asHandler) return mod
|
|
662
|
+
if (isFunction(mod)) mod = { level: 999, handler: mod }
|
|
663
|
+
if (!isPlainObject(mod)) {
|
|
664
|
+
if (this) throw this.error('fileNotModuleHandler%s', file)
|
|
665
|
+
throw new Error(`File '${file}' is NOT a handler module`)
|
|
666
|
+
}
|
|
667
|
+
return mod
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Freeze object.
|
|
672
|
+
*
|
|
673
|
+
* @method
|
|
674
|
+
* @param {Object} obj Object to freeze.
|
|
675
|
+
* @param {boolean} [shallow=false] If ```false``` (default), deep freeze object.
|
|
676
|
+
*/
|
|
677
|
+
export function freeze (obj, options = {}) {
|
|
678
|
+
const { shallow = false, clone = false } = options
|
|
679
|
+
if (shallow) Object.freeze(obj)
|
|
680
|
+
else deepFreeze(obj, clone)
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// take from https://github.com/3imed-jaberi/deepfreeze/blob/master/index.js
|
|
684
|
+
export function deepFreeze (object, clone = false) {
|
|
685
|
+
function _deepFreeze (_object) {
|
|
686
|
+
if (Object.isFrozen(_object)) return _object
|
|
687
|
+
if (_object instanceof Map) {
|
|
688
|
+
_object.set = _object.clear = _object.delete = function () {
|
|
689
|
+
throw new Error('Map is read-only')
|
|
690
|
+
}
|
|
691
|
+
return _object
|
|
692
|
+
}
|
|
693
|
+
if (_object instanceof Set) {
|
|
694
|
+
_object.add = _object.clear = _object.delete = function () {
|
|
695
|
+
throw new Error('Set is read-only')
|
|
696
|
+
}
|
|
697
|
+
return _object
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
Object.freeze(_object)
|
|
701
|
+
Object.getOwnPropertyNames(_object).forEach(function (key) {
|
|
702
|
+
if (Object.hasOwn(_object, key) && _object[key] !== null &&
|
|
703
|
+
(typeof _object[key] === 'object' || typeof _object[key] === 'function') &&
|
|
704
|
+
!Object.isFrozen(_object[key])
|
|
705
|
+
) _deepFreeze(_object[key])
|
|
706
|
+
})
|
|
707
|
+
|
|
708
|
+
return _object
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
if (!Object.isFrozen(object)) Object.defineProperty(object, 'isDeepFrozen', { value: () => true })
|
|
712
|
+
object = clone ? cloneDeep(object) : object
|
|
713
|
+
return _deepFreeze(object)
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Find item deep in paths.
|
|
718
|
+
*
|
|
719
|
+
* @method
|
|
720
|
+
* @param {string} item Item to find.
|
|
721
|
+
* @param {Array} paths Array of path to look for.
|
|
722
|
+
* @returns {string}
|
|
723
|
+
*/
|
|
724
|
+
export function findDeep (item, paths) {
|
|
725
|
+
let dir
|
|
726
|
+
for (const p of paths) {
|
|
727
|
+
const d = `${p}/${item}`
|
|
728
|
+
if (fs.existsSync(d)) {
|
|
729
|
+
dir = d
|
|
730
|
+
break
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
return dir
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Supported data types.
|
|
738
|
+
*
|
|
739
|
+
* @typedef {Object} TDataType
|
|
740
|
+
* @memberof Bajo
|
|
741
|
+
* @type {Array}
|
|
742
|
+
* @property {string} 0 string
|
|
743
|
+
* @property {string} 1 float
|
|
744
|
+
* @property {string} 2 double
|
|
745
|
+
* @property {string} 3 integer
|
|
746
|
+
* @property {string} 4 smallint
|
|
747
|
+
* @property {string} 5 date
|
|
748
|
+
* @property {string} 6 time
|
|
749
|
+
* @property {string} 7 datetime
|
|
750
|
+
* @property {string} 8 array
|
|
751
|
+
* @property {string} 9 object
|
|
752
|
+
* @property {string} 10 auto
|
|
753
|
+
*/
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* General format types,
|
|
757
|
+
*
|
|
758
|
+
* @typedef {Object} TFormatType
|
|
759
|
+
* @memberof Bajo
|
|
760
|
+
* @type {Array}
|
|
761
|
+
* @property {string} 0 speed
|
|
762
|
+
* @property {string} 1 distance
|
|
763
|
+
* @property {string} 2 area
|
|
764
|
+
* @property {string} 3 degree
|
|
765
|
+
*/
|
|
766
|
+
export const types = ['speed', 'distance', 'area', 'degree']
|
|
767
|
+
|
|
768
|
+
export const formats = {
|
|
769
|
+
metric: {
|
|
770
|
+
speedFn: (val) => val,
|
|
771
|
+
speedUnit: 'kmh',
|
|
772
|
+
distanceFn: (val) => val,
|
|
773
|
+
distanceUnit: 'km',
|
|
774
|
+
areaFn: (val) => val,
|
|
775
|
+
areaUnit: 'km²',
|
|
776
|
+
degreeFn: (val) => val,
|
|
777
|
+
degreeUnit: '°',
|
|
778
|
+
degreeUnitSep: ''
|
|
779
|
+
},
|
|
780
|
+
imperial: {
|
|
781
|
+
speedFn: (val) => val / 1.609,
|
|
782
|
+
speedUnit: 'mih',
|
|
783
|
+
distanceFn: (val) => val / 1.609,
|
|
784
|
+
distanceUnit: 'mi',
|
|
785
|
+
areaFn: (val) => val / 2.59,
|
|
786
|
+
areaUnit: 'mi²',
|
|
787
|
+
degreeFn: (val) => val,
|
|
788
|
+
degreeUnit: '°',
|
|
789
|
+
degreeUnitSep: ''
|
|
790
|
+
},
|
|
791
|
+
nautical: {
|
|
792
|
+
speedFn: (val) => val / 1.852,
|
|
793
|
+
speedUnit: 'knot',
|
|
794
|
+
distanceFn: (val) => val / 1.852,
|
|
795
|
+
distanceUnit: 'nm',
|
|
796
|
+
areaFn: (val) => val / 2.92,
|
|
797
|
+
areaUnit: 'nm²',
|
|
798
|
+
degreeFn: (val) => val,
|
|
799
|
+
degreeUnit: '°',
|
|
800
|
+
degreeUnitSep: ''
|
|
801
|
+
}
|
|
802
|
+
}
|