@mintlify/cli 4.0.1812 → 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 +43 -36
- 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/src/analytics/types.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
export interface KpiResponse {
|
|
2
|
-
humanVisitors: number;
|
|
3
|
-
humanViews: number;
|
|
4
|
-
humanAssistant: number;
|
|
5
|
-
humanSearches: number;
|
|
6
|
-
humanFeedback: number;
|
|
7
|
-
agentVisitors: number;
|
|
8
|
-
agentViews: number;
|
|
9
|
-
agentMcpSearches: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface BucketSummary {
|
|
13
|
-
id: string;
|
|
14
|
-
questionSummary: string;
|
|
15
|
-
size: number;
|
|
16
|
-
status: string;
|
|
17
|
-
lastAsked: string | null;
|
|
18
|
-
lastOccurredAt: string | null;
|
|
19
|
-
createdAt: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface BucketsResponse {
|
|
23
|
-
data: BucketSummary[];
|
|
24
|
-
pagination: { total: number };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface BucketThread {
|
|
28
|
-
id: string;
|
|
29
|
-
firstUserMessage: string | null;
|
|
30
|
-
feedback: { up: number; down: number };
|
|
31
|
-
resolutionStatus: string | null;
|
|
32
|
-
length: number;
|
|
33
|
-
createdAt: string;
|
|
34
|
-
lastMessageAt: string | null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface BucketThreadsResponse {
|
|
38
|
-
data: BucketThread[];
|
|
39
|
-
pagination: { total: number; hasMore: boolean; nextCursor: string | null };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface FeedbackItem {
|
|
43
|
-
id: string;
|
|
44
|
-
path: string;
|
|
45
|
-
comment: string | null;
|
|
46
|
-
createdAt: string | null;
|
|
47
|
-
source: string;
|
|
48
|
-
status: string;
|
|
49
|
-
helpful?: boolean;
|
|
50
|
-
contact?: string;
|
|
51
|
-
code?: string;
|
|
52
|
-
filename?: string;
|
|
53
|
-
lang?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface FeedbackResponse {
|
|
57
|
-
feedback: FeedbackItem[];
|
|
58
|
-
nextCursor: string | null;
|
|
59
|
-
hasMore: boolean;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface FeedbackByPageItem {
|
|
63
|
-
path: string;
|
|
64
|
-
thumbsUp: number;
|
|
65
|
-
thumbsDown: number;
|
|
66
|
-
code: number;
|
|
67
|
-
total: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface FeedbackByPageResponse {
|
|
71
|
-
feedback: FeedbackByPageItem[];
|
|
72
|
-
hasMore: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface ConversationSource {
|
|
76
|
-
title: string;
|
|
77
|
-
url: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface Conversation {
|
|
81
|
-
id: string;
|
|
82
|
-
timestamp: string;
|
|
83
|
-
query: string;
|
|
84
|
-
response: string;
|
|
85
|
-
sources: ConversationSource[];
|
|
86
|
-
queryCategory: string | null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface ConversationResponse {
|
|
90
|
-
conversations: Conversation[];
|
|
91
|
-
nextCursor: string | null;
|
|
92
|
-
hasMore: boolean;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface AssistantThreadMessage {
|
|
96
|
-
id: string;
|
|
97
|
-
role: 'user' | 'assistant';
|
|
98
|
-
content: string;
|
|
99
|
-
createdAt: string;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface AssistantThreadResponse {
|
|
103
|
-
threadId: string;
|
|
104
|
-
createdAt: string;
|
|
105
|
-
messages: AssistantThreadMessage[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface SearchRow {
|
|
109
|
-
searchQuery: string;
|
|
110
|
-
hits: number;
|
|
111
|
-
ctr: number;
|
|
112
|
-
topClickedPage: string | null;
|
|
113
|
-
lastSearchedAt: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface SearchResponse {
|
|
117
|
-
searches: SearchRow[];
|
|
118
|
-
totalSearches: number;
|
|
119
|
-
nextCursor: string | null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface TrafficTotals {
|
|
123
|
-
human: number;
|
|
124
|
-
ai: number;
|
|
125
|
-
total: number;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface TrafficRow {
|
|
129
|
-
path: string;
|
|
130
|
-
human: number;
|
|
131
|
-
ai: number;
|
|
132
|
-
total: number;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface ViewsResponse {
|
|
136
|
-
totals: TrafficTotals;
|
|
137
|
-
views: TrafficRow[];
|
|
138
|
-
hasMore: boolean;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface VisitorsResponse {
|
|
142
|
-
totals: TrafficTotals;
|
|
143
|
-
visitors: TrafficRow[];
|
|
144
|
-
hasMore: boolean;
|
|
145
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { getAccessToken } from './keyring.js';
|
|
2
|
-
import { refreshAccessToken } from './tokenRefresh.js';
|
|
3
|
-
|
|
4
|
-
async function getKeyringToken(): Promise<string | null> {
|
|
5
|
-
try {
|
|
6
|
-
return await getAccessToken();
|
|
7
|
-
} catch {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function authenticatedFetch(url: string | URL, init?: RequestInit): Promise<Response> {
|
|
13
|
-
const keyringToken = await getKeyringToken();
|
|
14
|
-
const envToken = process.env.MINTLIFY_SESSION_TOKEN;
|
|
15
|
-
const token = keyringToken ?? envToken;
|
|
16
|
-
|
|
17
|
-
if (!token) {
|
|
18
|
-
throw new Error('Not authenticated. Run `mint login` to authenticate.');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const makeRequest = (t: string) =>
|
|
22
|
-
fetch(url, {
|
|
23
|
-
...init,
|
|
24
|
-
headers: { ...init?.headers, Authorization: `Bearer ${t}` },
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const res = await makeRequest(token);
|
|
28
|
-
if (res.status !== 401) return res;
|
|
29
|
-
|
|
30
|
-
// If the keyring token expired, try refreshing it
|
|
31
|
-
if (keyringToken) {
|
|
32
|
-
const refreshed = await refreshAccessToken();
|
|
33
|
-
if (refreshed) return makeRequest(refreshed);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Fall back to the env session token if it wasn't already used
|
|
37
|
-
if (envToken && token !== envToken) {
|
|
38
|
-
return makeRequest(envToken);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return res;
|
|
42
|
-
}
|
package/src/brokenLinks.tsx
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { buildGraph, getBrokenExternalLinks, getFilesLinksDependOn } from '@mintlify/link-rot';
|
|
2
|
-
import {
|
|
3
|
-
addLog,
|
|
4
|
-
clearLogs,
|
|
5
|
-
BrokenLinksLog,
|
|
6
|
-
ErrorLog,
|
|
7
|
-
SpinnerLog,
|
|
8
|
-
SuccessLog,
|
|
9
|
-
WarningLog,
|
|
10
|
-
} from '@mintlify/previewing';
|
|
11
|
-
import fs from 'node:fs/promises';
|
|
12
|
-
import path from 'path';
|
|
13
|
-
|
|
14
|
-
import { autoUpgradeIfNeeded, CMD_EXEC_PATH, findDocsRoot, terminate } from './helpers.js';
|
|
15
|
-
import { resolveExplicitFiles } from './resolveFiles.js';
|
|
16
|
-
|
|
17
|
-
type BrokenLinksArgs = {
|
|
18
|
-
files?: (string | number)[];
|
|
19
|
-
'check-anchors': boolean;
|
|
20
|
-
'check-external': boolean;
|
|
21
|
-
'check-snippets': boolean;
|
|
22
|
-
'check-redirects': boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const brokenLinksHandler = async (argv: BrokenLinksArgs): Promise<void> => {
|
|
26
|
-
await autoUpgradeIfNeeded();
|
|
27
|
-
addLog(<SpinnerLog message="checking for broken links..." />);
|
|
28
|
-
try {
|
|
29
|
-
const docsRoot = await findDocsRoot(CMD_EXEC_PATH);
|
|
30
|
-
const fileArgs = (argv.files ?? []).map(String).filter(Boolean);
|
|
31
|
-
const sourceFiles =
|
|
32
|
-
fileArgs.length > 0
|
|
33
|
-
? new Set(
|
|
34
|
-
(await resolveExplicitFiles(CMD_EXEC_PATH, fileArgs)).map((file) =>
|
|
35
|
-
path.relative(docsRoot, path.resolve(CMD_EXEC_PATH, file))
|
|
36
|
-
)
|
|
37
|
-
)
|
|
38
|
-
: undefined;
|
|
39
|
-
// One unparseable page shouldn't hide every other result: report it and keep going
|
|
40
|
-
const parseErrorsByFile = new Map<string, string>();
|
|
41
|
-
const graph = await buildGraph(docsRoot, {
|
|
42
|
-
checkSnippets: argv['check-snippets'],
|
|
43
|
-
onParseError: (filePath, error) => parseErrorsByFile.set(filePath, error.message),
|
|
44
|
-
});
|
|
45
|
-
graph.precomputeFileResolutions();
|
|
46
|
-
// With --files, a failure elsewhere only matters when a selected link needs that
|
|
47
|
-
// file: an anchor pointing at it, or a snippet the selected page renders
|
|
48
|
-
const dependencies = sourceFiles
|
|
49
|
-
? getFilesLinksDependOn(graph, sourceFiles, {
|
|
50
|
-
checkAnchors: argv['check-anchors'],
|
|
51
|
-
checkSnippets: argv['check-snippets'],
|
|
52
|
-
})
|
|
53
|
-
: undefined;
|
|
54
|
-
const parseErrors = [...parseErrorsByFile]
|
|
55
|
-
.filter(
|
|
56
|
-
([filePath]) =>
|
|
57
|
-
!sourceFiles ||
|
|
58
|
-
sourceFiles.has(filePath) ||
|
|
59
|
-
dependencies?.has(filePath.split(path.sep).join('/'))
|
|
60
|
-
)
|
|
61
|
-
.map(([, message]) => message);
|
|
62
|
-
|
|
63
|
-
const brokenInternalLinks = graph
|
|
64
|
-
.getBrokenInternalLinks({
|
|
65
|
-
checkAnchors: argv['check-anchors'],
|
|
66
|
-
})
|
|
67
|
-
.filter(
|
|
68
|
-
({ relativeDir, filename }) =>
|
|
69
|
-
!sourceFiles || sourceFiles.has(path.join(relativeDir, filename))
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const brokenLinksByFile: Record<string, string[]> = {};
|
|
73
|
-
|
|
74
|
-
brokenInternalLinks.forEach((mdxPath) => {
|
|
75
|
-
const filename = path.join(mdxPath.relativeDir, mdxPath.filename);
|
|
76
|
-
const existing = brokenLinksByFile[filename];
|
|
77
|
-
if (existing) {
|
|
78
|
-
existing.push(mdxPath.originalPath);
|
|
79
|
-
} else {
|
|
80
|
-
brokenLinksByFile[filename] = [mdxPath.originalPath];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (argv['check-external']) {
|
|
85
|
-
const brokenExternalLinks = await getBrokenExternalLinks(
|
|
86
|
-
graph,
|
|
87
|
-
sourceFiles ? { sourceFiles } : undefined
|
|
88
|
-
);
|
|
89
|
-
for (const result of brokenExternalLinks) {
|
|
90
|
-
for (const source of result.sources) {
|
|
91
|
-
const label = result.status
|
|
92
|
-
? `${result.url} (${result.status})`
|
|
93
|
-
: `${result.url} (${result.error})`;
|
|
94
|
-
const existing = brokenLinksByFile[source.file];
|
|
95
|
-
if (existing) {
|
|
96
|
-
existing.push(label);
|
|
97
|
-
} else {
|
|
98
|
-
brokenLinksByFile[source.file] = [label];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (argv['check-redirects']) {
|
|
105
|
-
const brokenRedirects = graph.getBrokenRedirects();
|
|
106
|
-
if (brokenRedirects.length > 0) {
|
|
107
|
-
const configFilename = await fs
|
|
108
|
-
.access(path.join(docsRoot, 'docs.json'))
|
|
109
|
-
.then(() => 'docs.json')
|
|
110
|
-
.catch(() => 'mint.json');
|
|
111
|
-
const labels = brokenRedirects.map(
|
|
112
|
-
({ source, destination }) => `${source} → ${destination}`
|
|
113
|
-
);
|
|
114
|
-
const existing = brokenLinksByFile[configFilename];
|
|
115
|
-
if (existing) {
|
|
116
|
-
existing.push(...labels);
|
|
117
|
-
} else {
|
|
118
|
-
brokenLinksByFile[configFilename] = labels;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const hasBrokenLinks = Object.keys(brokenLinksByFile).length > 0;
|
|
124
|
-
if (!hasBrokenLinks && parseErrors.length === 0) {
|
|
125
|
-
clearLogs();
|
|
126
|
-
addLog(<SuccessLog message="no broken links found" />);
|
|
127
|
-
await terminate(0);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
clearLogs();
|
|
131
|
-
if (hasBrokenLinks) {
|
|
132
|
-
addLog(<BrokenLinksLog brokenLinksByFile={brokenLinksByFile} />);
|
|
133
|
-
} else {
|
|
134
|
-
addLog(<SuccessLog message="no broken links found in the files that parsed" />);
|
|
135
|
-
}
|
|
136
|
-
for (const message of parseErrors) {
|
|
137
|
-
addLog(<ErrorLog message={message} />);
|
|
138
|
-
}
|
|
139
|
-
if (parseErrors.length > 0) {
|
|
140
|
-
addLog(
|
|
141
|
-
<WarningLog
|
|
142
|
-
message={`skipped ${parseErrors.length} file(s) that could not be parsed; links in them were not checked`}
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
} catch (err) {
|
|
147
|
-
addLog(<ErrorLog message={err instanceof Error ? err.message : 'unknown error'} />);
|
|
148
|
-
await terminate(1);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
await terminate(1);
|
|
152
|
-
};
|
package/src/callbackServer.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { CALLBACK_PORT, DASHBOARD_URL } from './constants.js';
|
|
2
|
-
|
|
3
|
-
export async function startCallbackServer(): Promise<{
|
|
4
|
-
codePromise: Promise<string>;
|
|
5
|
-
close: () => void;
|
|
6
|
-
}> {
|
|
7
|
-
const { default: http } = await import('http');
|
|
8
|
-
|
|
9
|
-
let resolveCode: (code: string) => void;
|
|
10
|
-
let rejectCode: (err: Error) => void;
|
|
11
|
-
let closed = false;
|
|
12
|
-
|
|
13
|
-
const codePromise = new Promise<string>((res, rej) => {
|
|
14
|
-
resolveCode = res;
|
|
15
|
-
rejectCode = rej;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const server = http.createServer((req, res) => {
|
|
19
|
-
res.setHeader('Access-Control-Allow-Origin', DASHBOARD_URL);
|
|
20
|
-
res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
|
|
21
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
22
|
-
|
|
23
|
-
if (req.method === 'OPTIONS') {
|
|
24
|
-
res.writeHead(204);
|
|
25
|
-
res.end();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (req.method === 'POST') {
|
|
30
|
-
let body = '';
|
|
31
|
-
req.on('data', (chunk) => {
|
|
32
|
-
body += chunk;
|
|
33
|
-
});
|
|
34
|
-
req.on('end', () => {
|
|
35
|
-
try {
|
|
36
|
-
const { code } = JSON.parse(body) as { code: string };
|
|
37
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
38
|
-
res.end(JSON.stringify({ ok: true }));
|
|
39
|
-
closed = true;
|
|
40
|
-
server.close();
|
|
41
|
-
resolveCode(code);
|
|
42
|
-
} catch {
|
|
43
|
-
res.writeHead(400);
|
|
44
|
-
res.end(JSON.stringify({ error: 'invalid body' }));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
} else {
|
|
48
|
-
res.writeHead(405);
|
|
49
|
-
res.end();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
server.listen(CALLBACK_PORT, 'localhost');
|
|
54
|
-
|
|
55
|
-
const close = () => {
|
|
56
|
-
if (!closed) {
|
|
57
|
-
closed = true;
|
|
58
|
-
server.close();
|
|
59
|
-
rejectCode(new Error('Login cancelled'));
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return { codePromise, close };
|
|
64
|
-
}
|