bajo 1.1.6 → 1.1.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/boot/class/app.js
CHANGED
|
@@ -36,7 +36,7 @@ export async function buildBaseConfig () {
|
|
|
36
36
|
this.applet = this.app.argv._.applet
|
|
37
37
|
this.config = this.defaultsDeep({}, this.app.env._, this.app.argv._)
|
|
38
38
|
this.alias = this.name
|
|
39
|
-
set(this, 'dir.base', this.app.
|
|
39
|
+
set(this, 'dir.base', this.app.dir)
|
|
40
40
|
const path = currentLoc(import.meta).dir + '/../../..'
|
|
41
41
|
set(this, 'dir.pkg', this.resolvePath(path))
|
|
42
42
|
if (!get(this, 'dir.data')) set(this, 'dir.data', `${this.dir.base}/data`)
|
package/boot/class/bajo-core.js
CHANGED
|
@@ -377,14 +377,14 @@ class BajoCore extends Plugin {
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
getModuleDir = (pkgName, base) => {
|
|
380
|
-
if (pkgName === 'main') return resolvePath(
|
|
381
|
-
if (base === 'main') base =
|
|
380
|
+
if (pkgName === 'main') return resolvePath(this.app.dir)
|
|
381
|
+
if (base === 'main') base = this.app.dir
|
|
382
382
|
else if (this && this.app && this.app[base]) base = this.app[base].pkgName
|
|
383
383
|
const pkgPath = pkgName + '/package.json'
|
|
384
384
|
const paths = require.resolve.paths(pkgPath)
|
|
385
385
|
const gdir = this.getGlobalModuleDir()
|
|
386
386
|
paths.unshift(gdir)
|
|
387
|
-
paths.unshift(resolvePath(path.join(
|
|
387
|
+
paths.unshift(resolvePath(path.join(this.app.dir, 'node_modules')))
|
|
388
388
|
let dir = this.findDeep(pkgPath, paths)
|
|
389
389
|
if (base && !dir) dir = this.findDeep(`${base}/node_modules/${pkgPath}`, paths)
|
|
390
390
|
if (!dir) return null
|
|
@@ -503,7 +503,7 @@ class BajoCore extends Plugin {
|
|
|
503
503
|
}
|
|
504
504
|
|
|
505
505
|
isValidApp = (dir) => {
|
|
506
|
-
if (!dir) dir =
|
|
506
|
+
if (!dir) dir = this.app.dir
|
|
507
507
|
dir = resolvePath(dir)
|
|
508
508
|
const hasMainDir = fs.existsSync(`${dir}/main/plugin`)
|
|
509
509
|
const hasPackageJson = fs.existsSync(`${dir}/package.json`)
|
|
@@ -511,7 +511,7 @@ class BajoCore extends Plugin {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
isValidPlugin = (dir) => {
|
|
514
|
-
if (!dir) dir =
|
|
514
|
+
if (!dir) dir = this.app.dir
|
|
515
515
|
dir = resolvePath(dir)
|
|
516
516
|
const hasPluginDir = fs.existsSync(`${dir}/plugin`)
|
|
517
517
|
const hasPackageJson = fs.existsSync(`${dir}/package.json`)
|
package/boot/class/log.js
CHANGED
|
@@ -54,6 +54,10 @@ class Log {
|
|
|
54
54
|
data = null
|
|
55
55
|
}
|
|
56
56
|
args = without(args, undefined)
|
|
57
|
+
if (data instanceof Error) {
|
|
58
|
+
msg = 'error%s'
|
|
59
|
+
args = [data.message]
|
|
60
|
+
}
|
|
57
61
|
msg = `[${this.plugin.name}] ${this.write(msg, ...args)}`
|
|
58
62
|
if (this.plugin.app[this.bajoLog] && this.plugin.app[this.bajoLog].logger) {
|
|
59
63
|
this.plugin.app[this.bajoLog].logger[level](data, msg, ...args)
|
|
@@ -69,7 +73,10 @@ class Log {
|
|
|
69
73
|
text = `[${dayjs(dt).utc(true).format(this.format)}] ${upperFirst(level)}: ${msg}`
|
|
70
74
|
if (!isEmpty(data)) text += '\n' + JSON.stringify(data)
|
|
71
75
|
}
|
|
72
|
-
if (!this.isIgnored(level))
|
|
76
|
+
if (!this.isIgnored(level)) {
|
|
77
|
+
console.log(text)
|
|
78
|
+
if (data instanceof Error && level === 'trace') console.error(data)
|
|
79
|
+
}
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
}
|