@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/bin/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import yargs from 'yargs';
|
|
|
18
18
|
import { hideBin } from 'yargs/helpers';
|
|
19
19
|
import { accessibilityCheck } from './accessibilityCheck.js';
|
|
20
20
|
import { setTelemetryEnabled } from './config.js';
|
|
21
|
-
import { checkPort,
|
|
21
|
+
import { checkPort, checkNodeVersion, autoUpgradeIfNeeded, getVersions, suppressConsoleWarnings, terminate, readLocalOpenApiFile, } from './helpers.js';
|
|
22
22
|
import { init } from './init.js';
|
|
23
23
|
import { mdxLinter } from './mdxLinter.js';
|
|
24
24
|
import { migrateMdx } from './migrateMdx.js';
|
|
@@ -83,6 +83,7 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
83
83
|
.usage('usage: mintlify dev [options]')
|
|
84
84
|
.example('mintlify dev', 'run with default settings (opens in browser)')
|
|
85
85
|
.example('mintlify dev --no-open', 'run without opening in browser'), (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
yield autoUpgradeIfNeeded();
|
|
86
87
|
const port = yield checkPort(argv);
|
|
87
88
|
const { cli: cliVersion } = getVersions();
|
|
88
89
|
if (port != undefined) {
|
|
@@ -205,10 +206,7 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
205
206
|
default: false,
|
|
206
207
|
description: 'also check links inside <Snippet> components',
|
|
207
208
|
}), (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
208
|
-
|
|
209
|
-
if (!hasMintJson) {
|
|
210
|
-
yield checkForDocsJson();
|
|
211
|
-
}
|
|
209
|
+
yield autoUpgradeIfNeeded();
|
|
212
210
|
addLog(_jsx(SpinnerLog, { message: "checking for broken links..." }));
|
|
213
211
|
try {
|
|
214
212
|
const graph = yield buildGraph(undefined, {
|
|
@@ -276,23 +274,13 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
276
274
|
description: 'rename files and skip errors',
|
|
277
275
|
})
|
|
278
276
|
.epilog('example: `mintlify rename introduction.mdx overview.mdx`'), (_a) => __awaiter(void 0, [_a], void 0, function* ({ from, to, force }) {
|
|
279
|
-
|
|
280
|
-
if (!hasMintJson) {
|
|
281
|
-
yield checkForDocsJson();
|
|
282
|
-
}
|
|
277
|
+
yield autoUpgradeIfNeeded();
|
|
283
278
|
yield renameFilesAndUpdateLinksInContent(from, to, force);
|
|
284
279
|
yield terminate(0);
|
|
285
280
|
}))
|
|
286
281
|
.command('update', 'update the CLI to the latest version', () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
287
282
|
yield update({ packageName });
|
|
288
283
|
yield terminate(0);
|
|
289
|
-
}))
|
|
290
|
-
.command('upgrade', 'upgrade mint.json file to docs.json (current format)', () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
291
|
-
const hasMintJson = yield checkForMintJson();
|
|
292
|
-
if (!hasMintJson) {
|
|
293
|
-
yield checkForDocsJson();
|
|
294
|
-
}
|
|
295
|
-
yield upgradeConfig();
|
|
296
284
|
}))
|
|
297
285
|
.command('migrate-mdx', 'migrate mdx openapi endpoint pages to x-mint extensions and docs.json', () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
298
286
|
yield migrateMdx();
|
package/bin/helpers.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { getConfigPath } from '@mintlify/prebuild';
|
|
12
12
|
import { MintConfigUpdater } from '@mintlify/prebuild';
|
|
13
|
-
import { addLog, ErrorLog, getClientVersion, SuccessLog, InfoLog, SpinnerLog, removeLastLog, LOCAL_LINKED_CLI_VERSION, } from '@mintlify/previewing';
|
|
13
|
+
import { addLog, ErrorLog, getClientVersion, SuccessLog, InfoLog, SpinnerLog, removeLastLog, LOCAL_LINKED_CLI_VERSION, WarningLog, } from '@mintlify/previewing';
|
|
14
14
|
import { upgradeToDocsConfig, validatePathWithinCwd } from '@mintlify/validation';
|
|
15
15
|
import detect from 'detect-port';
|
|
16
16
|
import fse from 'fs-extra';
|
|
@@ -78,6 +78,18 @@ export const checkForDocsJson = () => __awaiter(void 0, void 0, void 0, function
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
+
export const autoUpgradeIfNeeded = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
const hasMintJson = yield checkForMintJson();
|
|
83
|
+
if (!hasMintJson)
|
|
84
|
+
return;
|
|
85
|
+
const docsJsonPath = path.join(CMD_EXEC_PATH, 'docs.json');
|
|
86
|
+
const hasDocsJson = yield fse.pathExists(docsJsonPath);
|
|
87
|
+
if (!hasDocsJson) {
|
|
88
|
+
addLog(_jsx(WarningLog, { message: "Legacy mint.json detected, auto-upgrading to docs.json" }));
|
|
89
|
+
addLog(_jsx(SpinnerLog, { message: "upgrading mint.json to docs.json..." }));
|
|
90
|
+
yield upgradeConfig();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
81
93
|
export const upgradeConfig = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
94
|
try {
|
|
83
95
|
const mintJsonPath = path.join(CMD_EXEC_PATH, 'mint.json');
|