@mintlify/cli 4.0.1087 → 4.0.1089

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/cli.js CHANGED
@@ -19,13 +19,15 @@ import { accessibilityCheck } from './accessibilityCheck.js';
19
19
  import { analyticsBuilder } from './analytics/index.js';
20
20
  import { setTelemetryEnabled } from './config.js';
21
21
  import { getConfigValue, setConfigValue, clearConfigValue } from './config.js';
22
+ import { API_URL } from './constants.js';
22
23
  import { CMD_EXEC_PATH, checkPort, checkNodeVersion, autoUpgradeIfNeeded, getVersions, suppressConsoleWarnings, terminate, } from './helpers.js';
23
24
  import { init } from './init.js';
25
+ import { getAccessToken } from './keyring.js';
24
26
  import { login } from './login.js';
25
27
  import { logout } from './logout.js';
26
28
  import { mdxLinter } from './mdxLinter.js';
27
29
  import { checkOpenApiFile, getOpenApiFilenamesFromDocsConfig } from './openApiCheck.js';
28
- import { status } from './status.js';
30
+ import { status, getCliSubdomain } from './status.js';
29
31
  import { createTelemetryMiddleware } from './telemetry/middleware.js';
30
32
  import { trackTelemetryPreferenceChange } from './telemetry/track.js';
31
33
  import { update } from './update.js';
@@ -86,13 +88,25 @@ export const cli = ({ packageName = 'mint' }) => {
86
88
  .usage('usage: mintlify dev [options]')
87
89
  .example('mintlify dev', 'run with default settings (opens in browser)')
88
90
  .example('mintlify dev --no-open', 'run without opening in browser'), (argv) => __awaiter(void 0, void 0, void 0, function* () {
91
+ var _a, _b;
89
92
  yield autoUpgradeIfNeeded();
90
93
  const port = yield checkPort(argv);
91
94
  const { cli: cliVersion } = getVersions();
95
+ let accessToken;
96
+ let subdomain;
97
+ try {
98
+ accessToken = (_a = (yield getAccessToken())) !== null && _a !== void 0 ? _a : undefined;
99
+ const configuredSubdomain = getConfigValue('subdomain');
100
+ subdomain =
101
+ configuredSubdomain !== null && configuredSubdomain !== void 0 ? configuredSubdomain : (accessToken ? (_b = (yield getCliSubdomain(accessToken))) !== null && _b !== void 0 ? _b : undefined : undefined);
102
+ }
103
+ catch (_c) { }
92
104
  if (port != undefined) {
93
105
  yield dev(Object.assign(Object.assign({}, argv), { port,
94
106
  packageName,
95
- cliVersion }));
107
+ cliVersion,
108
+ accessToken,
109
+ subdomain, apiUrl: API_URL }));
96
110
  }
97
111
  else {
98
112
  addLog(_jsx(ErrorLog, { message: "no available port found" }));
package/bin/status.js CHANGED
@@ -16,7 +16,26 @@ import { getAccessToken } from './keyring.js';
16
16
  const StatusResponseSchema = z.object({
17
17
  user: z.object({ email: z.string() }),
18
18
  org: z.object({ name: z.string() }),
19
+ subdomain: z.string().nullable().optional(),
19
20
  });
21
+ export function getCliSubdomain(accessToken) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ var _a;
24
+ try {
25
+ const res = yield fetch(`${API_URL}/api/cli/status`, {
26
+ headers: { Authorization: `Bearer ${accessToken}` },
27
+ });
28
+ if (!res.ok)
29
+ return null;
30
+ const json = yield res.json().catch(() => null);
31
+ const parsed = StatusResponseSchema.safeParse(json);
32
+ return parsed.success ? (_a = parsed.data.subdomain) !== null && _a !== void 0 ? _a : null : null;
33
+ }
34
+ catch (_b) {
35
+ return null;
36
+ }
37
+ });
38
+ }
20
39
  export function status() {
21
40
  return __awaiter(this, void 0, void 0, function* () {
22
41
  const accessToken = yield getAccessToken();