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.
@@ -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
- isValidApp = (dir) => {
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 = resolvePath(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 = resolvePath(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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {