@mintlify/cli 4.0.1813 → 4.1.1
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/dist/assets/export-scripts/README.classic.md +15 -0
- package/dist/assets/export-scripts/README.md +14 -0
- package/dist/assets/export-scripts/serve.js +114 -0
- package/dist/assets/export-scripts/start-docs.bat +10 -0
- package/dist/assets/export-scripts/start-docs.sh +9 -0
- package/dist/assets/og/Inter-Bold.ttf +0 -0
- package/dist/assets/og/Inter-Medium.ttf +0 -0
- package/dist/assets/og/Inter-Regular.ttf +0 -0
- package/dist/assets/og/Inter-SemiBold.ttf +0 -0
- package/dist/assets/og/PaperMono-Regular.ttf +0 -0
- package/dist/assets/og/index_bg.wasm +0 -0
- package/dist/assets/openChrome.applescript +94 -0
- package/dist/assets/socket.io/socket.io.esm.min.js +7 -0
- package/dist/assets/socket.io/socket.io.esm.min.js.map +1 -0
- package/dist/assets/socket.io/socket.io.js +4907 -0
- package/dist/assets/socket.io/socket.io.js.map +1 -0
- package/dist/assets/socket.io/socket.io.min.js +7 -0
- package/dist/assets/socket.io/socket.io.min.js.map +1 -0
- package/dist/assets/socket.io/socket.io.msgpack.min.js +7 -0
- package/dist/assets/socket.io/socket.io.msgpack.min.js.map +1 -0
- package/dist/assets/xdg-open +1066 -0
- package/dist/assets/yargs-locales/be.json +46 -0
- package/dist/assets/yargs-locales/cs.json +51 -0
- package/dist/assets/yargs-locales/de.json +46 -0
- package/dist/assets/yargs-locales/en.json +55 -0
- package/dist/assets/yargs-locales/es.json +46 -0
- package/dist/assets/yargs-locales/fi.json +49 -0
- package/dist/assets/yargs-locales/fr.json +53 -0
- package/dist/assets/yargs-locales/hi.json +49 -0
- package/dist/assets/yargs-locales/hu.json +46 -0
- package/dist/assets/yargs-locales/id.json +50 -0
- package/dist/assets/yargs-locales/it.json +46 -0
- package/dist/assets/yargs-locales/ja.json +51 -0
- package/dist/assets/yargs-locales/ko.json +49 -0
- package/dist/assets/yargs-locales/nb.json +44 -0
- package/dist/assets/yargs-locales/nl.json +49 -0
- package/dist/assets/yargs-locales/nn.json +44 -0
- package/dist/assets/yargs-locales/pirate.json +13 -0
- package/dist/assets/yargs-locales/pl.json +49 -0
- package/dist/assets/yargs-locales/pt.json +45 -0
- package/dist/assets/yargs-locales/pt_BR.json +48 -0
- package/dist/assets/yargs-locales/ru.json +51 -0
- package/dist/assets/yargs-locales/th.json +46 -0
- package/dist/assets/yargs-locales/tr.json +48 -0
- package/dist/assets/yargs-locales/uk_UA.json +51 -0
- package/dist/assets/yargs-locales/uz.json +52 -0
- package/dist/assets/yargs-locales/zh_CN.json +48 -0
- package/dist/assets/yargs-locales/zh_TW.json +51 -0
- package/dist/converter-d8O3xkdU.js +102 -0
- package/dist/devtools-CGNZQKFV.js +24 -0
- package/dist/index.js +8 -0
- package/dist/rolldown-runtime-CEAe2Uac.js +7 -0
- package/dist/schemas-CBsmCNpK.js +372 -0
- package/dist/start.js +2310 -0
- package/package.json +38 -31
- package/.oxlintrc.json +0 -5
- package/.prettierignore +0 -2
- package/.turbo/turbo-build.log +0 -1
- package/CONTRIBUTING.md +0 -45
- package/__test__/agent-auth.test.ts +0 -114
- package/__test__/agent-claim.test.ts +0 -164
- package/__test__/agent-credentials.test.ts +0 -149
- package/__test__/agent-deployment.test.ts +0 -106
- package/__test__/agent-setup-config.test.ts +0 -324
- package/__test__/agent-setup.test.ts +0 -207
- package/__test__/agent.test.ts +0 -64
- package/__test__/analytics/client.test.ts +0 -180
- package/__test__/analytics/dates.test.ts +0 -12
- package/__test__/analytics/filters.test.ts +0 -116
- package/__test__/analytics/format.test.ts +0 -137
- package/__test__/authenticatedFetch.test.ts +0 -182
- package/__test__/brokenLinks.test.ts +0 -283
- package/__test__/checkPort.test.ts +0 -92
- package/__test__/deploy-github-actions.test.ts +0 -202
- package/__test__/deploy-github-setup.test.ts +0 -240
- package/__test__/deploy-instructions.test.ts +0 -155
- package/__test__/deploy.test.ts +0 -202
- package/__test__/feedback.test.ts +0 -34
- package/__test__/foreignSyntax.test.ts +0 -73
- package/__test__/format.test.ts +0 -72
- package/__test__/helpers.test.ts +0 -52
- package/__test__/init.test.ts +0 -119
- package/__test__/instructions.test.ts +0 -53
- package/__test__/keyring.test.ts +0 -82
- package/__test__/mdxAccessibility.test.ts +0 -81
- package/__test__/migrate.test.ts +0 -186
- package/__test__/openApiCheck.test.ts +0 -185
- package/__test__/pathValidation.test.ts +0 -25
- package/__test__/resolveFiles.test.ts +0 -70
- package/__test__/sessionId.test.ts +0 -46
- package/__test__/signup.test.ts +0 -36
- package/__test__/update.test.ts +0 -117
- package/__test__/utils.ts +0 -25
- package/__test__/validateCommand.test.ts +0 -647
- package/__test__/validateEngine.test.ts +0 -245
- package/__test__/validateRules.test.ts +0 -1275
- package/__test__/welcome.test.ts +0 -15
- package/__test__/workflows/client.test.ts +0 -126
- package/bin/accessibility.js +0 -111
- package/bin/accessibilityCheck.js +0 -82
- package/bin/addDomain.js +0 -130
- package/bin/agent-auth.js +0 -104
- package/bin/agent-claim.js +0 -97
- package/bin/agent-credentials.js +0 -124
- package/bin/agent-deployment.js +0 -96
- package/bin/agent-http.js +0 -45
- package/bin/agent-setup-config.js +0 -141
- package/bin/agent-setup.js +0 -146
- package/bin/agent.js +0 -42
- package/bin/analytics/client.js +0 -60
- package/bin/analytics/dates.js +0 -6
- package/bin/analytics/filters.js +0 -27
- package/bin/analytics/format.js +0 -13
- package/bin/analytics/index.js +0 -496
- package/bin/analytics/output.js +0 -75
- package/bin/analytics/types.js +0 -1
- package/bin/authenticatedFetch.js +0 -46
- package/bin/brokenLinks.js +0 -122
- package/bin/callbackServer.js +0 -65
- package/bin/cli.js +0 -813
- package/bin/comingSoon.js +0 -26
- package/bin/config.js +0 -78
- package/bin/constants.js +0 -16
- package/bin/deploy-base.js +0 -20
- package/bin/deploy-github-actions.js +0 -102
- package/bin/deploy-github-setup.js +0 -165
- package/bin/deploy-instructions.js +0 -71
- package/bin/deploy.js +0 -123
- package/bin/feedback.js +0 -36
- package/bin/format.js +0 -121
- package/bin/helpers.js +0 -238
- package/bin/idToken.js +0 -14
- package/bin/index.js +0 -102
- package/bin/init.js +0 -182
- package/bin/instructions.js +0 -101
- package/bin/keyring.js +0 -78
- package/bin/login.js +0 -123
- package/bin/logout.js +0 -18
- package/bin/mdxAccessibility.js +0 -113
- package/bin/mdxLinter.js +0 -55
- package/bin/middlewares/subdomainMiddleware.js +0 -28
- package/bin/middlewares/telemetryMiddleware.js +0 -61
- package/bin/migrate.js +0 -54
- package/bin/og.js +0 -145
- package/bin/openApiCheck.js +0 -99
- package/bin/resolveFiles.js +0 -114
- package/bin/score/client.js +0 -40
- package/bin/score/index.js +0 -211
- package/bin/score/types.js +0 -1
- package/bin/signup.js +0 -118
- package/bin/start.js +0 -36
- package/bin/status.js +0 -106
- package/bin/telemetry/client.js +0 -53
- package/bin/telemetry/distinctId.js +0 -68
- package/bin/telemetry/sessionId.js +0 -36
- package/bin/telemetry/track.js +0 -149
- package/bin/templates.js +0 -127
- package/bin/tokenRefresh.js +0 -50
- package/bin/tsconfig.build.tsbuildinfo +0 -1
- package/bin/update.js +0 -65
- package/bin/validate/command.js +0 -127
- package/bin/validate/engine.js +0 -154
- package/bin/validate/files.js +0 -163
- package/bin/validate/mdx.js +0 -238
- package/bin/validate/output.js +0 -44
- package/bin/validate/report.js +0 -11
- package/bin/validate/rules/build.js +0 -102
- package/bin/validate/rules/content/duplicateH1.js +0 -57
- package/bin/validate/rules/content/foreignSyntax.js +0 -120
- package/bin/validate/rules/content/katex.js +0 -34
- package/bin/validate/rules/content/missingSnippet.js +0 -34
- package/bin/validate/rules/content/undefinedVariable.js +0 -13
- package/bin/validate/rules/content/unknownComponent.js +0 -121
- package/bin/validate/rules/content/voidTags.js +0 -38
- package/bin/validate/rules/index.js +0 -21
- package/bin/validate/rules/openapi.js +0 -50
- package/bin/validate/rules/parseError.js +0 -7
- package/bin/validate/site.js +0 -57
- package/bin/validate/types.js +0 -1
- package/bin/vendor/converter.js +0 -30882
- package/bin/welcome.js +0 -108
- package/bin/workflows/client.js +0 -34
- package/bin/workflows/index.js +0 -269
- package/bin/workflows/types.js +0 -11
- package/scripts/bundle-converter.mjs +0 -26
- package/scripts/generate-logo.mjs +0 -79
- package/src/accessibility.ts +0 -180
- package/src/accessibilityCheck.tsx +0 -150
- package/src/addDomain.tsx +0 -206
- package/src/agent-auth.ts +0 -119
- package/src/agent-claim.ts +0 -124
- package/src/agent-credentials.ts +0 -104
- package/src/agent-deployment.ts +0 -116
- package/src/agent-http.ts +0 -34
- package/src/agent-setup-config.ts +0 -144
- package/src/agent-setup.ts +0 -165
- package/src/agent.ts +0 -56
- package/src/analytics/client.ts +0 -153
- package/src/analytics/dates.ts +0 -6
- package/src/analytics/filters.ts +0 -50
- package/src/analytics/format.ts +0 -13
- package/src/analytics/index.tsx +0 -599
- package/src/analytics/output.ts +0 -99
- package/src/analytics/types.ts +0 -145
- package/src/authenticatedFetch.ts +0 -42
- package/src/brokenLinks.tsx +0 -152
- package/src/callbackServer.ts +0 -64
- package/src/cli.tsx +0 -1105
- package/src/comingSoon.tsx +0 -29
- package/src/config.ts +0 -75
- package/src/constants.ts +0 -28
- package/src/deploy-base.ts +0 -18
- package/src/deploy-github-actions.ts +0 -139
- package/src/deploy-github-setup.ts +0 -189
- package/src/deploy-instructions.ts +0 -76
- package/src/deploy.ts +0 -165
- package/src/feedback.tsx +0 -31
- package/src/format.tsx +0 -82
- package/src/helpers.tsx +0 -279
- package/src/idToken.ts +0 -17
- package/src/index.ts +0 -109
- package/src/init.tsx +0 -237
- package/src/instructions.ts +0 -99
- package/src/keyring.ts +0 -65
- package/src/login.tsx +0 -166
- package/src/logout.tsx +0 -8
- package/src/mdxAccessibility.ts +0 -134
- package/src/mdxLinter.tsx +0 -88
- package/src/middlewares/subdomainMiddleware.ts +0 -20
- package/src/middlewares/telemetryMiddleware.ts +0 -55
- package/src/migrate.ts +0 -76
- package/src/og.tsx +0 -185
- package/src/openApiCheck.tsx +0 -125
- package/src/resolveFiles.ts +0 -101
- package/src/score/client.ts +0 -36
- package/src/score/index.tsx +0 -205
- package/src/score/types.ts +0 -15
- package/src/signup.tsx +0 -172
- package/src/start.ts +0 -27
- package/src/status.tsx +0 -129
- package/src/telemetry/client.ts +0 -46
- package/src/telemetry/distinctId.ts +0 -70
- package/src/telemetry/sessionId.ts +0 -40
- package/src/telemetry/track.ts +0 -163
- package/src/templates.tsx +0 -143
- package/src/tokenRefresh.ts +0 -53
- package/src/update.tsx +0 -89
- package/src/validate/command.tsx +0 -135
- package/src/validate/engine.ts +0 -210
- package/src/validate/files.ts +0 -249
- package/src/validate/mdx.ts +0 -290
- package/src/validate/output.tsx +0 -76
- package/src/validate/report.ts +0 -40
- package/src/validate/rules/build.ts +0 -146
- package/src/validate/rules/content/duplicateH1.ts +0 -78
- package/src/validate/rules/content/foreignSyntax.ts +0 -144
- package/src/validate/rules/content/katex.ts +0 -33
- package/src/validate/rules/content/missingSnippet.ts +0 -36
- package/src/validate/rules/content/undefinedVariable.ts +0 -20
- package/src/validate/rules/content/unknownComponent.ts +0 -130
- package/src/validate/rules/content/voidTags.ts +0 -43
- package/src/validate/rules/index.ts +0 -23
- package/src/validate/rules/openapi.ts +0 -59
- package/src/validate/rules/parseError.ts +0 -9
- package/src/validate/site.ts +0 -53
- package/src/validate/types.ts +0 -102
- package/src/vendor/converter.ts +0 -1
- package/src/welcome.ts +0 -154
- package/src/workflows/client.ts +0 -39
- package/src/workflows/index.tsx +0 -287
- package/src/workflows/types.ts +0 -73
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -10
- package/vitest.config.ts +0 -9
package/__test__/utils.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { cli } from '../src/cli.js';
|
|
2
|
-
|
|
3
|
-
export async function runCommand(...args: string[]) {
|
|
4
|
-
const prevCliTestMode = process.env.CLI_TEST_MODE;
|
|
5
|
-
process.env.CLI_TEST_MODE = 'true';
|
|
6
|
-
process.argv = ['node', 'cli.js', ...args];
|
|
7
|
-
try {
|
|
8
|
-
return await cli({ packageName: 'mint' });
|
|
9
|
-
} finally {
|
|
10
|
-
if (prevCliTestMode === undefined) {
|
|
11
|
-
delete process.env.CLI_TEST_MODE;
|
|
12
|
-
} else {
|
|
13
|
-
process.env.CLI_TEST_MODE = prevCliTestMode;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const mockValidOpenApiDocument = {
|
|
19
|
-
openapi: '3.0.0',
|
|
20
|
-
info: {
|
|
21
|
-
title: 'Test API',
|
|
22
|
-
version: '1.0.0',
|
|
23
|
-
},
|
|
24
|
-
components: {},
|
|
25
|
-
};
|
|
@@ -1,647 +0,0 @@
|
|
|
1
|
-
import { addLog, checkBuild } from '@mintlify/previewing';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { mockProcessExit } from 'vitest-mock-process';
|
|
5
|
-
|
|
6
|
-
import { sendPublishPrompt } from '../src/signup.js';
|
|
7
|
-
import type { Report } from '../src/validate/report.js';
|
|
8
|
-
import { runCommand } from './utils.js';
|
|
9
|
-
|
|
10
|
-
const { dir } = vi.hoisted(() => ({
|
|
11
|
-
dir: `${process.env.TMPDIR ?? '/tmp'}/validate-command-${process.pid}`,
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
vi.mock('../src/helpers.js', async (importOriginal) => {
|
|
15
|
-
const mod = await importOriginal<typeof import('../src/helpers.js')>();
|
|
16
|
-
return { ...mod, CMD_EXEC_PATH: dir, autoUpgradeIfNeeded: vi.fn() };
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
vi.mock('../src/signup.js', async (importOriginal) => {
|
|
20
|
-
const mod = await importOriginal<typeof import('../src/signup.js')>();
|
|
21
|
-
return { ...mod, sendPublishPrompt: vi.fn() };
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
vi.mock('@mintlify/previewing', async (importOriginal) => {
|
|
25
|
-
const mod = await importOriginal<typeof import('@mintlify/previewing')>();
|
|
26
|
-
return { ...mod, addLog: vi.fn(), checkBuild: vi.fn() };
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const processExitMock = mockProcessExit();
|
|
30
|
-
|
|
31
|
-
const HOME = '---\ntitle: Home\n---\n\nBody\n';
|
|
32
|
-
|
|
33
|
-
const writeSite = (files: Record<string, string>, config: Record<string, unknown> = {}) => {
|
|
34
|
-
fs.emptyDirSync(dir);
|
|
35
|
-
fs.writeJSONSync(path.join(dir, 'docs.json'), {
|
|
36
|
-
theme: 'mint',
|
|
37
|
-
name: 'Test',
|
|
38
|
-
colors: { primary: '#000000' },
|
|
39
|
-
navigation: { pages: ['index'] },
|
|
40
|
-
...config,
|
|
41
|
-
});
|
|
42
|
-
for (const [file, content] of Object.entries(files)) {
|
|
43
|
-
fs.outputFileSync(path.join(dir, file), content);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const runJson = async (...args: string[]) => {
|
|
48
|
-
const write = vi.spyOn(process.stdout, 'write').mockImplementation((...params: unknown[]) => {
|
|
49
|
-
params.find((param): param is () => void => typeof param === 'function')?.();
|
|
50
|
-
return true;
|
|
51
|
-
});
|
|
52
|
-
try {
|
|
53
|
-
await runCommand(...args, '--format', 'json');
|
|
54
|
-
return write.mock.calls.map(([chunk]) => String(chunk));
|
|
55
|
-
} finally {
|
|
56
|
-
write.mockRestore();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const report = async (...args: string[]) => {
|
|
61
|
-
const chunks = await runJson(...args);
|
|
62
|
-
expect(chunks).toHaveLength(1);
|
|
63
|
-
return JSON.parse(chunks[0] ?? '') as Report;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/** Runs in json mode expecting a failure: nothing on stdout, the error on stderr. */
|
|
67
|
-
const jsonError = async (...args: string[]) => {
|
|
68
|
-
const stderr = vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
|
|
69
|
-
try {
|
|
70
|
-
expect(await runJson(...args)).toEqual([]);
|
|
71
|
-
return stderr.mock.calls.map(([chunk]) => String(chunk)).join('');
|
|
72
|
-
} finally {
|
|
73
|
-
stderr.mockRestore();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const rules = (result: { diagnostics: { rule: string }[] }) =>
|
|
78
|
-
result.diagnostics.map(({ rule }) => rule);
|
|
79
|
-
|
|
80
|
-
describe('mint validate', () => {
|
|
81
|
-
beforeEach(() => {
|
|
82
|
-
vi.clearAllMocks();
|
|
83
|
-
vi.mocked(checkBuild).mockResolvedValue({ passed: true, warnings: [] });
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
afterAll(() => {
|
|
87
|
-
fs.removeSync(dir);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('exits only after stdout has flushed the JSON report', async () => {
|
|
91
|
-
writeSite({ 'index.mdx': HOME });
|
|
92
|
-
let flush: (() => void) | undefined;
|
|
93
|
-
const write = vi.spyOn(process.stdout, 'write').mockImplementation((...params: unknown[]) => {
|
|
94
|
-
flush = params.find((param): param is () => void => typeof param === 'function');
|
|
95
|
-
return true;
|
|
96
|
-
});
|
|
97
|
-
try {
|
|
98
|
-
const run = runCommand('validate', '--no-build', '--format', 'json');
|
|
99
|
-
await vi.waitFor(() => expect(write).toHaveBeenCalled());
|
|
100
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
101
|
-
expect(processExitMock).not.toHaveBeenCalled();
|
|
102
|
-
|
|
103
|
-
flush?.();
|
|
104
|
-
await run;
|
|
105
|
-
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
106
|
-
} finally {
|
|
107
|
-
write.mockRestore();
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('prints one JSON report with a summary and every diagnostic', async () => {
|
|
112
|
-
writeSite({ 'index.mdx': '---\ntitle: Home\n---\n\n# Home\n\nline<br>\n' });
|
|
113
|
-
|
|
114
|
-
const result = await report('validate', '--no-build');
|
|
115
|
-
|
|
116
|
-
expect(result).toEqual({
|
|
117
|
-
passed: false,
|
|
118
|
-
summary: { errors: 1, warnings: 1, byRule: { 'duplicate-h1': 1, 'void-tags': 1 } },
|
|
119
|
-
diagnostics: [
|
|
120
|
-
expect.objectContaining({
|
|
121
|
-
rule: 'duplicate-h1',
|
|
122
|
-
group: 'content',
|
|
123
|
-
severity: 'warning',
|
|
124
|
-
file: 'index.mdx',
|
|
125
|
-
line: 5,
|
|
126
|
-
fix: { file: 'index.mdx', start: 21, end: 29, text: '' },
|
|
127
|
-
}),
|
|
128
|
-
expect.objectContaining({
|
|
129
|
-
rule: 'void-tags',
|
|
130
|
-
severity: 'error',
|
|
131
|
-
line: 7,
|
|
132
|
-
fix: { file: 'index.mdx', start: 33, end: 37, text: '<br />' },
|
|
133
|
-
}),
|
|
134
|
-
],
|
|
135
|
-
build: { ran: false, reason: 'disabled' },
|
|
136
|
-
});
|
|
137
|
-
expect(addLog).not.toHaveBeenCalled();
|
|
138
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('passes with warnings and runs the build', async () => {
|
|
142
|
-
writeSite({ 'index.mdx': '---\ntitle: Home\n---\n\n# Home\n' });
|
|
143
|
-
|
|
144
|
-
const result = await report('validate');
|
|
145
|
-
|
|
146
|
-
expect(result).toMatchObject({ passed: true, build: { ran: true, passed: true } });
|
|
147
|
-
expect(rules(result)).toEqual(['duplicate-h1']);
|
|
148
|
-
expect(checkBuild).toHaveBeenCalled();
|
|
149
|
-
expect(sendPublishPrompt).not.toHaveBeenCalled();
|
|
150
|
-
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('skips the build while there are errors', async () => {
|
|
154
|
-
writeSite({ 'index.mdx': '---\ntitle: Home\n---\n\nline<br>\n' });
|
|
155
|
-
|
|
156
|
-
const result = await report('validate');
|
|
157
|
-
|
|
158
|
-
expect(result.build).toEqual({ ran: false, reason: 'errors found' });
|
|
159
|
-
expect(checkBuild).not.toHaveBeenCalled();
|
|
160
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('turns build warnings into diagnostics', async () => {
|
|
164
|
-
writeSite({ 'index.mdx': HOME });
|
|
165
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
166
|
-
passed: false,
|
|
167
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
168
|
-
strict: true,
|
|
169
|
-
warnings: [
|
|
170
|
-
{
|
|
171
|
-
type: 'missing-nav-page',
|
|
172
|
-
message: '"gone" is referenced in the docs.json navigation but the file does not exist.',
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const result = await report('validate');
|
|
178
|
-
|
|
179
|
-
expect(result.diagnostics).toEqual([
|
|
180
|
-
expect.objectContaining({ rule: 'missing-nav-page', group: 'nav', file: 'docs.json' }),
|
|
181
|
-
]);
|
|
182
|
-
expect(result.build).toEqual({ ran: true, passed: false });
|
|
183
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('attributes a missing nav page that looks like a file to the config', async () => {
|
|
187
|
-
writeSite({ 'index.mdx': HOME }, { navigation: { pages: ['index', 'guides/setup.md'] } });
|
|
188
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
189
|
-
passed: false,
|
|
190
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
191
|
-
strict: true,
|
|
192
|
-
warnings: [
|
|
193
|
-
{
|
|
194
|
-
type: 'missing-nav-page',
|
|
195
|
-
message:
|
|
196
|
-
'"guides/setup.md" is referenced in the docs.json navigation but the file does not exist.',
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const result = await report('validate');
|
|
202
|
-
|
|
203
|
-
expect(result.diagnostics).toEqual([
|
|
204
|
-
expect.objectContaining({
|
|
205
|
-
rule: 'missing-nav-page',
|
|
206
|
-
file: 'docs.json',
|
|
207
|
-
line: expect.any(Number),
|
|
208
|
-
}),
|
|
209
|
-
]);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('reports a build failure no rule explains', async () => {
|
|
213
|
-
writeSite({ 'index.mdx': HOME });
|
|
214
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
215
|
-
passed: false,
|
|
216
|
-
error: 'boom',
|
|
217
|
-
strict: false,
|
|
218
|
-
warnings: [],
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const result = await report('validate');
|
|
222
|
-
|
|
223
|
-
expect(result.diagnostics).toEqual([
|
|
224
|
-
expect.objectContaining({ rule: 'build-failed', message: 'boom' }),
|
|
225
|
-
]);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('passes when the build fails only on disabled rules', async () => {
|
|
229
|
-
writeSite({ 'index.mdx': HOME });
|
|
230
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
231
|
-
passed: false,
|
|
232
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
233
|
-
strict: true,
|
|
234
|
-
warnings: [
|
|
235
|
-
{
|
|
236
|
-
type: 'missing-nav-page',
|
|
237
|
-
message: '"gone" is referenced in the docs.json navigation but the file does not exist.',
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
const result = await report('validate', '--disable', 'missing-nav-page');
|
|
243
|
-
|
|
244
|
-
expect(result).toMatchObject({ passed: true, build: { ran: true, passed: false } });
|
|
245
|
-
expect(rules(result)).toEqual([]);
|
|
246
|
-
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('fails on a build error even when a disabled rule covers its warnings', async () => {
|
|
250
|
-
writeSite({ 'index.mdx': HOME });
|
|
251
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
252
|
-
passed: false,
|
|
253
|
-
error: 'Unexpected token } in docs.json',
|
|
254
|
-
strict: false,
|
|
255
|
-
warnings: [{ type: 'openapi', message: 'Could not read OpenAPI overlay settings' }],
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
const result = await report('validate', '--disable', 'openapi');
|
|
259
|
-
|
|
260
|
-
expect(result.passed).toBe(false);
|
|
261
|
-
expect(result.diagnostics).toEqual([
|
|
262
|
-
expect.objectContaining({ rule: 'build-failed', message: 'Unexpected token } in docs.json' }),
|
|
263
|
-
]);
|
|
264
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('skips OpenAPI generation in the build only when no openapi rule is selected', async () => {
|
|
268
|
-
writeSite({ 'index.mdx': HOME });
|
|
269
|
-
|
|
270
|
-
await report('validate', '--disable', 'openapi');
|
|
271
|
-
expect(checkBuild).toHaveBeenLastCalledWith(expect.objectContaining({ disableOpenapi: true }));
|
|
272
|
-
|
|
273
|
-
await report('validate');
|
|
274
|
-
expect(checkBuild).toHaveBeenLastCalledWith(expect.objectContaining({ disableOpenapi: false }));
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('cleans build warning messages and lifts their position', async () => {
|
|
278
|
-
writeSite({ 'index.mdx': HOME });
|
|
279
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
280
|
-
passed: false,
|
|
281
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
282
|
-
strict: true,
|
|
283
|
-
warnings: [
|
|
284
|
-
{ type: 'parse-error', message: '\n\u001b[31m./index.mdx:3:7 Unexpected token\u001b[39m' },
|
|
285
|
-
],
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
const result = await report('validate');
|
|
289
|
-
|
|
290
|
-
expect(result.diagnostics).toEqual([
|
|
291
|
-
expect.objectContaining({
|
|
292
|
-
rule: 'parse-error',
|
|
293
|
-
file: 'index.mdx',
|
|
294
|
-
line: 3,
|
|
295
|
-
column: 7,
|
|
296
|
-
message: './index.mdx:3:7 Unexpected token',
|
|
297
|
-
}),
|
|
298
|
-
]);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('prefers structured warning fields over the message text', async () => {
|
|
302
|
-
writeSite(
|
|
303
|
-
{ 'index.mdx': HOME, 'guides/real.mdx': HOME },
|
|
304
|
-
{ navigation: { pages: ['index', 'guides/real', 'gone'] } }
|
|
305
|
-
);
|
|
306
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
307
|
-
passed: false,
|
|
308
|
-
error: 'Build validation failed with 2 warning(s). See above for details.',
|
|
309
|
-
strict: true,
|
|
310
|
-
warnings: [
|
|
311
|
-
{
|
|
312
|
-
type: 'parse-error',
|
|
313
|
-
message: '\u001b[31m./wrong.mdx:9:9 Unexpected token\u001b[39m',
|
|
314
|
-
file: 'guides/real.mdx',
|
|
315
|
-
line: 3,
|
|
316
|
-
column: 7,
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
type: 'missing-nav-page',
|
|
320
|
-
message: '"gone" is referenced in the docs.json navigation but the file does not exist.',
|
|
321
|
-
file: 'docs.json',
|
|
322
|
-
ref: 'gone',
|
|
323
|
-
},
|
|
324
|
-
],
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
const result = await report('validate');
|
|
328
|
-
|
|
329
|
-
expect(result.diagnostics).toHaveLength(2);
|
|
330
|
-
expect(result.diagnostics).toEqual(
|
|
331
|
-
expect.arrayContaining([
|
|
332
|
-
expect.objectContaining({
|
|
333
|
-
rule: 'parse-error',
|
|
334
|
-
file: 'guides/real.mdx',
|
|
335
|
-
line: 3,
|
|
336
|
-
column: 7,
|
|
337
|
-
message: './wrong.mdx:9:9 Unexpected token',
|
|
338
|
-
}),
|
|
339
|
-
expect.objectContaining({
|
|
340
|
-
rule: 'missing-nav-page',
|
|
341
|
-
file: 'docs.json',
|
|
342
|
-
line: expect.any(Number),
|
|
343
|
-
}),
|
|
344
|
-
])
|
|
345
|
-
);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
it('fails when the build fails on a parse error outside --files', async () => {
|
|
349
|
-
writeSite({ 'index.mdx': HOME, 'other.mdx': HOME });
|
|
350
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
351
|
-
passed: false,
|
|
352
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
353
|
-
strict: true,
|
|
354
|
-
warnings: [{ type: 'parse-error', message: './other.mdx:3:7 Unexpected token' }],
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
const result = await report('validate', '--files', 'index.mdx');
|
|
358
|
-
|
|
359
|
-
expect(result.passed).toBe(false);
|
|
360
|
-
expect(result.diagnostics).toEqual([
|
|
361
|
-
expect.objectContaining({ rule: 'build-failed', file: 'other.mdx' }),
|
|
362
|
-
]);
|
|
363
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it('attributes import warnings to the importing page', async () => {
|
|
367
|
-
writeSite({ 'index.mdx': HOME });
|
|
368
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
369
|
-
passed: false,
|
|
370
|
-
error: 'Build validation failed with 3 warning(s). See above for details.',
|
|
371
|
-
strict: true,
|
|
372
|
-
warnings: [
|
|
373
|
-
{
|
|
374
|
-
type: 'missing-file',
|
|
375
|
-
message: 'Could not find file snippets/gone.mdx - imported from index.mdx',
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
type: 'invalid-import-path',
|
|
379
|
-
message:
|
|
380
|
-
'Invalid import path https://example.com/a.jsx in index.mdx. Only local imports are supported.',
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
type: 'export-collision',
|
|
384
|
-
message: 'Widget is exported by snippets/a.jsx (in index.mdx, importing snippets/b.mdx)',
|
|
385
|
-
},
|
|
386
|
-
],
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
const result = await report('validate');
|
|
390
|
-
|
|
391
|
-
expect(result.diagnostics.map(({ file }: { file: string }) => file)).toEqual([
|
|
392
|
-
'index.mdx',
|
|
393
|
-
'index.mdx',
|
|
394
|
-
'index.mdx',
|
|
395
|
-
]);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it('reports missing imported files with the content group', async () => {
|
|
399
|
-
writeSite({ 'index.mdx': HOME });
|
|
400
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
401
|
-
passed: false,
|
|
402
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
403
|
-
strict: true,
|
|
404
|
-
warnings: [
|
|
405
|
-
{
|
|
406
|
-
type: 'missing-file',
|
|
407
|
-
message: 'Could not find file snippets/gone.mdx - imported from index.mdx',
|
|
408
|
-
},
|
|
409
|
-
],
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
const result = await report('validate', '--disable', 'all', '--enable', 'content');
|
|
413
|
-
|
|
414
|
-
expect(result.diagnostics).toEqual([
|
|
415
|
-
expect.objectContaining({ rule: 'missing-file', group: 'content', file: 'index.mdx' }),
|
|
416
|
-
]);
|
|
417
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it('keeps skipped-spec notices as warnings', async () => {
|
|
421
|
-
writeSite({ 'index.mdx': HOME }, { api: { openapi: 'http://example.com/openapi.json' } });
|
|
422
|
-
|
|
423
|
-
const result = await report('validate', '--no-build');
|
|
424
|
-
|
|
425
|
-
expect(result.passed).toBe(true);
|
|
426
|
-
expect(result.diagnostics).toEqual([
|
|
427
|
-
expect.objectContaining({
|
|
428
|
-
rule: 'openapi-spec',
|
|
429
|
-
severity: 'warning',
|
|
430
|
-
message: expect.stringContaining('--local-schema'),
|
|
431
|
-
}),
|
|
432
|
-
expect.objectContaining({
|
|
433
|
-
rule: 'openapi-spec',
|
|
434
|
-
severity: 'warning',
|
|
435
|
-
message: 'only https protocol is supported in production',
|
|
436
|
-
}),
|
|
437
|
-
]);
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it('exits 2 when the build could not be prepared', async () => {
|
|
441
|
-
writeSite({ 'index.mdx': HOME });
|
|
442
|
-
vi.mocked(checkBuild).mockRejectedValue(new Error('requires an internet connection'));
|
|
443
|
-
|
|
444
|
-
expect(await jsonError('validate')).toBe('Error: requires an internet connection\n');
|
|
445
|
-
expect(processExitMock).toHaveBeenCalledWith(2);
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
it('keeps console output during the build off stdout in json mode', async () => {
|
|
449
|
-
writeSite({ 'index.mdx': HOME });
|
|
450
|
-
vi.mocked(checkBuild).mockImplementation(async () => {
|
|
451
|
-
console.log('progress line');
|
|
452
|
-
return { passed: true, warnings: [] };
|
|
453
|
-
});
|
|
454
|
-
const stderr = vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
|
|
455
|
-
|
|
456
|
-
const result = await report('validate');
|
|
457
|
-
|
|
458
|
-
const errors = stderr.mock.calls.map(([chunk]) => String(chunk));
|
|
459
|
-
stderr.mockRestore();
|
|
460
|
-
expect(result.passed).toBe(true);
|
|
461
|
-
expect(errors).toContain('progress line\n');
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
it('applies fixes with --fix, lists them and leaves unfixable issues', async () => {
|
|
465
|
-
writeSite({ 'index.mdx': '---\ntitle: Home\n---\n\nline<br>\n\n<Missing />\n' });
|
|
466
|
-
|
|
467
|
-
const result = await report('validate', '--no-build', '--fix');
|
|
468
|
-
|
|
469
|
-
expect(fs.readFileSync(path.join(dir, 'index.mdx'), 'utf-8')).toContain('line<br />');
|
|
470
|
-
expect(result.fixed).toEqual([
|
|
471
|
-
{
|
|
472
|
-
rule: 'void-tags',
|
|
473
|
-
file: 'index.mdx',
|
|
474
|
-
line: 5,
|
|
475
|
-
column: 5,
|
|
476
|
-
before: '<br>',
|
|
477
|
-
after: '<br />',
|
|
478
|
-
},
|
|
479
|
-
]);
|
|
480
|
-
expect(rules(result)).toEqual(['unknown-component']);
|
|
481
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
it('turns rules and groups on and off', async () => {
|
|
485
|
-
writeSite({
|
|
486
|
-
'index.mdx': '---\ntitle: Home\n---\n\n# Home\n\nline<br>\n',
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
// Without void-tags, nothing makes the page parseable
|
|
490
|
-
expect(rules(await report('validate', '--no-build', '--disable', 'content'))).toEqual([
|
|
491
|
-
'parse-error',
|
|
492
|
-
]);
|
|
493
|
-
expect(rules(await report('validate', '--no-build', '--disable', 'all'))).toEqual([
|
|
494
|
-
'parse-error',
|
|
495
|
-
]);
|
|
496
|
-
expect(
|
|
497
|
-
rules(await report('validate', '--no-build', '--disable', 'all', '--enable', 'void-tags'))
|
|
498
|
-
).toEqual(['void-tags']);
|
|
499
|
-
expect(
|
|
500
|
-
rules(await report('validate', '--no-build', '--disable', 'openapi, duplicate-h1'))
|
|
501
|
-
).toEqual(['void-tags']);
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
it('rejects unknown rules and disabling parse-error', async () => {
|
|
505
|
-
writeSite({ 'index.mdx': HOME });
|
|
506
|
-
|
|
507
|
-
expect(await jsonError('validate', '--disable', 'nope')).toContain(
|
|
508
|
-
'Error: unknown rule or group "nope"'
|
|
509
|
-
);
|
|
510
|
-
expect(processExitMock).toHaveBeenLastCalledWith(2);
|
|
511
|
-
|
|
512
|
-
expect(await jsonError('validate', '--disable', 'parse-error')).toBe(
|
|
513
|
-
"Error: parse-error always runs and can't be disabled\n"
|
|
514
|
-
);
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
it('limits page findings to --files', async () => {
|
|
518
|
-
writeSite(
|
|
519
|
-
{
|
|
520
|
-
'index.mdx': '---\ntitle: Home\n---\n\nline<br>\n',
|
|
521
|
-
'other.mdx': '---\ntitle: Other\n---\n\n# Other\n\nline<br>\n',
|
|
522
|
-
},
|
|
523
|
-
{ navigation: { pages: ['index', 'other'] } }
|
|
524
|
-
);
|
|
525
|
-
|
|
526
|
-
const result = await report('validate', '--no-build', '--files', 'other.mdx');
|
|
527
|
-
|
|
528
|
-
expect(result.diagnostics.map(({ file }: { file: string }) => file)).toEqual([
|
|
529
|
-
'other.mdx',
|
|
530
|
-
'other.mdx',
|
|
531
|
-
]);
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
it('posix-normalizes Windows paths in build warnings', async () => {
|
|
535
|
-
writeSite({ 'index.mdx': HOME, 'snippets/card.mdx': 'Card\n' });
|
|
536
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
537
|
-
passed: false,
|
|
538
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
539
|
-
strict: true,
|
|
540
|
-
warnings: [{ type: 'parse-error', message: '.\\snippets\\card.mdx:2:1 Unexpected token' }],
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
const result = await report('validate');
|
|
544
|
-
|
|
545
|
-
expect(result.diagnostics).toEqual([
|
|
546
|
-
expect.objectContaining({ rule: 'parse-error', file: 'snippets/card.mdx', line: 2 }),
|
|
547
|
-
]);
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
it('checks every OpenAPI spec and sorts findings by file', async () => {
|
|
551
|
-
writeSite({ 'index.mdx': HOME }, { api: { openapi: ['b.json', 'a.json'] } });
|
|
552
|
-
fs.writeFileSync(path.join(dir, 'a.json'), '{ not json');
|
|
553
|
-
fs.writeFileSync(path.join(dir, 'b.json'), '{ not json');
|
|
554
|
-
|
|
555
|
-
const result = await report('validate', '--no-build');
|
|
556
|
-
|
|
557
|
-
expect(result.diagnostics.map(({ rule, file }) => [rule, file])).toEqual([
|
|
558
|
-
['openapi-spec', 'a.json'],
|
|
559
|
-
['openapi-spec', 'b.json'],
|
|
560
|
-
]);
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
it('reports invalid OpenAPI specs and skips them with --disable openapi', async () => {
|
|
564
|
-
writeSite({ 'index.mdx': HOME }, { api: { openapi: 'openapi.json' } });
|
|
565
|
-
fs.writeFileSync(path.join(dir, 'openapi.json'), '{ not json');
|
|
566
|
-
|
|
567
|
-
expect(rules(await report('validate', '--no-build'))).toEqual(['openapi-spec']);
|
|
568
|
-
expect(rules(await report('validate', '--no-build', '--disable', 'openapi'))).toEqual([]);
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
it('checks the OpenAPI specs a mint.json lists', async () => {
|
|
572
|
-
writeSite({ 'index.mdx': HOME });
|
|
573
|
-
fs.removeSync(path.join(dir, 'docs.json'));
|
|
574
|
-
fs.writeJSONSync(path.join(dir, 'mint.json'), {
|
|
575
|
-
name: 'Test',
|
|
576
|
-
colors: { primary: '#000000' },
|
|
577
|
-
navigation: [{ group: 'Home', pages: ['index'] }],
|
|
578
|
-
openapi: 'openapi.json',
|
|
579
|
-
});
|
|
580
|
-
fs.writeFileSync(path.join(dir, 'openapi.json'), '{ not json');
|
|
581
|
-
|
|
582
|
-
const result = await report('validate', '--no-build');
|
|
583
|
-
|
|
584
|
-
expect(result.diagnostics).toEqual([
|
|
585
|
-
expect.objectContaining({ rule: 'openapi-spec', file: 'openapi.json' }),
|
|
586
|
-
]);
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
it('rejects --files that match nothing', async () => {
|
|
590
|
-
writeSite({ 'index.mdx': HOME });
|
|
591
|
-
|
|
592
|
-
expect(await jsonError('validate', '--files', 'missing.mdx')).toContain(
|
|
593
|
-
'Error: No matching files'
|
|
594
|
-
);
|
|
595
|
-
expect(processExitMock).toHaveBeenCalledWith(2);
|
|
596
|
-
expect(checkBuild).not.toHaveBeenCalled();
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
it('rejects the removed --disable-openapi flag', async () => {
|
|
600
|
-
writeSite({ 'index.mdx': HOME });
|
|
601
|
-
const error = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
602
|
-
|
|
603
|
-
await expect(runCommand('validate', '--no-build', '--disable-openapi')).rejects.toThrow();
|
|
604
|
-
|
|
605
|
-
expect(error).toHaveBeenCalledWith(expect.stringContaining('Unknown argument'));
|
|
606
|
-
error.mockRestore();
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
it('logs diagnostics by file and a verdict in text mode', async () => {
|
|
610
|
-
writeSite({ 'index.mdx': '---\ntitle: Home\n---\n\nline<br>\n' });
|
|
611
|
-
|
|
612
|
-
await runCommand('validate', '--no-build');
|
|
613
|
-
|
|
614
|
-
const text = JSON.stringify(vi.mocked(addLog).mock.calls);
|
|
615
|
-
expect(text).toContain('index.mdx');
|
|
616
|
-
expect(text).toContain('must be self-closed');
|
|
617
|
-
expect(text).toContain('1 error');
|
|
618
|
-
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
it('prompts to publish in text mode only when the build passed', async () => {
|
|
622
|
-
writeSite({ 'index.mdx': HOME });
|
|
623
|
-
|
|
624
|
-
await runCommand('validate');
|
|
625
|
-
expect(sendPublishPrompt).toHaveBeenCalledTimes(1);
|
|
626
|
-
|
|
627
|
-
vi.mocked(checkBuild).mockResolvedValue({
|
|
628
|
-
passed: false,
|
|
629
|
-
error: 'Build validation failed with 1 warning(s). See above for details.',
|
|
630
|
-
strict: true,
|
|
631
|
-
warnings: [{ type: 'missing-nav-page', message: '"gone" is missing.' }],
|
|
632
|
-
});
|
|
633
|
-
await runCommand('validate', '--disable', 'missing-nav-page');
|
|
634
|
-
expect(sendPublishPrompt).toHaveBeenCalledTimes(1);
|
|
635
|
-
expect(processExitMock).toHaveBeenLastCalledWith(0);
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
it('rejects --format values other than text and json', async () => {
|
|
639
|
-
writeSite({ 'index.mdx': HOME });
|
|
640
|
-
const error = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
641
|
-
|
|
642
|
-
await expect(runCommand('validate', '--format', 'table')).rejects.toThrow();
|
|
643
|
-
|
|
644
|
-
expect(error).toHaveBeenCalledWith(expect.stringContaining('Invalid values'));
|
|
645
|
-
error.mockRestore();
|
|
646
|
-
});
|
|
647
|
-
});
|