1 | import * as _ from 'lodash/fp'
|
2 | import joi2desc from './joi2desc'
|
3 | import configSchema from './configSchema'
|
4 |
|
5 | function buildDesc (error) {
|
6 | return error.path.join('.') + ' ' + joi2desc(error)
|
7 | }
|
8 |
|
9 | function buildLine (error) {
|
10 | return {
|
11 | desc: buildDesc(error),
|
12 | valid: false
|
13 | }
|
14 | }
|
15 |
|
16 | function buildReport (configPath, errors) {
|
17 | const errorLines = _.compose(
|
18 | _.map(buildLine),
|
19 | _.get('details')
|
20 | )(errors)
|
21 | return {
|
22 | desc: `检查 Taro 配置 (${configPath}),请到文档查看详情:https://nervjs.github.io/taro/docs/next/config-detail。`,
|
23 | lines: errorLines
|
24 | }
|
25 | }
|
26 |
|
27 | export default async function ({ configPath, projectConfig }) {
|
28 | const { error } = configSchema.validate(projectConfig, { abortEarly: false })
|
29 | return buildReport(configPath, error)
|
30 | }
|