@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/bin/cli.js +5 -1
- package/bin/signup.js +80 -0
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/cli.tsx +10 -6
- package/src/login.tsx +1 -1
- package/src/signup.tsx +92 -0
package/bin/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ import { mdxLinter } from './mdxLinter.js';
|
|
|
29
29
|
import { createTelemetryMiddleware } from './middlewares/telemetryMiddleware.js';
|
|
30
30
|
import { checkOpenApiFile, getOpenApiFilenamesFromDocsConfig } from './openApiCheck.js';
|
|
31
31
|
import { scoreHandler } from './score/index.js';
|
|
32
|
+
import { signup } from './signup.js';
|
|
32
33
|
import { status, getCliSubdomains } from './status.js';
|
|
33
34
|
import { trackTelemetryPreferenceChange } from './telemetry/track.js';
|
|
34
35
|
import { update } from './update.js';
|
|
@@ -329,6 +330,10 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
329
330
|
.command('login', 'Authenticate your account to Mintlify', () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
330
331
|
yield login();
|
|
331
332
|
yield terminate(0);
|
|
333
|
+
}))
|
|
334
|
+
.command('signup', 'Create a new Mintlify account', () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
335
|
+
yield signup();
|
|
336
|
+
yield terminate(0);
|
|
332
337
|
}))
|
|
333
338
|
.command('config', 'Manage CLI configuration', (yargs) => yargs
|
|
334
339
|
.command('set <key> <value>', 'Set a configuration value', (yargs) => yargs
|
|
@@ -470,7 +475,6 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
470
475
|
// Coming soon commands — visible in help, tracked via telemetry to gauge interest.
|
|
471
476
|
.command('ai', '[Coming soon] AI-powered documentation (run mint ai to vote)', () => undefined, comingSoon('ai', packageName))
|
|
472
477
|
.command('test', '[Coming soon] Test your documentation (run mint test to vote)', () => undefined, comingSoon('test', packageName))
|
|
473
|
-
.command('signup', '[Coming soon] Sign up for a Mintlify account (run mint signup to vote)', () => undefined, comingSoon('signup', packageName))
|
|
474
478
|
.command('mcp', '[Coming soon] MCP server for documentation (run mint mcp to vote)', () => undefined, comingSoon('mcp', packageName))
|
|
475
479
|
// Print the help menu when the user enters an invalid command.
|
|
476
480
|
.strictCommands()
|
package/bin/signup.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { input } from '@inquirer/prompts';
|
|
12
|
+
import { addLog, ErrorLog, SuccessLog } from '@mintlify/previewing';
|
|
13
|
+
import { Box, Text } from 'ink';
|
|
14
|
+
import { calculatePKCECodeChallenge, randomNonce, randomPKCECodeVerifier, randomState, } from 'openid-client';
|
|
15
|
+
import { startCallbackServer } from './callbackServer.js';
|
|
16
|
+
import { API_URL, DASHBOARD_URL, STYTCH_CLIENT_ID, TOKEN_ENDPOINT } from './constants.js';
|
|
17
|
+
import { storeCredentials } from './keyring.js';
|
|
18
|
+
export function signup() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
const firstName = yield input({ message: 'First name' });
|
|
22
|
+
const lastName = yield input({ message: 'Last name' });
|
|
23
|
+
const company = yield input({ message: 'Company name' });
|
|
24
|
+
const email = yield input({ message: 'Email' });
|
|
25
|
+
const codeVerifier = randomPKCECodeVerifier();
|
|
26
|
+
const codeChallenge = yield calculatePKCECodeChallenge(codeVerifier);
|
|
27
|
+
const nonce = randomNonce();
|
|
28
|
+
const clientState = randomState();
|
|
29
|
+
const state = Buffer.from(JSON.stringify({ nonce, clientState })).toString('base64url');
|
|
30
|
+
const { codePromise, close: closeServer } = yield startCallbackServer();
|
|
31
|
+
codePromise.catch(() => { });
|
|
32
|
+
try {
|
|
33
|
+
const res = yield fetch(`${API_URL}/api/cli-onboarding/signup`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: { 'Content-Type': 'application/json' },
|
|
36
|
+
body: JSON.stringify({ firstName, lastName, company, email, state, codeChallenge }),
|
|
37
|
+
});
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
const body = yield res.json().catch(() => ({}));
|
|
40
|
+
closeServer();
|
|
41
|
+
addLog(_jsx(ErrorLog, { message: `signup failed: ${(_a = body.error) !== null && _a !== void 0 ? _a : 'unknown error'}` }));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (_d) {
|
|
46
|
+
closeServer();
|
|
47
|
+
addLog(_jsx(ErrorLog, { message: "signup failed: could not reach the server" }));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
addLog(_jsxs(Box, { flexDirection: "column", gap: 1, paddingY: 1, children: [_jsxs(Text, { bold: true, children: [_jsx(Text, { color: "green", children: "\u25C6 " }), "Check your email to verify your account"] }), _jsx(Box, { flexDirection: "column", paddingLeft: 3, gap: 1, children: _jsxs(Text, { dimColor: true, children: ["We sent a verification link to ", email, ". Click it to continue."] }) })] }));
|
|
51
|
+
let code;
|
|
52
|
+
try {
|
|
53
|
+
code = yield codePromise;
|
|
54
|
+
}
|
|
55
|
+
catch (_e) {
|
|
56
|
+
addLog(_jsx(ErrorLog, { message: "signup cancelled" }));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const res = yield fetch(TOKEN_ENDPOINT, {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
headers: { 'Content-Type': 'application/json' },
|
|
62
|
+
body: JSON.stringify({
|
|
63
|
+
client_id: STYTCH_CLIENT_ID,
|
|
64
|
+
grant_type: 'authorization_code',
|
|
65
|
+
code,
|
|
66
|
+
code_verifier: codeVerifier,
|
|
67
|
+
redirect_uri: `${DASHBOARD_URL}/api/cli/oauth/callback`,
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
const body = yield res.json().catch(() => ({}));
|
|
71
|
+
if (!res.ok) {
|
|
72
|
+
const reason = (_c = (_b = body.error_message) !== null && _b !== void 0 ? _b : body.error) !== null && _c !== void 0 ? _c : 'unknown error';
|
|
73
|
+
addLog(_jsx(ErrorLog, { message: `signup failed: ${reason}` }));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const token = body;
|
|
77
|
+
yield storeCredentials(token.access_token, token.refresh_token);
|
|
78
|
+
addLog(_jsx(SuccessLog, { message: "account created and logged in successfully" }));
|
|
79
|
+
});
|
|
80
|
+
}
|