@mintlify/cli 4.0.1344 → 4.0.1345
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/__test__/brokenLinks.test.ts +42 -1
- package/bin/cli.js +5 -4
- package/bin/helpers.js +11 -0
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/cli.tsx +5 -3
- package/src/helpers.tsx +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1345",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"vitest": "2.1.9",
|
|
104
104
|
"vitest-mock-process": "1.0.4"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "dfe8b3b4f02c37cd8d37e38838e40e7098a716e2"
|
|
107
107
|
}
|
package/src/cli.tsx
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
checkPort,
|
|
33
33
|
checkNodeVersion,
|
|
34
34
|
autoUpgradeIfNeeded,
|
|
35
|
+
findDocsRoot,
|
|
35
36
|
getVersions,
|
|
36
37
|
isAI,
|
|
37
38
|
suppressConsoleWarnings,
|
|
@@ -330,16 +331,17 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
|
|
|
330
331
|
await autoUpgradeIfNeeded();
|
|
331
332
|
addLog(<SpinnerLog message="checking for broken links..." />);
|
|
332
333
|
try {
|
|
334
|
+
const docsRoot = await findDocsRoot(CMD_EXEC_PATH);
|
|
333
335
|
const fileArgs = (argv.files ?? []).map(String).filter(Boolean);
|
|
334
336
|
const sourceFiles =
|
|
335
337
|
fileArgs.length > 0
|
|
336
338
|
? new Set(
|
|
337
339
|
(await resolveExplicitFiles(CMD_EXEC_PATH, fileArgs)).map((file) =>
|
|
338
|
-
path.
|
|
340
|
+
path.relative(docsRoot, path.resolve(CMD_EXEC_PATH, file))
|
|
339
341
|
)
|
|
340
342
|
)
|
|
341
343
|
: undefined;
|
|
342
|
-
const graph = await buildGraph(
|
|
344
|
+
const graph = await buildGraph(docsRoot, {
|
|
343
345
|
checkSnippets: argv['check-snippets'],
|
|
344
346
|
});
|
|
345
347
|
graph.precomputeFileResolutions();
|
|
@@ -389,7 +391,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
|
|
|
389
391
|
const brokenRedirects = graph.getBrokenRedirects();
|
|
390
392
|
if (brokenRedirects.length > 0) {
|
|
391
393
|
const configFilename = await fs
|
|
392
|
-
.access(path.join(
|
|
394
|
+
.access(path.join(docsRoot, 'docs.json'))
|
|
393
395
|
.then(() => 'docs.json')
|
|
394
396
|
.catch(() => 'mint.json');
|
|
395
397
|
const labels = brokenRedirects.map(
|
package/src/helpers.tsx
CHANGED
|
@@ -69,6 +69,18 @@ export const checkForMintJson = async () => {
|
|
|
69
69
|
return !!(await getConfigPath(CMD_EXEC_PATH, 'mint'));
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
export const findDocsRoot = async (startDir: string): Promise<string> => {
|
|
73
|
+
const start = path.resolve(startDir);
|
|
74
|
+
const { root } = path.parse(start);
|
|
75
|
+
|
|
76
|
+
let dir = start;
|
|
77
|
+
while (dir !== root) {
|
|
78
|
+
if ((await getConfigPath(dir, 'docs')) || (await getConfigPath(dir, 'mint'))) return dir;
|
|
79
|
+
dir = path.dirname(dir);
|
|
80
|
+
}
|
|
81
|
+
return start;
|
|
82
|
+
};
|
|
83
|
+
|
|
72
84
|
export const checkForDocsJson = async () => {
|
|
73
85
|
const docsJsonPath = path.join(CMD_EXEC_PATH, 'docs.json');
|
|
74
86
|
if (!(await fse.pathExists(docsJsonPath))) {
|