bajo 1.1.6 → 1.1.8

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
@@ -22,9 +22,8 @@ class App {
22
22
  const parts = l.split('=')
23
23
  cwd = parts[1]
24
24
  }
25
- cwd = resolvePath(cwd)
26
- process.env.BAJOCWD = cwd
27
- this.cwd = cwd
25
+ this.dir = resolvePath(cwd)
26
+ process.env.APPDIR = this.dir
28
27
  }
29
28
 
30
29
  addPlugin = (plugin) => {
@@ -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.cwd)
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`)
@@ -377,14 +377,14 @@ class BajoCore extends Plugin {
377
377
  }
378
378
 
379
379
  getModuleDir = (pkgName, base) => {
380
- if (pkgName === 'main') return resolvePath(process.env.BAJOCWD)
381
- if (base === 'main') base = process.env.BAJOCWD
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(process.env.BAJOCWD, 'node_modules')))
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 = process.env.BAJOCWD
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 = process.env.BAJOCWD
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`)
@@ -32,7 +32,7 @@ class BajoPlugin extends Plugin {
32
32
  ['name', 'version', 'description', 'author', 'license', 'homepage'])
33
33
  if (this.name === this.app.bajo.mainNs) {
34
34
  this.alias = this.app.bajo.mainNs
35
- this.title = this.alias
35
+ this.title = this.title ?? this.alias
36
36
  }
37
37
  // merge with config from datadir
38
38
  try {
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)) console.log(text)
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {