bajo 2.6.2 → 2.7.2

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/class/bajo.js CHANGED
@@ -225,8 +225,7 @@ class Bajo extends Plugin {
225
225
  * @returns {Object[]} The collection
226
226
  */
227
227
  buildCollections = async (options = {}) => {
228
- let { ns, handler, dupChecks = [], container, useDefaultName } = options
229
- useDefaultName = useDefaultName ?? true
228
+ let { ns, handler, dupChecks = [], container, useDefaultName = true, noDefault = true } = options
230
229
  if (!ns) ns = this.ns
231
230
  const cfg = this.app[ns].getConfig()
232
231
  let items = get(cfg, container, [])
@@ -269,6 +268,8 @@ class Bajo extends Plugin {
269
268
  }
270
269
  }
271
270
 
271
+ if (!noDefault && !items.find(item => item.name === 'default')) this.app[ns].fatal('missing%s%s', 'default', container)
272
+
272
273
  /**
273
274
  * Run after collection is built
274
275
  *
package/class/base.js CHANGED
@@ -38,7 +38,7 @@ class Base extends Plugin {
38
38
  */
39
39
  loadConfig = async () => {
40
40
  const { defaultsDeep } = this.app.lib.aneka
41
- const { get, keys, pick, isEmpty } = this.app.lib._
41
+ const { get, keys, pick, isEmpty, upperFirst } = this.app.lib._
42
42
  const { log, getModuleDir, readAllConfigs } = this.app.bajo
43
43
  const { parseObject } = this.app.lib
44
44
 
@@ -60,8 +60,7 @@ class Base extends Plugin {
60
60
  } catch (err) {}
61
61
  const cfgEnv = get(this, `app.env.${this.ns}`, {})
62
62
  const cfgArgv = get(this, `app.argv.${this.ns}`, {})
63
- const envArgv = defaultsDeep({}, cfgEnv, cfgArgv)
64
- cfg = pick(defaultsDeep({}, envArgv ?? {}, cfg ?? {}, this.config ?? {}), defKeys)
63
+ cfg = pick(defaultsDeep({}, cfgEnv ?? {}, cfgArgv ?? {}, cfg ?? {}, this[`config${upperFirst(this.app.bajo.config.env)}`] ?? {}, this.config ?? {}), defKeys)
65
64
  this.config = parseObject(cfg, { parseValue: true })
66
65
  }
67
66
 
@@ -10,9 +10,6 @@ import {
10
10
  collectHooks,
11
11
  run
12
12
  } from './base.js'
13
- import aneka from 'aneka'
14
-
15
- const { currentLoc, resolvePath } = aneka
16
13
 
17
14
  const {
18
15
  orderBy,
@@ -108,7 +105,7 @@ export default factory
108
105
  */
109
106
  export async function buildBaseConfig () {
110
107
  // dirs
111
- const { defaultsDeep } = this.app.lib.aneka
108
+ const { defaultsDeep, textToArray, currentLoc, resolvePath } = this.app.lib.aneka
112
109
  this.config = defaultsDeep({}, this.app.envVars._, this.app.argv._)
113
110
  set(this, 'dir.base', this.app.dir)
114
111
  const path = currentLoc(import.meta).dir + '/../..'
@@ -130,12 +127,7 @@ export async function buildBaseConfig () {
130
127
  if (isEmpty(pluginPkgs)) {
131
128
  const pluginsFile = `${this.dir.data}/config/.plugins`
132
129
  if (fs.existsSync(pluginsFile)) {
133
- let lines = fs.readFileSync(pluginsFile, 'utf8')
134
- lines = lines.trim().split('\n').map(p => p.trim())
135
- pluginPkgs = lines.filter(c => {
136
- const line = c.split('#')[0].trim()
137
- return !isEmpty(line)
138
- })
130
+ pluginPkgs = textToArray(fs.readFileSync(pluginsFile, 'utf8'))
139
131
  }
140
132
  }
141
133
  }
@@ -153,6 +145,7 @@ export async function buildBaseConfig () {
153
145
  * @async
154
146
  */
155
147
  export async function buildPlugins () {
148
+ const { resolvePath } = this.app.lib.aneka
156
149
  this.log.trace('buildPluginsStart')
157
150
  for (const pkg of this.app.pluginPkgs) {
158
151
  const ns = camelCase(pkg)
package/class/plugin.js CHANGED
@@ -170,6 +170,7 @@ class Plugin {
170
170
  * @param {string[]} names - Method's names
171
171
  */
172
172
  selfBind (names) {
173
+ if (!Array.isArray(names)) names = [names]
173
174
  for (const name of names) {
174
175
  this[name] = this[name].bind(this)
175
176
  }
@@ -180,5 +180,7 @@
180
180
  "method": "Method",
181
181
  "exist%s%s": "%s|upperFirst '%s' exists already",
182
182
  "fieldError%s%s": "'%s': %s|lowerFirst",
183
- "reservedName%s%s": "%s|upperFirst name '%s' is a reserved name. Please rename to something else"
183
+ "reservedName%s%s": "%s|upperFirst name '%s' is a reserved name. Please rename to something else",
184
+ "missing%s%s": "Missing '%s' %s",
185
+ "processing...": "Processing..."
184
186
  }
@@ -180,5 +180,7 @@
180
180
  "method": "Metode",
181
181
  "exist%s%s": "%s|upperFirst '%s' sudah ada",
182
182
  "fieldError%s%s": "'%s': %s|lowerFirst",
183
- "reservedName%s%s": "Nama %s|lowerFirst '%s' adalah nama tang di reserve. Silahkan gunakan nama lainnya"
183
+ "reservedName%s%s": "Nama %s|lowerFirst '%s' adalah nama tang di reserve. Silahkan gunakan nama lainnya",
184
+ "missing%s%s": "%s|upperFirst '%s' tidak ditemukan",
185
+ "processing...": "Memroses..."
184
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "2.6.2",
3
+ "version": "2.7.2",
4
4
  "description": "The ultimate framework for whipping up massive apps in no time",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,7 +26,7 @@
26
26
  "homepage": "https://github.com/ardhi/bajo#readme",
27
27
  "dependencies": {
28
28
  "add-filename-increment": "^1.0.0",
29
- "aneka": "^0.12.0",
29
+ "aneka": "^0.13.1",
30
30
  "chalk": "^5.6.0",
31
31
  "dayjs": "^1.11.13",
32
32
  "deep-freeze-strict": "^1.1.1",
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-03-11
4
+
5
+ - [2.7.2] Bug fix in env dependent config building
6
+ - [2.7.2] ```selfBind()``` now also accept string for single method
7
+
8
+ ## 2026-03-10
9
+
10
+ - [2.7.1] Using ```textToArray()``` from ```aneka``` instead of custom function to parse text into array
11
+
12
+ ## 2026-03-02
13
+
14
+ - [2.7.0] Add ```useDefaultName``` parameter to ```buildCollection()```
15
+ - [2.7.0] Add some translations
16
+
3
17
  ## 2026-02-26
4
18
 
5
19
  - [2.6.2] Bug fix on ```getMethod()```