@mintlify/cli 4.0.1129 → 4.0.1130
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 +22 -0
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/cli.tsx +24 -0
package/bin/cli.js
CHANGED
|
@@ -211,6 +211,11 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
211
211
|
type: 'boolean',
|
|
212
212
|
default: false,
|
|
213
213
|
description: 'also check links inside <Snippet> components',
|
|
214
|
+
})
|
|
215
|
+
.option('check-redirects', {
|
|
216
|
+
type: 'boolean',
|
|
217
|
+
default: false,
|
|
218
|
+
description: 'also check that docs.json redirect destinations resolve to valid paths',
|
|
214
219
|
}), (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
220
|
yield autoUpgradeIfNeeded();
|
|
216
221
|
addLog(_jsx(SpinnerLog, { message: "checking for broken links..." }));
|
|
@@ -250,6 +255,23 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
250
255
|
}
|
|
251
256
|
}
|
|
252
257
|
}
|
|
258
|
+
if (argv['check-redirects']) {
|
|
259
|
+
const brokenRedirects = graph.getBrokenRedirects();
|
|
260
|
+
if (brokenRedirects.length > 0) {
|
|
261
|
+
const configFilename = yield fs
|
|
262
|
+
.access(path.join(CMD_EXEC_PATH, 'docs.json'))
|
|
263
|
+
.then(() => 'docs.json')
|
|
264
|
+
.catch(() => 'mint.json');
|
|
265
|
+
const labels = brokenRedirects.map(({ source, destination }) => `${source} → ${destination}`);
|
|
266
|
+
const existing = brokenLinksByFile[configFilename];
|
|
267
|
+
if (existing) {
|
|
268
|
+
existing.push(...labels);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
brokenLinksByFile[configFilename] = labels;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
253
275
|
if (Object.keys(brokenLinksByFile).length === 0) {
|
|
254
276
|
clearLogs();
|
|
255
277
|
addLog(_jsx(SuccessLog, { message: "no broken links found" }));
|