bajo 1.2.3 → 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 +19 -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
|
|
@@ -489,20 +489,28 @@ class BajoCore extends Plugin {
|
|
|
489
489
|
return indexOf(levels, level) >= logLevel
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
|
|
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) => {
|
|
493
507
|
if (!dir) dir = this.app.dir
|
|
494
|
-
dir
|
|
495
|
-
const hasMainDir = fs.existsSync(`${dir}/main`)
|
|
496
|
-
const hasPackageJson = fs.existsSync(`${dir}/package.json`)
|
|
497
|
-
return hasMainDir && hasPackageJson
|
|
508
|
+
return this.isValidAppPlugin(dir, 'app', returnPkg)
|
|
498
509
|
}
|
|
499
510
|
|
|
500
|
-
isValidPlugin = (dir) => {
|
|
511
|
+
isValidPlugin = (dir, returnPkg) => {
|
|
501
512
|
if (!dir) dir = this.app.dir
|
|
502
|
-
dir
|
|
503
|
-
const hasPluginDir = fs.existsSync(dir)
|
|
504
|
-
const hasPackageJson = fs.existsSync(`${dir}/package.json`)
|
|
505
|
-
return hasPluginDir && hasPackageJson
|
|
513
|
+
return this.isValidAppPlugin(dir, 'plugin', returnPkg)
|
|
506
514
|
}
|
|
507
515
|
|
|
508
516
|
join = (array, sep) => {
|