bajo 2.7.3 → 2.9.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/bajo.js CHANGED
@@ -225,6 +225,7 @@ class Bajo extends Plugin {
225
225
  * @returns {Object[]} The collection
226
226
  */
227
227
  buildCollections = async (options = {}) => {
228
+ const { parseObject } = this.app.lib
228
229
  let { ns, handler, dupChecks = [], container, useDefaultName = true, noDefault = true } = options
229
230
  if (!ns) ns = this.ns
230
231
  const cfg = this.app[ns].getConfig()
@@ -244,7 +245,7 @@ class Bajo extends Plugin {
244
245
  await this.runHook(`${ns}:beforeBuildCollection`, container)
245
246
  const deleted = []
246
247
  for (const index in items) {
247
- const item = items[index]
248
+ const item = parseObject(items[index])
248
249
  if (useDefaultName) {
249
250
  if (!has(item, 'name')) {
250
251
  if (find(items, { name: 'default' })) throw this.app[ns].error('collExists%s', 'default')
@@ -853,6 +854,7 @@ class Bajo extends Plugin {
853
854
  */
854
855
  readConfig = async (file, { ns, pattern, globOptions = {}, ignoreError, defValue = {}, opts = {} } = {}) => {
855
856
  const { parseObject } = this.app.lib
857
+ opts.readFromFile = true
856
858
  if (!ns) ns = this.ns
857
859
  file = resolvePath(this.getPluginFile(file))
858
860
  let ext = path.extname(file)
@@ -862,7 +864,7 @@ class Bajo extends Plugin {
862
864
  const { readHandler } = find(this.app.configHandlers, { ext })
863
865
  return parseObject(await readHandler.call(this.app[ns], file, opts))
864
866
  }
865
- if (ext === '.json') return await this.fromJson(file, null)
867
+ if (ext === '.json') return await this.fromJson(file, opts)
866
868
  if (!['', '.*'].includes(ext)) {
867
869
  const item = find(this.app.configHandlers, { ext })
868
870
  if (!item) {
@@ -885,7 +887,7 @@ class Bajo extends Plugin {
885
887
  if (!ignoreError) throw this.error('cantParse%s', f, { code: 'BAJO_CONFIG_NO_PARSER' })
886
888
  continue
887
889
  }
888
- config = await item.readHandler.call(this.app[ns], f, undefined, opts)
890
+ config = await item.readHandler.call(this.app[ns], f, opts)
889
891
  if (!isEmpty(config)) break
890
892
  }
891
893
  return parseObject(config)
@@ -911,14 +913,18 @@ class Bajo extends Plugin {
911
913
  return parseObject(JSON.parse(resp))
912
914
  }
913
915
 
914
- fromJson (file, isContent) {
915
- const content = isContent ? file : fs.readFileSync(file, 'utf8')
916
+ fromJson (data, opts = {}) {
917
+ const content = opts.readFromFile ? fs.readFileSync(data, 'utf8') : data
916
918
  return JSON.parse(content)
917
919
  }
918
920
 
919
- toJson = (file, isContent, opts = 2) => {
920
- const content = isContent ? file : JSON.parse(fs.readFileSync(file, 'utf8'))
921
- return JSON.stringify(content, null, opts)
921
+ toJson = (data, opts = {}) => {
922
+ const content = JSON.stringify(data, null, omit(opts, ['writeToFile']))
923
+ if (opts.writeToFile) {
924
+ fs.writeFileSync(opts.saveAsFile, content, 'utf8')
925
+ return
926
+ }
927
+ return content
922
928
  }
923
929
 
924
930
  /**
package/class/plugin.js CHANGED
@@ -176,6 +176,16 @@ class Plugin {
176
176
  }
177
177
  }
178
178
 
179
+ /**
180
+ * Alias to ```this.app.dump()```
181
+ *
182
+ * @param {...any} args
183
+ * @returns
184
+ */
185
+ dump = (...args) => {
186
+ this.app.dump(...args)
187
+ }
188
+
179
189
  /**
180
190
  * Dispose internal references
181
191
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "2.7.3",
3
+ "version": "2.9.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,17 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-03-25
4
+
5
+ - [2.9.0] Add ```dump()``` now available through out plugins
6
+ - [2.9.0] Bug fix in ```buildCollections()```, now items to be collected are parsed with ```aneka.parseObject()```
7
+
8
+ ## 2026-03-22
9
+
10
+ - [2.8.0] Add ```options.readFromFile``` in ```readConfig()```
11
+ - [2.8.0] Bug fix in ```readConfig()``` while reading ```json``` file
12
+ - [2.8.0] Bug fix in ```fromJson()```
13
+ - [2.8.0] Bug fix in ```toJson()```
14
+
3
15
  ## 2026-03-15
4
16
 
5
17
  - [2.7.3] Bug fix in checking plugin dependency handler