@regressionproof/cli 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +44 -0
- package/build/components/Doctor.d.ts +7 -0
- package/build/components/Doctor.js +49 -0
- package/build/components/Doctor.tsx +75 -0
- package/build/doctor/Doctor.d.ts +7 -0
- package/build/doctor/Doctor.js +23 -0
- package/build/doctor/DoctorContext.d.ts +12 -0
- package/build/doctor/DoctorContext.js +44 -0
- package/build/doctor/DoctorOutput.d.ts +6 -0
- package/build/doctor/DoctorOutput.js +32 -0
- package/build/doctor/DoctorResult.d.ts +8 -0
- package/build/doctor/DoctorResult.js +1 -0
- package/build/doctor/DoctorRunner.d.ts +7 -0
- package/build/doctor/DoctorRunner.js +9 -0
- package/build/doctor/checks/CredentialsCheck.d.ts +6 -0
- package/build/doctor/checks/CredentialsCheck.js +55 -0
- package/build/doctor/checks/JestReporterCheck.d.ts +5 -0
- package/build/doctor/checks/JestReporterCheck.js +35 -0
- package/build/doctor/checks/LocalConfigCheck.d.ts +5 -0
- package/build/doctor/checks/LocalConfigCheck.js +17 -0
- package/build/doctor/checks/MirrorAccessCheck.d.ts +9 -0
- package/build/doctor/checks/MirrorAccessCheck.js +129 -0
- package/build/esm/cli.js +44 -0
- package/build/esm/components/Doctor.d.ts +7 -0
- package/build/esm/components/Doctor.js +49 -0
- package/build/esm/doctor/Doctor.d.ts +7 -0
- package/build/esm/doctor/Doctor.js +33 -0
- package/build/esm/doctor/DoctorContext.d.ts +12 -0
- package/build/esm/doctor/DoctorContext.js +41 -0
- package/build/esm/doctor/DoctorOutput.d.ts +6 -0
- package/build/esm/doctor/DoctorOutput.js +32 -0
- package/build/esm/doctor/DoctorResult.d.ts +8 -0
- package/build/esm/doctor/DoctorResult.js +1 -0
- package/build/esm/doctor/DoctorRunner.d.ts +7 -0
- package/build/esm/doctor/DoctorRunner.js +21 -0
- package/build/esm/doctor/checks/CredentialsCheck.d.ts +6 -0
- package/build/esm/doctor/checks/CredentialsCheck.js +66 -0
- package/build/esm/doctor/checks/JestReporterCheck.d.ts +5 -0
- package/build/esm/doctor/checks/JestReporterCheck.js +46 -0
- package/build/esm/doctor/checks/LocalConfigCheck.d.ts +5 -0
- package/build/esm/doctor/checks/LocalConfigCheck.js +28 -0
- package/build/esm/doctor/checks/MirrorAccessCheck.d.ts +9 -0
- package/build/esm/doctor/checks/MirrorAccessCheck.js +141 -0
- package/build/esm/jest/JestConfigurator.js +9 -0
- package/build/esm/jest/JestReporterConfigInspector.d.ts +13 -0
- package/build/esm/jest/JestReporterConfigInspector.js +60 -0
- package/build/jest/JestConfigurator.js +9 -0
- package/build/jest/JestReporterConfigInspector.d.ts +13 -0
- package/build/jest/JestReporterConfigInspector.js +56 -0
- package/package.json +3 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export default class JestReporterConfigInspector {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.reporterPackage = '@regressionproof/jest-reporter';
|
|
6
|
+
}
|
|
7
|
+
inspect(cwd) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const packageJsonPath = path.join(cwd, 'package.json');
|
|
10
|
+
const hasPackageJson = fs.existsSync(packageJsonPath);
|
|
11
|
+
const packageJson = hasPackageJson
|
|
12
|
+
? this.safeReadJson(packageJsonPath)
|
|
13
|
+
: null;
|
|
14
|
+
const isInstalled = Boolean((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) === null || _a === void 0 ? void 0 : _a[this.reporterPackage]) ||
|
|
15
|
+
Boolean((_b = packageJson === null || packageJson === void 0 ? void 0 : packageJson.devDependencies) === null || _b === void 0 ? void 0 : _b[this.reporterPackage]);
|
|
16
|
+
const configuredLocations = [];
|
|
17
|
+
if (this.isConfiguredInPackageJson(packageJson)) {
|
|
18
|
+
configuredLocations.push('package.json');
|
|
19
|
+
}
|
|
20
|
+
if (this.isConfiguredInFile(cwd, 'jest.config.js')) {
|
|
21
|
+
configuredLocations.push('jest.config.js');
|
|
22
|
+
}
|
|
23
|
+
if (this.isConfiguredInFile(cwd, 'jest.config.ts')) {
|
|
24
|
+
configuredLocations.push('jest.config.ts');
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
hasPackageJson,
|
|
28
|
+
isInstalled,
|
|
29
|
+
configuredLocations,
|
|
30
|
+
isConfigured: configuredLocations.length > 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
isConfiguredInPackageJson(packageJson) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const reporters = (_b = (_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.jest) === null || _a === void 0 ? void 0 : _a.reporters) !== null && _b !== void 0 ? _b : [];
|
|
36
|
+
const isConfigured = Array.isArray(reporters) && reporters.includes(this.reporterPackage);
|
|
37
|
+
return isConfigured;
|
|
38
|
+
}
|
|
39
|
+
isConfiguredInFile(cwd, filename) {
|
|
40
|
+
const configPath = path.join(cwd, filename);
|
|
41
|
+
if (!fs.existsSync(configPath)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
46
|
+
return content.includes(this.reporterPackage);
|
|
47
|
+
}
|
|
48
|
+
catch (_a) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
safeReadJson(filePath) {
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import JestReporterConfigInspector from './JestReporterConfigInspector.js';
|
|
3
4
|
export default class JestConfigurator {
|
|
4
5
|
cwd;
|
|
5
6
|
reporterPackage = '@regressionproof/jest-reporter';
|
|
@@ -7,6 +8,14 @@ export default class JestConfigurator {
|
|
|
7
8
|
this.cwd = cwd;
|
|
8
9
|
}
|
|
9
10
|
configure() {
|
|
11
|
+
const inspector = new JestReporterConfigInspector();
|
|
12
|
+
const inspection = inspector.inspect(this.cwd);
|
|
13
|
+
if (inspection.isConfigured) {
|
|
14
|
+
return {
|
|
15
|
+
configured: true,
|
|
16
|
+
location: inspection.configuredLocations[0],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
10
19
|
return (this.tryConfigurePackageJson() ??
|
|
11
20
|
this.tryConfigureJestConfig('jest.config.ts') ??
|
|
12
21
|
this.tryConfigureJestConfig('jest.config.js') ?? {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class JestReporterConfigInspector {
|
|
2
|
+
private reporterPackage;
|
|
3
|
+
inspect(cwd: string): InspectionResult;
|
|
4
|
+
private isConfiguredInPackageJson;
|
|
5
|
+
private isConfiguredInFile;
|
|
6
|
+
private safeReadJson;
|
|
7
|
+
}
|
|
8
|
+
export interface InspectionResult {
|
|
9
|
+
hasPackageJson: boolean;
|
|
10
|
+
isInstalled: boolean;
|
|
11
|
+
configuredLocations: string[];
|
|
12
|
+
isConfigured: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export default class JestReporterConfigInspector {
|
|
4
|
+
reporterPackage = '@regressionproof/jest-reporter';
|
|
5
|
+
inspect(cwd) {
|
|
6
|
+
const packageJsonPath = path.join(cwd, 'package.json');
|
|
7
|
+
const hasPackageJson = fs.existsSync(packageJsonPath);
|
|
8
|
+
const packageJson = hasPackageJson
|
|
9
|
+
? this.safeReadJson(packageJsonPath)
|
|
10
|
+
: null;
|
|
11
|
+
const isInstalled = Boolean(packageJson?.dependencies?.[this.reporterPackage]) ||
|
|
12
|
+
Boolean(packageJson?.devDependencies?.[this.reporterPackage]);
|
|
13
|
+
const configuredLocations = [];
|
|
14
|
+
if (this.isConfiguredInPackageJson(packageJson)) {
|
|
15
|
+
configuredLocations.push('package.json');
|
|
16
|
+
}
|
|
17
|
+
if (this.isConfiguredInFile(cwd, 'jest.config.js')) {
|
|
18
|
+
configuredLocations.push('jest.config.js');
|
|
19
|
+
}
|
|
20
|
+
if (this.isConfiguredInFile(cwd, 'jest.config.ts')) {
|
|
21
|
+
configuredLocations.push('jest.config.ts');
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
hasPackageJson,
|
|
25
|
+
isInstalled,
|
|
26
|
+
configuredLocations,
|
|
27
|
+
isConfigured: configuredLocations.length > 0,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
isConfiguredInPackageJson(packageJson) {
|
|
31
|
+
const reporters = packageJson?.jest?.reporters ?? [];
|
|
32
|
+
const isConfigured = Array.isArray(reporters) && reporters.includes(this.reporterPackage);
|
|
33
|
+
return isConfigured;
|
|
34
|
+
}
|
|
35
|
+
isConfiguredInFile(cwd, filename) {
|
|
36
|
+
const configPath = path.join(cwd, filename);
|
|
37
|
+
if (!fs.existsSync(configPath)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
42
|
+
return content.includes(this.reporterPackage);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
safeReadJson(filePath) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regressionproof/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"watch.tsc": "tsc -w"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@regressionproof/client": "^0.
|
|
41
|
+
"@regressionproof/client": "^0.8.0",
|
|
42
42
|
"dotenv": "^17.2.3",
|
|
43
43
|
"ink": "^5.1.0",
|
|
44
44
|
"ink-big-text": "^2.0.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "991c41905951b8c069c69b9a016affe53e819238"
|
|
88
88
|
}
|