bajo 1.0.5 → 1.0.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "packageNotFoundOrNotBajo%s": "Package '%s' not found or isn't a valid Bajo package",
3
3
  "unknownPluginOrNotLoaded%s": "Unknown plugin '%s' or plugin isn't loaded yet",
4
- "collectionExists%s": "Collection '%s' already exists",
4
+ "collExists%s": "Collection '%s' already exists",
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'",
@@ -132,5 +132,16 @@
132
132
  "applet": "Applet",
133
133
  "unsupported%s%s": "Unsupported %s '%s'",
134
134
  "error%": "Error: %s",
135
- "savedAs%%": "%s saved as '%s'"
135
+ "savedAs%%": "%s saved as '%s'",
136
+ "loaded%s": "Loaded %s",
137
+ "production": "production",
138
+ "staging": "staging",
139
+ "development": "development",
140
+ "unsupportedLangFallbackTo%s": "Unsupported language, fallback to '%s'",
141
+ "plugin%s": "%s plugin...",
142
+ "init": "Init",
143
+ "start": "Start",
144
+ "stop": "Stop",
145
+ "supportDisabled%s": "%s support is disabled",
146
+ "collect%s": "Collect %s"
136
147
  }
package/bajo/intl/id.json CHANGED
@@ -1,41 +1,41 @@
1
1
  {
2
- "packageNotFoundOrNotBajo%s": "Package '%s' not found or isn't a valid Bajo package",
3
- "unknownPluginOrNotLoaded%s": "Unknown plugin '%s' or plugin isn't loaded yet",
4
- "collectionExists%s": "Collection '%s' already exists",
5
- "cantLocateNpmGlobalDir": "Can't locate npm global module directory",
6
- "cantLocateGlobalDir%s": "Can't locate '%s' global module directory",
7
- "cantFindMethod%s": "Can't find method named '%s'",
8
- "pluginWithALiasNotLoaded%s": "Plugin with alias '%s' is not loaded",
9
- "cantFind%s": "Can't find %s",
10
- "dtUnparsable%s": "Date/time unparsable '%s'",
11
- "cantParse%s": "'Can't parse '%s'",
12
- "noConfigFileFound": "No config file found",
13
- "pluginNameClash%s%s%s%s": "Plugin name clash: '%s (%s)' with '%s (%s)'",
14
- "dependencyUnfulfilled%s%s": "Dependency for '%s' unfulfilled: %s",
15
- "semverCheckFailed%s%s": "Semver check '%s' against '%s' failed",
16
- "ddirNotExists%s": "Data directory '%s' doesn't exists!",
17
- "signalReceived%s": "'%s' signal received",
18
- "noAppletLoaded": "No applets loaded. Aborted!",
19
- "oneOrMoreSharedTheSame%s%s": "One or more %s shared the same '%s'",
20
- "bootCompleted%s": "Boot process completed in %s",
21
- "runInEnv%s": "Run in '%s' environment",
22
- "appRunningAsApplet": "App is running as applet...",
23
- "setupBootOrder": "Setup boot order",
2
+ "packageNotFoundOrNotBajo%s": "Paket '%s' tidak ditemukan atau bukan sebuah paket Bajo yang valid",
3
+ "unknownPluginOrNotLoaded%s": "Plugin '%s' tidak dikenal atau plugin belum termuat",
4
+ "collExists%s": "Koleksi '%s' sudah ada",
5
+ "cantLocateNpmGlobalDir": "Tidak bisa menentukan direktori global npm",
6
+ "cantLocateGlobalDir%s": "Tidak bisa menentukan direktori global modul '%s'",
7
+ "cantFindMethod%s": "Tidak menemukan metode dengan nama '%s'",
8
+ "pluginWithALiasNotLoaded%s": "Plugin dengan alias '%s' tidak termuat",
9
+ "cantFind%s": "Tidak bisa menemukan %s",
10
+ "dtUnparsable%s": "Tanggal/waktu tidak bisa di parsing '%s'",
11
+ "cantParse%s": "'Tidak bisa memparsing '%s'",
12
+ "noConfigFileFound": "Tidak ditemukan berkas konfigurasi satupun",
13
+ "pluginNameClash%s%s%s%s": "Bentrokan nama plugin: '%s (%s)' dengan '%s (%s)'",
14
+ "dependencyUnfulfilled%s%s": "Ketergantungan untuk '%s' tidak terpenuhi: %s",
15
+ "semverCheckFailed%s%s": "Cek Semver '%s' terhadap '%s' gagal",
16
+ "ddirNotExists%s": "Direktori data '%s' tidak ada!",
17
+ "signalReceived%s": "Sinyal '%s' diterima",
18
+ "noAppletLoaded": "Tidak ada applet yang termuat. Batalkan!",
19
+ "oneOrMoreSharedTheSame%s%s": "Satu atau lebih %s berbagi '%s'",
20
+ "bootCompleted%s": "Proses booting komplit dalam %s",
21
+ "runInEnv%s": "Berjalan di lingkungan '%s'",
22
+ "appRunningAsApplet": "App berjalan sebagai applet...",
23
+ "setupBootOrder": "Atur urutan booting",
24
24
  "configHandlers%s": "Pengatur konfigurasi: %s",
25
25
  "exited": "Exited",
26
- "appShutdown": "App shutdown",
27
- "appletModeActivated": "Applet mode activated",
28
- "collected%s%d": "%s collected: %d",
29
- "attachMethods": "Attach methods",
30
- "readConfigs": "Read configurations",
31
- "checkAliasNameClash": "Checking alias & name clashes",
32
- "checkDeps": "Checking dependencies",
33
- "collectHooks": "Collect hooks",
34
- "loadedPlugins%s": "Loaded plugins: %s",
35
- "collecting%s": "Collecting %s",
36
- "hookExecuted%s": "Hook '%s' executed",
37
- "exitHandlers%s": "Exit handlers: %s",
38
- "savedAs%s": "Saved as '%s'",
26
+ "appShutdown": "Aplikasi ditutup",
27
+ "appletModeActivated": "Mode applet diaktifkan",
28
+ "collected%s%d": "%s terkoleksi: %d",
29
+ "attachMethods": "Tempelkan metode",
30
+ "readConfigs": "Baca konfigurasi",
31
+ "checkAliasNameClash": "Cek bentrokan nama dan alias",
32
+ "checkDeps": "Cek ketergantungan",
33
+ "collectHooks": "Kumpulkan Hooks",
34
+ "loadedPlugins%s": "Plugin termuat: %s",
35
+ "collecting%s": "Mengumpulkan %s",
36
+ "hookExecuted%s": "Hook '%s' dieksekusi",
37
+ "exitHandlers%s": "Penanganan keluar: %s",
38
+ "savedAs%s": "Simpan sbg '%s'",
39
39
  "aborted": "Dibatalkan",
40
40
  "done": "Selesai",
41
41
  "error": "Kesalahan",
@@ -132,5 +132,16 @@
132
132
  "applet": "Applet",
133
133
  "unsupported%s%s": "%s '%s' tidak didukung",
134
134
  "error%": "Kesalahan: %s",
135
- "savedAs%%": "%s disimpan sbg '%s'"
135
+ "savedAs%%": "%s disimpan sbg '%s'",
136
+ "loaded%s": "%s termuat",
137
+ "production": "produksi",
138
+ "staging": "pemanggungan",
139
+ "development": "pengembangan",
140
+ "unsupportedLangFallbackTo%s": "Bahasa tidak didukung, gunakan '%s'",
141
+ "plugin%s": "%s plugin...",
142
+ "init": "Inisiasi",
143
+ "start": "Jalankan",
144
+ "stop": "Berhentikan",
145
+ "supportDisabled%s": "Dukungan %s dimatikan",
146
+ "collect%s": "Koleksi %s"
136
147
  }
