@mintlify/cli 4.0.1307 → 4.0.1309

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.1307",
3
+ "version": "4.0.1309",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -45,11 +45,11 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@inquirer/prompts": "7.9.0",
48
- "@mintlify/common": "1.0.1018",
49
- "@mintlify/link-rot": "3.0.1210",
48
+ "@mintlify/common": "1.0.1019",
49
+ "@mintlify/link-rot": "3.0.1211",
50
50
  "@mintlify/models": "0.0.339",
51
- "@mintlify/prebuild": "1.0.1166",
52
- "@mintlify/previewing": "4.0.1235",
51
+ "@mintlify/prebuild": "1.0.1167",
52
+ "@mintlify/previewing": "4.0.1236",
53
53
  "@mintlify/validation": "0.1.788",
54
54
  "adm-zip": "0.5.16",
55
55
  "chalk": "5.2.0",
@@ -92,5 +92,5 @@
92
92
  "vitest": "2.1.9",
93
93
  "vitest-mock-process": "1.0.4"
94
94
  },
95
- "gitHead": "35bad1c04f17f7bc1fe6e5a722aa9b98ca51b0bf"
95
+ "gitHead": "534ee2066c98331ba570f3e7829764af3f58c0ec"
96
96
  }
package/src/cli.tsx CHANGED
@@ -41,6 +41,7 @@ import { mdxLinter } from './mdxLinter.js';
41
41
  import { createTelemetryMiddleware } from './middlewares/telemetryMiddleware.js';
42
42
  import { checkOpenApiFile, getOpenApiFilenamesFromDocsConfig } from './openApiCheck.js';
43
43
  import { scoreHandler } from './score/index.js';
44
+ import { signup } from './signup.js';
44
45
  import { status, getCliSubdomains } from './status.js';
45
46
  import { trackTelemetryPreferenceChange } from './telemetry/track.js';
46
47
  import { update } from './update.js';
@@ -417,6 +418,15 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
417
418
  await terminate(0);
418
419
  }
419
420
  )
421
+ .command(
422
+ 'signup',
423
+ 'Create a new Mintlify account',
424
+ () => undefined,
425
+ async () => {
426
+ await signup();
427
+ await terminate(0);
428
+ }
429
+ )
420
430
  .command('config', 'Manage CLI configuration', (yargs) =>
421
431
  yargs
422
432
  .command(
@@ -649,12 +659,6 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
649
659
  () => undefined,
650
660
  comingSoon('test', packageName)
651
661
  )
652
- .command(
653
- 'signup',
654
- '[Coming soon] Sign up for a Mintlify account (run mint signup to vote)',
655
- () => undefined,
656
- comingSoon('signup', packageName)
657
- )
658
662
  .command(
659
663
  'mcp',
660
664
  '[Coming soon] MCP server for documentation (run mint mcp to vote)',
package/src/login.tsx CHANGED
@@ -17,7 +17,7 @@ import { storeCredentials } from './keyring.js';
17
17
  import { getCliSubdomains } from './status.js';
18
18
  import { trackLoginAttempt, trackLoginFailed, trackLoginSuccess } from './telemetry/track.js';
19
19
 
20
- interface TokenResponse {
20
+ export interface TokenResponse {
21
21
  access_token: string;
22
22
  id_token: string;
23
23
  refresh_token: string;
package/src/signup.tsx ADDED
@@ -0,0 +1,92 @@
1
+ import { input } from '@inquirer/prompts';
2
+ import { addLog, ErrorLog, SuccessLog } from '@mintlify/previewing';
3
+ import { Box, Text } from 'ink';
4
+ import {
5
+ calculatePKCECodeChallenge,
6
+ randomNonce,
7
+ randomPKCECodeVerifier,
8
+ randomState,
9
+ } from 'openid-client';
10
+
11
+ import { startCallbackServer } from './callbackServer.js';
12
+ import { API_URL, DASHBOARD_URL, STYTCH_CLIENT_ID, TOKEN_ENDPOINT } from './constants.js';
13
+ import { storeCredentials } from './keyring.js';
14
+ import type { TokenResponse } from './login.js';
15
+
16
+ export async function signup(): Promise<void> {
17
+ const firstName = await input({ message: 'First name' });
18
+ const lastName = await input({ message: 'Last name' });
19
+ const company = await input({ message: 'Company name' });
20
+ const email = await input({ message: 'Email' });
21
+
22
+ const codeVerifier = randomPKCECodeVerifier();
23
+ const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
24
+ const nonce = randomNonce();
25
+ const clientState = randomState();
26
+ const state = Buffer.from(JSON.stringify({ nonce, clientState })).toString('base64url');
27
+
28
+ const { codePromise, close: closeServer } = await startCallbackServer();
29
+ codePromise.catch(() => {});
30
+
31
+ try {
32
+ const res = await fetch(`${API_URL}/api/cli-onboarding/signup`, {
33
+ method: 'POST',
34
+ headers: { 'Content-Type': 'application/json' },
35
+ body: JSON.stringify({ firstName, lastName, company, email, state, codeChallenge }),
36
+ });
37
+
38
+ if (!res.ok) {
39
+ const body = await res.json().catch(() => ({}));
40
+ closeServer();
41
+ addLog(<ErrorLog message={`signup failed: ${body.error ?? 'unknown error'}`} />);
42
+ return;
43
+ }
44
+ } catch {
45
+ closeServer();
46
+ addLog(<ErrorLog message="signup failed: could not reach the server" />);
47
+ return;
48
+ }
49
+
50
+ addLog(
51
+ <Box flexDirection="column" gap={1} paddingY={1}>
52
+ <Text bold>
53
+ <Text color="green">◆ </Text>Check your email to verify your account
54
+ </Text>
55
+ <Box flexDirection="column" paddingLeft={3} gap={1}>
56
+ <Text dimColor>We sent a verification link to {email}. Click it to continue.</Text>
57
+ </Box>
58
+ </Box>
59
+ );
60
+
61
+ let code: string;
62
+ try {
63
+ code = await codePromise;
64
+ } catch {
65
+ addLog(<ErrorLog message="signup cancelled" />);
66
+ return;
67
+ }
68
+
69
+ const res = await fetch(TOKEN_ENDPOINT, {
70
+ method: 'POST',
71
+ headers: { 'Content-Type': 'application/json' },
72
+ body: JSON.stringify({
73
+ client_id: STYTCH_CLIENT_ID,
74
+ grant_type: 'authorization_code',
75
+ code,
76
+ code_verifier: codeVerifier,
77
+ redirect_uri: `${DASHBOARD_URL}/api/cli/oauth/callback`,
78
+ }),
79
+ });
80
+
81
+ const body = await res.json().catch(() => ({}));
82
+
83
+ if (!res.ok) {
84
+ const reason = body.error_message ?? body.error ?? 'unknown error';
85
+ addLog(<ErrorLog message={`signup failed: ${reason}`} />);
86
+ return;
87
+ }
88
+
89
+ const token = body as TokenResponse;
90
+ await storeCredentials(token.access_token, token.refresh_token);
91
+ addLog(<SuccessLog message="account created and logged in successfully" />);
92
+ }