1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = _default;
|
7 | exports.AUTOMATIC_FIX_LEVELS = void 0;
|
8 |
|
9 | function _chalk() {
|
10 | const data = _interopRequireDefault(require("chalk"));
|
11 |
|
12 | _chalk = function () {
|
13 | return data;
|
14 | };
|
15 |
|
16 | return data;
|
17 | }
|
18 |
|
19 | function _ora() {
|
20 | const data = _interopRequireDefault(require("ora"));
|
21 |
|
22 | _ora = function () {
|
23 | return data;
|
24 | };
|
25 |
|
26 | return data;
|
27 | }
|
28 |
|
29 | function _cliTools() {
|
30 | const data = require("@react-native-community/cli-tools");
|
31 |
|
32 | _cliTools = function () {
|
33 | return data;
|
34 | };
|
35 |
|
36 | return data;
|
37 | }
|
38 |
|
39 | var _healthchecks = require("./healthchecks");
|
40 |
|
41 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
42 |
|
43 | let AUTOMATIC_FIX_LEVELS;
|
44 | exports.AUTOMATIC_FIX_LEVELS = AUTOMATIC_FIX_LEVELS;
|
45 |
|
46 | (function (AUTOMATIC_FIX_LEVELS) {
|
47 | AUTOMATIC_FIX_LEVELS["ALL_ISSUES"] = "ALL_ISSUES";
|
48 | AUTOMATIC_FIX_LEVELS["ERRORS"] = "ERRORS";
|
49 | AUTOMATIC_FIX_LEVELS["WARNINGS"] = "WARNINGS";
|
50 | })(AUTOMATIC_FIX_LEVELS || (exports.AUTOMATIC_FIX_LEVELS = AUTOMATIC_FIX_LEVELS = {}));
|
51 |
|
52 | async function _default({
|
53 | healthchecks,
|
54 | automaticFixLevel,
|
55 | stats,
|
56 | environmentInfo
|
57 | }) {
|
58 |
|
59 | if (process.stdout.isTTY) {
|
60 |
|
61 | process.stdout.moveCursor(0, -6);
|
62 |
|
63 | process.stdout.clearScreenDown();
|
64 | }
|
65 |
|
66 | const totalIssuesBasedOnFixLevel = {
|
67 | [AUTOMATIC_FIX_LEVELS.ALL_ISSUES]: stats.errors + stats.warnings,
|
68 | [AUTOMATIC_FIX_LEVELS.ERRORS]: stats.errors,
|
69 | [AUTOMATIC_FIX_LEVELS.WARNINGS]: stats.warnings
|
70 | };
|
71 | const issuesCount = totalIssuesBasedOnFixLevel[automaticFixLevel];
|
72 |
|
73 | _cliTools().logger.log(`\nAttempting to fix ${_chalk().default.bold(issuesCount.toString())} issue${issuesCount > 1 ? 's' : ''}...`);
|
74 |
|
75 | for (const category of healthchecks) {
|
76 | const healthchecksToRun = category.healthchecks.filter(healthcheck => {
|
77 | if (automaticFixLevel === AUTOMATIC_FIX_LEVELS.ALL_ISSUES) {
|
78 | return healthcheck.needsToBeFixed;
|
79 | }
|
80 |
|
81 | if (automaticFixLevel === AUTOMATIC_FIX_LEVELS.ERRORS) {
|
82 | return healthcheck.needsToBeFixed && healthcheck.type === _healthchecks.HEALTHCHECK_TYPES.ERROR;
|
83 | }
|
84 |
|
85 | if (automaticFixLevel === AUTOMATIC_FIX_LEVELS.WARNINGS) {
|
86 | return healthcheck.needsToBeFixed && healthcheck.type === _healthchecks.HEALTHCHECK_TYPES.WARNING;
|
87 | }
|
88 |
|
89 | return;
|
90 | });
|
91 |
|
92 | if (!healthchecksToRun.length) {
|
93 | continue;
|
94 | }
|
95 |
|
96 | _cliTools().logger.log(`\n${_chalk().default.dim(category.label)}`);
|
97 |
|
98 | for (const healthcheckToRun of healthchecksToRun) {
|
99 | const spinner = (0, _ora().default)({
|
100 | prefixText: '',
|
101 | text: healthcheckToRun.label
|
102 | }).start();
|
103 |
|
104 | try {
|
105 | await healthcheckToRun.runAutomaticFix({
|
106 | loader: spinner,
|
107 | environmentInfo
|
108 | });
|
109 | } catch (error) {
|
110 | }
|
111 | }
|
112 | }
|
113 | } |
\ | No newline at end of file |