bajo 2.7.2 → 2.8.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 +12 -7
- package/class/helper/base.js +2 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +11 -0
package/class/bajo.js
CHANGED
|
@@ -853,6 +853,7 @@ class Bajo extends Plugin {
|
|
|
853
853
|
*/
|
|
854
854
|
readConfig = async (file, { ns, pattern, globOptions = {}, ignoreError, defValue = {}, opts = {} } = {}) => {
|
|
855
855
|
const { parseObject } = this.app.lib
|
|
856
|
+
opts.readFromFile = true
|
|
856
857
|
if (!ns) ns = this.ns
|
|
857
858
|
file = resolvePath(this.getPluginFile(file))
|
|
858
859
|
let ext = path.extname(file)
|
|
@@ -862,7 +863,7 @@ class Bajo extends Plugin {
|
|
|
862
863
|
const { readHandler } = find(this.app.configHandlers, { ext })
|
|
863
864
|
return parseObject(await readHandler.call(this.app[ns], file, opts))
|
|
864
865
|
}
|
|
865
|
-
if (ext === '.json') return await this.fromJson(file,
|
|
866
|
+
if (ext === '.json') return await this.fromJson(file, opts)
|
|
866
867
|
if (!['', '.*'].includes(ext)) {
|
|
867
868
|
const item = find(this.app.configHandlers, { ext })
|
|
868
869
|
if (!item) {
|
|
@@ -885,7 +886,7 @@ class Bajo extends Plugin {
|
|
|
885
886
|
if (!ignoreError) throw this.error('cantParse%s', f, { code: 'BAJO_CONFIG_NO_PARSER' })
|
|
886
887
|
continue
|
|
887
888
|
}
|
|
888
|
-
config = await item.readHandler.call(this.app[ns], f,
|
|
889
|
+
config = await item.readHandler.call(this.app[ns], f, opts)
|
|
889
890
|
if (!isEmpty(config)) break
|
|
890
891
|
}
|
|
891
892
|
return parseObject(config)
|
|
@@ -911,14 +912,18 @@ class Bajo extends Plugin {
|
|
|
911
912
|
return parseObject(JSON.parse(resp))
|
|
912
913
|
}
|
|
913
914
|
|
|
914
|
-
fromJson (
|
|
915
|
-
const content =
|
|
915
|
+
fromJson (data, opts = {}) {
|
|
916
|
+
const content = opts.readFromFile ? fs.readFileSync(data, 'utf8') : data
|
|
916
917
|
return JSON.parse(content)
|
|
917
918
|
}
|
|
918
919
|
|
|
919
|
-
toJson = (
|
|
920
|
-
const content =
|
|
921
|
-
|
|
920
|
+
toJson = (data, opts = {}) => {
|
|
921
|
+
const content = JSON.stringify(data, null, omit(opts, ['writeToFile']))
|
|
922
|
+
if (opts.writeToFile) {
|
|
923
|
+
fs.writeFileSync(opts.saveAsFile, content, 'utf8')
|
|
924
|
+
return
|
|
925
|
+
}
|
|
926
|
+
return content
|
|
922
927
|
}
|
|
923
928
|
|
|
924
929
|
/**
|
package/class/helper/base.js
CHANGED
|
@@ -50,9 +50,9 @@ export async function checkNameAliases () {
|
|
|
50
50
|
const plugin = this.bajo.app[camelCase(pkg)]
|
|
51
51
|
const { ns, alias } = plugin
|
|
52
52
|
let item = find(refs, { ns })
|
|
53
|
-
if (item) throw this.error('pluginNameClash%s%s%s%s', ns, pkg, item.ns, item.pkg, { code: 'BAJO_NAME_CLASH' })
|
|
53
|
+
if (item) throw this.bajo.error('pluginNameClash%s%s%s%s', ns, pkg, item.ns, item.pkg, { code: 'BAJO_NAME_CLASH' })
|
|
54
54
|
item = find(refs, { alias })
|
|
55
|
-
if (item) throw this.error('pluginNameClash%s%s%s%s', alias, pkg, item.alias, item.pkg, { code: 'BAJO_ALIAS_CLASH' })
|
|
55
|
+
if (item) throw this.bajo.error('pluginNameClash%s%s%s%s', alias, pkg, item.alias, item.pkg, { code: 'BAJO_ALIAS_CLASH' })
|
|
56
56
|
refs.push({ ns, alias, pkg })
|
|
57
57
|
}
|
|
58
58
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-03-22
|
|
4
|
+
|
|
5
|
+
- [2.8.0] Add ```options.readFromFile``` in ```readConfig()```
|
|
6
|
+
- [2.8.0] Bug fix in ```readConfig()``` while reading ```json``` file
|
|
7
|
+
- [2.8.0] Bug fix in ```fromJson()```
|
|
8
|
+
- [2.8.0] Bug fix in ```toJson()```
|
|
9
|
+
|
|
10
|
+
## 2026-03-15
|
|
11
|
+
|
|
12
|
+
- [2.7.3] Bug fix in checking plugin dependency handler
|
|
13
|
+
|
|
3
14
|
## 2026-03-11
|
|
4
15
|
|
|
5
16
|
- [2.7.2] Bug fix in env dependent config building
|