bajo 1.0.3 → 1.0.5

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.
Files changed (57) hide show
  1. package/bajo/intl/en-US.json +136 -0
  2. package/bajo/intl/id.json +136 -0
  3. package/boot/class/app.js +4 -3
  4. package/boot/class/bajo-core/helper/attach-method.js +3 -2
  5. package/boot/class/bajo-core/helper/boot-order.js +6 -4
  6. package/boot/class/bajo-core/helper/build-config.js +18 -3
  7. package/boot/class/bajo-core/helper/build-plugins.js +3 -1
  8. package/boot/class/bajo-core/helper/collect-config-handlers.js +2 -1
  9. package/boot/class/bajo-core/helper/exit-handler.js +3 -3
  10. package/boot/class/bajo-core/helper/run-as-applet.js +4 -4
  11. package/boot/class/bajo-core/method/arrange-array.js +2 -1
  12. package/boot/class/bajo-core/method/break-ns-path-from-file.js +2 -1
  13. package/boot/class/bajo-core/method/break-ns-path.js +4 -2
  14. package/boot/class/bajo-core/method/build-collections.js +7 -5
  15. package/boot/class/bajo-core/method/call-handler.js +3 -1
  16. package/boot/class/bajo-core/method/defaults-deep.js +4 -1
  17. package/boot/class/bajo-core/method/each-plugins.js +3 -1
  18. package/boot/class/bajo-core/method/format.js +36 -0
  19. package/boot/class/bajo-core/method/get-global-module-dir.js +5 -3
  20. package/boot/class/bajo-core/method/get-method.js +4 -2
  21. package/boot/class/bajo-core/method/get-plugin-file.js +3 -1
  22. package/boot/class/bajo-core/method/get-plugin.js +1 -1
  23. package/boot/class/bajo-core/method/import-module.js +3 -1
  24. package/boot/class/bajo-core/method/import-pkg.js +4 -2
  25. package/boot/class/bajo-core/method/includes.js +1 -3
  26. package/boot/class/bajo-core/method/is-log-in-range.js +3 -1
  27. package/boot/class/bajo-core/method/join.js +3 -1
  28. package/boot/class/bajo-core/method/num-unit.js +3 -1
  29. package/boot/class/bajo-core/method/paginate.js +3 -1
  30. package/boot/class/bajo-core/method/parse-object.js +10 -7
  31. package/boot/class/bajo-core/method/pascal-case.js +3 -1
  32. package/boot/class/bajo-core/method/read-config.js +6 -4
  33. package/boot/class/bajo-core/method/read-json.js +4 -2
  34. package/boot/class/bajo-core/method/run-hook.js +4 -2
  35. package/boot/class/bajo-core/method/save-as-download.js +4 -2
  36. package/boot/class/bajo-core/method/sec-to-hms.js +2 -1
  37. package/boot/class/bajo-core/method/titleize.js +2 -1
  38. package/boot/class/bajo-core.js +2 -1
  39. package/boot/class/bajo-plugin/helper/attach-method.js +1 -1
  40. package/boot/class/bajo-plugin/helper/build-config.js +8 -3
  41. package/boot/class/bajo-plugin/helper/check-clash.js +6 -4
  42. package/boot/class/bajo-plugin/helper/check-dependency.js +6 -4
  43. package/boot/class/bajo-plugin/helper/collect-exit-handlers.js +1 -1
  44. package/boot/class/bajo-plugin/helper/collect-hooks.js +4 -2
  45. package/boot/class/bajo-plugin/helper/run.js +3 -2
  46. package/boot/class/bajo-plugin.js +7 -4
  47. package/boot/class/error.js +2 -1
  48. package/boot/class/log.js +6 -4
  49. package/boot/class/plugin.js +5 -2
  50. package/boot/class/print.js +42 -6
  51. package/boot/lib/create-method.js +3 -1
  52. package/boot/lib/parse-args-argv.js +3 -1
  53. package/boot/lib/parse-env.js +3 -1
  54. package/boot/lib/read-all-configs.js +2 -2
  55. package/boot/lib/translate.js +2 -1
  56. package/package.json +2 -2
  57. package/bajoI18N/resource/id.json +0 -31
