@mintlify/cli 4.0.1359 → 4.0.1361
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/addDomain.js +49 -9
- package/bin/cli.js +7 -2
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/addDomain.tsx +74 -4
- package/src/cli.tsx +11 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1361",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@inquirer/prompts": "7.9.0",
|
|
48
|
-
"@mintlify/common": "1.0.
|
|
49
|
-
"@mintlify/link-rot": "3.0.
|
|
48
|
+
"@mintlify/common": "1.0.1059",
|
|
49
|
+
"@mintlify/link-rot": "3.0.1253",
|
|
50
50
|
"@mintlify/models": "0.0.344",
|
|
51
|
-
"@mintlify/prebuild": "1.0.
|
|
52
|
-
"@mintlify/previewing": "4.0.
|
|
53
|
-
"@mintlify/validation": "0.1.
|
|
51
|
+
"@mintlify/prebuild": "1.0.1208",
|
|
52
|
+
"@mintlify/previewing": "4.0.1277",
|
|
53
|
+
"@mintlify/validation": "0.1.809",
|
|
54
54
|
"adm-zip": "0.5.16",
|
|
55
55
|
"chalk": "5.2.0",
|
|
56
56
|
"color": "4.2.3",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"keytar": "7.9.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@mintlify/editor": "0.0.
|
|
84
|
+
"@mintlify/editor": "0.0.266",
|
|
85
85
|
"@mintlify/ts-config": "2.0.2",
|
|
86
86
|
"@tsconfig/recommended": "1.0.2",
|
|
87
87
|
"@types/adm-zip": "0.5.7",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"vitest": "2.1.9",
|
|
102
102
|
"vitest-mock-process": "1.0.4"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "01132fcdea1229b4af02723b1cd62a2bae73ecf6"
|
|
105
105
|
}
|
package/src/addDomain.tsx
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getRelativeRecordName,
|
|
3
|
+
normalizeBasePath,
|
|
4
|
+
validateCustomDomainBasePath,
|
|
5
|
+
} from '@mintlify/common';
|
|
2
6
|
import { addLog, ErrorLog, removeLastLog, SpinnerLog, SuccessLog } from '@mintlify/previewing';
|
|
3
7
|
import { Box, Text } from 'ink';
|
|
4
8
|
|
|
@@ -24,7 +28,7 @@ const DNS_POLL_MAX_ATTEMPTS = 3;
|
|
|
24
28
|
|
|
25
29
|
const DOMAIN_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i;
|
|
26
30
|
|
|
27
|
-
export async function addDomain(domain: string): Promise<void> {
|
|
31
|
+
export async function addDomain(domain: string, basePath?: string): Promise<void> {
|
|
28
32
|
if (!DOMAIN_PATTERN.test(domain)) {
|
|
29
33
|
addLog(
|
|
30
34
|
<ErrorLog
|
|
@@ -34,6 +38,15 @@ export async function addDomain(domain: string): Promise<void> {
|
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
|
|
41
|
+
const normalizedBasePath = normalizeBasePath(basePath?.trim());
|
|
42
|
+
if (normalizedBasePath) {
|
|
43
|
+
const basePathError = validateCustomDomainBasePath(normalizedBasePath);
|
|
44
|
+
if (basePathError) {
|
|
45
|
+
addLog(<ErrorLog message={`invalid base path "${basePath}": ${basePathError}`} />);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
const accessToken = await getAccessToken();
|
|
38
51
|
if (!accessToken) {
|
|
39
52
|
addLog(<ErrorLog message="not logged in. Run `mint login` to authenticate." />);
|
|
@@ -57,7 +70,7 @@ export async function addDomain(domain: string): Promise<void> {
|
|
|
57
70
|
{
|
|
58
71
|
method: 'POST',
|
|
59
72
|
headers: { 'Content-Type': 'application/json' },
|
|
60
|
-
body: JSON.stringify({ basePath: '' }),
|
|
73
|
+
body: JSON.stringify({ basePath: normalizedBasePath ? '/docs' : '' }),
|
|
61
74
|
}
|
|
62
75
|
);
|
|
63
76
|
|
|
@@ -71,6 +84,44 @@ export async function addDomain(domain: string): Promise<void> {
|
|
|
71
84
|
return;
|
|
72
85
|
}
|
|
73
86
|
|
|
87
|
+
let basePathSaved = false;
|
|
88
|
+
let basePathPending = false;
|
|
89
|
+
if (normalizedBasePath) {
|
|
90
|
+
addLog(<SpinnerLog message={`setting base path to ${normalizedBasePath}...`} />);
|
|
91
|
+
try {
|
|
92
|
+
const basePathRes = await authenticatedFetch(
|
|
93
|
+
`${API_URL}/api/cli/deployment/base-path/${subdomain}`,
|
|
94
|
+
{
|
|
95
|
+
method: 'PUT',
|
|
96
|
+
headers: { 'Content-Type': 'application/json' },
|
|
97
|
+
body: JSON.stringify({ basePath: normalizedBasePath }),
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
removeLastLog();
|
|
102
|
+
|
|
103
|
+
if (basePathRes.ok) {
|
|
104
|
+
const body = (await basePathRes.json().catch(() => ({}))) as {
|
|
105
|
+
pendingBasePathUpdate?: unknown;
|
|
106
|
+
};
|
|
107
|
+
basePathSaved = true;
|
|
108
|
+
basePathPending = Boolean(body.pendingBasePathUpdate);
|
|
109
|
+
} else {
|
|
110
|
+
const body = (await basePathRes.json().catch(() => ({}))) as {
|
|
111
|
+
error?: string;
|
|
112
|
+
issues?: Array<{ message?: string }>;
|
|
113
|
+
};
|
|
114
|
+
const reason = body.issues?.[0]?.message ?? body.error ?? 'unknown error';
|
|
115
|
+
addLog(<ErrorLog message={`domain added, but base path was not saved: ${reason}`} />);
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
removeLastLog();
|
|
119
|
+
addLog(
|
|
120
|
+
<ErrorLog message="domain added, but base path was not saved: could not reach the server" />
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
74
125
|
const maxWaitSeconds = ((DNS_POLL_MAX_ATTEMPTS - 1) * DNS_POLL_INTERVAL_MS) / 1000;
|
|
75
126
|
addLog(
|
|
76
127
|
<SpinnerLog message={`waiting for DNS records to generate (up to ${maxWaitSeconds}s)...`} />
|
|
@@ -111,7 +162,13 @@ export async function addDomain(domain: string): Promise<void> {
|
|
|
111
162
|
(record) => record.type === 'TXT' && record.value !== 'loading'
|
|
112
163
|
);
|
|
113
164
|
|
|
114
|
-
|
|
165
|
+
const successMessage = basePathPending
|
|
166
|
+
? `domain ${domain} added; base path ${normalizedBasePath} queued for the next deploy`
|
|
167
|
+
: basePathSaved
|
|
168
|
+
? `domain ${domain} added (serving at ${normalizedBasePath})`
|
|
169
|
+
: `domain ${domain} added`;
|
|
170
|
+
|
|
171
|
+
addLog(<SuccessLog message={successMessage} />);
|
|
115
172
|
addLog(
|
|
116
173
|
<Box flexDirection="column" gap={1} paddingY={1}>
|
|
117
174
|
<Text bold>Add these DNS records with your domain provider:</Text>
|
|
@@ -126,6 +183,19 @@ export async function addDomain(domain: string): Promise<void> {
|
|
|
126
183
|
</Text>
|
|
127
184
|
</Box>
|
|
128
185
|
<Text dimColor>Add the TXT records first; add the CNAME once they're validated.</Text>
|
|
186
|
+
{basePathPending && (
|
|
187
|
+
<Text dimColor>
|
|
188
|
+
The base path takes effect when that deploy finishes; the current path stays up until
|
|
189
|
+
then.
|
|
190
|
+
</Text>
|
|
191
|
+
)}
|
|
192
|
+
{basePathSaved && (
|
|
193
|
+
<Text dimColor>
|
|
194
|
+
The CNAME sends all paths on {domain} to Mintlify. Only add it if this domain hosts
|
|
195
|
+
nothing else. Otherwise, set up a reverse proxy for {normalizedBasePath}:
|
|
196
|
+
https://www.mintlify.com/docs/deploy/docs-subpath
|
|
197
|
+
</Text>
|
|
198
|
+
)}
|
|
129
199
|
{!recordsReady && (
|
|
130
200
|
<Text dimColor>
|
|
131
201
|
Some TXT records are still being generated. Check the dashboard in a moment for the rest.
|
package/src/cli.tsx
CHANGED
|
@@ -482,13 +482,18 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
|
|
|
482
482
|
'add-domain <domain>',
|
|
483
483
|
'Add a custom domain to your deployment',
|
|
484
484
|
(yargs: Argv) =>
|
|
485
|
-
yargs
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
485
|
+
yargs
|
|
486
|
+
.positional('domain', {
|
|
487
|
+
type: 'string',
|
|
488
|
+
demandOption: true,
|
|
489
|
+
description: 'The custom domain to add (e.g. docs.example.com)',
|
|
490
|
+
})
|
|
491
|
+
.option('basePath', {
|
|
492
|
+
type: 'string',
|
|
493
|
+
description: 'Serve the docs under a base path (e.g. /docs)',
|
|
494
|
+
}),
|
|
490
495
|
async (argv) => {
|
|
491
|
-
await addDomain(argv.domain);
|
|
496
|
+
await addDomain(argv.domain, argv.basePath);
|
|
492
497
|
await terminate(0);
|
|
493
498
|
}
|
|
494
499
|
)
|