@mintlify/cli 4.0.1096 → 4.0.1098

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 CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { input } from '@inquirer/prompts';
12
- import { addLog } from '@mintlify/previewing';
12
+ import { addLog, ErrorLog, SuccessLog } from '@mintlify/previewing';
13
13
  import chalk from 'chalk';
14
14
  import { Box, Text } from 'ink';
15
15
  import open from 'open';
@@ -32,7 +32,7 @@ export function login() {
32
32
  const url = authorizeUrl.toString();
33
33
  void trackLoginAttempt();
34
34
  const { codePromise, close: closeServer } = yield startCallbackServer();
35
- addLog(_jsxs(Box, { flexDirection: "column", gap: 1, paddingY: 1, children: [_jsxs(Text, { bold: true, children: [_jsx(Text, { color: "green", children: "\u25C6 " }), "A browser window will open for Mintlify authentication"] }), _jsxs(Box, { flexDirection: "column", paddingLeft: 3, gap: 1, children: [_jsx(Text, { dimColor: true, children: "If your browser doesn't open automatically, copy this URL:" }), _jsx(Text, { color: "cyan", children: url })] })] }));
35
+ addLog(_jsxs(Box, { flexDirection: "column", gap: 1, paddingY: 1, children: [_jsxs(Text, { bold: true, children: [_jsx(Text, { color: "green", children: "\u25C6 " }), "A browser window will open for Mintlify authentication"] }), _jsxs(Box, { flexDirection: "column", paddingLeft: 3, gap: 1, children: [_jsx(Text, { dimColor: true, children: "If your browser doesn't open automatically, copy this URL:" }), _jsx(Text, { dimColor: true, children: url })] })] }));
36
36
  open(url).catch(() => { });
37
37
  addLog(_jsxs(Box, { flexDirection: "column", paddingLeft: 1, marginTop: 1, children: [_jsx(Text, { dimColor: true, children: "\u256D\u2500 Paste the authorization code from your browser" }), _jsx(Text, { dimColor: true, children: "\u2502" })] }));
38
38
  // Let ink finish rendering before inquirer takes over stdout
@@ -53,7 +53,7 @@ export function login() {
53
53
  catch (_c) {
54
54
  closeServer();
55
55
  inputPromise.cancel();
56
- addLog(_jsx(Text, { color: "red", children: "\u2716 Login cancelled." }));
56
+ addLog(_jsx(ErrorLog, { message: "login cancelled" }));
57
57
  return;
58
58
  }
59
59
  closeServer();
@@ -73,12 +73,12 @@ export function login() {
73
73
  if (!res.ok) {
74
74
  const reason = (_b = (_a = body.error_message) !== null && _a !== void 0 ? _a : body.error) !== null && _b !== void 0 ? _b : 'unknown error';
75
75
  void trackLoginFailed(reason);
76
- addLog(_jsxs(Text, { color: "red", children: ["\u2716 Login failed: ", reason] }));
76
+ addLog(_jsx(ErrorLog, { message: `login failed: ${reason}` }));
77
77
  return;
78
78
  }
79
79
  const token = body;
80
80
  yield storeCredentials(token.access_token, token.refresh_token);
81
81
  void trackLoginSuccess();
82
- addLog(_jsx(Text, { color: "green", children: "\u2714 Logged in successfully." }));
82
+ addLog(_jsx(SuccessLog, { message: "logged in successfully" }));
83
83
  });
84
84
  }
package/bin/logout.js CHANGED
@@ -8,12 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- import { addLog } from '@mintlify/previewing';
12
- import { Text } from 'ink';
11
+ import { addLog, SuccessLog } from '@mintlify/previewing';
13
12
  import { clearCredentials } from './keyring.js';
14
13
  export function logout() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
16
15
  yield clearCredentials();
17
- addLog(_jsx(Text, { color: "green", children: "Logged out successfully." }));
16
+ addLog(_jsx(SuccessLog, { message: "logged out successfully" }));
18
17
  });
19
18
  }
package/bin/status.js CHANGED
@@ -8,10 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { addLog } from '@mintlify/previewing';
12
- import { Text } from 'ink';
11
+ import { addLog, ErrorLog } from '@mintlify/previewing';
12
+ import { Box, Text } from 'ink';
13
13
  import { z } from 'zod';
14
+ import { getConfigValue } from './config.js';
14
15
  import { API_URL } from './constants.js';
16
+ import { getCliVersion } from './helpers.js';
15
17
  import { getAccessToken } from './keyring.js';
16
18
  const StatusResponseSchema = z.object({
17
19
  user: z.object({ email: z.string() }),
@@ -38,9 +40,10 @@ export function getCliSubdomain(accessToken) {
38
40
  }
39
41
  export function status() {
40
42
  return __awaiter(this, void 0, void 0, function* () {
43
+ var _a, _b;
41
44
  const accessToken = yield getAccessToken();
42
45
  if (!accessToken) {
43
- addLog(_jsx(Text, { color: "red", children: "Not logged in. Run `mint login` to authenticate." }));
46
+ addLog(_jsx(ErrorLog, { message: "not logged in. Run `mint login` to authenticate." }));
44
47
  return;
45
48
  }
46
49
  try {
@@ -48,20 +51,22 @@ export function status() {
48
51
  headers: { Authorization: `Bearer ${accessToken}` },
49
52
  });
50
53
  if (!res.ok) {
51
- addLog(_jsx(Text, { color: "red", children: "Not logged in. Run `mint login` to authenticate." }));
54
+ addLog(_jsx(ErrorLog, { message: "not logged in. Run `mint login` to authenticate." }));
52
55
  return;
53
56
  }
54
57
  const json = yield res.json().catch(() => null);
55
58
  const parsed = StatusResponseSchema.safeParse(json);
56
59
  if (!parsed.success) {
57
- addLog(_jsx(Text, { color: "red", children: "Unexpected response from server. Please try again." }));
60
+ addLog(_jsx(ErrorLog, { message: "unexpected response from server. please try again." }));
58
61
  return;
59
62
  }
60
- const { user, org } = parsed.data;
61
- addLog(_jsxs(Text, { children: ["Logged in as ", _jsx(Text, { color: "green", children: user.email }), " in org", ' ', _jsx(Text, { color: "green", children: org.name })] }));
63
+ const { user, org, subdomain: apiSubdomain } = parsed.data;
64
+ const version = getCliVersion();
65
+ const subdomain = (_b = (_a = getConfigValue('subdomain')) !== null && _a !== void 0 ? _a : apiSubdomain) !== null && _b !== void 0 ? _b : null;
66
+ addLog(_jsxs(Box, { flexDirection: "column", paddingY: 1, children: [version && (_jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Version" }) }), _jsx(Text, { children: version })] })), _jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Email" }) }), _jsx(Text, { children: user.email })] }), _jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Organization" }) }), _jsx(Text, { children: org.name })] }), subdomain && (_jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Subdomain" }) }), _jsx(Text, { children: subdomain })] }))] }));
62
67
  }
63
68
  catch (e) {
64
- addLog(_jsx(Text, { color: "red", children: "Unexpected response from server. Please try again." }));
69
+ addLog(_jsx(ErrorLog, { message: "unexpected response from server. please try again." }));
65
70
  }
66
71
  });
67
72
  }