@@ -0,0 +1,136 @@
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",
24
+ "configHandlers%s": "Config handlers: %s",
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'",
39
+ "aborted": "Aborted",
40
+ "done": "Done",
41
+ "error": "Error",
42
+ "language": "Language",
43
+ "langEnUs": "American English",
44
+ "langId": "Indonesian",
45
+ "gotoHome": "Goto Home",
46
+ "copyClipboard": "Copy to Clipboard",
47
+ "clear": "Clear",
48
+ "close": "Close",
49
+ "image": "Image",
50
+ "reset": "Reset",
51
+ "submit": "Submit",
52
+ "upload": "Upload",
53
+ "home": "Home",
54
+ "smallL": "small",
55
+ "mediumL": "medium",
56
+ "largeL": "large",
57
+ "sunday": "Sunday",
58
+ "monday": "Monday",
59
+ "tuesday": "Tuesday",
60
+ "wednesday": "Wednesday",
61
+ "thursday": "Thursday",
62
+ "friday": "Friday",
63
+ "saturday": "Saturday",
64
+ "sun": "Sun",
65
+ "mon": "Mon",
66
+ "tue": "Tue",
67
+ "wed": "Wed",
68
+ "thu": "Thu",
69
+ "fri": "Fri",
70
+ "sat": "Sat",
71
+ "back": "Back",
72
+ "forward": "Forward",
73
+ "weekends": "Weekends",
74
+ "workingDays": "Working Days",
75
+ "search": "Search",
76
+ "prev": "Prev",
77
+ "next": "Next",
78
+ "large": "Large",
79
+ "small": "Small",
80
+ "center": "Center",
81
+ "height": "Height",
82
+ "source": "Source",
83
+ "ok": "OK",
84
+ "cancel": "Cancel",
85
+ "information": "Information",
86
+ "warning": "Warning",
87
+ "danger": "Danger",
88
+ "apply": "Apply",
89
+ "options": "Options",
90
+ "confirmation": "Confirmation",
91
+ "statistics": "Statistics",
92
+ "general": "General",
93
+ "meta": "Meta",
94
+ "copied": "Copied",
95
+ "name": "Name",
96
+ "role": "Role",
97
+ "phone": "Phone",
98
+ "secondL": "second",
99
+ "minuteL": "minute",
100
+ "hourL": "hour",
101
+ "dayL": "day",
102
+ "monthL": "month",
103
+ "yearL": "year",
104
+ "second": "Second",
105
+ "minute": "Minute",
106
+ "hour": "Hour",
107
+ "day": "Day",
108
+ "month": "Month",
109
+ "year": "Year",
110
+ "description": "Description",
111
+ "dashboard": "Dashboard",
112
+ "task": "Task",
113
+ "allRightsReserved": "All rights reserved",
114
+ "date": "Date",
115
+ "status": "Status",
116
+ "missingPlugin%s": "Plugin '%s' is missing",
117
+ "unknownParser%s": "Unknown parser '%s'",
118
+ "unknownConn%s": "Unknown connection %s",
119
+ "connIs%s%s": "Connection '%s' is %s",
120
+ "connError%s%s": "Connection '%s' error: %s",
121
+ "closedL": "closed",
122
+ "openedL": "opened",
123
+ "connectedL": "connected",
124
+ "disconnectedL": "disconnected",
125
+ "endedL": "ended",
126
+ "offlineL": "offline",
127
+ "reconnectingL": "reconnecting",
128
+ "connMustHave%s": "Connection must have '%s'",
129
+ "notFound%s%s": "%s '%s' not found",
130
+ "connection": "Connection",
131
+ "file": "File",
132
+ "applet": "Applet",
133
+ "unsupported%s%s": "Unsupported %s '%s'",
134
+ "error%": "Error: %s",
135
+ "savedAs%%": "%s saved as '%s'"
136
+ }
@@ -0,0 +1,136 @@
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",
24
+ "configHandlers%s": "Pengatur konfigurasi: %s",
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'",
39
+ "aborted": "Dibatalkan",
40
+ "done": "Selesai",
41
+ "error": "Kesalahan",
42
+ "language": "Bahasa",
43
+ "langEnUs": "Bahasa Inggris Amerika",
44
+ "langId": "Bahasa Indonesia",
45
+ "gotoHome": "Ke Beranda",
46
+ "copyClipboard": "Kopi ke Papan Tempel",
47
+ "clear": "Bersihkan",
48
+ "close": "Tutup",
49
+ "image": "Gambar",
50
+ "reset": "Reset",
51
+ "submit": "Kirim",
52
+ "upload": "Unggah",
53
+ "home": "Beranda",
54
+ "smallL": "kecil",
55
+ "mediumL": "menengah",
56
+ "largeL": "besar",
57
+ "sunday": "Minggu",
58
+ "monday": "Senin",
59
+ "tuesday": "Selasa",
60
+ "wednesday": "Rabu",
61
+ "thursday": "Kamis",
62
+ "friday": "Jumat",
63
+ "saturday": "Sabtu",
64
+ "sun": "Min",
65
+ "mon": "Sen",
66
+ "tue": "Sel",
67
+ "wed": "Rab",
68
+ "thu": "Kam",
69
+ "fri": "Jum",
70
+ "sat": "Sab",
71
+ "back": "Kembali",
72
+ "forward": "Maju",
73
+ "weekends": "Akhir Minggu",
74
+ "workingDays": "Hari Kerja",
75
+ "search": "Cari",
76
+ "prev": "Sebelumnya",
77
+ "next": "Berikutnya",
78
+ "large": "Besar",
79
+ "small": "Kecil",
80
+ "center": "Tengah",
81
+ "height": "Tinggi",
82
+ "source": "Sumber",
83
+ "ok": "Oke",
84
+ "cancel": "Batal",
85
+ "information": "Informasi",
86
+ "warning": "Perhatian",
87
+ "danger": "Bahaya",
88
+ "apply": "Terapkan",
89
+ "options": "Opsi-opsi",
90
+ "confirmation": "Konfirmasi",
91
+ "statistics": "Statistik",
92
+ "general": "Umum",
93
+ "meta": "Meta",
94
+ "copied": "Tertempel!",
95
+ "name": "Nama",
96
+ "role": "Peran",
97
+ "phone": "Telpon",
98
+ "secondL": "detik",
99
+ "minuteL": "menit",
100
+ "hourL": "jam",
101
+ "dayL": "hari",
102
+ "monthL": "bulan",
103
+ "yearL": "tahun",
104
+ "second": "Detik",
105
+ "minute": "Menit",
106
+ "hour": "Jam",
107
+ "day": "Hari",
108
+ "month": "Bulan",
109
+ "year": "Tahun",
110
+ "description": "Keterangan",
111
+ "dashboard": "Dasbor",
112
+ "task": "Pekerjaan",
113
+ "allRightsReserved": "Hak cipta dilindungi Undang-undang",
114
+ "date": "Tanggal",
115
+ "status": "Status",
116
+ "missingPlugin%s": "Plugin '%s' tidak ditemukan",
117
+ "unknownParser%s": "Parser tak dikenal '%s'",
118
+ "unknownConn%s": "Koneksi tak dikenal '%s'",
119
+ "connIs%s%s": "Koneksi '%s' %s",
120
+ "connError%s%s": "Koneksi '%s' ada kesalahan: %s",
121
+ "closedL": "tertutup",
122
+ "openedL": "terbuka",
123
+ "connectedL": "terhubung",
124
+ "disconnectedL": "terputus",
125
+ "endedL": "berhenti",
126
+ "offlineL": "offline",
127
+ "reconnectingL": "mencoba menghubung kembali",
128
+ "connMustHave%s": "Koneksi harus memiliki '%s'",
129
+ "notFound%s%s": "%s '%s' tidak ditemukan",
130
+ "connection": "Koneksi",
131
+ "file": "Berkas",
132
+ "applet": "Applet",
133
+ "unsupported%s%s": "%s '%s' tidak didukung",
134
+ "error%": "Kesalahan: %s",
135
+ "savedAs%%": "%s disimpan sbg '%s'"
136
+ }
package/boot/class/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import util from 'util'
2
- import { last } from 'lodash-es'
2
+ import lodash from 'lodash'
3
3
  import BajoCore from './bajo-core.js'
4
4
  import resolvePath from './bajo-core/method/resolve-path.js'
5
5
  import parseArgsArgv from '../lib/parse-args-argv.js'
@@ -13,6 +13,8 @@ import bootPlugins from './bajo-core/helper/boot-plugins.js'
13
13
  import exitHandler from './bajo-core/helper/exit-handler.js'
14
14
  import runAsApplet from './bajo-core/helper/run-as-applet.js'
15
15
 
16
+ const { last } = lodash
17
+
16
18
  class App {
17
19
  constructor (cwd) {
18
20
  if (!cwd) cwd = process.cwd()
@@ -29,7 +31,6 @@ class App {
29
31
  addPlugin (plugin) {
30
32
  if (this[plugin.name]) throw new Error(`Plugin '${plugin.name}' added already`)
31
33
  this[plugin.name] = plugin
32
- plugin.initPrint()
33
34
  }
34
35
 
35
36
  dump (...args) {
@@ -61,7 +62,7 @@ class App {
61
62
  // boot complete
62
63
  await bajo.runHook('bajo:bootComplete')
63
64
  const elapsed = new Date() - bajo.runAt
64
- bajo.log.info('Boot process completed in %s', bajo.secToHms(elapsed, true))
65
+ bajo.log.info('bootCompleted%s', bajo.secToHms(elapsed, true))
65
66
  if (bajo.applet) await runAsApplet.call(bajo)
66
67
  }
67
68
  }
@@ -5,6 +5,7 @@ import fs from 'fs-extra'
5
5
  import fastGlob from 'fast-glob'
6
6
  import { sprintf } from 'sprintf-js'
7
7
  import outmatch from 'outmatch'
8
+ import lodash from 'lodash'
8
9
 
9
10
  export default async function () {
10
11
  await createMethod.call(this, `${currentLoc(import.meta).dir}/../method`)
@@ -18,13 +19,13 @@ export default async function () {
18
19
  })
19
20
  }
20
21
  // commonly used libraries
21
- this.lib._ = await import('lodash-es')
22
+ this.lib._ = lodash
22
23
  this.lib.fs = fs
23
24
  this.lib.fastGlob = fastGlob
24
25
  this.lib.sprintf = sprintf
25
26
  this.lib.outmatch = outmatch
26
27
  // last cleanup
27
28
  if (!fs.existsSync(this.dir.data)) {
28
- this.log.warn('Data directory \'%s\' doesn\'t exists!', this.dir.data)
29
+ this.log.warn('ddirNotExists%s', this.dir.data)
29
30
  }
30
31
  }
@@ -1,9 +1,11 @@
1
- import { reduce, map, isNaN, trim, forOwn, orderBy } from 'lodash-es'
1
+ import lodash from 'lodash'
2
2
  import fs from 'fs-extra'
3
3
  import getModuleDir from '../method/get-module-dir.js'
4
4
 
5
+ const { reduce, map, isNaN, trim, forOwn, orderBy } = lodash
6
+
5
7
  async function bootOrder () {
6
- this.log.debug('Setup boot order')
8
+ this.log.debug('setupBootOrder')
7
9
  const order = reduce(this.pluginPkgs, (o, k, i) => {
8
10
  const key = map(k.split(':'), m => trim(m))
9
11
  if (key[1] && !isNaN(Number(key[1]))) o[key[0]] = Number(key[1])
@@ -14,7 +16,7 @@ async function bootOrder () {
14
16
  for (let n of this.pluginPkgs) {
15
17
  n = map(n.split(':'), m => trim(m))[0]
16
18
  const dir = n === this.mainNs ? (`${this.dir.base}/${this.mainNs}`) : getModuleDir(n)
17
- if (n !== this.mainNs && !fs.existsSync(`${dir}/bajo`)) throw this.error('Package \'%s\' not found or isn\'t a valid Bajo package', n)
19
+ if (n !== this.mainNs && !fs.existsSync(`${dir}/bajo`)) throw this.error('packageNotFoundOrNotBajo%s', n)
18
20
  norder[n] = NaN
19
21
  try {
20
22
  norder[n] = Number(trim(await fs.readFile(`${dir}/bajo/.bootorder`, 'utf8')))
@@ -26,7 +28,7 @@ async function bootOrder () {
26
28
  result.push(item)
27
29
  })
28
30
  this.pluginPkgs = map(orderBy(result, ['v']), 'k')
29
- this.log.info('Run in \'%s\' environment', this.envs[this.config.env])
31
+ this.log.info('runInEnv%s', this.envs[this.config.env])
30
32
  // misc
31
33
  this.freeze(this.config)
32
34
  }
@@ -9,7 +9,8 @@ import omitDeep from 'omit-deep'
9
9
  import os from 'os'
10
10
  import fs from 'fs-extra'
11
11
 
12
- import { map, pick, values, keys, set, get } from 'lodash-es'
12
+ import lodash from 'lodash'
13
+ const { map, pick, values, keys, set, get } = lodash
13
14
 
14
15
  const omitted = ['spawn', 'cwd', 'name', 'alias', 'applet', 'a', 'plugins']
15
16
 
@@ -20,6 +21,19 @@ const defConfig = {
20
21
  traceHook: false
21
22
  },
22
23
  lang: Intl.DateTimeFormat().resolvedOptions().lang ?? 'en-US',
24
+ intl: {
25
+ supported: ['en-US', 'id'],
26
+ fallback: 'en-US',
27
+ lookupOrder: [],
28
+ format: {
29
+ emptyValue: '',
30
+ datetime: { dateStyle: 'medium', 'timeStyle': 'short' },
31
+ date: { dateStyle: 'medium' },
32
+ time: { timeStyle: 'short' },
33
+ float: { maximumFractionDigits: 2 },
34
+ integer: {}
35
+ }
36
+ },
23
37
  exitHandler: true
24
38
  }
25
39
 
@@ -56,6 +70,7 @@ export async function buildExtConfig () {
56
70
  this.config.exitHandler = false
57
71
  }
58
72
  const exts = map(this.configHandlers, 'ext')
59
- this.log.init()
60
- this.log.debug('Config handlers: %s', join(exts))
73
+ this.initPrint()
74
+ this.initLog()
75
+ this.log.debug('configHandlers%s', join(exts))
61
76
  }
@@ -1,8 +1,10 @@
1
- import { isString, filter, map, trim, without, uniq, camelCase, isEmpty } from 'lodash-es'
1
+ import lodash from 'lodash'
2
2
  import fs from 'fs-extra'
3
3
  import getModuleDir from '../method/get-module-dir.js'
4
4
  import BajoPlugin from '../../bajo-plugin.js'
5
5
 
6
+ const { isString, filter, map, trim, without, uniq, camelCase, isEmpty } = lodash
7
+
6
8
  async function buildPlugins () {
7
9
  let pluginPkgs = this.config.plugins ?? []
8
10
  if (isString(pluginPkgs)) pluginPkgs = [pluginPkgs]
@@ -1,6 +1,7 @@
1
1
  import getModuleDir from '../method/get-module-dir.js'
2
2
  import importModule from '../method/import-module.js'
3
- import { isFunction, isPlainObject, camelCase } from 'lodash-es'
3
+ import lodash from 'lodash'
4
+ const { isFunction, isPlainObject, camelCase } = lodash
4
5
 
5
6
  async function collectConfigHandlers () {
6
7
  for (const pkg of this.pluginPkgs) {
@@ -1,15 +1,15 @@
1
1
  async function exit (signal) {
2
2
  const { eachPlugins } = this
3
- this.log.warn('\'%s\' signal received', signal)
3
+ this.log.warn('signalReceived%s', signal)
4
4
  await eachPlugins(async function ({ ns }) {
5
5
  const handler = this.exitHandler
6
6
  if (!handler) return undefined
7
7
  try {
8
8
  await handler.call(this)
9
9
  } catch (err) {}
10
- this.log.debug('Exited')
10
+ this.log.debug('exited')
11
11
  })
12
- this.log.debug('App shutdown')
12
+ this.log.debug('appShutdown')
13
13
  process.exit(0)
14
14
  }
15
15
 
@@ -4,9 +4,9 @@ async function runAsApplet () {
4
4
  this.app.bajo.applets.push({ ns, file, alias })
5
5
  }, { glob: 'applet.js', prefix: 'bajoCli' })
6
6
 
7
- this.log.debug('Applet mode activated')
8
- this.print.info('App is running as applet...')
9
- if (this.applets.length === 0) this.print.fatal('No applets loaded. Aborted!')
7
+ this.log.debug('appletModeActivated')
8
+ this.print.info('appRunningAsApplet')
9
+ if (this.applets.length === 0) this.print.fatal('noAppletLoaded')
10
10
  let name = this.applet
11
11
  if (!isString(this.applet)) {
12
12
  const select = await this.importPkg('bajoCli:@inquirer/select')
@@ -17,7 +17,7 @@ async function runAsApplet () {
17
17
  }
18
18
  const [ns, path] = name.split(':')
19
19
  const applet = find(this.applets, a => (a.ns === ns || a.alias === ns))
20
- if (!applet) this.print.fatal('Applet \'%s\' not found. Aborted!', name)
20
+ if (!applet) this.print.fatal('notFound%s%s', this.print.write('applet'), name)
21
21
  await this.runHook(`${this.app[applet.ns]}:beforeAppletRun`)
22
22
  await this.app.bajoCli.runApplet(applet, path, ...this.app.args)
23
23
  await this.runHook(`${this.app[applet.ns]}:afterAppletRun`)
@@ -1,4 +1,5 @@
1
- import { filter, trim } from 'lodash-es'
1
+ import lodash from 'lodash'
2
+ const { filter, trim } = lodash
2
3
 
3
4
  function arrangeArray (inputs, trimItem = true) {
4
5
  const first = []
@@ -1,5 +1,6 @@
1
1
  import _path from 'path'
2
- import { map, camelCase } from 'lodash-es'
2
+ import lodash from 'lodash'
3
+ const { map, camelCase } = lodash
3
4
 
4
5
  function breakNsPathFromFile ({ file, dir, baseNs, suffix = '', getType } = {}) {
5
6
  let item = file.replace(dir + suffix, '')
@@ -1,6 +1,8 @@
1
- import { isEmpty } from 'lodash-es'
1
+ import lodash from 'lodash'
2
2
  import querystring from 'querystring'
3
3
 
4
+ const { isEmpty } = lodash
5
+
4
6
  function breakNsPath (item = '', defaultNs = 'bajo', checkNs = true) {
5
7
  let [ns, ...path] = item.split(':')
6
8
  let subNs
@@ -17,7 +19,7 @@ function breakNsPath (item = '', defaultNs = 'bajo', checkNs = true) {
17
19
  const plugin = this.getPlugin(ns)
18
20
  if (plugin) ns = plugin.name
19
21
  }
20
- if (!this.app[ns]) throw this.error('Unknown plugin \'%s\' or plugin isn\'t loaded yet')
22
+ if (!this.app[ns]) throw this.error('unknownPluginOrNotLoaded%s')
21
23
  }
22
24
  const fullPath = path
23
25
  let qs
@@ -1,4 +1,6 @@
1
- import { filter, isArray, pullAt, camelCase, has, find, set, get, isFunction } from 'lodash-es'
1
+ import lodash from 'lodash'
2
+
3
+ const { filter, isArray, pullAt, camelCase, has, find, set, get, isFunction } = lodash
2
4
 
3
5
  async function buildCollections (options = {}) {
4
6
  const { runHook, join } = this.app.bajo
@@ -8,14 +10,14 @@ async function buildCollections (options = {}) {
8
10
  const cfg = this.app[ns].getConfig()
9
11
  let items = get(cfg, container, [])
10
12
  if (!isArray(items)) items = [items]
11
- this.app[ns].log.trace('Collecting %s', this.app[ns].print.write(container))
13
+ this.app[ns].log.trace('collecting%s', this.app[ns].print.write(container))
12
14
  await runHook(`${ns}:${camelCase('beforeBuildCollection')}`, container)
13
15
  const deleted = []
14
16
  for (const index in items) {
15
17
  const item = items[index]
16
18
  if (useDefaultName) {
17
19
  if (!has(item, 'name')) {
18
- if (find(items, { name: 'default' })) throw this.app[ns].error('Collection \'default\' already exists')
20
+ if (find(items, { name: 'default' })) throw this.app[ns].error('collectionExists%s', 'default')
19
21
  else item.name = 'default'
20
22
  }
21
23
  }
@@ -34,12 +36,12 @@ async function buildCollections (options = {}) {
34
36
  else {
35
37
  const checker = set({}, d, c[d])
36
38
  const match = filter(items, checker)
37
- if (match.length > 1) this.app[ns].fatal('One or more %s shared the same \'%s\'', container, join(dupChecks.filter(i => !isFunction(i))))
39
+ if (match.length > 1) this.app[ns].fatal('oneOrMoreSharedTheSame%s%s', container, join(dupChecks.filter(i => !isFunction(i))))
38
40
  }
39
41
  }
40
42
  }
41
43
  await runHook(`${ns}:${camelCase('afterBuildCollection')}`, container)
42
- this.app[ns].log.debug('%s collected: %d', this.app[ns].print.write(container), items.length)
44
+ this.app[ns].log.debug('collected%s%d', this.app[ns].print.write(container), items.length)
43
45
  return items
44
46
  }
45
47
 
@@ -1,6 +1,8 @@
1
- import { isString, isFunction, isPlainObject, find } from 'lodash-es'
1
+ import lodash from 'lodash'
2
2
  import BajoPlugin from '../../bajo-plugin.js'
3
3
 
4
+ const { isString, isFunction, isPlainObject, find } = lodash
5
+
4
6
  async function callHandler (item, ...args) {
5
7
  let result
6
8
  let scope = this
@@ -1,4 +1,7 @@
1
- import { mergeWith, isArray } from 'lodash-es'
1
+ import lodash from 'lodash'
2
+
3
+ const { mergeWith, isArray } = lodash
4
+
2
5
  // based on https://github.com/nodeutils/defaults-deep/blob/master/lib/index.js
3
6
 
4
7
  const defaultsDeep = (...args) => {
@@ -1,7 +1,9 @@
1
- import { camelCase, isString, omit, cloneDeep } from 'lodash-es'
1
+ import lodash from 'lodash'
2
2
  import fastGlob from 'fast-glob'
3
3
  import path from 'path'
4
4
 
5
+ const { camelCase, isString, omit, cloneDeep } = lodash
6
+
5
7
  async function eachPlugins (handler, options = {}) {
6
8
  if (typeof options === 'string') options = { glob: options }
7
9
  const result = {}
@@ -0,0 +1,36 @@
1
+ function format (value, type, lang, options = {}) {
2
+ const { defaultsDeep } = this.app.bajo
3
+ const { format } = this.config.intl
4
+ const { emptyValue = format.emptyValue } = options
5
+ if ([undefined, null, ''].includes(value)) return emptyValue
6
+ if (type === 'auto') {
7
+ if (value instanceof Date) type = 'datetime'
8
+ }
9
+ if (['integer', 'smallint'].includes(type)) {
10
+ value = parseInt(value)
11
+ if (isNaN(value)) return emptyValue
12
+ const setting = defaultsDeep(options.integer, format.integer)
13
+ return new Intl.NumberFormat(lang, setting).format(value)
14
+ }
15
+ if (['float', 'double'].includes(type)) {
16
+ value = parseFloat(value)
17
+ if (isNaN(value)) return emptyValue
18
+ if (this.app.bajoSpatial && options.latitude) return this.app.bajoSpatial.latToDms(value)
19
+ if (this.app.bajoSpatial && options.longitude) return this.app.bajoSpatial.lngToDms(value)
20
+ const setting = defaultsDeep(options.float, format.float)
21
+ return new Intl.NumberFormat(lang, setting).format(value)
22
+ }
23
+ if (['datetime', 'date'].includes(type)) {
24
+ const setting = defaultsDeep(options[type], format[type])
25
+ return new Intl.DateTimeFormat(lang, setting).format(new Date(value))
26
+ }
27
+ if (['time'].includes(type)) {
28
+ const setting = defaultsDeep(options.time, format.time)
29
+ return new Intl.DateTimeFormat(lang, setting).format(new Date(`1970-01-01T${value}Z`))
30
+ }
31
+ if (['array'].includes(type)) return value.join(', ')
32
+ if (['object'].includes(type)) return JSON.stringify(value)
33
+ return value
34
+ }
35
+
36
+ export default format
@@ -1,15 +1,17 @@
1
1
  import getGlobalPath from 'get-global-path'
2
2
  import resolvePath from './resolve-path.js'
3
- import { dropRight } from 'lodash-es'
3
+ import lodash from 'lodash'
4
4
  import fs from 'fs-extra'
5
5
 
6
+ const { dropRight } = lodash
7
+
6
8
  function getGlobalModuleDir (pkgName, silent = true) {
7
9
  let nodeModulesDir = process.env.BAJO_GLOBAL_MODULE_DIR
8
10
  if (!nodeModulesDir) {
9
11
  const npmPath = getGlobalPath('npm')
10
12
  if (!npmPath) {
11
13
  if (silent) return
12
- throw this.error('Can\'t locate npm global module directory', { code: 'BAJO_CANT_LOCATE_NPM_GLOBAL_DIR' })
14
+ throw this.error('cantLocateNpmGlobalDir', { code: 'BAJO_CANT_LOCATE_NPM_GLOBAL_DIR' })
13
15
  }
14
16
  nodeModulesDir = dropRight(resolvePath(npmPath).split('/'), 1).join('/')
15
17
  process.env.BAJO_GLOBAL_MODULE_DIR = nodeModulesDir
@@ -18,7 +20,7 @@ function getGlobalModuleDir (pkgName, silent = true) {
18
20
  const dir = `${nodeModulesDir}/${pkgName}`
19
21
  if (!fs.existsSync(dir)) {
20
22
  if (silent) return
21
- throw this.error('Can\'t locate \'%s\' global module directory', pkgName, { code: 'BAJO_CANT_LOCATE_MODULE_GLOBAL_DIR' })
23
+ throw this.error('cantLocateGlobalDir%s', pkgName, { code: 'BAJO_CANT_LOCATE_MODULE_GLOBAL_DIR' })
22
24
  }
23
25
  return dir
24
26
  }
@@ -1,10 +1,12 @@
1
- import { get, isFunction } from 'lodash-es'
1
+ import lodash from 'lodash'
2
+
3
+ const { get, isFunction } = lodash
2
4
 
3
5
  function getMethod (name = '', thrown = true) {
4
6
  const { ns, path } = this.breakNsPath(name)
5
7
  const method = get(this.app, `${ns}.${path}`)
6
8
  if (method && isFunction(method)) return method
7
- if (thrown) throw this.error('Can\'t find method named \'%s\'', name)
9
+ if (thrown) throw this.error('cantFindMethod%s', name)
8
10
  }
9
11
 
10
12
  export default getMethod