UNPKG

@yolkai/nx-workspace

Version:

Extensible Dev Tools for Monorepos

50 lines (48 loc) 2.23 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const core_1 = require("@angular-devkit/core"); const literals_1 = require("@angular-devkit/core/src/utils/literals"); const ast_utils_1 = require("../../utils/ast-utils"); const workspace_1 = require("../../utils/workspace"); function fixTslints(host) { return __awaiter(this, void 0, void 0, function* () { const workspace = yield workspace_1.getWorkspace(host); const rules = []; workspace.projects.forEach(proj => { const tslintPath = core_1.join(core_1.normalize(proj.root), 'tslint.json'); if (host.exists(tslintPath)) { rules.push(ast_utils_1.updateJsonInTree(tslintPath, (json, context) => { if (Array.isArray(json.rules)) { if (json.rules.length === 0) { json.rules = {}; } else { context.logger.warn(`"rules" in "${tslintPath}" is an array but should be an object.`); } } return json; })); } }); return schematics_1.chain(rules); }); } function showInfo(host, context) { context.logger.info(literals_1.stripIndents ` Nx generated invalid tslint configurations in a prior version. These invalid configurations will be fixed. `); } function default_1() { return schematics_1.chain([showInfo, fixTslints]); } exports.default = default_1;