@mintlify/cli 4.0.1080 → 4.0.1082
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 +10 -5
- package/__test__/openApiCheck.test.ts +7 -2
- package/bin/cli.js +1 -81
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -8
- package/src/cli.tsx +1 -117
- package/__test__/migrateMdx.test.ts +0 -236
- package/bin/migrateMdx.js +0 -378
- package/bin/scrape.js +0 -108
- package/src/migrateMdx.tsx +0 -469
- package/src/scrape.tsx +0 -122
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { buildGraph, getBrokenExternalLinks } from '@mintlify/link-rot';
|
|
2
2
|
import { MdxPath } from '@mintlify/link-rot/dist/graph.js';
|
|
3
|
-
import
|
|
3
|
+
import { addLog, clearLogs } from '@mintlify/previewing';
|
|
4
4
|
import { mockProcessExit } from 'vitest-mock-process';
|
|
5
5
|
|
|
6
6
|
import { checkForMintJson } from '../src/helpers.js';
|
|
7
7
|
import { runCommand } from './utils.js';
|
|
8
8
|
|
|
9
|
-
vi.mock('
|
|
10
|
-
const
|
|
9
|
+
vi.mock('@mintlify/previewing', async (importOriginal) => {
|
|
10
|
+
const mod = await importOriginal<typeof import('@mintlify/previewing')>();
|
|
11
|
+
return { ...mod, addLog: vi.fn(), clearLogs: vi.fn() };
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
vi.mock('../src/helpers.js', async (importOriginal) => {
|
|
15
|
+
const actual = await importOriginal<typeof import('../src/helpers.js')>();
|
|
11
16
|
return {
|
|
12
17
|
...actual,
|
|
13
18
|
checkForMintJson: vi.fn(),
|
|
@@ -29,8 +34,8 @@ vi.mock('@mintlify/link-rot', async () => {
|
|
|
29
34
|
};
|
|
30
35
|
});
|
|
31
36
|
|
|
32
|
-
const addLogSpy = vi.
|
|
33
|
-
const clearLogsSpy = vi.
|
|
37
|
+
const addLogSpy = vi.mocked(addLog);
|
|
38
|
+
const clearLogsSpy = vi.mocked(clearLogs);
|
|
34
39
|
const processExitMock = mockProcessExit();
|
|
35
40
|
|
|
36
41
|
describe('brokenLinks', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOpenApiDocumentFromUrl, isAllowedLocalSchemaUrl, validate } from '@mintlify/common';
|
|
2
|
-
import
|
|
2
|
+
import { addLog } from '@mintlify/previewing';
|
|
3
3
|
import { mockProcessExit } from 'vitest-mock-process';
|
|
4
4
|
|
|
5
5
|
import { readLocalOpenApiFile } from '../src/helpers.js';
|
|
@@ -12,6 +12,11 @@ vi.mock('@mintlify/common', () => ({
|
|
|
12
12
|
validate: vi.fn(),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
+
vi.mock('@mintlify/previewing', async (importOriginal) => {
|
|
16
|
+
const mod = await importOriginal<typeof import('@mintlify/previewing')>();
|
|
17
|
+
return { ...mod, addLog: vi.fn() };
|
|
18
|
+
});
|
|
19
|
+
|
|
15
20
|
vi.mock('../src/helpers.js', async (importOriginal) => {
|
|
16
21
|
const originalModule = await importOriginal<typeof import('../src/helpers.js')>();
|
|
17
22
|
return {
|
|
@@ -20,7 +25,7 @@ vi.mock('../src/helpers.js', async (importOriginal) => {
|
|
|
20
25
|
};
|
|
21
26
|
});
|
|
22
27
|
|
|
23
|
-
const addLogSpy = vi.
|
|
28
|
+
const addLogSpy = vi.mocked(addLog);
|
|
24
29
|
const processExitMock = mockProcessExit();
|
|
25
30
|
|
|
26
31
|
describe('getOpenApiFilenamesFromDocsConfig', () => {
|
package/bin/cli.js
CHANGED
|
@@ -8,9 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { buildGraph, getBrokenExternalLinks
|
|
11
|
+
import { buildGraph, getBrokenExternalLinks } from '@mintlify/link-rot';
|
|
12
12
|
import { addLog, dev, exportSite, validateBuild, ErrorLog, SpinnerLog, SuccessLog, Logs, clearLogs, BrokenLinksLog, WarningLog, } from '@mintlify/previewing';
|
|
13
|
-
import { checkUrl } from '@mintlify/scraping';
|
|
14
13
|
import { render, Text } from 'ink';
|
|
15
14
|
import fs from 'node:fs/promises';
|
|
16
15
|
import path from 'path';
|
|
@@ -24,9 +23,7 @@ import { init } from './init.js';
|
|
|
24
23
|
import { login } from './login.js';
|
|
25
24
|
import { logout } from './logout.js';
|
|
26
25
|
import { mdxLinter } from './mdxLinter.js';
|
|
27
|
-
import { migrateMdx } from './migrateMdx.js';
|
|
28
26
|
import { checkOpenApiFile, getOpenApiFilenamesFromDocsConfig } from './openApiCheck.js';
|
|
29
|
-
import { scrapeSite, scrapePage, scrapeOpenApi } from './scrape.js';
|
|
30
27
|
import { status } from './status.js';
|
|
31
28
|
import { createTelemetryMiddleware } from './telemetry/middleware.js';
|
|
32
29
|
import { trackTelemetryPreferenceChange } from './telemetry/track.js';
|
|
@@ -250,26 +247,6 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
250
247
|
yield terminate(1);
|
|
251
248
|
}
|
|
252
249
|
yield terminate(1);
|
|
253
|
-
}))
|
|
254
|
-
.command('rename <from> <to>', 'rename a file and update all internal link references', (yargs) => yargs
|
|
255
|
-
.positional('from', {
|
|
256
|
-
describe: 'the file to rename',
|
|
257
|
-
type: 'string',
|
|
258
|
-
})
|
|
259
|
-
.positional('to', {
|
|
260
|
-
describe: 'the new name for the file',
|
|
261
|
-
type: 'string',
|
|
262
|
-
})
|
|
263
|
-
.demandOption(['from', 'to'])
|
|
264
|
-
.option('force', {
|
|
265
|
-
type: 'boolean',
|
|
266
|
-
default: false,
|
|
267
|
-
description: 'rename files and skip errors',
|
|
268
|
-
})
|
|
269
|
-
.epilog('example: `mintlify rename introduction.mdx overview.mdx`'), (_a) => __awaiter(void 0, [_a], void 0, function* ({ from, to, force }) {
|
|
270
|
-
yield autoUpgradeIfNeeded();
|
|
271
|
-
yield renameFilesAndUpdateLinksInContent(from, to, force);
|
|
272
|
-
yield terminate(0);
|
|
273
250
|
}))
|
|
274
251
|
.command('status', false, () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
275
252
|
yield status();
|
|
@@ -286,10 +263,6 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
286
263
|
.command('update', 'update the CLI to the latest version', () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
287
264
|
yield update({ packageName });
|
|
288
265
|
yield terminate(0);
|
|
289
|
-
}))
|
|
290
|
-
.command('migrate-mdx', 'migrate mdx openapi endpoint pages to x-mint extensions and docs.json', () => undefined, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
291
|
-
yield migrateMdx();
|
|
292
|
-
yield terminate(0);
|
|
293
266
|
}))
|
|
294
267
|
.command(['a11y', 'accessibility-check', 'a11y-check', 'accessibility'], 'check for accessibility issues in documentation', (yargs) => yargs
|
|
295
268
|
.option('skip-contrast', {
|
|
@@ -364,59 +337,6 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
364
337
|
yield terminate(1);
|
|
365
338
|
}
|
|
366
339
|
}))
|
|
367
|
-
.command('scrape', 'scrape documentation from external sites', (yargs) => yargs
|
|
368
|
-
.command(['$0 <url>', 'site <url>'], 'scrape an entire documentation site', (yargs) => yargs
|
|
369
|
-
.positional('url', {
|
|
370
|
-
describe: 'The URL of the documentation site to scrape',
|
|
371
|
-
type: 'string',
|
|
372
|
-
demandOption: true,
|
|
373
|
-
})
|
|
374
|
-
.option('filter', {
|
|
375
|
-
describe: 'Only scrape URLs matching this path filter (e.g. /docs will match /docs and /docs/*)',
|
|
376
|
-
type: 'string',
|
|
377
|
-
alias: 'f',
|
|
378
|
-
})
|
|
379
|
-
.check(checkUrl), (_a) => __awaiter(void 0, [_a], void 0, function* ({ url, filter }) {
|
|
380
|
-
yield scrapeSite(url, filter);
|
|
381
|
-
}))
|
|
382
|
-
.command('page <url>', 'scrape a single documentation page', (yargs) => yargs
|
|
383
|
-
.positional('url', {
|
|
384
|
-
describe: 'The URL of the documentation page to scrape',
|
|
385
|
-
type: 'string',
|
|
386
|
-
demandOption: true,
|
|
387
|
-
})
|
|
388
|
-
.check(checkUrl), (_a) => __awaiter(void 0, [_a], void 0, function* ({ url }) {
|
|
389
|
-
yield scrapePage(url);
|
|
390
|
-
}))
|
|
391
|
-
.command('openapi <openapiLocation>', 'generate mdx files from an openapi spec', (yargs) => yargs
|
|
392
|
-
.positional('openapiLocation', {
|
|
393
|
-
describe: 'The filename or URL location of the OpenAPI spec',
|
|
394
|
-
type: 'string',
|
|
395
|
-
demandOption: true,
|
|
396
|
-
})
|
|
397
|
-
.option('writeFiles', {
|
|
398
|
-
describe: 'Whether or not to write the frontmatter files',
|
|
399
|
-
default: true,
|
|
400
|
-
type: 'boolean',
|
|
401
|
-
alias: 'w',
|
|
402
|
-
})
|
|
403
|
-
.option('outDir', {
|
|
404
|
-
describe: 'The folder in which to write any created frontmatter files',
|
|
405
|
-
type: 'string',
|
|
406
|
-
alias: 'o',
|
|
407
|
-
})
|
|
408
|
-
.option('overwrite', {
|
|
409
|
-
describe: 'Whether or not to overwrite existing files',
|
|
410
|
-
default: false,
|
|
411
|
-
type: 'boolean',
|
|
412
|
-
}), (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
413
|
-
yield scrapeOpenApi({
|
|
414
|
-
openapiLocation: argv.openapiLocation,
|
|
415
|
-
writeFiles: argv.writeFiles,
|
|
416
|
-
outDir: argv.outDir,
|
|
417
|
-
overwrite: argv.overwrite,
|
|
418
|
-
});
|
|
419
|
-
})))
|
|
420
340
|
// Print the help menu when the user enters an invalid command.
|
|
421
341
|
.strictCommands()
|
|
422
342
|
.demandCommand(1, 'unknown command. see above for the list of supported commands.')
|