UNPKG

679 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(_.map(buildLine), _.get('details'))(errors)
18 return {
19 desc: `检查 Taro 配置 (${configPath})`,
20 lines: errorLines
21 }
22}
23
24export default async function ({ configPath, projectConfig }) {
25 const { error } = configSchema.validate(projectConfig, { abortEarly: false })
26 return buildReport(configPath, error)
27}