bajo 1.2.2 → 1.2.4
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/bajo-core.js +25 -11
- package/package.json +1 -1
package/boot/class/bajo-core.js
CHANGED
|
@@ -23,7 +23,7 @@ import { types as formatTypes, formats } from '../lib/formats.js'
|
|
|
23
23
|
const require = createRequire(import.meta.url)
|
|
24
24
|
|
|
25
25
|
const {
|
|
26
|
-
isFunction, map,
|
|
26
|
+
isFunction, map, isObject,
|
|
27
27
|
trim, filter, isEmpty, orderBy, pullAt, find, camelCase, isNumber,
|
|
28
28
|
cloneDeep, isPlainObject, isArray, isString, set, omit, keys, indexOf,
|
|
29
29
|
last, get, has, values, dropRight, pick
|
|
@@ -88,6 +88,12 @@ class BajoCore extends Plugin {
|
|
|
88
88
|
return { ns, subNs, path: _path, fullNs: names.join('.'), type }
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
buildNsPath = ({ ns = '', subNs, subSubNs, path } = {}) => {
|
|
92
|
+
if (subNs) ns += '.' + subNs
|
|
93
|
+
if (subSubNs) ns += '.' + subSubNs
|
|
94
|
+
return `${ns}:${path}`
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
breakNsPath = (item = '', defaultNs = 'bajo', checkNs = true) => {
|
|
92
98
|
let [ns, ...path] = item.split(':')
|
|
93
99
|
const fullNs = ns
|
|
@@ -483,20 +489,28 @@ class BajoCore extends Plugin {
|
|
|
483
489
|
return indexOf(levels, level) >= logLevel
|
|
484
490
|
}
|
|
485
491
|
|
|
486
|
-
|
|
492
|
+
isValidAppPlugin = (file, type, returnPkg) => {
|
|
493
|
+
if (isObject(file)) return get(file, 'bajo.type') === type
|
|
494
|
+
file = resolvePath(file)
|
|
495
|
+
if (path.basename(file) !== 'package.json') file += '/package.json'
|
|
496
|
+
try {
|
|
497
|
+
const pkg = fs.readJsonSync(file)
|
|
498
|
+
const valid = get(pkg, 'bajo.type') === type
|
|
499
|
+
if (valid) return returnPkg ? pkg : valid
|
|
500
|
+
return false
|
|
501
|
+
} catch (err) {
|
|
502
|
+
return false
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
isValidApp = (dir, returnPkg) => {
|
|
487
507
|
if (!dir) dir = this.app.dir
|
|
488
|
-
dir
|
|
489
|
-
const hasMainDir = fs.existsSync(`${dir}/main`)
|
|
490
|
-
const hasPackageJson = fs.existsSync(`${dir}/package.json`)
|
|
491
|
-
return hasMainDir && hasPackageJson
|
|
508
|
+
return this.isValidAppPlugin(dir, 'app', returnPkg)
|
|
492
509
|
}
|
|
493
510
|
|
|
494
|
-
isValidPlugin = (dir) => {
|
|
511
|
+
isValidPlugin = (dir, returnPkg) => {
|
|
495
512
|
if (!dir) dir = this.app.dir
|
|
496
|
-
dir
|
|
497
|
-
const hasPluginDir = fs.existsSync(dir)
|
|
498
|
-
const hasPackageJson = fs.existsSync(`${dir}/package.json`)
|
|
499
|
-
return hasPluginDir && hasPackageJson
|
|
513
|
+
return this.isValidAppPlugin(dir, 'plugin', returnPkg)
|
|
500
514
|
}
|
|
501
515
|
|
|
502
516
|
join = (array, sep) => {
|