@regressionproof/cli 0.3.7 → 0.3.8
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/.spruce/settings.json +16 -0
- package/build/cli.d.ts +2 -0
- package/build/cli.js +52 -0
- package/build/commands/invite/AcceptInvite.d.ts +1 -0
- package/build/commands/invite/AcceptInvite.js +17 -0
- package/build/commands/invite/CreateInvite.d.ts +1 -0
- package/build/commands/invite/CreateInvite.js +42 -0
- package/build/commands/invite/ListInvites.d.ts +1 -0
- package/build/commands/invite/ListInvites.js +18 -0
- package/build/commands/invite/RevokeInvite.d.ts +1 -0
- package/build/commands/invite/RevokeInvite.js +11 -0
- package/build/components/Init.d.ts +4 -0
- package/build/components/Init.js +286 -0
- package/build/components/Init.tsx +435 -0
- package/build/config/ConfigManager.d.ts +17 -0
- package/build/config/ConfigManager.js +35 -0
- package/build/esm/cli.d.ts +2 -0
- package/build/esm/cli.js +52 -0
- package/build/esm/commands/invite/AcceptInvite.d.ts +1 -0
- package/build/esm/commands/invite/AcceptInvite.js +29 -0
- package/build/esm/commands/invite/CreateInvite.d.ts +1 -0
- package/build/esm/commands/invite/CreateInvite.js +55 -0
- package/build/esm/commands/invite/ListInvites.d.ts +1 -0
- package/build/esm/commands/invite/ListInvites.js +30 -0
- package/build/esm/commands/invite/RevokeInvite.d.ts +1 -0
- package/build/esm/commands/invite/RevokeInvite.js +23 -0
- package/build/esm/components/Init.d.ts +4 -0
- package/build/esm/components/Init.js +301 -0
- package/build/esm/config/ConfigManager.d.ts +17 -0
- package/build/esm/config/ConfigManager.js +34 -0
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +2 -0
- package/build/esm/jest/JestConfigurator.d.ts +12 -0
- package/build/esm/jest/JestConfigurator.js +57 -0
- package/build/esm/utilities/slug.d.ts +2 -0
- package/build/esm/utilities/slug.js +22 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -0
- package/build/jest/JestConfigurator.d.ts +12 -0
- package/build/jest/JestConfigurator.js +59 -0
- package/build/utilities/slug.d.ts +2 -0
- package/build/utilities/slug.js +21 -0
- package/package.json +5 -3
package/build/cli.d.ts
ADDED
package/build/cli.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { render } from 'ink';
|
|
4
|
+
import React from 'react';
|
|
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 Init from './components/Init.js';
|
|
10
|
+
const command = process.argv[2];
|
|
11
|
+
const projectNameArg = process.argv[3];
|
|
12
|
+
if (command === 'init') {
|
|
13
|
+
render(React.createElement(Init, { projectName: projectNameArg }));
|
|
14
|
+
}
|
|
15
|
+
else if (command === 'invite') {
|
|
16
|
+
const subcommand = process.argv[3];
|
|
17
|
+
const arg = process.argv[4];
|
|
18
|
+
if (subcommand === 'create') {
|
|
19
|
+
const noteArg = process.argv.find((value) => value.startsWith('--note='));
|
|
20
|
+
const note = noteArg ? noteArg.replace('--note=', '') : undefined;
|
|
21
|
+
void createInvite(arg, note);
|
|
22
|
+
}
|
|
23
|
+
else if (subcommand === 'accept') {
|
|
24
|
+
if (!arg) {
|
|
25
|
+
console.error('Usage: regressionproof invite accept <token>');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
void acceptInvite(arg);
|
|
29
|
+
}
|
|
30
|
+
else if (subcommand === 'list') {
|
|
31
|
+
void listInvites(arg);
|
|
32
|
+
}
|
|
33
|
+
else if (subcommand === 'revoke') {
|
|
34
|
+
if (!arg) {
|
|
35
|
+
console.error('Usage: regressionproof invite revoke <token>');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
void revokeInvite(arg);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.error('Usage: regressionproof invite <create|accept|list|revoke>');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.log('Usage: regressionproof <command>');
|
|
47
|
+
console.log('');
|
|
48
|
+
console.log('Commands:');
|
|
49
|
+
console.log(' init [projectName] Initialize a new project');
|
|
50
|
+
console.log(' invite ... Manage project invites');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function acceptInvite(token: string): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const API_URL = process.env.REGRESSIONPROOF_API_URL ?? 'https://api.regressionproof.ai';
|
|
2
|
+
export default async function acceptInvite(token) {
|
|
3
|
+
const response = await fetch(`${API_URL}/invites/accept`, {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
headers: {
|
|
6
|
+
'Content-Type': 'application/json',
|
|
7
|
+
},
|
|
8
|
+
body: JSON.stringify({ token }),
|
|
9
|
+
});
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
const text = await response.text();
|
|
12
|
+
throw new Error(`Invite accept failed: ${response.status} ${text}`);
|
|
13
|
+
}
|
|
14
|
+
const data = (await response.json());
|
|
15
|
+
console.log('Project URL:', data.url);
|
|
16
|
+
console.log('Project token:', data.token);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function createInvite(projectName?: string, note?: string): Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import ConfigManager from '../../config/ConfigManager.js';
|
|
2
|
+
import { getRepoNameFromGit, toSlug } from '../../utilities/slug.js';
|
|
3
|
+
const API_URL = process.env.REGRESSIONPROOF_API_URL ?? 'https://api.regressionproof.ai';
|
|
4
|
+
class InviteCreator {
|
|
5
|
+
configManager;
|
|
6
|
+
constructor(configManager = new ConfigManager()) {
|
|
7
|
+
this.configManager = configManager;
|
|
8
|
+
}
|
|
9
|
+
async run(projectNameArg, note) {
|
|
10
|
+
const projectName = this.resolveProjectName(projectNameArg);
|
|
11
|
+
const creds = this.configManager.loadCredentials(projectName);
|
|
12
|
+
if (!creds) {
|
|
13
|
+
throw new Error(`No credentials found for ${projectName}. Run regressionproof init first.`);
|
|
14
|
+
}
|
|
15
|
+
const response = await fetch(`${API_URL}/invites`, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
Authorization: `Bearer ${creds.token}`,
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify({ name: projectName, note }),
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
const text = await response.text();
|
|
25
|
+
throw new Error(`Invite create failed: ${response.status} ${text}`);
|
|
26
|
+
}
|
|
27
|
+
const data = (await response.json());
|
|
28
|
+
console.log('Invite token:', data.token);
|
|
29
|
+
}
|
|
30
|
+
resolveProjectName(projectNameArg) {
|
|
31
|
+
const provided = projectNameArg ? toSlug(projectNameArg) : '';
|
|
32
|
+
const name = provided || getRepoNameFromGit();
|
|
33
|
+
if (!name) {
|
|
34
|
+
throw new Error('Project name is required. Provide it explicitly or ensure git origin is set.');
|
|
35
|
+
}
|
|
36
|
+
return name;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export default async function createInvite(projectName, note) {
|
|
40
|
+
const creator = new InviteCreator();
|
|
41
|
+
await creator.run(projectName, note);
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function listInvites(projectName?: string): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const API_URL = process.env.REGRESSIONPROOF_API_URL ?? 'https://api.regressionproof.ai';
|
|
2
|
+
export default async function listInvites(projectName) {
|
|
3
|
+
const query = projectName ? `?name=${encodeURIComponent(projectName)}` : '';
|
|
4
|
+
const response = await fetch(`${API_URL}/invites${query}`);
|
|
5
|
+
if (!response.ok) {
|
|
6
|
+
const text = await response.text();
|
|
7
|
+
throw new Error(`Invite list failed: ${response.status} ${text}`);
|
|
8
|
+
}
|
|
9
|
+
const data = (await response.json());
|
|
10
|
+
if (data.length === 0) {
|
|
11
|
+
console.log('No invites found.');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
for (const invite of data) {
|
|
15
|
+
console.log(`${invite.projectName} | ${invite.status} | created ${invite.createdAt}` +
|
|
16
|
+
(invite.note ? ` | ${invite.note}` : ''));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function revokeInvite(token: string): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const API_URL = process.env.REGRESSIONPROOF_API_URL ?? 'https://api.regressionproof.ai';
|
|
2
|
+
export default async function revokeInvite(token) {
|
|
3
|
+
const response = await fetch(`${API_URL}/invites/${encodeURIComponent(token)}`, {
|
|
4
|
+
method: 'DELETE',
|
|
5
|
+
});
|
|
6
|
+
if (!response.ok) {
|
|
7
|
+
const text = await response.text();
|
|
8
|
+
throw new Error(`Invite revoke failed: ${response.status} ${text}`);
|
|
9
|
+
}
|
|
10
|
+
console.log('Invite revoked.');
|
|
11
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { RegressionProofClient } from '@regressionproof/client';
|
|
4
|
+
import { Box, Text, useApp } from 'ink';
|
|
5
|
+
import BigText from 'ink-big-text';
|
|
6
|
+
import TextInput from 'ink-text-input';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import ConfigManager from '../config/ConfigManager.js';
|
|
9
|
+
import JestConfigurator from '../jest/JestConfigurator.js';
|
|
10
|
+
import { getRepoNameFromGit, toSlug } from '../utilities/slug.js';
|
|
11
|
+
const API_URL = process.env.REGRESSIONPROOF_API_URL ?? 'https://api.regressionproof.ai';
|
|
12
|
+
class InitComponent extends React.Component {
|
|
13
|
+
checkTimeout = null;
|
|
14
|
+
apiClient;
|
|
15
|
+
configManager;
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
const providedName = props.projectName;
|
|
19
|
+
const defaultName = providedName ?? getRepoNameFromGit();
|
|
20
|
+
this.configManager = new ConfigManager();
|
|
21
|
+
this.apiClient = new RegressionProofClient(API_URL);
|
|
22
|
+
// Check if already registered (idempotent)
|
|
23
|
+
const existingCreds = this.configManager.loadCredentials(defaultName);
|
|
24
|
+
if (existingCreds) {
|
|
25
|
+
this.state = {
|
|
26
|
+
name: defaultName,
|
|
27
|
+
step: 'installing',
|
|
28
|
+
availability: 'available',
|
|
29
|
+
errorMessage: '',
|
|
30
|
+
credentials: existingCreds,
|
|
31
|
+
jestConfig: null,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.state = {
|
|
36
|
+
name: defaultName,
|
|
37
|
+
step: providedName ? 'registering' : 'input',
|
|
38
|
+
availability: 'idle',
|
|
39
|
+
errorMessage: '',
|
|
40
|
+
credentials: null,
|
|
41
|
+
jestConfig: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
// If we have a provided name and not already registered, start registration
|
|
47
|
+
if (this.props.projectName && this.state.step === 'registering') {
|
|
48
|
+
void this.register();
|
|
49
|
+
}
|
|
50
|
+
else if (this.state.step === 'installing') {
|
|
51
|
+
void this.installAndConfigure();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
void this.checkAvailability();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
componentDidUpdate(_, prevState) {
|
|
58
|
+
if (prevState.name !== this.state.name && this.state.step === 'input') {
|
|
59
|
+
void this.checkAvailability();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
componentWillUnmount() {
|
|
63
|
+
this.clearCheckTimeout();
|
|
64
|
+
}
|
|
65
|
+
clearCheckTimeout() {
|
|
66
|
+
if (this.checkTimeout) {
|
|
67
|
+
clearTimeout(this.checkTimeout);
|
|
68
|
+
this.checkTimeout = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async checkAvailability() {
|
|
72
|
+
this.clearCheckTimeout();
|
|
73
|
+
const { name } = this.state;
|
|
74
|
+
if (name.length < 3) {
|
|
75
|
+
this.setState({ availability: 'idle', errorMessage: '' });
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.setState({ availability: 'checking' });
|
|
79
|
+
this.checkTimeout = setTimeout(async () => {
|
|
80
|
+
try {
|
|
81
|
+
const isAvailable = await this.apiClient.checkNameAvailability(name);
|
|
82
|
+
this.setState({
|
|
83
|
+
availability: isAvailable ? 'available' : 'taken',
|
|
84
|
+
errorMessage: '',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
this.setState({
|
|
89
|
+
availability: 'error',
|
|
90
|
+
errorMessage: this.formatError(err),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}, 300);
|
|
94
|
+
}
|
|
95
|
+
formatError(err) {
|
|
96
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
97
|
+
const cause = err instanceof Error && 'cause' in err ? ` (${err.cause})` : '';
|
|
98
|
+
return `${message}${cause} - ${API_URL}`;
|
|
99
|
+
}
|
|
100
|
+
handleNameChange = (value) => {
|
|
101
|
+
this.setState({ name: toSlug(value) });
|
|
102
|
+
};
|
|
103
|
+
handleSubmit = async () => {
|
|
104
|
+
const { availability, name } = this.state;
|
|
105
|
+
if (availability !== 'available' || name.length < 3) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.setState({ step: 'registering' });
|
|
109
|
+
await this.register();
|
|
110
|
+
};
|
|
111
|
+
async register() {
|
|
112
|
+
const { name } = this.state;
|
|
113
|
+
try {
|
|
114
|
+
const credentials = await this.apiClient.registerProject({ name });
|
|
115
|
+
this.setState({ credentials });
|
|
116
|
+
this.configManager.saveCredentials(name, credentials);
|
|
117
|
+
await this.installAndConfigure();
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
this.setState({
|
|
121
|
+
step: 'error',
|
|
122
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async installAndConfigure() {
|
|
127
|
+
this.setState({ step: 'installing' });
|
|
128
|
+
const installResult = this.installDependencies();
|
|
129
|
+
if (!installResult.success) {
|
|
130
|
+
this.setState({
|
|
131
|
+
step: 'error',
|
|
132
|
+
errorMessage: installResult.message ?? 'Failed to install dependencies.',
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.setState({ step: 'configuring' });
|
|
137
|
+
const jestConfigurator = new JestConfigurator();
|
|
138
|
+
const jestConfig = jestConfigurator.configure();
|
|
139
|
+
this.setState({ jestConfig, step: 'success' });
|
|
140
|
+
setTimeout(() => this.props.exit(), 3000);
|
|
141
|
+
}
|
|
142
|
+
installDependencies() {
|
|
143
|
+
if (!existsSync('package.json')) {
|
|
144
|
+
return {
|
|
145
|
+
success: false,
|
|
146
|
+
message: 'No package.json found. regressionproof currently supports Node.js + Jest projects.',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
let packageJson;
|
|
150
|
+
try {
|
|
151
|
+
packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
155
|
+
return {
|
|
156
|
+
success: false,
|
|
157
|
+
message: `Failed to read package.json: ${message}`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const hasReporter = Boolean(packageJson.dependencies?.['@regressionproof/jest-reporter'] ??
|
|
161
|
+
packageJson.devDependencies?.['@regressionproof/jest-reporter']);
|
|
162
|
+
if (hasReporter) {
|
|
163
|
+
return { success: true };
|
|
164
|
+
}
|
|
165
|
+
const packageManager = this.getPackageManager();
|
|
166
|
+
const result = spawnSync(packageManager.command, [...packageManager.args, '@regressionproof/jest-reporter'], {
|
|
167
|
+
encoding: 'utf8',
|
|
168
|
+
shell: true,
|
|
169
|
+
});
|
|
170
|
+
if (result.error || result.status !== 0) {
|
|
171
|
+
const details = result.stderr?.trim() ||
|
|
172
|
+
result.stdout?.trim() ||
|
|
173
|
+
result.error?.message;
|
|
174
|
+
return {
|
|
175
|
+
success: false,
|
|
176
|
+
message: `Failed to install dependencies${details ? `: ${details}` : ''}`,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return { success: true };
|
|
180
|
+
}
|
|
181
|
+
getPackageManager() {
|
|
182
|
+
if (existsSync('pnpm-lock.yaml')) {
|
|
183
|
+
return { command: 'pnpm', args: ['add', '-D'] };
|
|
184
|
+
}
|
|
185
|
+
if (existsSync('yarn.lock')) {
|
|
186
|
+
return { command: 'yarn', args: ['add', '-D'] };
|
|
187
|
+
}
|
|
188
|
+
if (existsSync('package-lock.json')) {
|
|
189
|
+
return { command: 'npm', args: ['install', '-D'] };
|
|
190
|
+
}
|
|
191
|
+
return { command: 'npm', args: ['install', '-D'] };
|
|
192
|
+
}
|
|
193
|
+
renderStatusIndicator() {
|
|
194
|
+
const { availability, errorMessage } = this.state;
|
|
195
|
+
switch (availability) {
|
|
196
|
+
case 'idle':
|
|
197
|
+
return null;
|
|
198
|
+
case 'checking':
|
|
199
|
+
return React.createElement(Text, { color: "yellow" }, "checking...");
|
|
200
|
+
case 'available':
|
|
201
|
+
return React.createElement(Text, { color: "green" }, "available (press Enter)");
|
|
202
|
+
case 'taken':
|
|
203
|
+
return React.createElement(Text, { color: "red" }, "already taken");
|
|
204
|
+
case 'error':
|
|
205
|
+
return React.createElement(Text, { color: "red" }, errorMessage);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
renderRegistering() {
|
|
209
|
+
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
|
|
210
|
+
React.createElement(Text, { color: "yellow" },
|
|
211
|
+
"Registering project \"",
|
|
212
|
+
this.state.name,
|
|
213
|
+
"\"...")));
|
|
214
|
+
}
|
|
215
|
+
renderConfiguring() {
|
|
216
|
+
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
|
|
217
|
+
React.createElement(Text, { color: "yellow" }, "Configuring Jest reporter...")));
|
|
218
|
+
}
|
|
219
|
+
renderInstalling() {
|
|
220
|
+
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
|
|
221
|
+
React.createElement(Text, { color: "yellow" }, "Installing dependencies...")));
|
|
222
|
+
}
|
|
223
|
+
renderSuccess() {
|
|
224
|
+
const { name, credentials, jestConfig } = this.state;
|
|
225
|
+
const configDir = this.configManager.getConfigDir(name);
|
|
226
|
+
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
|
|
227
|
+
React.createElement(Text, { color: "green", bold: true }, "Project registered successfully!"),
|
|
228
|
+
React.createElement(Box, { marginTop: 1, flexDirection: "column" },
|
|
229
|
+
React.createElement(Text, null,
|
|
230
|
+
"Config saved to:",
|
|
231
|
+
' ',
|
|
232
|
+
React.createElement(Text, { color: "cyan" },
|
|
233
|
+
configDir,
|
|
234
|
+
"/config.json")),
|
|
235
|
+
React.createElement(Text, null,
|
|
236
|
+
"Git remote: ",
|
|
237
|
+
React.createElement(Text, { color: "cyan" }, credentials?.url)),
|
|
238
|
+
jestConfig?.configured ? (React.createElement(Text, null,
|
|
239
|
+
"Jest reporter added to:",
|
|
240
|
+
' ',
|
|
241
|
+
React.createElement(Text, { color: "cyan" }, jestConfig.location))) : (React.createElement(Text, { color: "yellow" }, "Could not auto-configure Jest. Add manually:"))),
|
|
242
|
+
!jestConfig?.configured && (React.createElement(Box, { marginTop: 1, flexDirection: "column" },
|
|
243
|
+
React.createElement(Text, { color: "gray" }, "// jest.config.js"),
|
|
244
|
+
React.createElement(Text, { color: "gray" }, "reporters: ['default', '@regressionproof/jest-reporter']"))),
|
|
245
|
+
React.createElement(Box, { marginTop: 1 },
|
|
246
|
+
React.createElement(Text, { color: "green" }, "Run your tests and snapshots will be captured automatically!"))));
|
|
247
|
+
}
|
|
248
|
+
renderError() {
|
|
249
|
+
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
|
|
250
|
+
React.createElement(Text, { color: "red", bold: true }, "Registration failed"),
|
|
251
|
+
React.createElement(Text, { color: "red" }, this.state.errorMessage)));
|
|
252
|
+
}
|
|
253
|
+
renderInput() {
|
|
254
|
+
const { name } = this.state;
|
|
255
|
+
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
|
|
256
|
+
React.createElement(BigText, { text: "regressionproof.ai", font: "tiny", colors: ['magenta', 'cyan'] }),
|
|
257
|
+
React.createElement(Text, { color: "gray" }, "Teaching LLMs to write better code."),
|
|
258
|
+
React.createElement(Box, { marginTop: 1, flexDirection: "column" },
|
|
259
|
+
React.createElement(Text, { bold: true }, "Project name:"),
|
|
260
|
+
React.createElement(Box, null,
|
|
261
|
+
React.createElement(TextInput, { value: name, onChange: this.handleNameChange, onSubmit: this.handleSubmit, placeholder: "my-awesome-project" }),
|
|
262
|
+
React.createElement(Box, { marginLeft: 2 }, this.renderStatusIndicator())),
|
|
263
|
+
name.length > 0 && name.length < 3 && (React.createElement(Text, { color: "gray" }, "Name must be at least 3 characters")))));
|
|
264
|
+
}
|
|
265
|
+
render() {
|
|
266
|
+
const { step } = this.state;
|
|
267
|
+
switch (step) {
|
|
268
|
+
case 'registering':
|
|
269
|
+
return this.renderRegistering();
|
|
270
|
+
case 'installing':
|
|
271
|
+
return this.renderInstalling();
|
|
272
|
+
case 'configuring':
|
|
273
|
+
return this.renderConfiguring();
|
|
274
|
+
case 'success':
|
|
275
|
+
return this.renderSuccess();
|
|
276
|
+
case 'error':
|
|
277
|
+
return this.renderError();
|
|
278
|
+
default:
|
|
279
|
+
return this.renderInput();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export default function Init(props) {
|
|
284
|
+
const { exit } = useApp();
|
|
285
|
+
return React.createElement(InitComponent, { exit: exit, projectName: props.projectName });
|
|
286
|
+
}
|