bajo 1.2.4 → 1.2.6

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.
@@ -2,7 +2,7 @@ import lodash from 'lodash'
2
2
  import fs from 'fs-extra'
3
3
  import resolvePath from '../../lib/resolve-path.js'
4
4
 
5
- const { isString, filter, map, trim, without, uniq, camelCase, isEmpty } = lodash
5
+ const { isString, filter, map, trim, without, uniq, camelCase, isEmpty, omit } = lodash
6
6
 
7
7
  async function buildPlugins () {
8
8
  let pluginPkgs = this.config.plugins ?? []
@@ -38,7 +38,7 @@ async function buildPlugins () {
38
38
  this.pluginNames.push(plugin.name)
39
39
  this.app.addPlugin(plugin)
40
40
  }
41
- delete this.config.plugins
41
+ this.config = omit(this.config, this.pluginNames)
42
42
  }
43
43
 
44
44
  export default buildPlugins
@@ -13,6 +13,7 @@ class BajoPlugin extends Plugin {
13
13
 
14
14
  loadConfig = async () => {
15
15
  const { defaultsDeep } = this.lib.aneka
16
+ const { get } = this.lib._
16
17
  const { log, readJson, parseObject, getModuleDir } = this.app.bajo
17
18
  log.trace('- %s', this.name)
18
19
  const dir = this.name === this.app.bajo.mainNs ? (`${this.app.bajo.dir.base}/${this.app.bajo.mainNs}`) : getModuleDir(this.pkgName)
@@ -37,7 +38,9 @@ class BajoPlugin extends Plugin {
37
38
  const altCfg = await readAllConfigs.call(this.app, `${this.app.bajo.dir.data}/config/${this.name}`)
38
39
  cfg = defaultsDeep({}, omit(altCfg, omittedPluginKeys), cfg)
39
40
  } catch (err) {}
40
- const envArgv = defaultsDeep({}, omit(this.app.env[this.name] ?? {}, omittedPluginKeys) ?? {}, omit(this.app.argv[this.name] ?? {}, omittedPluginKeys) ?? {})
41
+ const cfgEnv = omit(get(this, `app.env._.${this.name}`, {}), omittedPluginKeys) ?? {}
42
+ const cfgArgv = omit(get(this, `app.argv._.${this.name}`, {}), omittedPluginKeys) ?? {}
43
+ const envArgv = defaultsDeep({}, cfgEnv, cfgArgv)
41
44
  cfg = defaultsDeep({}, envArgv ?? {}, cfg ?? {}, this.config ?? {})
42
45
  this.title = this.title ?? cfg.title ?? this.alias
43
46
 
@@ -46,7 +46,7 @@ class Plugin {
46
46
  }
47
47
 
48
48
  getConfig = (path, options = {}) => {
49
- let obj = isEmpty(path) ? this.config : get(this.config, path, options.defValue)
49
+ let obj = isEmpty(path) ? this.config : get(this.config, path, options.defValue ?? {})
50
50
  options.omit = options.omit ?? omittedPluginKeys
51
51
  if (isPlainObject(obj) && !isEmpty(options.omit)) obj = omit(obj, options.omit)
52
52
  if (!options.noclone) obj = cloneDeep(obj)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {