1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 | });
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 | const _ = require("lodash/fp");
|
13 | const configSchema_1 = require("./configSchema");
|
14 | const joi2desc_1 = require("./joi2desc");
|
15 | function buildDesc(error) {
|
16 | return error.path.join('.') + ' ' + (0, joi2desc_1.default)(error);
|
17 | }
|
18 | function buildLine(error) {
|
19 | return {
|
20 | desc: buildDesc(error),
|
21 | valid: false
|
22 | };
|
23 | }
|
24 | function buildReport(configPath, errors) {
|
25 | const errorLines = _.compose(_.map(buildLine), _.get('details'))(errors);
|
26 | return {
|
27 | desc: `检查 Taro 配置 (${configPath}),请到文档查看详情:https://nervjs.github.io/taro/docs/next/config-detail。`,
|
28 | lines: errorLines
|
29 | };
|
30 | }
|
31 | function default_1({ configPath, projectConfig }) {
|
32 | return __awaiter(this, void 0, void 0, function* () {
|
33 | const { error } = configSchema_1.default.validate(projectConfig, { abortEarly: false });
|
34 | return buildReport(configPath, error);
|
35 | });
|
36 | }
|
37 | exports.default = default_1;
|
38 |
|
\ | No newline at end of file |