@mintlify/cli 4.0.1068 → 4.0.1069
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 +4 -16
- package/bin/helpers.js +13 -1
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/cli.tsx +4 -24
- package/src/helpers.tsx +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1069",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"vitest": "2.1.9",
|
|
89
89
|
"vitest-mock-process": "1.0.4"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "10c9be1d7e8d3ccf3f86df9498a1e334090b401e"
|
|
92
92
|
}
|
package/src/cli.tsx
CHANGED
|
@@ -27,10 +27,8 @@ import { accessibilityCheck } from './accessibilityCheck.js';
|
|
|
27
27
|
import { setTelemetryEnabled } from './config.js';
|
|
28
28
|
import {
|
|
29
29
|
checkPort,
|
|
30
|
-
checkForMintJson,
|
|
31
30
|
checkNodeVersion,
|
|
32
|
-
|
|
33
|
-
checkForDocsJson,
|
|
31
|
+
autoUpgradeIfNeeded,
|
|
34
32
|
getVersions,
|
|
35
33
|
suppressConsoleWarnings,
|
|
36
34
|
terminate,
|
|
@@ -109,6 +107,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
|
|
|
109
107
|
.example('mintlify dev', 'run with default settings (opens in browser)')
|
|
110
108
|
.example('mintlify dev --no-open', 'run without opening in browser'),
|
|
111
109
|
async (argv) => {
|
|
110
|
+
await autoUpgradeIfNeeded();
|
|
112
111
|
const port = await checkPort(argv);
|
|
113
112
|
const { cli: cliVersion } = getVersions();
|
|
114
113
|
if (port != undefined) {
|
|
@@ -273,11 +272,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
|
|
|
273
272
|
description: 'also check links inside <Snippet> components',
|
|
274
273
|
}),
|
|
275
274
|
async (argv) => {
|
|
276
|
-
|
|
277
|
-
if (!hasMintJson) {
|
|
278
|
-
await checkForDocsJson();
|
|
279
|
-
}
|
|
280
|
-
|
|
275
|
+
await autoUpgradeIfNeeded();
|
|
281
276
|
addLog(<SpinnerLog message="checking for broken links..." />);
|
|
282
277
|
try {
|
|
283
278
|
const graph = await buildGraph(undefined, {
|
|
@@ -355,10 +350,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
|
|
|
355
350
|
})
|
|
356
351
|
.epilog('example: `mintlify rename introduction.mdx overview.mdx`'),
|
|
357
352
|
async ({ from, to, force }) => {
|
|
358
|
-
|
|
359
|
-
if (!hasMintJson) {
|
|
360
|
-
await checkForDocsJson();
|
|
361
|
-
}
|
|
353
|
+
await autoUpgradeIfNeeded();
|
|
362
354
|
await renameFilesAndUpdateLinksInContent(from, to, force);
|
|
363
355
|
await terminate(0);
|
|
364
356
|
}
|
|
@@ -372,18 +364,6 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
|
|
|
372
364
|
await terminate(0);
|
|
373
365
|
}
|
|
374
366
|
)
|
|
375
|
-
.command(
|
|
376
|
-
'upgrade',
|
|
377
|
-
'upgrade mint.json file to docs.json (current format)',
|
|
378
|
-
() => undefined,
|
|
379
|
-
async () => {
|
|
380
|
-
const hasMintJson = await checkForMintJson();
|
|
381
|
-
if (!hasMintJson) {
|
|
382
|
-
await checkForDocsJson();
|
|
383
|
-
}
|
|
384
|
-
await upgradeConfig();
|
|
385
|
-
}
|
|
386
|
-
)
|
|
387
367
|
.command(
|
|
388
368
|
'migrate-mdx',
|
|
389
369
|
'migrate mdx openapi endpoint pages to x-mint extensions and docs.json',
|
package/src/helpers.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
SpinnerLog,
|
|
10
10
|
removeLastLog,
|
|
11
11
|
LOCAL_LINKED_CLI_VERSION,
|
|
12
|
+
WarningLog,
|
|
12
13
|
} from '@mintlify/previewing';
|
|
13
14
|
import { upgradeToDocsConfig, validatePathWithinCwd } from '@mintlify/validation';
|
|
14
15
|
import detect from 'detect-port';
|
|
@@ -94,6 +95,19 @@ export const checkForDocsJson = async () => {
|
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
97
|
|
|
98
|
+
export const autoUpgradeIfNeeded = async () => {
|
|
99
|
+
const hasMintJson = await checkForMintJson();
|
|
100
|
+
if (!hasMintJson) return;
|
|
101
|
+
|
|
102
|
+
const docsJsonPath = path.join(CMD_EXEC_PATH, 'docs.json');
|
|
103
|
+
const hasDocsJson = await fse.pathExists(docsJsonPath);
|
|
104
|
+
if (!hasDocsJson) {
|
|
105
|
+
addLog(<WarningLog message="Legacy mint.json detected, auto-upgrading to docs.json" />);
|
|
106
|
+
addLog(<SpinnerLog message="upgrading mint.json to docs.json..." />);
|
|
107
|
+
await upgradeConfig();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
97
111
|
export const upgradeConfig = async () => {
|
|
98
112
|
try {
|
|
99
113
|
const mintJsonPath = path.join(CMD_EXEC_PATH, 'mint.json');
|