@@ -28,7 +28,7 @@ async function bootOrder () {
28
28
  result.push(item)
29
29
  })
30
30
  this.pluginPkgs = map(orderBy(result, ['v']), 'k')
31
- this.log.info('runInEnv%s', this.envs[this.config.env])
31
+ this.log.info('runInEnv%s', this.print.write(this.envs[this.config.env]))
32
32
  // misc
33
33
  this.freeze(this.config)
34
34
  }
@@ -17,7 +17,7 @@ async function buildCollections (options = {}) {
17
17
  const item = items[index]
18
18
  if (useDefaultName) {
19
19
  if (!has(item, 'name')) {
20
- if (find(items, { name: 'default' })) throw this.app[ns].error('collectionExists%s', 'default')
20
+ if (find(items, { name: 'default' })) throw this.app[ns].error('collExists%s', 'default')
21
21
  else item.name = 'default'
22
22
  }
23
23
  }
@@ -1,6 +1,6 @@
1
1
  const envs = {
2
2
  dev: 'development',
3
- staging: 'Staging',
3
+ staging: 'staging',
4
4
  prod: 'production'
5
5
  }
6
6
 
@@ -1,7 +1,7 @@
1
- function format (value, type, lang, options = {}) {
2
- const { defaultsDeep } = this.app.bajo
1
+ function format (value, type, options = {}) {
3
2
  const { format } = this.config.intl
4
3
  const { emptyValue = format.emptyValue } = options
4
+ const lang = options.lang ?? this.config.lang
5
5
  if ([undefined, null, ''].includes(value)) return emptyValue
6
6
  if (type === 'auto') {
7
7
  if (value instanceof Date) type = 'datetime'
@@ -9,7 +9,7 @@ function format (value, type, lang, options = {}) {
9
9
  if (['integer', 'smallint'].includes(type)) {
10
10
  value = parseInt(value)
11
11
  if (isNaN(value)) return emptyValue
12
- const setting = defaultsDeep(options.integer, format.integer)
12
+ const setting = this.defaultsDeep(options.integer, format.integer)
13
13
  return new Intl.NumberFormat(lang, setting).format(value)
14
14
  }
15
15
  if (['float', 'double'].includes(type)) {
@@ -17,15 +17,15 @@ function format (value, type, lang, options = {}) {
17
17
  if (isNaN(value)) return emptyValue
18
18
  if (this.app.bajoSpatial && options.latitude) return this.app.bajoSpatial.latToDms(value)
19
19
  if (this.app.bajoSpatial && options.longitude) return this.app.bajoSpatial.lngToDms(value)
20
- const setting = defaultsDeep(options.float, format.float)
20
+ const setting = this.defaultsDeep(options.float, format.float)
21
21
  return new Intl.NumberFormat(lang, setting).format(value)
22
22
  }
23
23
  if (['datetime', 'date'].includes(type)) {
24
- const setting = defaultsDeep(options[type], format[type])
24
+ const setting = this.defaultsDeep(options[type], format[type])
25
25
  return new Intl.DateTimeFormat(lang, setting).format(new Date(value))
26
26
  }
27
27
  if (['time'].includes(type)) {
28
- const setting = defaultsDeep(options.time, format.time)
28
+ const setting = this.defaultsDeep(options.time, format.time)
29
29
  return new Intl.DateTimeFormat(lang, setting).format(new Date(`1970-01-01T${value}Z`))
30
30
  }
31
31
  if (['array'].includes(type)) return value.join(', ')
@@ -50,11 +50,12 @@ class BajoPlugin extends Plugin {
50
50
  this.config = omit(cfg, ['title', 'dependencies'])
51
51
  }
52
52
 
53
- async _onoff (item, text, ...args) {
53
+ async _onoff (item, ...args) {
54
54
  this.state[item] = false
55
55
  const { runHook, importModule } = this.app.bajo
56
56
  const mod = await importModule(`${this.dir.pkg}/bajo/${item}.js`)
57
57
  if (mod) {
58
+ const text = this.print.write('plugin%s', this.print.write(item))
58
59
  this.log.trace(text)
59
60
  await runHook(`${this.name}:${camelCase(`before ${item}`)}`)
60
61
  await mod.call(this, ...args)
@@ -64,17 +65,17 @@ class BajoPlugin extends Plugin {
64
65
  }
65
66
 
66
67
  async init () {
67
- await this._onoff('init', 'Init plugin...')
68
+ await this._onoff('init')
68
69
  }
69
70
 
70
71
  async start (...args) {
71
72
  const { freeze } = this.app.bajo
72
73
  freeze(this.config)
73
- await this._onoff('start', 'Start plugin...', ...args)
74
+ await this._onoff('start', ...args)
74
75
  }
75
76
 
76
77
  async stop () {
77
- await this._onoff('stop', 'Stop plugin...')
78
+ await this._onoff('stop')
78
79
  }
79
80
  }
80
81
 
@@ -8,7 +8,7 @@ class BajoError {
8
8
  this.plugin = plugin
9
9
  this.payload = args.length > 0 && isPlainObject(args[args.length - 1]) ? args[args.length - 1] : {}
10
10
  this.orgMessage = msg
11
- this.message = this.plugin.print.write(msg, ...args)
11
+ this.message = plugin.print.write(msg, ...args)
12
12
  this.write()
13
13
  }
14
14
 
package/boot/class/log.js CHANGED
@@ -17,8 +17,7 @@ class Log {
17
17
  }
18
18
 
19
19
  write (text, ...args) {
20
- const lang = this.plugin.app.bajo.config.lang
21
- return this.plugin.print.write(text, lang, ...args)
20
+ return this.plugin.print.write(text, ...args)
22
21
  }
23
22
 
24
23
  isExtLogger () {
@@ -4,8 +4,9 @@ import defaultsDeep from './bajo-core/method/defaults-deep.js'
4
4
  import fs from 'fs-extra'
5
5
  import Sprintf from 'sprintf-js'
6
6
  const { sprintf } = Sprintf
7
+ let unknownLangWarning = false
7
8
 
8
- const { isPlainObject, get, without, reverse } = lodash
9
+ const { last, isPlainObject, get, without, reverse } = lodash
9
10
 
10
11
  class Print {
11
12
  constructor (plugin, opts = {}) {
@@ -29,8 +30,18 @@ class Print {
29
30
  }
30
31
  }
31
32
 
32
- write (text, lang, ...args) {
33
- const fallback = this.plugin.app.bajo.config.intl.fallback
33
+ write (text, ...args) {
34
+ const opts = last(args)
35
+ let lang = this.plugin.app.bajo.config.lang
36
+ if (isPlainObject(opts)) {
37
+ args.pop()
38
+ lang = opts.lang
39
+ }
40
+ const { fallback, supported } = this.plugin.app.bajo.config.intl
41
+ if (!unknownLangWarning && !supported.includes(lang)) {
42
+ unknownLangWarning = true
43
+ this.plugin.app.bajo.log.warn('unsupportedLangFallbackTo%s', fallback)
44
+ }
34
45
  const plugins = reverse(without([...this.plugin.app.bajo.pluginNames], this.plugin.name))
35
46
  plugins.unshift(this.plugin.name)
36
47
  plugins.push('bajo')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {