bajo 1.2.9 → 2.0.0
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/.jsdoc.conf.json +6 -3
- package/README.md +8 -148
- package/class/app.js +113 -0
- package/{boot/class/bajo-core.js → class/bajo.js} +448 -35
- package/{boot/class/error.js → class/base/err.js} +29 -3
- package/class/base/log.js +205 -0
- package/class/base/plugin.js +177 -0
- package/class/base/print.js +272 -0
- package/class/helper/bajo.js +344 -0
- package/class/helper/plugin.js +169 -0
- package/{boot/class/bajo-plugin.js → class/plugin.js} +60 -3
- package/docs/App.html +3 -0
- package/docs/Bajo.html +15 -0
- package/docs/BasePlugin.html +5 -0
- package/docs/Err.html +3 -0
- package/docs/Log.html +3 -0
- package/docs/Plugin.html +3 -0
- package/docs/Print.html +3 -0
- package/docs/bitcoin.jpeg +0 -0
- package/docs/class_app.js.html +116 -0
- package/docs/class_bajo.js.html +1100 -0
- package/docs/class_base_err.js.html +99 -0
- package/docs/class_base_log.js.html +208 -0
- package/docs/class_base_plugin.js.html +180 -0
- package/docs/class_base_print.js.html +275 -0
- package/docs/class_helper_bajo.js.html +347 -0
- package/docs/class_helper_plugin.js.html +172 -0
- package/docs/class_plugin.js.html +121 -0
- package/docs/data/search.json +1 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +3 -0
- package/docs/index.html +3 -0
- package/docs/lib_create-method.js.html +42 -0
- package/docs/lib_formats.js.html +68 -0
- package/docs/lib_log-levels.js.html +28 -0
- package/docs/lib_resolve-path.js.html +30 -0
- package/docs/lib_shim.js.html +35 -0
- package/docs/module-class_helper_bajo.html +3 -0
- package/docs/module-class_helper_plugin.html +3 -0
- package/docs/module-lib_create-method.html +3 -0
- package/docs/module-lib_formats.html +3 -0
- package/docs/module-lib_log-levels.html +3 -0
- package/docs/module-lib_resolve-path.html +3 -0
- package/docs/module-lib_shim.html +3 -0
- package/docs/scripts/core.js +726 -0
- package/docs/scripts/core.min.js +23 -0
- package/docs/scripts/resize.js +90 -0
- package/docs/scripts/search.js +265 -0
- package/docs/scripts/search.min.js +6 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/scripts/third-party/fuse.js +9 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/scripts/third-party/hljs-original.js +5171 -0
- package/docs/scripts/third-party/hljs.js +1 -0
- package/docs/scripts/third-party/popper.js +5 -0
- package/docs/scripts/third-party/tippy.js +1 -0
- package/docs/scripts/third-party/tocbot.js +672 -0
- package/docs/scripts/third-party/tocbot.min.js +1 -0
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/tutorial-contribution.html +3 -0
- package/docs/tutorial-ecosystem.html +3 -0
- package/docs/tutorial-getting-started.html +13 -0
- package/docs/tutorial-plugin-dev.html +3 -0
- package/docs/tutorial-user-guide.html +3 -0
- package/lib/create-method.js +39 -0
- package/{boot/lib → lib}/formats.js +28 -0
- package/{boot/lib → lib}/log-levels.js +16 -0
- package/{boot/lib → lib}/parse-args-argv.js +1 -1
- package/{boot/lib → lib}/resolve-path.js +12 -0
- package/{boot/lib → lib}/shim.js +10 -0
- package/misc-docs/bitcoin.jpeg +0 -0
- package/misc-docs/contribution.md +20 -0
- package/{docs → misc-docs}/ecosystem.md +41 -12
- package/misc-docs/getting-started.md +142 -0
- package/misc-docs/plugin-dev.md +0 -0
- package/misc-docs/toc.json +17 -0
- package/misc-docs/user-guide.md +1 -0
- package/package.json +14 -13
- package/bajoBook/book/doc/.metadata.json +0 -28
- package/bajoBook/book/doc/How-to-Make-a-Paper-Boat-564x400@2x.jpg +0 -0
- package/bajoBook/book/doc/pages/guides/definition.md +0 -7
- package/bajoBook/book/doc/pages/guides/intro.md +0 -3
- package/bajoBook/book/doc/pages/guides/setup.md +0 -22
- package/bajoBook/book/reference/.metadata.json +0 -152
- package/bajoBook/book/reference/concept-leadership-business-with-paper-boats.jpg +0 -0
- package/bajoBook/book/reference/pages/configuration/configuration-file.md +0 -52
- package/bajoBook/book/reference/pages/helper/break-ns-path.md +0 -24
- package/bajoBook/book/reference/pages/helper/build-collections.md +0 -19
- package/bajoBook/book/reference/pages/helper/call-helper-or-handler.md +0 -35
- package/bajoBook/book/reference/pages/helper/current-loc.md +0 -28
- package/bajoBook/book/reference/pages/helper/dayjs.md +0 -13
- package/bajoBook/book/reference/pages/helper/defaults-deep.md +0 -29
- package/bajoBook/book/reference/pages/helper/dump.md +0 -32
- package/bajoBook/book/reference/pages/helper/each-plugins.md +0 -24
- package/bajoBook/book/reference/pages/helper/envs.md +0 -11
- package/bajoBook/book/reference/pages/helper/error.md +0 -29
- package/bajoBook/book/reference/pages/helper/fatal.md +0 -18
- package/bajoBook/book/reference/pages/helper/freeze.md +0 -13
- package/bajoBook/book/reference/pages/helper/generate-id.md +0 -36
- package/bajoBook/book/reference/pages/helper/get-config.md +0 -27
- package/bajoBook/book/reference/pages/helper/get-global-module-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-helper.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-item-by-name.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-key-by-value.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-module-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin-data-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin-name.md +0 -13
- package/bajoBook/book/reference/pages/helper/get-plugin.md +0 -13
- package/bajoBook/book/reference/pages/helper/import-module.md +0 -13
- package/bajoBook/book/reference/pages/helper/import-pkg.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-empty-dir.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-log-in-range.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-set.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-valid-app.md +0 -13
- package/bajoBook/book/reference/pages/helper/is-valid-plugin.md +0 -13
- package/bajoBook/book/reference/pages/helper/log-levels.md +0 -13
- package/bajoBook/book/reference/pages/helper/log.md +0 -13
- package/bajoBook/book/reference/pages/helper/paginate.md +0 -13
- package/bajoBook/book/reference/pages/helper/pascal-case.md +0 -13
- package/bajoBook/book/reference/pages/helper/print.md +0 -13
- package/bajoBook/book/reference/pages/helper/read-config.md +0 -13
- package/bajoBook/book/reference/pages/helper/read-json.md +0 -13
- package/bajoBook/book/reference/pages/helper/resolve-path.md +0 -13
- package/bajoBook/book/reference/pages/helper/resolve-tpl-path.md +0 -13
- package/bajoBook/book/reference/pages/helper/run-hook.md +0 -13
- package/bajoBook/book/reference/pages/helper/save-as-download.md +0 -13
- package/bajoBook/book/reference/pages/helper/titleize.md +0 -13
- package/bajoBook/book/reference/pages/helper/white-space.md +0 -13
- package/boot/class/app.js +0 -67
- package/boot/class/bajo-core/boot-order.js +0 -35
- package/boot/class/bajo-core/boot-plugins.js +0 -17
- package/boot/class/bajo-core/build-config.js +0 -86
- package/boot/class/bajo-core/build-plugins.js +0 -44
- package/boot/class/bajo-core/collect-config-handlers.js +0 -20
- package/boot/class/bajo-core/exit-handler.js +0 -53
- package/boot/class/bajo-core/run-as-applet.js +0 -26
- package/boot/class/bajo-plugin/attach-method.js +0 -14
- package/boot/class/bajo-plugin/build-config.js +0 -15
- package/boot/class/bajo-plugin/check-clash.js +0 -18
- package/boot/class/bajo-plugin/check-dependency.js +0 -39
- package/boot/class/bajo-plugin/collect-hooks.js +0 -31
- package/boot/class/bajo-plugin/run.js +0 -23
- package/boot/class/log.js +0 -96
- package/boot/class/plugin.js +0 -79
- package/boot/class/print.js +0 -153
- package/boot/lib/create-method.js +0 -33
- package/test/method/isSet.js +0 -43
- /package/{bajo → extend/bajo}/intl/en-US.json +0 -0
- /package/{bajo → extend/bajo}/intl/id.json +0 -0
- /package/{waibuStatic → extend/waibuStatic}/virtual.json +0 -0
- /package/{boot/index.js → index.js} +0 -0
- /package/{boot/lib → lib}/current-loc.js +0 -0
- /package/{boot/lib → lib}/dayjs.js +0 -0
- /package/{boot/lib → lib}/import-module.js +0 -0
- /package/{boot/lib → lib}/omitted-plugin-keys.js +0 -0
- /package/{boot/lib → lib}/parse-env.js +0 -0
- /package/{boot/lib → lib}/read-all-configs.js +0 -0
- /package/{docs/hook.md → misc-docs/.hook.md} +0 -0
package/boot/class/print.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import ora from 'ora'
|
|
2
|
-
import lodash from 'lodash'
|
|
3
|
-
import fs from 'fs-extra'
|
|
4
|
-
import Sprintf from 'sprintf-js'
|
|
5
|
-
const { sprintf } = Sprintf
|
|
6
|
-
let unknownLangWarning = false
|
|
7
|
-
|
|
8
|
-
const { isString, last, isPlainObject, get, without, reverse, map } = lodash
|
|
9
|
-
|
|
10
|
-
class Print {
|
|
11
|
-
constructor (plugin, opts = {}) {
|
|
12
|
-
this.opts = opts
|
|
13
|
-
this.plugin = plugin
|
|
14
|
-
this.startTime = this.plugin.app.bajo.lib.dayjs()
|
|
15
|
-
this.setOpts()
|
|
16
|
-
this.ora = ora(this.opts)
|
|
17
|
-
this.intl = {}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
init = () => {
|
|
21
|
-
for (const l of this.plugin.app.bajo.config.intl.supported) {
|
|
22
|
-
this.intl[l] = {}
|
|
23
|
-
const path = `${this.plugin.dir.pkg}/bajo/intl/${l}.json`
|
|
24
|
-
if (!fs.existsSync(path)) continue
|
|
25
|
-
const trans = fs.readFileSync(path, 'utf8')
|
|
26
|
-
try {
|
|
27
|
-
this.intl[l] = JSON.parse(trans)
|
|
28
|
-
} catch (err) {}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
write = (text, ...args) => {
|
|
33
|
-
const opts = last(args)
|
|
34
|
-
let lang = this.plugin.app.bajo.config.lang
|
|
35
|
-
if (isPlainObject(opts)) {
|
|
36
|
-
args.pop()
|
|
37
|
-
if (opts.lang) lang = opts.lang
|
|
38
|
-
}
|
|
39
|
-
const { fallback, supported } = this.plugin.app.bajo.config.intl
|
|
40
|
-
if (!unknownLangWarning && !supported.includes(lang)) {
|
|
41
|
-
unknownLangWarning = true
|
|
42
|
-
this.plugin.app.bajo.log.warn('unsupportedLangFallbackTo%s', fallback)
|
|
43
|
-
}
|
|
44
|
-
const plugins = reverse(without([...this.plugin.app.bajo.pluginNames], this.plugin.name))
|
|
45
|
-
plugins.unshift(this.plugin.name)
|
|
46
|
-
plugins.push('bajo')
|
|
47
|
-
|
|
48
|
-
let trans
|
|
49
|
-
for (const p of plugins) {
|
|
50
|
-
const root = get(this, `plugin.app.${p}.print.intl.${lang}`, {})
|
|
51
|
-
trans = get(root, text)
|
|
52
|
-
if (trans) break
|
|
53
|
-
}
|
|
54
|
-
if (!trans) {
|
|
55
|
-
for (const p of plugins) {
|
|
56
|
-
const root = get(this, `plugin.app.${p}.print.intl.${fallback}`, {})
|
|
57
|
-
trans = get(root, text)
|
|
58
|
-
if (trans) break
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (!trans) trans = text
|
|
62
|
-
const params = map(args, a => {
|
|
63
|
-
if (!isString(a)) return a
|
|
64
|
-
return a
|
|
65
|
-
})
|
|
66
|
-
return sprintf(trans, ...params)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
setOpts = (args = []) => {
|
|
70
|
-
const config = this.plugin.app.bajo.config
|
|
71
|
-
let opts = {}
|
|
72
|
-
if (isPlainObject(args.slice(-1)[0])) opts = args.pop()
|
|
73
|
-
this.opts.isSilent = !!(config.silent || this.opts.isSilent)
|
|
74
|
-
this.opts = this.plugin.lib.aneka.defaultsDeep(opts, this.opts)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setText = (text, ...args) => {
|
|
78
|
-
text = this.write(text, ...args)
|
|
79
|
-
this.setOpts(args)
|
|
80
|
-
const prefixes = []
|
|
81
|
-
const texts = []
|
|
82
|
-
if (this.opts.showDatetime) prefixes.push('[' + this.plugin.app.bajo.lib.dayjs().toISOString() + ']')
|
|
83
|
-
if (this.opts.showCounter) texts.push('[' + this.getElapsed() + ']')
|
|
84
|
-
if (prefixes.length > 0) this.ora.prefixText = this.ora.prefixText + prefixes.join(' ')
|
|
85
|
-
if (texts.length > 0) text = texts.join(' ') + ' ' + text
|
|
86
|
-
this.ora.text = text
|
|
87
|
-
return this
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getElapsed = (unit = 'hms') => {
|
|
91
|
-
const u = unit === 'hms' ? 'second' : unit
|
|
92
|
-
const elapsed = this.plugin.lib.dayjs().diff(this.startTime, u)
|
|
93
|
-
return unit === 'hms' ? this.plugin.lib.aneka.secToHms(elapsed) : elapsed
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
start = (text, ...args) => {
|
|
97
|
-
this.setOpts(args)
|
|
98
|
-
this.setText(text, ...args)
|
|
99
|
-
this.ora.start()
|
|
100
|
-
return this
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
stop = () => {
|
|
104
|
-
this.ora.stop()
|
|
105
|
-
return this
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
succeed = (text, ...args) => {
|
|
109
|
-
this.setText(text, ...args)
|
|
110
|
-
this.ora.succeed()
|
|
111
|
-
return this
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
fail = (text, ...args) => {
|
|
115
|
-
this.setText(text, ...args)
|
|
116
|
-
this.ora.fail()
|
|
117
|
-
return this
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
warn = (text, ...args) => {
|
|
121
|
-
this.setText(text, ...args)
|
|
122
|
-
this.ora.warn()
|
|
123
|
-
return this
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
info = (text, ...args) => {
|
|
127
|
-
this.setText(text, ...args)
|
|
128
|
-
this.ora.info()
|
|
129
|
-
return this
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
clear = () => {
|
|
133
|
-
this.ora.clear()
|
|
134
|
-
return this
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
render = () => {
|
|
138
|
-
this.ora.render()
|
|
139
|
-
return this
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
fatal = (text, ...args) => {
|
|
143
|
-
this.setText(text, ...args)
|
|
144
|
-
this.ora.fail()
|
|
145
|
-
process.kill(process.pid, 'SIGINT')
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
spinner = () => {
|
|
149
|
-
return new Print(this.plugin)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export default Print
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fastGlob from 'fast-glob'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import lodash from 'lodash'
|
|
4
|
-
import resolvePath from './resolve-path.js'
|
|
5
|
-
|
|
6
|
-
const { camelCase, isFunction } = lodash
|
|
7
|
-
|
|
8
|
-
export default async function (dir, pkg = 'bajo') {
|
|
9
|
-
dir = resolvePath(dir)
|
|
10
|
-
const files = await fastGlob([`!${dir}/**/_*.{js,json}`, `${dir}/**/*.{js,json}`])
|
|
11
|
-
const me = this
|
|
12
|
-
for (const f of files) {
|
|
13
|
-
const ext = path.extname(f)
|
|
14
|
-
const base = f.replace(dir, '').replace(ext, '')
|
|
15
|
-
const name = camelCase(base)
|
|
16
|
-
let mod
|
|
17
|
-
if (ext === '.json') mod = this.app.bajo.readJson(f)
|
|
18
|
-
else mod = await this.app.bajo.importModule(f)
|
|
19
|
-
if (isFunction(mod)) {
|
|
20
|
-
const fn = mod.bind(this)
|
|
21
|
-
if (mod.constructor.name === 'AsyncFunction') {
|
|
22
|
-
mod = async (...args) => {
|
|
23
|
-
await me.app.bajo.runHook(`${me.name}.${name}:beforeExec`, ...args)
|
|
24
|
-
const result = await fn(...args)
|
|
25
|
-
await me.app.bajo.runHook(`${me.name}.${name}:afterExec`, result, ...args)
|
|
26
|
-
return result
|
|
27
|
-
}
|
|
28
|
-
} else mod = fn
|
|
29
|
-
}
|
|
30
|
-
this[name] = mod
|
|
31
|
-
}
|
|
32
|
-
return files.length
|
|
33
|
-
}
|
package/test/method/isSet.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* global describe, context, it */
|
|
2
|
-
|
|
3
|
-
import { expect } from 'chai'
|
|
4
|
-
import { faker } from '@faker-js/faker'
|
|
5
|
-
import isSet from '../boot/core/method/is-set.js'
|
|
6
|
-
|
|
7
|
-
describe('isSet()', function () {
|
|
8
|
-
context('without argument', function () {
|
|
9
|
-
it("should return 'false'", function () {
|
|
10
|
-
expect(isSet()).to.equal(false)
|
|
11
|
-
})
|
|
12
|
-
})
|
|
13
|
-
context("with 'null' as argument", function () {
|
|
14
|
-
it("should return 'false'", function () {
|
|
15
|
-
expect(isSet(null)).to.equal(false)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
context("with 'undefined' as argument", function () {
|
|
19
|
-
it("should return 'false'", function () {
|
|
20
|
-
expect(isSet(undefined)).to.equal(false)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
context('with any number as argument', function () {
|
|
24
|
-
it("should return 'true'", function () {
|
|
25
|
-
expect(isSet(faker.number.float())).to.equal(true)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
context('with any string as argument', function () {
|
|
29
|
-
it("should return 'true'", function () {
|
|
30
|
-
expect(isSet(faker.string.alphanumeric())).to.equal(true)
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
context('with empty object as argument', function () {
|
|
34
|
-
it("should return 'true'", function () {
|
|
35
|
-
expect(isSet({})).to.equal(true)
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
context('with non empty object as argument', function () {
|
|
39
|
-
it("should return 'true'", function () {
|
|
40
|
-
expect(isSet({ a: 1, b: 2 })).to.equal(true)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|