@mintlify/cli 4.0.1076 → 4.0.1077
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/bin/login.js +21 -6
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/login.tsx +40 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1077",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"inquirer": "12.3.0",
|
|
63
63
|
"js-yaml": "4.1.0",
|
|
64
64
|
"mdast-util-mdx-jsx": "3.2.0",
|
|
65
|
+
"open": "^8.4.2",
|
|
65
66
|
"openid-client": "^6.8.2",
|
|
66
67
|
"posthog-node": "5.17.2",
|
|
67
68
|
"react": "19.2.3",
|
|
@@ -94,5 +95,5 @@
|
|
|
94
95
|
"vitest": "2.1.9",
|
|
95
96
|
"vitest-mock-process": "1.0.4"
|
|
96
97
|
},
|
|
97
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "8df236c3a874c2c179b018ee4dd5a4384e552724"
|
|
98
99
|
}
|
package/src/login.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { input } from '@inquirer/prompts';
|
|
2
2
|
import { addLog } from '@mintlify/previewing';
|
|
3
|
-
import
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { Box, Text } from 'ink';
|
|
5
|
+
import open from 'open';
|
|
4
6
|
import {
|
|
5
7
|
calculatePKCECodeChallenge,
|
|
6
8
|
randomNonce,
|
|
@@ -32,10 +34,41 @@ export async function login(): Promise<void> {
|
|
|
32
34
|
const authorizeUrl = new URL('/api/cli/oauth/authorize', DASHBOARD_URL);
|
|
33
35
|
authorizeUrl.searchParams.set('state', state);
|
|
34
36
|
authorizeUrl.searchParams.set('code_challenge', codeChallenge);
|
|
37
|
+
const url = authorizeUrl.toString();
|
|
35
38
|
|
|
36
|
-
addLog(
|
|
39
|
+
addLog(
|
|
40
|
+
<Box flexDirection="column" gap={1} paddingY={1}>
|
|
41
|
+
<Text bold>
|
|
42
|
+
<Text color="green">◆ </Text>A browser window will open for Mintlify authentication
|
|
43
|
+
</Text>
|
|
44
|
+
<Box flexDirection="column" paddingLeft={3} gap={1}>
|
|
45
|
+
<Text dimColor>If your browser doesn't open automatically, copy this URL:</Text>
|
|
46
|
+
<Text color="cyan">{url}</Text>
|
|
47
|
+
</Box>
|
|
48
|
+
</Box>
|
|
49
|
+
);
|
|
37
50
|
|
|
38
|
-
|
|
51
|
+
open(url).catch(() => {});
|
|
52
|
+
|
|
53
|
+
addLog(
|
|
54
|
+
<Box flexDirection="column" paddingLeft={1} marginTop={1}>
|
|
55
|
+
<Text dimColor>╭─ Paste the authorization code from your browser</Text>
|
|
56
|
+
<Text dimColor>│</Text>
|
|
57
|
+
</Box>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Let ink finish rendering before inquirer takes over stdout
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
62
|
+
|
|
63
|
+
const code = await input({
|
|
64
|
+
message: '█',
|
|
65
|
+
theme: {
|
|
66
|
+
prefix: chalk.dim(' │'),
|
|
67
|
+
style: {
|
|
68
|
+
answer: (text: string) => chalk.cyan(text),
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
39
72
|
|
|
40
73
|
const res = await fetch(TOKEN_ENDPOINT, {
|
|
41
74
|
method: 'POST',
|
|
@@ -53,7 +86,9 @@ export async function login(): Promise<void> {
|
|
|
53
86
|
|
|
54
87
|
if (!res.ok) {
|
|
55
88
|
addLog(
|
|
56
|
-
<Text color="red">
|
|
89
|
+
<Text color="red">
|
|
90
|
+
✖ Login failed: {body.error_message ?? body.error ?? 'unknown error'}
|
|
91
|
+
</Text>
|
|
57
92
|
);
|
|
58
93
|
return;
|
|
59
94
|
}
|
|
@@ -61,5 +96,5 @@ export async function login(): Promise<void> {
|
|
|
61
96
|
const token = body as TokenResponse;
|
|
62
97
|
await storeCredentials(token.access_token, token.refresh_token);
|
|
63
98
|
|
|
64
|
-
addLog(<Text color="green"
|
|
99
|
+
addLog(<Text color="green">✔ Logged in successfully.</Text>);
|
|
65
100
|
}
|