bajo 2.3.1 → 2.4.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/class/app.js CHANGED
@@ -264,6 +264,8 @@ class App {
264
264
  */
265
265
  boot = async () => {
266
266
  this.bajo = new Bajo(this)
267
+ this.bajo.hooks.push(...(this.options.hooks ?? []))
268
+ delete this.options.hooks
267
269
  // argv/args/env
268
270
  const { parseArgsArgv, parseEnv, secToHms } = this.lib.aneka
269
271
  const { parseObject } = this.lib
@@ -273,6 +275,7 @@ class App {
273
275
  this.argv = parseObject(argv, { parseValue: true })
274
276
  this.envVars = parseObject(parseEnv(), { parseValue: true })
275
277
  this.applet = this.envVars._.applet ?? this.argv._.applet
278
+ await this.bajo.runHook('bajo:beforeBoot')
276
279
  await this.bajo.init()
277
280
  // boot complete
278
281
  const elapsed = new Date() - this.runAt
@@ -285,7 +288,7 @@ class App {
285
288
  * @see {@tutorial hook}
286
289
  * @see App#boot
287
290
  */
288
- await this.bajo.runHook('bajo:afterBootCompleted')
291
+ await this.bajo.runHook('bajo:afterBoot')
289
292
  if (this.applet) await runAsApplet.call(this.bajo)
290
293
  return this
291
294
  }
package/class/bajo.js CHANGED
@@ -60,6 +60,8 @@ class Bajo extends Plugin {
60
60
  { ext: '.js', readHandler: this._defConfigHandler },
61
61
  { ext: '.json', readHandler: this.fromJson, writeHandler: this.toJson }
62
62
  ]
63
+
64
+ this.hooks = []
63
65
  }
64
66
 
65
67
  async _defConfigHandler (file, opts = {}) {
@@ -969,13 +971,15 @@ class Bajo extends Plugin {
969
971
  const results = []
970
972
  for (const i in fns) {
971
973
  const fn = fns[i]
972
- const scope = this.app[fn.src]
973
- const res = await fn.handler.call(scope, ...args)
974
- results.push({
975
- hook: hookName,
976
- resp: res
977
- })
978
- if (this.config.log.traceHook) scope.log.trace('hookExecuted%s', hookName)
974
+ const scope = this.app[fn.src ?? 'main']
975
+ if (fn.noWait) fn.handler.call(scope, ...args)
976
+ else {
977
+ const res = await fn.handler.call(scope, ...args)
978
+ results.push({
979
+ hook: hookName,
980
+ resp: res
981
+ })
982
+ }
979
983
  }
980
984
  return results
981
985
  }
@@ -101,7 +101,6 @@ export async function checkDependencies () {
101
101
  export async function collectHooks () {
102
102
  const { eachPlugins, runHook, isLogInRange, importModule, breakNsPathFromFile } = this.bajo
103
103
  const me = this
104
- me.bajo.hooks = this.bajo.hooks ?? []
105
104
  me.bajo.log.trace('collecting%s', this.t('hooks'))
106
105
  // collects
107
106
  await eachPlugins(async function ({ dir, file }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "The ultimate framework for whipping up massive apps in no time",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-01-29
4
+
5
+ - [2.4.0] Hooks can now be added through ```config``` object. This is specially usefull if you provide a custom config object on app boot
6
+
7
+ ## 2026-01-24
8
+
9
+ - [2.3.2] Hook now can be executed without waiting if property ```noWait``` is ```true```
10
+
3
11
  ## 2026-01-21
4
12
 
5
13
  - [2.3.1] Bug fix on keys that needs to be used while reading plugin's config files