@regressionproof/cli 0.8.0 → 0.9.1
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
package/build/cli.js
CHANGED
|
@@ -1,96 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import 'dotenv/config';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import acceptInvite from './commands/invite/AcceptInvite.js';
|
|
6
|
-
import createInvite from './commands/invite/CreateInvite.js';
|
|
7
|
-
import listInvites from './commands/invite/ListInvites.js';
|
|
8
|
-
import revokeInvite from './commands/invite/RevokeInvite.js';
|
|
9
|
-
import Doctor from './components/Doctor.js';
|
|
10
|
-
import Init from './components/Init.js';
|
|
11
|
-
import DoctorOutput from './doctor/DoctorOutput.js';
|
|
12
|
-
import DoctorRunner from './doctor/DoctorRunner.js';
|
|
3
|
+
import { runCommand } from './commands/CommandRunner.js';
|
|
4
|
+
import { getCommandHandler } from './commands/commands.js';
|
|
13
5
|
const command = process.argv[2];
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
else if (subcommand === 'accept') {
|
|
27
|
-
if (!arg) {
|
|
28
|
-
console.error('Usage: regressionproof invite accept <token>');
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
void acceptInvite(arg);
|
|
32
|
-
}
|
|
33
|
-
else if (subcommand === 'list') {
|
|
34
|
-
void listInvites(arg);
|
|
35
|
-
}
|
|
36
|
-
else if (subcommand === 'revoke') {
|
|
37
|
-
if (!arg) {
|
|
38
|
-
console.error('Usage: regressionproof invite revoke <token>');
|
|
6
|
+
const commandArgs = process.argv.slice(3);
|
|
7
|
+
const handler = getCommandHandler(command);
|
|
8
|
+
if (!handler) {
|
|
9
|
+
void runCommand({
|
|
10
|
+
heading: 'RegressionProof CLI',
|
|
11
|
+
handler: () => {
|
|
12
|
+
console.log('Usage: regressionproof <command>');
|
|
13
|
+
console.log('');
|
|
14
|
+
console.log('Commands:');
|
|
15
|
+
console.log(' init [projectName] Initialize a new project');
|
|
16
|
+
console.log(' invite ... Manage project invites');
|
|
17
|
+
console.log(' doctor Check project configuration');
|
|
39
18
|
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
void revokeInvite(arg);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
console.error('Usage: regressionproof invite <create|accept|list|revoke>');
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else if (command === 'doctor') {
|
|
49
|
-
const options = parseDoctorArgs(process.argv.slice(3));
|
|
50
|
-
void DoctorRunner.run({ cwd: options.cwd })
|
|
51
|
-
.then((results) => {
|
|
52
|
-
if (options.json) {
|
|
53
|
-
console.log(JSON.stringify(results, null, 2));
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const { waitUntilExit } = render(React.createElement(Doctor, { results }));
|
|
57
|
-
void waitUntilExit().then(() => {
|
|
58
|
-
process.exit(DoctorOutput.exitCode(results));
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
process.exit(DoctorOutput.exitCode(results));
|
|
63
|
-
})
|
|
64
|
-
.catch((err) => {
|
|
65
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
66
|
-
console.error(message);
|
|
67
|
-
process.exit(1);
|
|
19
|
+
},
|
|
68
20
|
});
|
|
69
21
|
}
|
|
70
22
|
else {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(' doctor Check project configuration');
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
function parseDoctorArgs(args) {
|
|
80
|
-
const options = { json: false };
|
|
81
|
-
for (let i = 0; i < args.length; i++) {
|
|
82
|
-
const arg = args[i];
|
|
83
|
-
if (arg === '--json') {
|
|
84
|
-
options.json = true;
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
if (arg === '--cwd') {
|
|
88
|
-
const value = args[i + 1];
|
|
89
|
-
if (value) {
|
|
90
|
-
options.cwd = value;
|
|
91
|
-
i++;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return options;
|
|
23
|
+
void runCommand({
|
|
24
|
+
heading: handler.heading,
|
|
25
|
+
isInk: handler.isInk,
|
|
26
|
+
handler: () => handler.run(commandArgs),
|
|
27
|
+
});
|
|
96
28
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { renderBanner } from '../utilities/renderBanner.js';
|
|
2
|
+
export async function runCommand(options) {
|
|
3
|
+
renderBanner();
|
|
4
|
+
if (!options.isInk && options.heading) {
|
|
5
|
+
console.log(options.heading);
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
await options.handler();
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
12
|
+
console.error(message);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { render } from 'ink';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import CommandLayout from '../components/CommandLayout.js';
|
|
4
|
+
import Doctor from '../components/Doctor.js';
|
|
5
|
+
import Init from '../components/Init.js';
|
|
6
|
+
import DoctorOutput from '../doctor/DoctorOutput.js';
|
|
7
|
+
import DoctorRunner from '../doctor/DoctorRunner.js';
|
|
8
|
+
import acceptInvite from './invite/AcceptInvite.js';
|
|
9
|
+
import createInvite from './invite/CreateInvite.js';
|
|
10
|
+
import listInvites from './invite/ListInvites.js';
|
|
11
|
+
import revokeInvite from './invite/RevokeInvite.js';
|
|
12
|
+
const commandHandlers = {
|
|
13
|
+
init: {
|
|
14
|
+
heading: 'RegressionProof Init',
|
|
15
|
+
isInk: true,
|
|
16
|
+
run: (args) => {
|
|
17
|
+
const projectName = args[0];
|
|
18
|
+
render(React.createElement(CommandLayout, { heading: 'RegressionProof Init' }, React.createElement(Init, { projectName })));
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
invite: {
|
|
22
|
+
heading: 'RegressionProof Invite',
|
|
23
|
+
run: async (args) => {
|
|
24
|
+
const subcommand = args[0];
|
|
25
|
+
const arg = args[1];
|
|
26
|
+
if (subcommand === 'create') {
|
|
27
|
+
const noteArg = args.find((value) => value.startsWith('--note='));
|
|
28
|
+
const note = noteArg
|
|
29
|
+
? noteArg.replace('--note=', '')
|
|
30
|
+
: undefined;
|
|
31
|
+
await createInvite(arg, note);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (subcommand === 'accept') {
|
|
35
|
+
if (!arg) {
|
|
36
|
+
throw new Error('Usage: regressionproof invite accept <token>');
|
|
37
|
+
}
|
|
38
|
+
await acceptInvite(arg);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (subcommand === 'list') {
|
|
42
|
+
await listInvites(arg);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (subcommand === 'revoke') {
|
|
46
|
+
if (!arg) {
|
|
47
|
+
throw new Error('Usage: regressionproof invite revoke <token>');
|
|
48
|
+
}
|
|
49
|
+
await revokeInvite(arg);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
throw new Error('Usage: regressionproof invite <create|accept|list|revoke>');
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
doctor: {
|
|
56
|
+
heading: 'RegressionProof Doctor',
|
|
57
|
+
isInk: true,
|
|
58
|
+
run: async (args) => {
|
|
59
|
+
const options = parseDoctorArgs(args);
|
|
60
|
+
if (options.help) {
|
|
61
|
+
console.log('RegressionProof Doctor');
|
|
62
|
+
console.log('');
|
|
63
|
+
console.log('Usage:\n regressionproof doctor [--fix] [--json] [--cwd <path>]');
|
|
64
|
+
console.log('');
|
|
65
|
+
console.log('Options:');
|
|
66
|
+
console.log(' --fix Attempt safe fixes (currently only mirror sync)');
|
|
67
|
+
console.log(' --json Output machine-readable JSON');
|
|
68
|
+
console.log(' --cwd Run checks for a specific directory');
|
|
69
|
+
console.log(' --help Show this help');
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
const results = await DoctorRunner.run({
|
|
73
|
+
cwd: options.cwd,
|
|
74
|
+
fix: options.fix,
|
|
75
|
+
});
|
|
76
|
+
if (options.json) {
|
|
77
|
+
console.log(JSON.stringify(results, null, 2));
|
|
78
|
+
process.exit(DoctorOutput.exitCode(results));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const { waitUntilExit } = render(React.createElement(CommandLayout, { heading: 'RegressionProof Doctor' }, React.createElement(Doctor, { results })));
|
|
82
|
+
await waitUntilExit();
|
|
83
|
+
process.exit(DoctorOutput.exitCode(results));
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
export function getCommandHandler(command) {
|
|
88
|
+
if (!command) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return commandHandlers[command] ?? null;
|
|
92
|
+
}
|
|
93
|
+
function parseDoctorArgs(args) {
|
|
94
|
+
const options = { json: false, fix: false, help: false };
|
|
95
|
+
for (let i = 0; i < args.length; i++) {
|
|
96
|
+
const arg = args[i];
|
|
97
|
+
if (arg === '--json') {
|
|
98
|
+
options.json = true;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (arg === '--fix') {
|
|
102
|
+
options.fix = true;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (arg === '--help' || arg === '-h') {
|
|
106
|
+
options.help = true;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (arg === '--cwd') {
|
|
110
|
+
const value = args[i + 1];
|
|
111
|
+
if (value) {
|
|
112
|
+
options.cwd = value;
|
|
113
|
+
i++;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return options;
|
|
118
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Box, Text } from 'ink';
|
|
2
|
+
import BigText from 'ink-big-text';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { getCliVersion } from '../utilities/version.js';
|
|
5
|
+
export default function Banner() {
|
|
6
|
+
const version = getCliVersion();
|
|
7
|
+
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
|
|
8
|
+
React.createElement(BigText, { text: "regressionproof.ai", font: "tiny", colors: ['magenta', 'cyan'] }),
|
|
9
|
+
React.createElement(Text, { color: "gray" }, "Teaching LLMs to write better code."),
|
|
10
|
+
React.createElement(Text, { color: "gray" },
|
|
11
|
+
"CLI v",
|
|
12
|
+
version)));
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Box, Text } from 'ink'
|
|
2
|
+
import BigText from 'ink-big-text'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { getCliVersion } from '../utilities/version.js'
|
|
5
|
+
|
|
6
|
+
export default function Banner(): React.ReactElement {
|
|
7
|
+
const version = getCliVersion()
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Box flexDirection="column" padding={1}>
|
|
11
|
+
<BigText
|
|
12
|
+
text="regressionproof.ai"
|
|
13
|
+
font="tiny"
|
|
14
|
+
colors={['magenta', 'cyan']}
|
|
15
|
+
/>
|
|
16
|
+
<Text color="gray">Teaching LLMs to write better code.</Text>
|
|
17
|
+
<Text color="gray">CLI v{version}</Text>
|
|
18
|
+
</Box>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Box } from 'ink';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import CommandHeading from './CommandHeading.js';
|
|
4
|
+
export default function CommandLayout(props) {
|
|
5
|
+
return (React.createElement(Box, { flexDirection: "column", paddingX: 1, paddingBottom: 1 },
|
|
6
|
+
React.createElement(CommandHeading, { heading: props.heading }),
|
|
7
|
+
React.createElement(Box, { marginTop: 1 }, props.children)));
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Box } from 'ink'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import CommandHeading from './CommandHeading.js'
|
|
4
|
+
|
|
5
|
+
export default function CommandLayout(props: Props): React.ReactElement {
|
|
6
|
+
return (
|
|
7
|
+
<Box flexDirection="column" paddingX={1} paddingBottom={1}>
|
|
8
|
+
<CommandHeading heading={props.heading} />
|
|
9
|
+
<Box marginTop={1}>{props.children}</Box>
|
|
10
|
+
</Box>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
heading: string
|
|
16
|
+
children?: React.ReactNode
|
|
17
|
+
}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import { Box, Text } from 'ink';
|
|
2
|
-
import BigText from 'ink-big-text';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
class DoctorComponent extends React.Component {
|
|
5
4
|
render() {
|
|
6
5
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
7
|
-
React.createElement(Box, { flexDirection: "column",
|
|
8
|
-
React.createElement(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
React.createElement(Text, { bold: true }, "RegressionProof Doctor"),
|
|
12
|
-
this.props.results.map((result) => (React.createElement(Box, { key: result.name, flexDirection: "column" },
|
|
13
|
-
React.createElement(Box, null,
|
|
14
|
-
React.createElement(Text, { color: this.colorFor(result.status) }, this.labelFor(result.status)),
|
|
15
|
-
React.createElement(Text, null,
|
|
16
|
-
" ",
|
|
17
|
-
result.name)),
|
|
18
|
-
result.details.map((detail) => (React.createElement(Text, { key: detail },
|
|
6
|
+
React.createElement(Box, { flexDirection: "column", paddingX: 1, paddingBottom: 1 }, this.props.results.map((result) => (React.createElement(Box, { key: result.name, flexDirection: "column" },
|
|
7
|
+
React.createElement(Box, null,
|
|
8
|
+
React.createElement(Text, { color: this.colorFor(result.status) }, this.labelFor(result.status)),
|
|
9
|
+
React.createElement(Text, null,
|
|
19
10
|
" ",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
result.name)),
|
|
12
|
+
result.details.map((detail) => (React.createElement(Text, { key: detail },
|
|
13
|
+
" ",
|
|
14
|
+
detail))),
|
|
15
|
+
result.fix ? (React.createElement(Text, null,
|
|
16
|
+
" Fix: ",
|
|
17
|
+
result.fix)) : null,
|
|
18
|
+
React.createElement(Text, null, " ")))))));
|
|
25
19
|
}
|
|
26
20
|
labelFor(status) {
|
|
27
21
|
switch (status) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Box, Text } from 'ink'
|
|
2
|
-
import BigText from 'ink-big-text'
|
|
3
2
|
import React from 'react'
|
|
4
3
|
import type { DoctorResult } from '../doctor/DoctorResult.js'
|
|
5
4
|
|
|
@@ -7,18 +6,7 @@ class DoctorComponent extends React.Component<Props> {
|
|
|
7
6
|
public render(): React.ReactElement {
|
|
8
7
|
return (
|
|
9
8
|
<Box flexDirection="column">
|
|
10
|
-
<Box flexDirection="column" padding={1}>
|
|
11
|
-
<BigText
|
|
12
|
-
text="regressionproof.ai"
|
|
13
|
-
font="tiny"
|
|
14
|
-
colors={['magenta', 'cyan']}
|
|
15
|
-
/>
|
|
16
|
-
<Text color="gray">
|
|
17
|
-
Teaching LLMs to write better code.
|
|
18
|
-
</Text>
|
|
19
|
-
</Box>
|
|
20
9
|
<Box flexDirection="column" paddingX={1} paddingBottom={1}>
|
|
21
|
-
<Text bold>RegressionProof Doctor</Text>
|
|
22
10
|
{this.props.results.map((result) => (
|
|
23
11
|
<Box key={result.name} flexDirection="column">
|
|
24
12
|
<Box>
|
package/build/components/Init.js
CHANGED
|
@@ -2,7 +2,6 @@ import { spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { buildRegressionProofClient } from '@regressionproof/client';
|
|
4
4
|
import { Box, Text, useApp } from 'ink';
|
|
5
|
-
import BigText from 'ink-big-text';
|
|
6
5
|
import TextInput from 'ink-text-input';
|
|
7
6
|
import React from 'react';
|
|
8
7
|
import ConfigManager from '../config/ConfigManager.js';
|
|
@@ -253,10 +252,8 @@ class InitComponent extends React.Component {
|
|
|
253
252
|
}
|
|
254
253
|
renderInput() {
|
|
255
254
|
const { name } = this.state;
|
|
256
|
-
return (React.createElement(Box, { flexDirection: "column"
|
|
257
|
-
React.createElement(
|
|
258
|
-
React.createElement(Text, { color: "gray" }, "Teaching LLMs to write better code."),
|
|
259
|
-
React.createElement(Box, { marginTop: 1, flexDirection: "column" },
|
|
255
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
256
|
+
React.createElement(Box, { padding: 1, flexDirection: "column" },
|
|
260
257
|
React.createElement(Text, { bold: true }, "Project name:"),
|
|
261
258
|
React.createElement(Box, null,
|
|
262
259
|
React.createElement(TextInput, { value: name, onChange: this.handleNameChange, onSubmit: this.handleSubmit, placeholder: "my-awesome-project" }),
|
|
@@ -3,7 +3,6 @@ import { existsSync, readFileSync } from 'node:fs'
|
|
|
3
3
|
import type { RegressionProofClient } from '@regressionproof/client'
|
|
4
4
|
import { buildRegressionProofClient } from '@regressionproof/client'
|
|
5
5
|
import { Box, Text, useApp } from 'ink'
|
|
6
|
-
import BigText from 'ink-big-text'
|
|
7
6
|
import TextInput from 'ink-text-input'
|
|
8
7
|
import React from 'react'
|
|
9
8
|
import ConfigManager, { Credentials } from '../config/ConfigManager.js'
|
|
@@ -347,15 +346,8 @@ class InitComponent extends React.Component<Props, State> {
|
|
|
347
346
|
const { name } = this.state
|
|
348
347
|
|
|
349
348
|
return (
|
|
350
|
-
<Box flexDirection="column"
|
|
351
|
-
<
|
|
352
|
-
text="regressionproof.ai"
|
|
353
|
-
font="tiny"
|
|
354
|
-
colors={['magenta', 'cyan']}
|
|
355
|
-
/>
|
|
356
|
-
<Text color="gray">Teaching LLMs to write better code.</Text>
|
|
357
|
-
|
|
358
|
-
<Box marginTop={1} flexDirection="column">
|
|
349
|
+
<Box flexDirection="column">
|
|
350
|
+
<Box padding={1} flexDirection="column">
|
|
359
351
|
<Text bold>Project name:</Text>
|
|
360
352
|
<Box>
|
|
361
353
|
<TextInput
|
package/build/doctor/Doctor.d.ts
CHANGED
package/build/doctor/Doctor.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ApiReachabilityCheck from './checks/ApiReachabilityCheck.js';
|
|
1
2
|
import CredentialsCheck from './checks/CredentialsCheck.js';
|
|
2
3
|
import JestReporterCheck from './checks/JestReporterCheck.js';
|
|
3
4
|
import LocalConfigCheck from './checks/LocalConfigCheck.js';
|
|
@@ -13,11 +14,42 @@ export default class Doctor {
|
|
|
13
14
|
new JestReporterCheck(),
|
|
14
15
|
new CredentialsCheck(),
|
|
15
16
|
new MirrorAccessCheck(),
|
|
17
|
+
new ApiReachabilityCheck(),
|
|
16
18
|
];
|
|
17
19
|
const results = [];
|
|
20
|
+
if (this.context.fix) {
|
|
21
|
+
return this.runFixOnly(checks, results);
|
|
22
|
+
}
|
|
18
23
|
for (const check of checks) {
|
|
19
24
|
results.push(await check.run(this.context));
|
|
20
25
|
}
|
|
21
26
|
return results;
|
|
22
27
|
}
|
|
28
|
+
async runFixOnly(checks, results) {
|
|
29
|
+
let mirrorResult;
|
|
30
|
+
for (const check of checks) {
|
|
31
|
+
if (check instanceof MirrorAccessCheck) {
|
|
32
|
+
mirrorResult = await check.run(this.context);
|
|
33
|
+
results.push(mirrorResult);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!mirrorResult) {
|
|
38
|
+
throw new Error('Doctor --fix not implemented (missing mirror check).');
|
|
39
|
+
}
|
|
40
|
+
if (mirrorResult.status === 'fail') {
|
|
41
|
+
throw new Error('Doctor --fix not implemented for this mirror issue.');
|
|
42
|
+
}
|
|
43
|
+
for (const check of checks) {
|
|
44
|
+
if (check instanceof MirrorAccessCheck) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const result = await check.run(this.context);
|
|
48
|
+
results.push(result);
|
|
49
|
+
if (result.status !== 'ok') {
|
|
50
|
+
throw new Error(`Doctor --fix not implemented for ${result.name}.`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
23
55
|
}
|
|
@@ -3,8 +3,10 @@ export default class DoctorContext {
|
|
|
3
3
|
projectName: string | null;
|
|
4
4
|
localConfigPath: string | null;
|
|
5
5
|
homeConfigDir: string;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
apiUrl: string;
|
|
7
|
+
fix: boolean;
|
|
8
|
+
constructor(cwd: string, projectName: string | null, localConfigPath: string | null, homeConfigDir: string, apiUrl: string, fix: boolean);
|
|
9
|
+
static fromCwd(cwd: string, apiUrl: string, fix: boolean): DoctorContext;
|
|
8
10
|
get configDir(): string | null;
|
|
9
11
|
get credentialsPath(): string | null;
|
|
10
12
|
get mirrorPath(): string | null;
|
|
@@ -6,20 +6,24 @@ export default class DoctorContext {
|
|
|
6
6
|
projectName;
|
|
7
7
|
localConfigPath;
|
|
8
8
|
homeConfigDir;
|
|
9
|
-
|
|
9
|
+
apiUrl;
|
|
10
|
+
fix;
|
|
11
|
+
constructor(cwd, projectName, localConfigPath, homeConfigDir, apiUrl, fix) {
|
|
10
12
|
this.cwd = cwd;
|
|
11
13
|
this.projectName = projectName;
|
|
12
14
|
this.localConfigPath = localConfigPath;
|
|
13
15
|
this.homeConfigDir = homeConfigDir;
|
|
16
|
+
this.apiUrl = apiUrl;
|
|
17
|
+
this.fix = fix;
|
|
14
18
|
}
|
|
15
|
-
static fromCwd(cwd) {
|
|
19
|
+
static fromCwd(cwd, apiUrl, fix) {
|
|
16
20
|
const localConfigPath = path.join(cwd, '.regressionproof.json');
|
|
17
21
|
const localExists = fs.existsSync(localConfigPath);
|
|
18
22
|
const projectName = localExists
|
|
19
23
|
? DoctorContext.readProjectName(localConfigPath)
|
|
20
24
|
: null;
|
|
21
25
|
const homeConfigDir = path.join(os.homedir(), '.regressionproof');
|
|
22
|
-
return new DoctorContext(cwd, projectName, localExists ? localConfigPath : null, homeConfigDir);
|
|
26
|
+
return new DoctorContext(cwd, projectName, localExists ? localConfigPath : null, homeConfigDir, apiUrl, fix);
|
|
23
27
|
}
|
|
24
28
|
get configDir() {
|
|
25
29
|
return this.projectName
|
|
@@ -3,7 +3,11 @@ import DoctorContext from './DoctorContext.js';
|
|
|
3
3
|
export default class DoctorRunner {
|
|
4
4
|
static async run(options) {
|
|
5
5
|
const cwd = options?.cwd ?? process.cwd();
|
|
6
|
-
const
|
|
6
|
+
const apiUrl = options?.apiUrl ??
|
|
7
|
+
process.env.REGRESSIONPROOF_API_URL ??
|
|
8
|
+
'https://api.regressionproof.ai';
|
|
9
|
+
const fix = options?.fix ?? false;
|
|
10
|
+
const context = DoctorContext.fromCwd(cwd, apiUrl, fix);
|
|
7
11
|
return new Doctor(context).run();
|
|
8
12
|
}
|
|
9
13
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export default class ApiReachabilityCheck {
|
|
2
|
+
async run(context) {
|
|
3
|
+
const checkName = `rp-doctor-${Date.now()}`;
|
|
4
|
+
const url = `${context.apiUrl}/check-name/${checkName}`;
|
|
5
|
+
try {
|
|
6
|
+
const response = await fetch(url, { method: 'GET' });
|
|
7
|
+
if (response.ok) {
|
|
8
|
+
return {
|
|
9
|
+
status: 'ok',
|
|
10
|
+
name: 'API reachability',
|
|
11
|
+
details: [`API responded at ${context.apiUrl}.`],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (response.status === 502) {
|
|
15
|
+
return {
|
|
16
|
+
status: 'warn',
|
|
17
|
+
name: 'API reachability',
|
|
18
|
+
details: [
|
|
19
|
+
'API is reachable, but Git server communication failed (502).',
|
|
20
|
+
],
|
|
21
|
+
fix: 'Check the Git server connectivity or API configuration.',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
status: 'warn',
|
|
26
|
+
name: 'API reachability',
|
|
27
|
+
details: [`API responded with status ${response.status}.`],
|
|
28
|
+
fix: 'Verify REGRESSIONPROOF_API_URL or check API logs.',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
33
|
+
return {
|
|
34
|
+
status: 'fail',
|
|
35
|
+
name: 'API reachability',
|
|
36
|
+
details: [`API request failed: ${message}`],
|
|
37
|
+
fix: 'Check your network or verify REGRESSIONPROOF_API_URL.',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|