-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetoxDoctorCheck.js
113 lines (93 loc) · 3.16 KB
/
detoxDoctorCheck.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import WindowsTools from "./operatingSystemChecks/windowsTools.js";
import LinuxTools from "./operatingSystemChecks/linuxTools.js";
import chalk from "chalk";
import MacOsTools from "./operatingSystemChecks/macosTools.js";
import { printFail, printWarning, printCheckMessage } from "./utils/logger.js";
class DetoxDoctorCheck {
constructor(options) {
this.options = options;
}
start() {
this.reportOptionsUsed();
switch (process.platform) {
case "darwin":
const macosTools = new MacOsTools(this.options);
macosTools.reportSystemInfo();
const macOsResults = macosTools.runMacOsCheck();
if (!this.options.excludeOptional) {
this.reportOptionalActionsToTake(macOsResults);
}
this.reportActionsToTake(macOsResults);
break;
case "win32":
const windowsTools = new WindowsTools(this.options);
windowsTools.reportSystemInfo();
const windowResults = windowsTools.runWindowsCheck(this.options);
if (!this.options?.excludeOptional) {
this.reportOptionalActionsToTake(windowResults);
}
this.reportActionsToTake(windowResults);
break;
case "linux":
const linuxTools = new LinuxTools();
linuxTools.reportSystemInfo();
const linuxResults = linuxTools.runLinuxCheck(this.options);
if (!this.options.excludeOptional) {
this.reportOptionalActionsToTake(linuxResults);
}
this.reportActionsToTake(linuxResults);
break;
default:
console.log(chalk.red.bold("Unrecognised OS"));
break;
}
}
reportOptionsUsed() {
printCheckMessage("\nChecks to be performed 🗒️");
if (!this.options.iosOnly) {
console.log(chalk.white("Android"));
}
if (!this.options.androidOnly && process.platform === "darwin") {
console.log(chalk.white("iOS"));
}
console.log(chalk.white("Mandatory Detox Checks"));
if (!this.options.excludeOptional) {
console.log(chalk.white("Optional Detox Checks"));
}
}
reportOptionalActionsToTake(results) {
if (results) {
let filteredOptionalResults = results.filter(
(result) => result?.optional === true && result?.success === false
);
if (filteredOptionalResults.length > 0) {
console.log(chalk.yellow.underline("\nOptional Steps to take:"));
filteredOptionalResults.forEach((result) => {
printWarning(chalk.yellow(result.message));
});
}
} else {
console.log(chalk.bgGreen("\nNo optional steps to take!\n"));
}
}
reportActionsToTake(results) {
if (results) {
let filteredResults = results.filter(
(result) => result?.optional === false && result?.success === false
);
if (filteredResults.length > 0) {
console.log(chalk.bgRed("\nMandatory Steps to take:"));
filteredResults.forEach((result) => {
printFail(chalk.red(result.message));
});
} else {
console.log(
chalk.bgGreen(
"\nNo mandatory steps to take! You are ready to use Detox!\n"
)
);
}
}
}
}
export default DetoxDoctorCheck;