bajo 1.1.2 → 1.1.3

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.
@@ -154,5 +154,7 @@
154
154
  "thankYou": "Thank you!",
155
155
  "adminArea": "Admin Area",
156
156
  "instanceCreatedOnConn%s%s": "Instance '%s' created on connection '%s'",
157
- "fileNotModuleHandler%s": "File '%s' is NOT a module handler"
157
+ "fileNotModuleHandler%s": "File '%s' is NOT a module handler",
158
+ "error%s": "Error: %s",
159
+ "invalid%s%s": "Invalid %s (%s)"
158
160
  }
package/bajo/intl/id.json CHANGED
@@ -154,5 +154,7 @@
154
154
  "thankYou": "Terima kasih!",
155
155
  "adminArea": "Area Admin",
156
156
  "instanceCreatedOnConn%s%s": "Instance '%s' telah dibuat pada koneksi '%s'",
157
- "fileNotModuleHandler%s": "Berkas '%s' BUKAN merupakan module handler"
157
+ "fileNotModuleHandler%s": "Berkas '%s' BUKAN merupakan module handler",
158
+ "error%s": "Kesalahan: %s",
159
+ "invalid%s%s": "%s tidak valid (%s)"
158
160
  }
@@ -42,8 +42,10 @@ export async function buildBaseConfig () {
42
42
  if (!get(this, 'dir.data')) set(this, 'dir.data', `${this.dir.base}/data`)
43
43
  this.dir.data = this.resolvePath(this.dir.data)
44
44
  if (!fs.existsSync(this.dir.data)) {
45
- this.log.warn('ddirNotExists%s', this.dir.data)
45
+ console.log('Data directory (%s) doesn\'t exist yet', this.dir.data)
46
+ process.exit(1)
46
47
  }
48
+ fs.ensureDirSync(`${this.dir.data}/config`)
47
49
  if (!this.dir.tmp) {
48
50
  this.dir.tmp = `${this.resolvePath(os.tmpdir())}/${this.name}`
49
51
  fs.ensureDirSync(this.dir.tmp)
@@ -19,8 +19,15 @@ async function buildPlugins () {
19
19
  this.pluginPkgs.push(this.mainNs)
20
20
  for (const pkg of this.pluginPkgs) {
21
21
  const ns = camelCase(pkg)
22
- const dir = ns === this.mainNs ? (`${this.dir.base}/${this.mainNs}`) : this.getModuleDir(pkg)
23
- if (ns !== this.mainNs && !fs.existsSync(`${dir}/plugin`)) throw new Error(`Package '${pkg}' isn't a valid Bajo package`)
22
+ let dir
23
+ if (ns === 'main') {
24
+ dir = `${this.dir.base}/${this.mainNs}`
25
+ fs.ensureDirSync(dir)
26
+ fs.ensureDirSync(`${dir}/plugin`)
27
+ } else {
28
+ dir = this.getModuleDir(pkg)
29
+ if (!fs.existsSync(`${dir}/plugin`)) throw new Error(`Package '${pkg}' isn't a valid Bajo package`)
30
+ }
24
31
  let plugin
25
32
  const factory = `${dir}/plugin/factory.js`
26
33
  if (fs.existsSync(factory)) {
@@ -28,7 +28,7 @@ const {
28
28
  isFunction, words, upperFirst, map, concat, uniq, forOwn, padStart,
29
29
  trim, filter, isEmpty, orderBy, pullAt, find, camelCase, isNumber,
30
30
  cloneDeep, isPlainObject, isArray, isString, set, omit, keys, indexOf,
31
- last, get, has, values, dropRight, mergeWith
31
+ last, get, has, values, dropRight, pick, mergeWith
32
32
  } = lodash
33
33
 
34
34
  class BajoCore extends Plugin {
@@ -163,14 +163,11 @@ class BajoCore extends Plugin {
163
163
  if (deleted.length > 0) pullAt(items, deleted)
164
164
 
165
165
  // check for duplicity
166
- for (const c of items) {
167
- for (const d of dupChecks) {
168
- if (isFunction(d)) await d.call(this.app[ns], c, items)
169
- else {
170
- const checker = set({}, d, c[d])
171
- const match = filter(items, checker)
172
- if (match.length > 1) this.app[ns].fatal('oneOrMoreSharedTheSame%s%s', container, this.join(dupChecks.filter(i => !isFunction(i))))
173
- }
166
+ if (dupChecks.length > 0) {
167
+ const checkers = []
168
+ for (const c of items) {
169
+ const checker = JSON.stringify(pick(c, dupChecks))
170
+ if (checkers.includes(checker)) this.app[ns].fatal('oneOrMoreSharedTheSame%s%s', container, this.join(dupChecks.filter(i => !isFunction(i))))
174
171
  }
175
172
  }
176
173
  await this.runHook(`${ns}:${camelCase('afterBuildCollection')}`, container)
@@ -3,6 +3,20 @@ import omittedPluginKeys from '../lib/omitted-plugin-keys.js'
3
3
  import Log from './log.js'
4
4
  import Print from './print.js'
5
5
  import BajoError from './error.js'
6
+ import fastGlob from 'fast-glob'
7
+ import { sprintf } from 'sprintf-js'
8
+ import outmatch from 'outmatch'
9
+ import dayjs from '../lib/dayjs.js'
10
+ import fs from 'fs-extra'
11
+
12
+ const lib = {
13
+ _: lodash,
14
+ fs,
15
+ fastGlob,
16
+ sprintf,
17
+ outmatch,
18
+ dayjs
19
+ }
6
20
 
7
21
  const { get, isEmpty, cloneDeep, omit, isPlainObject, camelCase } = lodash
8
22
 
@@ -12,7 +26,7 @@ class Plugin {
12
26
  this.name = camelCase(pkgName)
13
27
  this.app = app
14
28
  this.config = {}
15
- this.lib = {}
29
+ this.lib = lib
16
30
  this.exitHandler = undefined
17
31
  }
18
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {