UNPKG

777 BPlain TextView Raw
1import * as _ from 'lodash/fp'
2import joi2desc from './joi2desc'
3import configSchema from './configSchema'
4
5function buildDesc (error) {
6 return error.path.join('.') + ' ' + joi2desc(error)
7}
8
9function buildLine (error) {
10 return {
11 desc: buildDesc(error),
12 valid: false
13 }
14}
15
16function 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
27export default async function ({ configPath, projectConfig }) {
28 const { error } = configSchema.validate(projectConfig, { abortEarly: false })
29 return buildReport(configPath, error)
30}