codeant-cli 0.5.10 → 0.5.11
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/package.json +1 -1
- package/src/commands/login.js +20 -6
package/package.json
CHANGED
package/src/commands/login.js
CHANGED
|
@@ -12,6 +12,7 @@ export default function Login() {
|
|
|
12
12
|
const [status, setStatus] = useState('opening');
|
|
13
13
|
const [error, setError] = useState(null);
|
|
14
14
|
const [loginUrl, setLoginUrl] = useState('');
|
|
15
|
+
const [pollResults, setPollResults] = useState([]);
|
|
15
16
|
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
// Check if already logged in
|
|
@@ -25,9 +26,11 @@ export default function Login() {
|
|
|
25
26
|
const token = `cli___${randomUUID()}`;
|
|
26
27
|
const baseUrl = getBaseUrl();
|
|
27
28
|
const pollUrl = `${baseUrl}/extension/login/status?apiKey=${token}`;
|
|
29
|
+
const displayPollUrl = `${baseUrl}/extension/login/status?apiKey=[redacted]`;
|
|
28
30
|
|
|
29
31
|
let intervalId;
|
|
30
32
|
let timeoutId;
|
|
33
|
+
let pollCount = 0;
|
|
31
34
|
|
|
32
35
|
(async () => {
|
|
33
36
|
let dashboardUrl;
|
|
@@ -54,11 +57,14 @@ export default function Login() {
|
|
|
54
57
|
|
|
55
58
|
// Poll for login status
|
|
56
59
|
intervalId = setInterval(async () => {
|
|
60
|
+
const attempt = ++pollCount;
|
|
61
|
+
let response;
|
|
57
62
|
try {
|
|
58
|
-
|
|
63
|
+
response = await fetch(pollUrl);
|
|
59
64
|
const data = await response.json();
|
|
65
|
+
setPollResults((results) => [...results, `Check ${attempt}: GET ${displayPollUrl} → HTTP ${response.status}, status: ${data?.status ?? 'missing'}`]);
|
|
60
66
|
|
|
61
|
-
if (data
|
|
67
|
+
if (data?.status === 'yes') {
|
|
62
68
|
clearInterval(intervalId);
|
|
63
69
|
clearTimeout(timeoutId);
|
|
64
70
|
|
|
@@ -69,7 +75,8 @@ export default function Login() {
|
|
|
69
75
|
setTimeout(() => exit(), 100);
|
|
70
76
|
}
|
|
71
77
|
} catch (err) {
|
|
72
|
-
|
|
78
|
+
const code = err.cause?.code || err.code || err.name;
|
|
79
|
+
setPollResults((results) => [...results, `Check ${attempt}: GET ${displayPollUrl} → ${response ? `HTTP ${response.status}, ` : ''}error: ${code}`]);
|
|
73
80
|
}
|
|
74
81
|
}, POLL_INTERVAL);
|
|
75
82
|
|
|
@@ -89,6 +96,10 @@ export default function Login() {
|
|
|
89
96
|
};
|
|
90
97
|
}, []);
|
|
91
98
|
|
|
99
|
+
const pollLines = pollResults.map((result, index) =>
|
|
100
|
+
React.createElement(Text, { color: 'gray', key: index }, result)
|
|
101
|
+
);
|
|
102
|
+
|
|
92
103
|
if (status === 'already_logged_in') {
|
|
93
104
|
return React.createElement(
|
|
94
105
|
Box,
|
|
@@ -112,7 +123,8 @@ export default function Login() {
|
|
|
112
123
|
{ flexDirection: 'column', padding: 1 },
|
|
113
124
|
React.createElement(Text, { color: 'cyan' }, `Waiting for login. Open this URL in your browser: ${loginUrl}`),
|
|
114
125
|
React.createElement(Text, { color: 'gray' }, 'Complete the login in your browser.'),
|
|
115
|
-
React.createElement(Text, { color: 'gray' }, 'Checking every 10 seconds. Timeout in 10 minutes.')
|
|
126
|
+
React.createElement(Text, { color: 'gray' }, 'Checking every 10 seconds. Timeout in 10 minutes.'),
|
|
127
|
+
...pollLines
|
|
116
128
|
);
|
|
117
129
|
}
|
|
118
130
|
|
|
@@ -120,7 +132,8 @@ export default function Login() {
|
|
|
120
132
|
return React.createElement(
|
|
121
133
|
Box,
|
|
122
134
|
{ flexDirection: 'column', padding: 1 },
|
|
123
|
-
React.createElement(Text, { color: 'green' }, '✓ Login successful!')
|
|
135
|
+
React.createElement(Text, { color: 'green' }, '✓ Login successful!'),
|
|
136
|
+
...pollLines
|
|
124
137
|
);
|
|
125
138
|
}
|
|
126
139
|
|
|
@@ -128,7 +141,8 @@ export default function Login() {
|
|
|
128
141
|
return React.createElement(
|
|
129
142
|
Box,
|
|
130
143
|
{ flexDirection: 'column', padding: 1 },
|
|
131
|
-
React.createElement(Text, { color: 'red' }, '✗ ', error)
|
|
144
|
+
React.createElement(Text, { color: 'red' }, '✗ ', error),
|
|
145
|
+
...pollLines
|
|
132
146
|
);
|
|
133
147
|
}
|
|
134
148
|
|