bajo 0.3.2 → 0.3.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.
package/boot/attach-helper.js
CHANGED
|
@@ -7,6 +7,7 @@ import dayjs from './lib/dayjs.js'
|
|
|
7
7
|
import fs from 'fs-extra'
|
|
8
8
|
import fastGlob from 'fast-glob'
|
|
9
9
|
import { sprintf } from 'sprintf-js'
|
|
10
|
+
import outmatch from 'outmatch'
|
|
10
11
|
|
|
11
12
|
export default async function () {
|
|
12
13
|
this.bajo.helper = await buildHelper.call(this, `${currentLoc(import.meta).dir}/helper`)
|
|
@@ -27,6 +28,7 @@ export default async function () {
|
|
|
27
28
|
this.bajo.helper.fs = fs
|
|
28
29
|
this.bajo.helper.fastGlob = fastGlob
|
|
29
30
|
this.bajo.helper.sprintf = sprintf
|
|
31
|
+
this.bajo.helper.outmatch = outmatch
|
|
30
32
|
// last cleanup
|
|
31
33
|
this.bajo.helper.freeze(this.bajo.helper, true)
|
|
32
34
|
if (!fs.existsSync(this.bajo.config.dir.data)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPlainObject, isArray, isNumber, set } from 'lodash-es'
|
|
1
|
+
import { isPlainObject, isArray, isNumber, set, cloneDeep } from 'lodash-es'
|
|
2
2
|
import dotenvParseVariables from 'dotenv-parse-variables'
|
|
3
3
|
import ms from 'ms'
|
|
4
4
|
import dayjs from '../lib/dayjs.js'
|
|
@@ -16,7 +16,8 @@ function parseDt (val) {
|
|
|
16
16
|
return dt.toDate()
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function parseObject (
|
|
19
|
+
function parseObject (input, silent = true, parseValue = false) {
|
|
20
|
+
const obj = cloneDeep(input)
|
|
20
21
|
const keys = Object.keys(obj)
|
|
21
22
|
keys.forEach(k => {
|
|
22
23
|
const v = obj[k]
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { camelCase, pick, isString, omit
|
|
1
|
+
import { camelCase, pick, isString, omit } from 'lodash-es'
|
|
2
2
|
import fs from 'fs-extra'
|
|
3
|
-
import lockfile from 'proper-lockfile'
|
|
4
3
|
import omittedPluginKeys from '../lib/omitted-plugin-keys.js'
|
|
5
4
|
import titleize from '../helper/titleize.js'
|
|
6
5
|
|
|
@@ -24,7 +23,7 @@ export async function readAllConfigs (base, name) {
|
|
|
24
23
|
return cfg
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
async function runner (pkg, {
|
|
26
|
+
async function runner (pkg, { argv, env }) {
|
|
28
27
|
const { log, getConfig, getModuleDir, readConfig, error, readJson, defaultsDeep } = this.bajo.helper
|
|
29
28
|
const config = getConfig()
|
|
30
29
|
const name = camelCase(pkg)
|
|
@@ -53,29 +52,16 @@ async function runner (pkg, { singles, argv, env }) {
|
|
|
53
52
|
cfg = defaultsDeep({}, envArgv ?? {}, cfg ?? {})
|
|
54
53
|
cfg.dependencies = cfg.dependencies ?? []
|
|
55
54
|
if (isString(cfg.dependencies)) cfg.dependencies = [cfg.dependencies]
|
|
56
|
-
if (cfg.single) {
|
|
57
|
-
const lockfileDir = `${config.dir.tmp}/lock`
|
|
58
|
-
const lockfilePath = `${lockfileDir}/${name}.lock`
|
|
59
|
-
fs.ensureDirSync(lockfileDir)
|
|
60
|
-
const file = `${dir}/package.json`
|
|
61
|
-
try {
|
|
62
|
-
await lockfile.lock(file, { lockfilePath })
|
|
63
|
-
} catch (err) {
|
|
64
|
-
singles.push(pkg)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
55
|
if (!this[name]) this[name] = {}
|
|
68
56
|
this[name].config = cfg
|
|
69
57
|
}
|
|
70
58
|
|
|
71
|
-
async function buildConfig ({
|
|
59
|
+
async function buildConfig ({ argv, env }) {
|
|
72
60
|
const { log, freeze } = this.bajo.helper
|
|
73
61
|
log.debug('Read configurations')
|
|
74
62
|
for (const pkg of this.bajo.config.plugins) {
|
|
75
|
-
await runner.call(this, pkg, {
|
|
63
|
+
await runner.call(this, pkg, { argv, env })
|
|
76
64
|
}
|
|
77
|
-
pull(this.bajo.config.plugins, ...singles)
|
|
78
|
-
each(singles, s => delete this[camelCase(s)])
|
|
79
65
|
freeze(this.bajo.config)
|
|
80
66
|
}
|
|
81
67
|
|
package/boot/plugins/index.js
CHANGED
|
@@ -11,17 +11,16 @@ import parseArgsArgv from '../lib/parse-args-argv.js'
|
|
|
11
11
|
import parseEnv from '../lib/parse-env.js'
|
|
12
12
|
|
|
13
13
|
async function bootBajos () {
|
|
14
|
-
const singles = []
|
|
15
14
|
const { argv } = await parseArgsArgv({ useParser: true }) ?? {}
|
|
16
15
|
const env = parseEnv() ?? {}
|
|
17
16
|
await collectConfigHandlers.call(this)
|
|
18
|
-
await buildConfig.call(this, {
|
|
17
|
+
await buildConfig.call(this, { argv, env })
|
|
19
18
|
await extendConfig.call(this)
|
|
20
19
|
await checkClash.call(this)
|
|
21
20
|
await checkDependency.call(this)
|
|
22
21
|
await attachHelper.call(this)
|
|
23
22
|
await collectHooks.call(this)
|
|
24
|
-
await run.call(this
|
|
23
|
+
await run.call(this)
|
|
25
24
|
await collectExitHandlers.call(this)
|
|
26
25
|
}
|
|
27
26
|
|
package/boot/plugins/run.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { set, get, camelCase, upperFirst, map } from 'lodash-es'
|
|
2
2
|
|
|
3
|
-
async function run (
|
|
3
|
+
async function run () {
|
|
4
4
|
const { runHook, log, eachPlugins, importModule, freeze, getConfig, print } = this.bajo.helper
|
|
5
5
|
const config = getConfig()
|
|
6
6
|
const methods = ['init']
|
|
@@ -22,9 +22,6 @@ async function run ({ singles }) {
|
|
|
22
22
|
await runHook(`bajo:${camelCase(`after ${f} all plugins`)}`)
|
|
23
23
|
}
|
|
24
24
|
log.debug('Loaded plugins: %s', map(config.plugins, b => camelCase(b)).join(', '))
|
|
25
|
-
if (singles.length > 0) {
|
|
26
|
-
log.warn('Unloaded \'single\' plugins: %s', map(singles, s => camelCase(s)).join(', '))
|
|
27
|
-
}
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
export default run
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bajo",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "A framework to build a giant monstrous app rapidly",
|
|
5
5
|
"main": "boot/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"omit-deep": "^0.3.0",
|
|
44
44
|
"ora": "^8.0.1",
|
|
45
45
|
"outmatch": "^0.7.0",
|
|
46
|
-
"proper-lockfile": "^4.1.2",
|
|
47
46
|
"semver": "^7.5.1",
|
|
48
47
|
"sprintf-js": "^1.1.2",
|
|
49
48
|
"yargs": "^17.7.2"
|