bajo 1.0.5 → 1.0.7
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/bajo/intl/en-US.json +13 -2
- package/bajo/intl/id.json +47 -36
- package/boot/class/bajo-core/helper/boot-order.js +1 -1
- package/boot/class/bajo-core/method/build-collections.js +1 -1
- package/boot/class/bajo-core/method/envs.js +1 -1
- package/boot/class/bajo-core/method/format.js +6 -6
- package/boot/class/bajo-plugin.js +5 -4
- package/boot/class/error.js +1 -1
- package/boot/class/log.js +1 -2
- package/boot/class/print.js +19 -4
- package/package.json +1 -1
package/bajo/intl/en-US.json
CHANGED
|
@@ -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
|
-
"
|
|
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": "
|
|
3
|
-
"unknownPluginOrNotLoaded%s": "
|
|
4
|
-
"
|
|
5
|
-
"cantLocateNpmGlobalDir": "
|
|
6
|
-
"cantLocateGlobalDir%s": "
|
|
7
|
-
"cantFindMethod%s": "
|
|
8
|
-
"pluginWithALiasNotLoaded%s": "Plugin
|
|
9
|
-
"cantFind%s": "
|
|
10
|
-
"dtUnparsable%s": "
|
|
11
|
-
"cantParse%s": "'
|
|
12
|
-
"noConfigFileFound": "
|
|
13
|
-
"pluginNameClash%s%s%s%s": "
|
|
14
|
-
"dependencyUnfulfilled%s%s": "
|
|
15
|
-
"semverCheckFailed%s%s": "Semver
|
|
16
|
-
"ddirNotExists%s": "
|
|
17
|
-
"signalReceived%s": "'%s'
|
|
18
|
-
"noAppletLoaded": "
|
|
19
|
-
"oneOrMoreSharedTheSame%s%s": "
|
|
20
|
-
"bootCompleted%s": "
|
|
21
|
-
"runInEnv%s": "
|
|
22
|
-
"appRunningAsApplet": "App
|
|
23
|
-
"setupBootOrder": "
|
|
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": "
|
|
27
|
-
"appletModeActivated": "
|
|
28
|
-
"collected%s%d": "%s
|
|
29
|
-
"attachMethods": "
|
|
30
|
-
"readConfigs": "
|
|
31
|
-
"checkAliasNameClash": "
|
|
32
|
-
"checkDeps": "
|
|
33
|
-
"collectHooks": "
|
|
34
|
-
"loadedPlugins%s": "
|
|
35
|
-
"collecting%s": "
|
|
36
|
-
"hookExecuted%s": "Hook '%s'
|
|
37
|
-
"exitHandlers%s": "
|
|
38
|
-
"savedAs%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('
|
|
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,7 +1,7 @@
|
|
|
1
|
-
function format (value, type,
|
|
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,
|
|
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'
|
|
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',
|
|
74
|
+
await this._onoff('start', ...args)
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
async stop () {
|
|
77
|
-
await this._onoff('stop'
|
|
78
|
+
await this._onoff('stop')
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
package/boot/class/error.js
CHANGED
|
@@ -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 =
|
|
11
|
+
this.message = plugin.print.write(msg, ...args)
|
|
12
12
|
this.write()
|
|
13
13
|
}
|
|
14
14
|
|
package/boot/class/log.js
CHANGED
package/boot/class/print.js
CHANGED
|
@@ -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 { isString, last, isPlainObject, get, without, reverse, map } = 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,
|
|
33
|
-
const
|
|
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')
|
|
@@ -49,7 +60,11 @@ class Print {
|
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
62
|
if (!trans) trans = text
|
|
52
|
-
|
|
63
|
+
const params = map(args, a => {
|
|
64
|
+
if (!isString(a)) return a
|
|
65
|
+
return a.replaceAll('%', '%%')
|
|
66
|
+
})
|
|
67
|
+
return sprintf(trans, ...params)
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
setOpts (args = []) {
|