@regressionproof/cli 0.8.0 → 0.9.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 +20 -88
- package/build/commands/CommandRunner.d.ts +7 -0
- package/build/commands/CommandRunner.js +15 -0
- package/build/commands/commands.d.ts +7 -0
- package/build/commands/commands.js +118 -0
- package/build/components/Banner.d.ts +2 -0
- package/build/components/Banner.js +13 -0
- package/build/components/Banner.tsx +20 -0
- package/build/components/CommandHeading.d.ts +6 -0
- package/build/components/CommandHeading.js +5 -0
- package/build/components/CommandHeading.tsx +10 -0
- package/build/components/CommandLayout.d.ts +7 -0
- package/build/components/CommandLayout.js +8 -0
- package/build/components/CommandLayout.tsx +17 -0
- package/build/components/Doctor.js +12 -18
- package/build/components/Doctor.tsx +0 -12
- package/build/components/Init.js +2 -5
- package/build/components/Init.tsx +2 -10
- package/build/doctor/Doctor.d.ts +1 -0
- package/build/doctor/Doctor.js +32 -0
- package/build/doctor/DoctorContext.d.ts +4 -2
- package/build/doctor/DoctorContext.js +7 -3
- package/build/doctor/DoctorRunner.d.ts +2 -0
- package/build/doctor/DoctorRunner.js +5 -1
- package/build/doctor/checks/ApiReachabilityCheck.d.ts +5 -0
- package/build/doctor/checks/ApiReachabilityCheck.js +41 -0
- package/build/doctor/checks/MirrorAccessCheck.d.ts +3 -0
- package/build/doctor/checks/MirrorAccessCheck.js +83 -2
- package/build/esm/cli.js +20 -88
- package/build/esm/commands/CommandRunner.d.ts +7 -0
- package/build/esm/commands/CommandRunner.js +26 -0
- package/build/esm/commands/commands.d.ts +7 -0
- package/build/esm/commands/commands.js +128 -0
- package/build/esm/components/Banner.d.ts +2 -0
- package/build/esm/components/Banner.js +13 -0
- package/build/esm/components/CommandHeading.d.ts +6 -0
- package/build/esm/components/CommandHeading.js +5 -0
- package/build/esm/components/CommandLayout.d.ts +7 -0
- package/build/esm/components/CommandLayout.js +8 -0
- package/build/esm/components/Doctor.js +12 -18
- package/build/esm/components/Init.js +2 -5
- package/build/esm/doctor/Doctor.d.ts +1 -0
- package/build/esm/doctor/Doctor.js +34 -0
- package/build/esm/doctor/DoctorContext.d.ts +4 -2
- package/build/esm/doctor/DoctorContext.js +5 -3
- package/build/esm/doctor/DoctorRunner.d.ts +2 -0
- package/build/esm/doctor/DoctorRunner.js +4 -2
- package/build/esm/doctor/checks/ApiReachabilityCheck.d.ts +5 -0
- package/build/esm/doctor/checks/ApiReachabilityCheck.js +52 -0
- package/build/esm/doctor/checks/MirrorAccessCheck.d.ts +3 -0
- package/build/esm/doctor/checks/MirrorAccessCheck.js +88 -5
- package/build/esm/utilities/renderBanner.d.ts +1 -0
- package/build/esm/utilities/renderBanner.js +7 -0
- package/build/utilities/renderBanner.d.ts +1 -0
- package/build/utilities/renderBanner.js +7 -0
- package/package.json +4 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export default class ApiReachabilityCheck {
|
|
11
|
+
run(context) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const checkName = `rp-doctor-${Date.now()}`;
|
|
14
|
+
const url = `${context.apiUrl}/check-name/${checkName}`;
|
|
15
|
+
try {
|
|
16
|
+
const response = yield fetch(url, { method: 'GET' });
|
|
17
|
+
if (response.ok) {
|
|
18
|
+
return {
|
|
19
|
+
status: 'ok',
|
|
20
|
+
name: 'API reachability',
|
|
21
|
+
details: [`API responded at ${context.apiUrl}.`],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (response.status === 502) {
|
|
25
|
+
return {
|
|
26
|
+
status: 'warn',
|
|
27
|
+
name: 'API reachability',
|
|
28
|
+
details: [
|
|
29
|
+
'API is reachable, but Git server communication failed (502).',
|
|
30
|
+
],
|
|
31
|
+
fix: 'Check the Git server connectivity or API configuration.',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
status: 'warn',
|
|
36
|
+
name: 'API reachability',
|
|
37
|
+
details: [`API responded with status ${response.status}.`],
|
|
38
|
+
fix: 'Verify REGRESSIONPROOF_API_URL or check API logs.',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
43
|
+
return {
|
|
44
|
+
status: 'fail',
|
|
45
|
+
name: 'API reachability',
|
|
46
|
+
details: [`API request failed: ${message}`],
|
|
47
|
+
fix: 'Check your network or verify REGRESSIONPROOF_API_URL.',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -9,11 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { execSync } from 'child_process';
|
|
11
11
|
import fs from 'fs';
|
|
12
|
+
import { MirrorSyncer } from '@regressionproof/snapshotter';
|
|
12
13
|
import ConfigManager from '../../config/ConfigManager.js.js';
|
|
13
14
|
export default class MirrorAccessCheck {
|
|
14
15
|
run(context) {
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
+
var _a, _b, _c, _d;
|
|
17
18
|
if (!context.projectName) {
|
|
18
19
|
return {
|
|
19
20
|
name: 'Mirror directory',
|
|
@@ -60,13 +61,61 @@ export default class MirrorAccessCheck {
|
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
const pushResult = this.checkPushAccess(mirrorPath, authedUrl);
|
|
64
|
+
if (context.fix && pushResult.status === 'warn') {
|
|
65
|
+
if (pushResult.reason === 'non_fast_forward') {
|
|
66
|
+
const fixResult = yield this.trySyncMirror(mirrorPath);
|
|
67
|
+
if (!fixResult.ok) {
|
|
68
|
+
const message = (_b = fixResult.message) !== null && _b !== void 0 ? _b : 'Unknown error.';
|
|
69
|
+
if (this.isDivergedBranchError(message)) {
|
|
70
|
+
return {
|
|
71
|
+
name: 'Mirror directory',
|
|
72
|
+
status: 'warn',
|
|
73
|
+
details: [
|
|
74
|
+
'Mirror has diverged; manual merge/rebase required.',
|
|
75
|
+
],
|
|
76
|
+
fix: 'Run `git -C <mirror> pull --rebase` (or merge) to resolve divergence.',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
name: 'Mirror directory',
|
|
81
|
+
status: 'fail',
|
|
82
|
+
details: ['Unable to sync mirror.', message],
|
|
83
|
+
fix: 'Run `npx regressionproof doctor --fix` again or pull the mirror manually.',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const retryResult = this.checkPushAccess(mirrorPath, authedUrl);
|
|
87
|
+
if (retryResult.status === 'ok') {
|
|
88
|
+
return {
|
|
89
|
+
name: 'Mirror directory',
|
|
90
|
+
status: 'ok',
|
|
91
|
+
details: [
|
|
92
|
+
`Mirror directory exists at ${mirrorPath}.`,
|
|
93
|
+
'Mirror synced successfully.',
|
|
94
|
+
'Remote access confirmed (pull/push).',
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
name: 'Mirror directory',
|
|
100
|
+
status: 'warn',
|
|
101
|
+
details: [
|
|
102
|
+
`Mirror directory exists at ${mirrorPath}.`,
|
|
103
|
+
'Mirror sync completed; recheck push access.',
|
|
104
|
+
],
|
|
105
|
+
fix: 'Re-run `npx regressionproof doctor` to confirm sync results.',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw new Error('Doctor --fix not implemented for this mirror issue.');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
63
112
|
if (pushResult.status === 'fail') {
|
|
64
113
|
return {
|
|
65
114
|
name: 'Mirror directory',
|
|
66
115
|
status: 'fail',
|
|
67
116
|
details: [
|
|
68
117
|
'Unable to access remote (push).',
|
|
69
|
-
(
|
|
118
|
+
(_c = pushResult.message) !== null && _c !== void 0 ? _c : 'Unknown error.',
|
|
70
119
|
],
|
|
71
120
|
fix: 'Run `npx regressionproof invite accept <token>` to refresh credentials.',
|
|
72
121
|
};
|
|
@@ -77,9 +126,9 @@ export default class MirrorAccessCheck {
|
|
|
77
126
|
status: 'warn',
|
|
78
127
|
details: [
|
|
79
128
|
'Remote access confirmed (pull).',
|
|
80
|
-
(
|
|
129
|
+
(_d = pushResult.message) !== null && _d !== void 0 ? _d : 'Unknown error.',
|
|
81
130
|
],
|
|
82
|
-
fix: 'Run
|
|
131
|
+
fix: 'Run `npx regressionproof doctor --fix` or pull latest changes in the mirror.',
|
|
83
132
|
};
|
|
84
133
|
}
|
|
85
134
|
return {
|
|
@@ -117,9 +166,17 @@ export default class MirrorAccessCheck {
|
|
|
117
166
|
return {
|
|
118
167
|
status: 'warn',
|
|
119
168
|
message: 'No commits in mirror; push check skipped.',
|
|
169
|
+
reason: 'no_commits',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (this.isNonFastForwardError(message)) {
|
|
173
|
+
return {
|
|
174
|
+
status: 'warn',
|
|
175
|
+
message: 'Remote has newer commits; mirror is behind (non-fast-forward).',
|
|
176
|
+
reason: 'non_fast_forward',
|
|
120
177
|
};
|
|
121
178
|
}
|
|
122
|
-
return { status: 'fail', message };
|
|
179
|
+
return { status: 'fail', message, reason: 'other' };
|
|
123
180
|
}
|
|
124
181
|
}
|
|
125
182
|
isNoCommitsError(message) {
|
|
@@ -128,6 +185,32 @@ export default class MirrorAccessCheck {
|
|
|
128
185
|
normalized.includes('does not match any') ||
|
|
129
186
|
normalized.includes('no commits'));
|
|
130
187
|
}
|
|
188
|
+
isNonFastForwardError(message) {
|
|
189
|
+
const normalized = message.toLowerCase();
|
|
190
|
+
return (normalized.includes('fetch first') ||
|
|
191
|
+
normalized.includes('non-fast-forward') ||
|
|
192
|
+
normalized.includes('failed to push some refs'));
|
|
193
|
+
}
|
|
194
|
+
isDivergedBranchError(message) {
|
|
195
|
+
const normalized = message.toLowerCase();
|
|
196
|
+
return (normalized.includes('diverging branches') ||
|
|
197
|
+
normalized.includes('not possible to fast-forward'));
|
|
198
|
+
}
|
|
199
|
+
trySyncMirror(mirrorPath) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
try {
|
|
202
|
+
const syncer = new MirrorSyncer();
|
|
203
|
+
yield syncer.syncBlocking(mirrorPath);
|
|
204
|
+
return { ok: true };
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
return {
|
|
208
|
+
ok: false,
|
|
209
|
+
message: this.getErrorMessage(err),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
131
214
|
getErrorMessage(err) {
|
|
132
215
|
var _a, _b;
|
|
133
216
|
if (err && typeof err === 'object') {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderBanner(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderBanner(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regressionproof/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"watch.tsc": "tsc -w"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@regressionproof/client": "^0.
|
|
41
|
+
"@regressionproof/client": "^0.9.0",
|
|
42
|
+
"@regressionproof/snapshotter": "^0.9.0",
|
|
42
43
|
"dotenv": "^17.2.3",
|
|
43
44
|
"ink": "^5.1.0",
|
|
44
45
|
"ink-big-text": "^2.0.0",
|
|
@@ -84,5 +85,5 @@
|
|
|
84
85
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
85
86
|
}
|
|
86
87
|
},
|
|
87
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "6f734949b5cd75ead7249cd6d6b4305cf350274e"
|
|
88
89
|
}
|