@mintlify/cli 4.0.1129 → 4.0.1131
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 +26 -4
- package/bin/score/index.js +25 -2
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/cli.tsx +28 -4
- package/src/score/index.tsx +25 -3
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" }));
|
|
@@ -401,18 +423,18 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
401
423
|
}
|
|
402
424
|
}))
|
|
403
425
|
.command('analytics', 'View analytics for your documentation', analyticsBuilder)
|
|
404
|
-
.command('score
|
|
426
|
+
.command('score [url]', 'Run agent readiness checks on a docs site', (yargs) => yargs
|
|
405
427
|
.positional('url', {
|
|
406
428
|
type: 'string',
|
|
407
|
-
|
|
408
|
-
description: 'URL of the docs site to check',
|
|
429
|
+
description: 'URL of the docs site to check (defaults to your configured subdomain)',
|
|
409
430
|
})
|
|
410
431
|
.option('format', {
|
|
411
432
|
type: 'string',
|
|
412
433
|
choices: ['table', 'plain', 'json'],
|
|
413
434
|
description: 'Output format',
|
|
414
435
|
})
|
|
415
|
-
.example('mint score
|
|
436
|
+
.example('mint score', 'Run agent readiness checks on your default subdomain')
|
|
437
|
+
.example('mint score docs.example.com', 'Run agent readiness checks on a URL'), scoreHandler)
|
|
416
438
|
// Coming soon commands — visible in help, tracked via telemetry to gauge interest.
|
|
417
439
|
.command('ai', '[Coming soon] AI-powered documentation (run mint ai to vote)', () => undefined, comingSoon('ai', packageName))
|
|
418
440
|
.command('test', '[Coming soon] Test your documentation (run mint test to vote)', () => undefined, comingSoon('test', packageName))
|
package/bin/score/index.js
CHANGED
|
@@ -11,7 +11,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
import { addLog, ErrorLog, SpinnerLog, removeLastLog } from '@mintlify/previewing';
|
|
12
12
|
import chalk from 'chalk';
|
|
13
13
|
import { Text } from 'ink';
|
|
14
|
+
import { getConfigValue } from '../config.js';
|
|
14
15
|
import { terminate } from '../helpers.js';
|
|
16
|
+
import { getAccessToken } from '../keyring.js';
|
|
17
|
+
import { getCliSubdomains } from '../status.js';
|
|
15
18
|
import { trackEvent } from '../telemetry/track.js';
|
|
16
19
|
import { fetchScoreBySlug, resolveScoreForUrl } from './client.js';
|
|
17
20
|
const POLL_INTERVAL_MS = 3000;
|
|
@@ -93,12 +96,32 @@ function pollForScore(slug, afterIso, onAttempt) {
|
|
|
93
96
|
throw new Error(`Score did not complete within ${POLL_TIMEOUT_MS / 1000}s`);
|
|
94
97
|
});
|
|
95
98
|
}
|
|
99
|
+
function resolveDefaultSubdomain() {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const fromConfig = getConfigValue('subdomain');
|
|
102
|
+
if (fromConfig)
|
|
103
|
+
return fromConfig;
|
|
104
|
+
const accessToken = yield getAccessToken();
|
|
105
|
+
if (!accessToken)
|
|
106
|
+
return undefined;
|
|
107
|
+
const subdomains = yield getCliSubdomains(accessToken);
|
|
108
|
+
return subdomains[0];
|
|
109
|
+
});
|
|
110
|
+
}
|
|
96
111
|
export const scoreHandler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
112
|
const format = resolveFormat(argv);
|
|
98
113
|
try {
|
|
114
|
+
let url = argv.url;
|
|
115
|
+
if (!url) {
|
|
116
|
+
const subdomain = yield resolveDefaultSubdomain();
|
|
117
|
+
if (!subdomain) {
|
|
118
|
+
throw new Error('No URL provided and no default subdomain set. Run `mint login` to set one, or pass a URL: `mint score <url>`.');
|
|
119
|
+
}
|
|
120
|
+
url = `${subdomain}.mintlify.app`;
|
|
121
|
+
}
|
|
99
122
|
if (format === 'table')
|
|
100
123
|
addLog(_jsx(SpinnerLog, { message: "Checking agent readiness..." }));
|
|
101
|
-
const resolved = yield resolveScoreForUrl(
|
|
124
|
+
const resolved = yield resolveScoreForUrl(url);
|
|
102
125
|
let final;
|
|
103
126
|
if (resolved.status === 'ready') {
|
|
104
127
|
const score = yield fetchScoreBySlug(resolved.slug);
|
|
@@ -138,7 +161,7 @@ export const scoreHandler = (argv) => __awaiter(void 0, void 0, void 0, function
|
|
|
138
161
|
removeLastLog();
|
|
139
162
|
}
|
|
140
163
|
void trackEvent('cli.score.executed', {
|
|
141
|
-
url
|
|
164
|
+
url,
|
|
142
165
|
score: final.overallScore,
|
|
143
166
|
format,
|
|
144
167
|
status: resolved.status,
|