UNPKG

@rnv/engine-core

Version:
96 lines 4.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var get_1 = tslib_1.__importDefault(require("lodash/get")); var core_1 = require("@rnv/core"); var configTargets = [ 'workspace.config', 'workspace.project.config', 'workspace.appConfig.configs', 'project.config', 'appConfig.configs', ]; exports.default = (0, core_1.createTask)({ description: 'Checks validity and config health of your project', dependsOn: [core_1.RnvTaskName.appConfigure], beforeDependsOn: function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, (0, core_1.configureRuntimeDefaults)()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }, fn: function (_a) { var ctx = _a.ctx; return tslib_1.__awaiter(void 0, void 0, void 0, function () { var configPaths, errMsg, hasErrors; return tslib_1.__generator(this, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, (0, core_1.configureRuntimeDefaults)()]; case 1: _b.sent(); configPaths = []; configTargets.forEach(function (target) { var tPath = (0, get_1.default)(ctx.paths, target); if (tPath) { if (Array.isArray(tPath)) { configPaths.push.apply(configPaths, tPath); } else { configPaths.push(tPath); } } }); errMsg = 'RENATIVE JSON SCHEMA VALIDITY CHECK:\n\n'; hasErrors = false; configPaths.forEach(function (cPath) { var _a; if ((0, core_1.fsExistsSync)(cPath)) { var cObj = (0, core_1.readObjectSync)(cPath); var result = (0, core_1.validateRenativeProjectSchema)(cObj); if (!result.success) { hasErrors = true; errMsg += (0, core_1.chalk)().yellow("\nInvalid schema in ".concat(cPath, ". ISSUES:\n\n")); (_a = result.error.errors) === null || _a === void 0 ? void 0 : _a.forEach(function (err) { errMsg += (0, core_1.chalk)().yellow("".concat((0, core_1.chalk)().grey(err.path), ": ").concat(err.message)); }); } // if (!valid) { // hasErrors = true; // // console.log('ERROR', ajv.errors); // errMsg += chalk().yellow( // `\nInvalid schema in ${ // // cPath}. ISSUES: ${JSON.stringify(ajv.errors, null, 2)}\n`); // cPath // }. ISSUES:\n\n` // ); // if (typeof ajv !== 'boolean' && ajv) { // ajv.errors?.forEach((err) => { // errMsg += chalk().yellow( // `${chalk().grey(err.dataPath === '' ? '/' : err.dataPath)}: ${err.message} ${Object.keys( // err.params // ) // .map((k) => `=> ${chalk().red(err.params[k])}`) // .join('\n')}\n` // ); // }); // } // } } }); if (!hasErrors) { errMsg += (0, core_1.chalk)().green("PASSED ".concat(configPaths.length, " files")); } (0, core_1.logToSummary)(errMsg); return [2 /*return*/]; } }); }); }, task: core_1.RnvTaskName.doctor, isGlobalScope: true, }); //# sourceMappingURL=taskDoctor.js.map