-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.js
More file actions
68 lines (59 loc) · 2.29 KB
/
boot.js
File metadata and controls
68 lines (59 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import _ from 'lodash'
const _debug = process.env.cimpl.debug
const debug = function () {
if (_debug)
for (const x in arguments)
if (typeof arguments[x] === 'object')
console.log("** cimpl-boot: ", arguments[x])
else console.log(`** cimpl-boot: ${arguments[x]}`)
}
const locale = 'en-US'
var imported = {
lang: [],
directives: []
}
debug("preparing...")
for (const importType in imported) {
for (const x in process.env.cimpl[importType]) {
const importName = process.env.cimpl[importType][x]
var importPath = `FOOO./${importType}/${process.env.cimpl[importType][x]}`
switch (importType) {
case 'lang':
importPath = `./${importType}/${locale}/${importName}.js`
break
case 'directives':
importPath = `./${importType}/${importName}/index.js`
break
}
debug(`import ${importType} '${importName}' from '${importPath}'`)
imported[importType][importName] = import(importPath)
}
}
debug("finished preparations")
export default async function ({ app }) {
console.log("running", process.env)
for (const importType in imported) {
for (const x in imported[importType]) {
debug(`processing import [${importType}] '${x}'`, imported[importType][x])
switch (importType) {
case 'lang':
imported[importType][x].then((res) => {
debug(`result for import lang ? ${x}`, res)
const i18nGlobal = app.__VUE_I18N__.global
i18nGlobal.setLocaleMessage(locale, _.merge({}, i18nGlobal.getLocaleMessage(locale), res.default))
}).catch((res) => {
debug(`import ERROR [${importType}] '${x}'`, res)
})
break
case 'directives':
debug("result for import directive?", imported[importType][x])
imported[importType][x].then((res) => {
app.directive(x, res.default)
}).catch((res) => {
debug(`import ERROR [${importType}] '${x}'`, res)
})
break
}
}
}
}