bajo 1.0.7 → 1.0.9

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.
@@ -5,7 +5,7 @@
5
5
  "cantLocateNpmGlobalDir": "Can't locate npm global module directory",
6
6
  "cantLocateGlobalDir%s": "Can't locate '%s' global module directory",
7
7
  "cantFindMethod%s": "Can't find method named '%s'",
8
- "pluginWithALiasNotLoaded%s": "Plugin with alias '%s' is not loaded",
8
+ "pluginWithAliasNotLoaded%s": "Plugin with alias '%s' is not loaded",
9
9
  "cantFind%s": "Can't find %s",
10
10
  "dtUnparsable%s": "Date/time unparsable '%s'",
11
11
  "cantParse%s": "'Can't parse '%s'",
@@ -143,5 +143,9 @@
143
143
  "start": "Start",
144
144
  "stop": "Stop",
145
145
  "supportDisabled%s": "%s support is disabled",
146
- "collect%s": "Collect %s"
146
+ "collect%s": "Collect %s",
147
+ "andL": "and",
148
+ "orL": "or",
149
+ "noneL": "none",
150
+ "isRequired%s": "'%s' is required"
147
151
  }
package/bajo/intl/id.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "cantLocateNpmGlobalDir": "Tidak bisa menentukan direktori global npm",
6
6
  "cantLocateGlobalDir%s": "Tidak bisa menentukan direktori global modul '%s'",
7
7
  "cantFindMethod%s": "Tidak menemukan metode dengan nama '%s'",
8
- "pluginWithALiasNotLoaded%s": "Plugin dengan alias '%s' tidak termuat",
8
+ "pluginWithAliasNotLoaded%s": "Plugin dengan alias '%s' tidak termuat",
9
9
  "cantFind%s": "Tidak bisa menemukan %s",
10
10
  "dtUnparsable%s": "Tanggal/waktu tidak bisa di parsing '%s'",
11
11
  "cantParse%s": "'Tidak bisa memparsing '%s'",
@@ -143,5 +143,8 @@
143
143
  "start": "Jalankan",
144
144
  "stop": "Berhentikan",
145
145
  "supportDisabled%s": "Dukungan %s dimatikan",
146
- "collect%s": "Koleksi %s"
146
+ "collect%s": "Koleksi %s",
147
+ "andL": "dan",
148
+ "orL": "atau",
149
+ "noneL": "kosong"
147
150
  }
@@ -25,10 +25,9 @@ async function exitHandler () {
25
25
  })
26
26
 
27
27
  process.on('uncaughtException', (error, origin) => {
28
- if (this.config.log.report.includes('sys:uncaughtException')) this.log.fatal({ origin }, '%s', error.message)
29
28
  setTimeout(() => {
30
29
  console.error(error)
31
- process.exit(1)
30
+ // process.exit(1)
32
31
  }, 50)
33
32
  })
34
33
 
@@ -0,0 +1,14 @@
1
+ function extractText (text, start, end) {
2
+ let result = ''
3
+ const open = text.indexOf(start)
4
+ if (open > -1) {
5
+ text = text.slice(open + end.length)
6
+ const close = text.indexOf(end)
7
+ if (close > -1) {
8
+ result = text.slice(0, close)
9
+ }
10
+ }
11
+ return result
12
+ }
13
+
14
+ export default extractText
@@ -13,7 +13,7 @@ function getPlugin (name, silent) {
13
13
  }
14
14
  if (!plugin) {
15
15
  if (silent) return false
16
- throw this.error('pluginWithALiasNotLoaded%s', name)
16
+ throw this.error('pluginWithAliasNotLoaded%s', name)
17
17
  }
18
18
  name = plugin.name
19
19
  }
@@ -4,12 +4,15 @@ import isSet from './is-set.js'
4
4
  const { isPlainObject } = lodash
5
5
 
6
6
  function join (array, sep) {
7
- const isI18n = this && this.app && this.app.bajoI18N
8
- if (array.length === 0) return isI18n ? this.app.bajoI18N.t('none') : 'none'
7
+ const translate = val => {
8
+ if (this && this.print) return this.print.write(val)
9
+ return val
10
+ }
11
+ if (array.length === 0) return translate('noneL')
9
12
  if (array.length === 1) return array[0]
10
13
  if (isSet(sep) && !isPlainObject(sep)) return array.join(sep)
11
- let { separator = ', ', joiner = 'and' } = sep ?? {}
12
- if (isI18n && this.app.bajoI18N.t) joiner = this.app.bajoI18N.t(joiner)
14
+ let { separator = ', ', joiner = 'andL' } = sep ?? {}
15
+ joiner = translate(joiner)
13
16
  const last = (array.pop() ?? '').trim()
14
17
  return array.map(a => (a + '').trim()).join(separator) + ` ${joiner} ${last}`
15
18
  }
@@ -42,11 +42,9 @@ function parseObject (input, { silent = true, parseValue = false, lang, ns } = {
42
42
  const scope = ns ? me.app[ns] : me
43
43
  let [text, ...args] = v.split('|')
44
44
  args = args.map(a => {
45
- // if (a.slice(0, 2) === 't:') a = translate.call(scope, i18n, a.slice(2))
46
45
  if (a.slice(0, 2) === 't:') a = scope.print.write(lang, a.slice(2))
47
46
  return a
48
47
  })
49
- // obj[newK] = translate.call(scope, i18n, text, ...args)
50
48
  obj[newK] = scope.print.write(text, lang, ...args)
51
49
  } else obj[newK] = v
52
50
  mutated.push(k)
@@ -6,7 +6,7 @@ import readJson from './bajo-core/method/read-json.js'
6
6
  import lodash from 'lodash'
7
7
  const { isFunction } = lodash
8
8
 
9
- async function defConfigHandler (file, opts) {
9
+ async function defConfigHandler (file, opts = {}) {
10
10
  let mod = await importModule(file)
11
11
  if (isFunction(mod)) mod = await mod.call(this, opts)
12
12
  return mod
@@ -48,7 +48,7 @@ class BajoError {
48
48
  const val = get(v, 'context.value')
49
49
  value[i] = {
50
50
  field,
51
- error: print.write(`validation.${v.type}`, v.context),
51
+ error: print.write(`validation.${v.type}`, v.context ?? {}, {}),
52
52
  value: val,
53
53
  ext: { type: v.type, context: v.context }
54
54
  }
@@ -35,7 +35,7 @@ class Print {
35
35
  let lang = this.plugin.app.bajo.config.lang
36
36
  if (isPlainObject(opts)) {
37
37
  args.pop()
38
- lang = opts.lang
38
+ if (opts.lang) lang = opts.lang
39
39
  }
40
40
  const { fallback, supported } = this.plugin.app.bajo.config.intl
41
41
  if (!unknownLangWarning && !supported.includes(lang)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {