bajo 0.2.26 → 0.2.28

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.
@@ -30,9 +30,9 @@ function formatErrorDetails (value, ns) {
30
30
  const val = get(v, 'context.value')
31
31
  value[i] = {
32
32
  field,
33
- error: print.__(`validation.${v.type}`, v.context, { ns })
33
+ error: print.__(`validation.${v.type}`, v.context, { ns }),
34
+ value: val
34
35
  }
35
- result[field] = val
36
36
  })
37
37
  return result
38
38
  }
@@ -4,6 +4,8 @@ import ms from 'ms'
4
4
  import dayjs from '../lib/dayjs.js'
5
5
  import isSet from './is-set.js'
6
6
 
7
+ const statics = ['*']
8
+
7
9
  function parseDur (val) {
8
10
  return isNumber(val) ? val : ms(val)
9
11
  }
@@ -22,11 +24,17 @@ function parseObject (obj, silent = true, parseValue = false) {
22
24
  else if (isArray(v)) {
23
25
  v.forEach((i, idx) => {
24
26
  if (isPlainObject(i)) obj[k][idx] = parseObject(i)
27
+ else if (statics.includes(i)) obj[k][idx] = i
25
28
  else if (parseValue) obj[k][idx] = dotenvParseVariables(set({}, 'item', obj[k][idx]), { assignToProcessEnv: false }).item
29
+ if (isArray(obj[k][idx])) obj[k][idx] = obj[k][idx].map(item => typeof item === 'string' ? item.trim() : item)
26
30
  })
27
31
  } else if (isSet(v)) {
28
32
  try {
29
- if (parseValue) obj[k] = dotenvParseVariables(set({}, 'item', v), { assignToProcessEnv: false }).item
33
+ if (statics.includes(v)) obj[k] = v
34
+ else if (parseValue) {
35
+ obj[k] = dotenvParseVariables(set({}, 'item', v), { assignToProcessEnv: false }).item
36
+ if (isArray(obj[k])) obj[k] = obj[k].map(item => typeof item === 'string' ? item.trim() : item)
37
+ }
30
38
  if (k.slice(-3) === 'Dur') obj[k] = parseDur(v)
31
39
  if (k.slice(-2) === 'Dt') obj[k] = parseDt(v)
32
40
  } catch (err) {
package/boot/run-tool.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { isString, map, find } from 'lodash-es'
2
+ import Path from 'path'
2
3
  const tools = []
3
4
 
4
5
  async function runTool () {
@@ -27,8 +28,14 @@ async function runTool () {
27
28
  if (!tool) print.fatal('Sidetool \'%s\' not found. Aborted!', name)
28
29
  const opts = { ns, toc, path, params, args: config.args }
29
30
  const mod = await importModule(tool.file)
30
- const handler = mod.handler ?? mod
31
- await handler.call(this, opts)
31
+ if (mod === 'defCliHandler' && this.bajoCli) {
32
+ const { runToolMethod } = this.bajoCli.helper
33
+ const dir = `${Path.dirname(tool.file)}/tool`
34
+ await runToolMethod({ path, args: config.args, dir })
35
+ } else {
36
+ const handler = mod.handler ?? mod
37
+ await handler.call(this, opts)
38
+ }
32
39
  }
33
40
 
34
41
  export default runTool
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {