bajo 1.1.0 → 1.1.2
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 +4 -2
- package/bajo/intl/id.json +4 -2
- package/boot/class/app.js +8 -10
- package/boot/class/bajo-core/{helper/boot-order.js → boot-order.js} +1 -2
- package/boot/class/bajo-core/boot-plugins.js +19 -0
- package/boot/class/bajo-core/{helper/build-config.js → build-config.js} +15 -17
- package/boot/class/bajo-core/{helper/build-plugins.js → build-plugins.js} +2 -3
- package/boot/class/bajo-core/{helper/collect-config-handlers.js → collect-config-handlers.js} +2 -4
- package/boot/class/bajo-core.js +739 -11
- package/boot/class/bajo-plugin/{helper/attach-method.js → attach-method.js} +1 -1
- package/boot/class/bajo-plugin.js +1 -2
- package/boot/class/log.js +4 -5
- package/boot/class/print.js +1 -2
- package/boot/lib/create-method.js +3 -5
- package/boot/lib/current-loc.js +1 -1
- package/boot/lib/import-module.js +27 -0
- package/boot/lib/log-levels.js +1 -0
- package/boot/lib/parse-args-argv.js +2 -3
- package/boot/lib/read-all-configs.js +3 -6
- package/boot/{class/bajo-core/method → lib}/resolve-path.js +1 -1
- package/package.json +1 -1
- package/boot/class/bajo-core/helper/attach-method.js +0 -31
- package/boot/class/bajo-core/helper/boot-plugins.js +0 -19
- package/boot/class/bajo-core/method/arrange-array.js +0 -19
- package/boot/class/bajo-core/method/break-ns-path-from-file.js +0 -25
- package/boot/class/bajo-core/method/break-ns-path.js +0 -31
- package/boot/class/bajo-core/method/build-collections.js +0 -48
- package/boot/class/bajo-core/method/call-handler.js +0 -31
- package/boot/class/bajo-core/method/defaults-deep.js +0 -17
- package/boot/class/bajo-core/method/each-plugins.js +0 -57
- package/boot/class/bajo-core/method/envs.js +0 -7
- package/boot/class/bajo-core/method/extract-text.js +0 -15
- package/boot/class/bajo-core/method/format.js +0 -36
- package/boot/class/bajo-core/method/generate-id.js +0 -23
- package/boot/class/bajo-core/method/get-global-module-dir.js +0 -28
- package/boot/class/bajo-core/method/get-key-by-value.js +0 -5
- package/boot/class/bajo-core/method/get-method.js +0 -12
- package/boot/class/bajo-core/method/get-module-dir.js +0 -35
- package/boot/class/bajo-core/method/get-plugin-data-dir.js +0 -11
- package/boot/class/bajo-core/method/get-plugin-file.js +0 -21
- package/boot/class/bajo-core/method/get-plugin.js +0 -23
- package/boot/class/bajo-core/method/import-module.js +0 -27
- package/boot/class/bajo-core/method/import-pkg.js +0 -48
- package/boot/class/bajo-core/method/includes.js +0 -11
- package/boot/class/bajo-core/method/is-class.js +0 -7
- package/boot/class/bajo-core/method/is-empty-dir.js +0 -9
- package/boot/class/bajo-core/method/is-log-in-range.js +0 -12
- package/boot/class/bajo-core/method/is-set.js +0 -5
- package/boot/class/bajo-core/method/is-valid-app.js +0 -12
- package/boot/class/bajo-core/method/is-valid-plugin.js +0 -12
- package/boot/class/bajo-core/method/join.js +0 -20
- package/boot/class/bajo-core/method/log-levels.js +0 -9
- package/boot/class/bajo-core/method/num-unit.js +0 -11
- package/boot/class/bajo-core/method/paginate.js +0 -28
- package/boot/class/bajo-core/method/parse-object.js +0 -62
- package/boot/class/bajo-core/method/pascal-case.js +0 -9
- package/boot/class/bajo-core/method/pick.js +0 -13
- package/boot/class/bajo-core/method/read-config.js +0 -50
- package/boot/class/bajo-core/method/read-json.js +0 -14
- package/boot/class/bajo-core/method/round.js +0 -6
- package/boot/class/bajo-core/method/run-hook.js +0 -28
- package/boot/class/bajo-core/method/save-as-download.js +0 -19
- package/boot/class/bajo-core/method/sec-to-hms.js +0 -25
- package/boot/class/bajo-core/method/titleize.js +0 -24
- package/boot/class/bajo-core/method/white-space.js +0 -3
- /package/boot/class/bajo-core/{helper/exit-handler.js → exit-handler.js} +0 -0
- /package/boot/class/bajo-core/{helper/run-as-applet.js → run-as-applet.js} +0 -0
- /package/boot/class/bajo-plugin/{helper/build-config.js → build-config.js} +0 -0
- /package/boot/class/bajo-plugin/{helper/check-clash.js → check-clash.js} +0 -0
- /package/boot/class/bajo-plugin/{helper/check-dependency.js → check-dependency.js} +0 -0
- /package/boot/class/bajo-plugin/{helper/collect-exit-handlers.js → collect-exit-handlers.js} +0 -0
- /package/boot/class/bajo-plugin/{helper/collect-hooks.js → collect-hooks.js} +0 -0
- /package/boot/class/bajo-plugin/{helper/run.js → run.js} +0 -0
package/bajo/intl/en-US.json
CHANGED
|
@@ -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
|
-
"
|
|
8
|
+
"pluginWithNameAliasNotLoaded%s": "Plugin with name/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'",
|
|
@@ -152,5 +152,7 @@
|
|
|
152
152
|
"formSubmitted": "Form Submitted",
|
|
153
153
|
"formSubmittedInfo": "The form you entered has been successfully submitted and is stored securely in our system.",
|
|
154
154
|
"thankYou": "Thank you!",
|
|
155
|
-
"adminArea": "Admin Area"
|
|
155
|
+
"adminArea": "Admin Area",
|
|
156
|
+
"instanceCreatedOnConn%s%s": "Instance '%s' created on connection '%s'",
|
|
157
|
+
"fileNotModuleHandler%s": "File '%s' is NOT a module handler"
|
|
156
158
|
}
|
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
|
-
"
|
|
8
|
+
"pluginWithNameAliasNotLoaded%s": "Plugin dengan name/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'",
|
|
@@ -152,5 +152,7 @@
|
|
|
152
152
|
"formSubmitted": "Form Terkirim",
|
|
153
153
|
"formSubmittedInfo": "Form yang Anda masukkan telah sukses terkirim dan disimpan dengan aman di sistim kami.",
|
|
154
154
|
"thankYou": "Terima kasih!",
|
|
155
|
-
"adminArea": "Area Admin"
|
|
155
|
+
"adminArea": "Area Admin",
|
|
156
|
+
"instanceCreatedOnConn%s%s": "Instance '%s' telah dibuat pada koneksi '%s'",
|
|
157
|
+
"fileNotModuleHandler%s": "Berkas '%s' BUKAN merupakan module handler"
|
|
156
158
|
}
|
package/boot/class/app.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import util from 'util'
|
|
2
2
|
import lodash from 'lodash'
|
|
3
3
|
import BajoCore from './bajo-core.js'
|
|
4
|
-
import resolvePath from '
|
|
4
|
+
import resolvePath from '../lib/resolve-path.js'
|
|
5
5
|
import parseArgsArgv from '../lib/parse-args-argv.js'
|
|
6
6
|
import parseEnv from '../lib/parse-env.js'
|
|
7
|
-
import buildPlugins from './bajo-core/
|
|
8
|
-
import { buildBaseConfig, buildExtConfig } from './bajo-core/
|
|
9
|
-
import collectConfigHandlers from './bajo-core/
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import runAsApplet from './bajo-core/helper/run-as-applet.js'
|
|
7
|
+
import buildPlugins from './bajo-core/build-plugins.js'
|
|
8
|
+
import { buildBaseConfig, buildExtConfig } from './bajo-core/build-config.js'
|
|
9
|
+
import collectConfigHandlers from './bajo-core/collect-config-handlers.js'
|
|
10
|
+
import bootOrder from './bajo-core/boot-order.js'
|
|
11
|
+
import bootPlugins from './bajo-core/boot-plugins.js'
|
|
12
|
+
import exitHandler from './bajo-core/exit-handler.js'
|
|
13
|
+
import runAsApplet from './bajo-core/run-as-applet.js'
|
|
15
14
|
|
|
16
15
|
const { last } = lodash
|
|
17
16
|
|
|
@@ -55,7 +54,6 @@ class App {
|
|
|
55
54
|
await buildPlugins.call(bajo)
|
|
56
55
|
await collectConfigHandlers.call(bajo)
|
|
57
56
|
await buildExtConfig.call(bajo)
|
|
58
|
-
await attachMethod.call(bajo)
|
|
59
57
|
await bootOrder.call(bajo)
|
|
60
58
|
await bootPlugins.call(bajo)
|
|
61
59
|
await exitHandler.call(bajo)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import lodash from 'lodash'
|
|
2
2
|
import fs from 'fs-extra'
|
|
3
|
-
import getModuleDir from '../method/get-module-dir.js'
|
|
4
3
|
|
|
5
4
|
const { reduce, map, isNaN, trim, forOwn, orderBy } = lodash
|
|
6
5
|
|
|
@@ -15,7 +14,7 @@ async function bootOrder () {
|
|
|
15
14
|
const norder = {}
|
|
16
15
|
for (let n of this.pluginPkgs) {
|
|
17
16
|
n = map(n.split(':'), m => trim(m))[0]
|
|
18
|
-
const dir = n === this.mainNs ? (`${this.dir.base}/${this.mainNs}`) : getModuleDir(n)
|
|
17
|
+
const dir = n === this.mainNs ? (`${this.dir.base}/${this.mainNs}`) : this.getModuleDir(n)
|
|
19
18
|
if (n !== this.mainNs && !fs.existsSync(`${dir}/plugin`)) throw this.error('packageNotFoundOrNotBajo%s', n)
|
|
20
19
|
norder[n] = NaN
|
|
21
20
|
try {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import buildConfig from '../bajo-plugin/build-config.js'
|
|
2
|
+
import checkDependency from '../bajo-plugin/check-dependency.js'
|
|
3
|
+
import checkClash from '../bajo-plugin/check-clash.js'
|
|
4
|
+
import attachMethod from '../bajo-plugin/attach-method.js'
|
|
5
|
+
import collectHooks from '../bajo-plugin/collect-hooks.js'
|
|
6
|
+
import run from '../bajo-plugin/run.js'
|
|
7
|
+
import collectExitHandlers from '../bajo-plugin/collect-exit-handlers.js'
|
|
8
|
+
|
|
9
|
+
async function bootPlugins () {
|
|
10
|
+
await buildConfig.call(this.app)
|
|
11
|
+
await checkClash.call(this.app)
|
|
12
|
+
await checkDependency.call(this.app)
|
|
13
|
+
await attachMethod.call(this.app)
|
|
14
|
+
await collectHooks.call(this.app)
|
|
15
|
+
await collectExitHandlers.call(this.app)
|
|
16
|
+
await run.call(this.app)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default bootPlugins
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import readAllConfigs from '
|
|
2
|
-
import
|
|
3
|
-
import getKeyByValue from '../method/get-key-by-value.js'
|
|
4
|
-
import resolvePath from '../method/resolve-path.js'
|
|
5
|
-
import currentLoc from '../../../lib/current-loc.js'
|
|
6
|
-
import envs from '../method/envs.js'
|
|
7
|
-
import join from '../method/join.js'
|
|
1
|
+
import readAllConfigs from '../../lib/read-all-configs.js'
|
|
2
|
+
import currentLoc from '../../lib/current-loc.js'
|
|
8
3
|
import omitDeep from 'omit-deep'
|
|
9
4
|
import os from 'os'
|
|
10
5
|
import fs from 'fs-extra'
|
|
@@ -39,15 +34,18 @@ const defConfig = {
|
|
|
39
34
|
|
|
40
35
|
export async function buildBaseConfig () {
|
|
41
36
|
this.applet = this.app.argv._.applet
|
|
42
|
-
this.config = defaultsDeep({}, this.app.env._, this.app.argv._)
|
|
37
|
+
this.config = this.defaultsDeep({}, this.app.env._, this.app.argv._)
|
|
43
38
|
this.alias = this.name
|
|
44
39
|
set(this, 'dir.base', this.app.cwd)
|
|
45
|
-
const path = currentLoc(import.meta).dir + '
|
|
46
|
-
set(this, 'dir.pkg', resolvePath(path))
|
|
40
|
+
const path = currentLoc(import.meta).dir + '/../../..'
|
|
41
|
+
set(this, 'dir.pkg', this.resolvePath(path))
|
|
47
42
|
if (!get(this, 'dir.data')) set(this, 'dir.data', `${this.dir.base}/data`)
|
|
48
|
-
this.dir.data = resolvePath(this.dir.data)
|
|
43
|
+
this.dir.data = this.resolvePath(this.dir.data)
|
|
44
|
+
if (!fs.existsSync(this.dir.data)) {
|
|
45
|
+
this.log.warn('ddirNotExists%s', this.dir.data)
|
|
46
|
+
}
|
|
49
47
|
if (!this.dir.tmp) {
|
|
50
|
-
this.dir.tmp = `${resolvePath(os.tmpdir())}/${this.name}`
|
|
48
|
+
this.dir.tmp = `${this.resolvePath(os.tmpdir())}/${this.name}`
|
|
51
49
|
fs.ensureDirSync(this.dir.tmp)
|
|
52
50
|
}
|
|
53
51
|
this.app.addPlugin(this)
|
|
@@ -57,11 +55,11 @@ export async function buildExtConfig () {
|
|
|
57
55
|
// config merging
|
|
58
56
|
let resp = await readAllConfigs.call(this.app, `${this.dir.data}/config/${this.name}`)
|
|
59
57
|
resp = omitDeep(pick(resp, ['log', 'exitHandler', 'env']), omitted)
|
|
60
|
-
this.config = defaultsDeep({}, resp, this.config, defConfig)
|
|
58
|
+
this.config = this.defaultsDeep({}, resp, this.config, defConfig)
|
|
61
59
|
this.config.env = (this.config.env ?? 'dev').toLowerCase()
|
|
62
|
-
if (values(envs).includes(this.config.env)) this.config.env = getKeyByValue(envs, this.config.env)
|
|
63
|
-
if (!keys(envs).includes(this.config.env)) throw new Error(`Unknown environment '${this.config.env}'. Supported: ${join(keys(envs))}`)
|
|
64
|
-
process.env.NODE_ENV = envs[this.config.env]
|
|
60
|
+
if (values(this.envs).includes(this.config.env)) this.config.env = this.getKeyByValue(this.envs, this.config.env)
|
|
61
|
+
if (!keys(this.envs).includes(this.config.env)) throw new Error(`Unknown environment '${this.config.env}'. Supported: ${this.join(keys(this.envs))}`)
|
|
62
|
+
process.env.NODE_ENV = this.envs[this.config.env]
|
|
65
63
|
if (!this.config.log.level) this.config.log.level = this.config.env === 'dev' ? 'debug' : 'info'
|
|
66
64
|
if (this.config.silent) this.config.log.level = 'silent'
|
|
67
65
|
if (this.applet) {
|
|
@@ -72,5 +70,5 @@ export async function buildExtConfig () {
|
|
|
72
70
|
const exts = map(this.configHandlers, 'ext')
|
|
73
71
|
this.initPrint()
|
|
74
72
|
this.initLog()
|
|
75
|
-
this.log.debug('configHandlers%s', join(exts))
|
|
73
|
+
this.log.debug('configHandlers%s', this.join(exts))
|
|
76
74
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import lodash from 'lodash'
|
|
2
2
|
import fs from 'fs-extra'
|
|
3
|
-
import
|
|
4
|
-
import resolvePath from '../method/resolve-path.js'
|
|
3
|
+
import resolvePath from '../../lib/resolve-path.js'
|
|
5
4
|
|
|
6
5
|
const { isString, filter, map, trim, without, uniq, camelCase, isEmpty } = lodash
|
|
7
6
|
|
|
@@ -20,7 +19,7 @@ async function buildPlugins () {
|
|
|
20
19
|
this.pluginPkgs.push(this.mainNs)
|
|
21
20
|
for (const pkg of this.pluginPkgs) {
|
|
22
21
|
const ns = camelCase(pkg)
|
|
23
|
-
const dir = ns === this.mainNs ? (`${this.dir.base}/${this.mainNs}`) : getModuleDir
|
|
22
|
+
const dir = ns === this.mainNs ? (`${this.dir.base}/${this.mainNs}`) : this.getModuleDir(pkg)
|
|
24
23
|
if (ns !== this.mainNs && !fs.existsSync(`${dir}/plugin`)) throw new Error(`Package '${pkg}' isn't a valid Bajo package`)
|
|
25
24
|
let plugin
|
|
26
25
|
const factory = `${dir}/plugin/factory.js`
|
package/boot/class/bajo-core/{helper/collect-config-handlers.js → collect-config-handlers.js}
RENAMED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import getModuleDir from '../method/get-module-dir.js'
|
|
2
|
-
import importModule from '../method/import-module.js'
|
|
3
1
|
import lodash from 'lodash'
|
|
4
2
|
const { isFunction, isPlainObject, camelCase } = lodash
|
|
5
3
|
|
|
@@ -7,11 +5,11 @@ async function collectConfigHandlers () {
|
|
|
7
5
|
for (const pkg of this.pluginPkgs) {
|
|
8
6
|
let dir
|
|
9
7
|
try {
|
|
10
|
-
dir = getModuleDir
|
|
8
|
+
dir = this.getModuleDir(pkg)
|
|
11
9
|
} catch (err) {}
|
|
12
10
|
if (!dir) continue
|
|
13
11
|
const file = `${dir}/bajo/config-handlers.js`
|
|
14
|
-
let mod = await importModule
|
|
12
|
+
let mod = await this.importModule(file)
|
|
15
13
|
if (!mod) continue
|
|
16
14
|
if (isFunction(mod)) mod = await mod.call(this.app[camelCase(pkg)])
|
|
17
15
|
if (isPlainObject(mod)) mod = [mod]
|