@mintlify/cli 4.0.1075 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1075",
3
+ "version": "4.0.1077",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -61,8 +61,8 @@
61
61
  "ink": "6.3.0",
62
62
  "inquirer": "12.3.0",
63
63
  "js-yaml": "4.1.0",
64
- "keytar": "^7.9.0",
65
64
  "mdast-util-mdx-jsx": "3.2.0",
65
+ "open": "^8.4.2",
66
66
  "openid-client": "^6.8.2",
67
67
  "posthog-node": "5.17.2",
68
68
  "react": "19.2.3",
@@ -71,6 +71,9 @@
71
71
  "yargs": "17.7.1",
72
72
  "zod": "^4.3.6"
73
73
  },
74
+ "optionalDependencies": {
75
+ "keytar": "^7.9.0"
76
+ },
74
77
  "devDependencies": {
75
78
  "@mintlify/eslint-config-typescript": "1.0.13",
76
79
  "@mintlify/prettier-config": "1.0.4",
@@ -92,5 +95,5 @@
92
95
  "vitest": "2.1.9",
93
96
  "vitest-mock-process": "1.0.4"
94
97
  },
95
- "gitHead": "6c1a25cb98edc21e1a89329012113848bb226fd5"
98
+ "gitHead": "8df236c3a874c2c179b018ee4dd5a4384e552724"
96
99
  }
package/src/keyring.ts CHANGED
@@ -1,10 +1,19 @@
1
- import keytar from 'keytar';
2
-
3
1
  const SERVICE = 'mintlify';
4
2
  const ACCESS_TOKEN_ACCOUNT = 'access_token';
5
3
  const REFRESH_TOKEN_ACCOUNT = 'refresh_token';
6
4
 
5
+ async function getKeytar(): Promise<typeof import('keytar')> {
6
+ try {
7
+ return await import('keytar');
8
+ } catch {
9
+ throw new Error(
10
+ 'keytar is required for credential storage but is not installed. Install it with: npm install keytar'
11
+ );
12
+ }
13
+ }
14
+
7
15
  export async function storeCredentials(accessToken: string, refreshToken: string): Promise<void> {
16
+ const keytar = await getKeytar();
8
17
  await Promise.all([
9
18
  keytar.setPassword(SERVICE, ACCESS_TOKEN_ACCOUNT, accessToken),
10
19
  keytar.setPassword(SERVICE, REFRESH_TOKEN_ACCOUNT, refreshToken),
@@ -12,10 +21,12 @@ export async function storeCredentials(accessToken: string, refreshToken: string
12
21
  }
13
22
 
14
23
  export async function getAccessToken(): Promise<string | null> {
24
+ const keytar = await getKeytar();
15
25
  return keytar.getPassword(SERVICE, ACCESS_TOKEN_ACCOUNT);
16
26
  }
17
27
 
18
28
  export async function clearCredentials(): Promise<void> {
29
+ const keytar = await getKeytar();
19
30
  await Promise.all([
20
31
  keytar.deletePassword(SERVICE, ACCESS_TOKEN_ACCOUNT),
21
32
  keytar.deletePassword(SERVICE, REFRESH_TOKEN_ACCOUNT),
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 { Text } from 'ink';
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(<Text>Opening browser to log in to Mintlify... {authorizeUrl.toString()}</Text>);
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
- const code = await input({ message: 'Paste the code from your browser:' });
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">Login failed: {body.error_message ?? body.error ?? 'unknown error'}</Text>
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">Logged in successfully.</Text>);
99
+ addLog(<Text color="green">✔ Logged in successfully.</Text>);
65
100
  }