@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.
Files changed (274) hide show
  1. package/dist/assets/export-scripts/README.classic.md +15 -0
  2. package/dist/assets/export-scripts/README.md +14 -0
  3. package/dist/assets/export-scripts/serve.js +114 -0
  4. package/dist/assets/export-scripts/start-docs.bat +10 -0
  5. package/dist/assets/export-scripts/start-docs.sh +9 -0
  6. package/dist/assets/og/Inter-Bold.ttf +0 -0
  7. package/dist/assets/og/Inter-Medium.ttf +0 -0
  8. package/dist/assets/og/Inter-Regular.ttf +0 -0
  9. package/dist/assets/og/Inter-SemiBold.ttf +0 -0
  10. package/dist/assets/og/PaperMono-Regular.ttf +0 -0
  11. package/dist/assets/og/index_bg.wasm +0 -0
  12. package/dist/assets/openChrome.applescript +94 -0
  13. package/dist/assets/socket.io/socket.io.esm.min.js +7 -0
  14. package/dist/assets/socket.io/socket.io.esm.min.js.map +1 -0
  15. package/dist/assets/socket.io/socket.io.js +4907 -0
  16. package/dist/assets/socket.io/socket.io.js.map +1 -0
  17. package/dist/assets/socket.io/socket.io.min.js +7 -0
  18. package/dist/assets/socket.io/socket.io.min.js.map +1 -0
  19. package/dist/assets/socket.io/socket.io.msgpack.min.js +7 -0
  20. package/dist/assets/socket.io/socket.io.msgpack.min.js.map +1 -0
  21. package/dist/assets/xdg-open +1066 -0
  22. package/dist/assets/yargs-locales/be.json +46 -0
  23. package/dist/assets/yargs-locales/cs.json +51 -0
  24. package/dist/assets/yargs-locales/de.json +46 -0
  25. package/dist/assets/yargs-locales/en.json +55 -0
  26. package/dist/assets/yargs-locales/es.json +46 -0
  27. package/dist/assets/yargs-locales/fi.json +49 -0
  28. package/dist/assets/yargs-locales/fr.json +53 -0
  29. package/dist/assets/yargs-locales/hi.json +49 -0
  30. package/dist/assets/yargs-locales/hu.json +46 -0
  31. package/dist/assets/yargs-locales/id.json +50 -0
  32. package/dist/assets/yargs-locales/it.json +46 -0
  33. package/dist/assets/yargs-locales/ja.json +51 -0
  34. package/dist/assets/yargs-locales/ko.json +49 -0
  35. package/dist/assets/yargs-locales/nb.json +44 -0
  36. package/dist/assets/yargs-locales/nl.json +49 -0
  37. package/dist/assets/yargs-locales/nn.json +44 -0
  38. package/dist/assets/yargs-locales/pirate.json +13 -0
  39. package/dist/assets/yargs-locales/pl.json +49 -0
  40. package/dist/assets/yargs-locales/pt.json +45 -0
  41. package/dist/assets/yargs-locales/pt_BR.json +48 -0
  42. package/dist/assets/yargs-locales/ru.json +51 -0
  43. package/dist/assets/yargs-locales/th.json +46 -0
  44. package/dist/assets/yargs-locales/tr.json +48 -0
  45. package/dist/assets/yargs-locales/uk_UA.json +51 -0
  46. package/dist/assets/yargs-locales/uz.json +52 -0
  47. package/dist/assets/yargs-locales/zh_CN.json +48 -0
  48. package/dist/assets/yargs-locales/zh_TW.json +51 -0
  49. package/dist/converter-d8O3xkdU.js +102 -0
  50. package/dist/devtools-CGNZQKFV.js +24 -0
  51. package/dist/index.js +8 -0
  52. package/dist/rolldown-runtime-CEAe2Uac.js +7 -0
  53. package/dist/schemas-CBsmCNpK.js +372 -0
  54. package/dist/start.js +2310 -0
  55. package/package.json +43 -36
  56. package/.oxlintrc.json +0 -5
  57. package/.prettierignore +0 -2
  58. package/.turbo/turbo-build.log +0 -1
  59. package/CONTRIBUTING.md +0 -45
  60. package/__test__/agent-auth.test.ts +0 -114
  61. package/__test__/agent-claim.test.ts +0 -164
  62. package/__test__/agent-credentials.test.ts +0 -149
  63. package/__test__/agent-deployment.test.ts +0 -106
  64. package/__test__/agent-setup-config.test.ts +0 -324
  65. package/__test__/agent-setup.test.ts +0 -207
  66. package/__test__/agent.test.ts +0 -64
  67. package/__test__/analytics/client.test.ts +0 -180
  68. package/__test__/analytics/dates.test.ts +0 -12
  69. package/__test__/analytics/filters.test.ts +0 -116
  70. package/__test__/analytics/format.test.ts +0 -137
  71. package/__test__/authenticatedFetch.test.ts +0 -182
  72. package/__test__/brokenLinks.test.ts +0 -283
  73. package/__test__/checkPort.test.ts +0 -92
  74. package/__test__/deploy-github-actions.test.ts +0 -202
  75. package/__test__/deploy-github-setup.test.ts +0 -240
  76. package/__test__/deploy-instructions.test.ts +0 -155
  77. package/__test__/deploy.test.ts +0 -202
  78. package/__test__/feedback.test.ts +0 -34
  79. package/__test__/foreignSyntax.test.ts +0 -73
  80. package/__test__/format.test.ts +0 -72
  81. package/__test__/helpers.test.ts +0 -52
  82. package/__test__/init.test.ts +0 -119
  83. package/__test__/instructions.test.ts +0 -53
  84. package/__test__/keyring.test.ts +0 -82
  85. package/__test__/mdxAccessibility.test.ts +0 -81
  86. package/__test__/migrate.test.ts +0 -186
  87. package/__test__/openApiCheck.test.ts +0 -185
  88. package/__test__/pathValidation.test.ts +0 -25
  89. package/__test__/resolveFiles.test.ts +0 -70
  90. package/__test__/sessionId.test.ts +0 -46
  91. package/__test__/signup.test.ts +0 -36
  92. package/__test__/update.test.ts +0 -117
  93. package/__test__/utils.ts +0 -25
  94. package/__test__/validateCommand.test.ts +0 -647
  95. package/__test__/validateEngine.test.ts +0 -245
  96. package/__test__/validateRules.test.ts +0 -1275
  97. package/__test__/welcome.test.ts +0 -15
  98. package/__test__/workflows/client.test.ts +0 -126
  99. package/bin/accessibility.js +0 -111
  100. package/bin/accessibilityCheck.js +0 -82
  101. package/bin/addDomain.js +0 -130
  102. package/bin/agent-auth.js +0 -104
  103. package/bin/agent-claim.js +0 -97
  104. package/bin/agent-credentials.js +0 -124
  105. package/bin/agent-deployment.js +0 -96
  106. package/bin/agent-http.js +0 -45
  107. package/bin/agent-setup-config.js +0 -141
  108. package/bin/agent-setup.js +0 -146
  109. package/bin/agent.js +0 -42
  110. package/bin/analytics/client.js +0 -60
  111. package/bin/analytics/dates.js +0 -6
  112. package/bin/analytics/filters.js +0 -27
  113. package/bin/analytics/format.js +0 -13
  114. package/bin/analytics/index.js +0 -496
  115. package/bin/analytics/output.js +0 -75
  116. package/bin/analytics/types.js +0 -1
  117. package/bin/authenticatedFetch.js +0 -46
  118. package/bin/brokenLinks.js +0 -122
  119. package/bin/callbackServer.js +0 -65
  120. package/bin/cli.js +0 -813
  121. package/bin/comingSoon.js +0 -26
  122. package/bin/config.js +0 -78
  123. package/bin/constants.js +0 -16
  124. package/bin/deploy-base.js +0 -20
  125. package/bin/deploy-github-actions.js +0 -102
  126. package/bin/deploy-github-setup.js +0 -165
  127. package/bin/deploy-instructions.js +0 -71
  128. package/bin/deploy.js +0 -123
  129. package/bin/feedback.js +0 -36
  130. package/bin/format.js +0 -121
  131. package/bin/helpers.js +0 -238
  132. package/bin/idToken.js +0 -14
  133. package/bin/index.js +0 -102
  134. package/bin/init.js +0 -182
  135. package/bin/instructions.js +0 -101
  136. package/bin/keyring.js +0 -78
  137. package/bin/login.js +0 -123
  138. package/bin/logout.js +0 -18
  139. package/bin/mdxAccessibility.js +0 -113
  140. package/bin/mdxLinter.js +0 -55
  141. package/bin/middlewares/subdomainMiddleware.js +0 -28
  142. package/bin/middlewares/telemetryMiddleware.js +0 -61
  143. package/bin/migrate.js +0 -54
  144. package/bin/og.js +0 -145
  145. package/bin/openApiCheck.js +0 -99
  146. package/bin/resolveFiles.js +0 -114
  147. package/bin/score/client.js +0 -40
  148. package/bin/score/index.js +0 -211
  149. package/bin/score/types.js +0 -1
  150. package/bin/signup.js +0 -118
  151. package/bin/start.js +0 -36
  152. package/bin/status.js +0 -106
  153. package/bin/telemetry/client.js +0 -53
  154. package/bin/telemetry/distinctId.js +0 -68
  155. package/bin/telemetry/sessionId.js +0 -36
  156. package/bin/telemetry/track.js +0 -149
  157. package/bin/templates.js +0 -127
  158. package/bin/tokenRefresh.js +0 -50
  159. package/bin/tsconfig.build.tsbuildinfo +0 -1
  160. package/bin/update.js +0 -65
  161. package/bin/validate/command.js +0 -127
  162. package/bin/validate/engine.js +0 -154
  163. package/bin/validate/files.js +0 -163
  164. package/bin/validate/mdx.js +0 -238
  165. package/bin/validate/output.js +0 -44
  166. package/bin/validate/report.js +0 -11
  167. package/bin/validate/rules/build.js +0 -102
  168. package/bin/validate/rules/content/duplicateH1.js +0 -57
  169. package/bin/validate/rules/content/foreignSyntax.js +0 -120
  170. package/bin/validate/rules/content/katex.js +0 -34
  171. package/bin/validate/rules/content/missingSnippet.js +0 -34
  172. package/bin/validate/rules/content/undefinedVariable.js +0 -13
  173. package/bin/validate/rules/content/unknownComponent.js +0 -121
  174. package/bin/validate/rules/content/voidTags.js +0 -38
  175. package/bin/validate/rules/index.js +0 -21
  176. package/bin/validate/rules/openapi.js +0 -50
  177. package/bin/validate/rules/parseError.js +0 -7
  178. package/bin/validate/site.js +0 -57
  179. package/bin/validate/types.js +0 -1
  180. package/bin/vendor/converter.js +0 -30882
  181. package/bin/welcome.js +0 -108
  182. package/bin/workflows/client.js +0 -34
  183. package/bin/workflows/index.js +0 -269
  184. package/bin/workflows/types.js +0 -11
  185. package/scripts/bundle-converter.mjs +0 -26
  186. package/scripts/generate-logo.mjs +0 -79
  187. package/src/accessibility.ts +0 -180
  188. package/src/accessibilityCheck.tsx +0 -150
  189. package/src/addDomain.tsx +0 -206
  190. package/src/agent-auth.ts +0 -119
  191. package/src/agent-claim.ts +0 -124
  192. package/src/agent-credentials.ts +0 -104
  193. package/src/agent-deployment.ts +0 -116
  194. package/src/agent-http.ts +0 -34
  195. package/src/agent-setup-config.ts +0 -144
  196. package/src/agent-setup.ts +0 -165
  197. package/src/agent.ts +0 -56
  198. package/src/analytics/client.ts +0 -153
  199. package/src/analytics/dates.ts +0 -6
  200. package/src/analytics/filters.ts +0 -50
  201. package/src/analytics/format.ts +0 -13
  202. package/src/analytics/index.tsx +0 -599
  203. package/src/analytics/output.ts +0 -99
  204. package/src/analytics/types.ts +0 -145
  205. package/src/authenticatedFetch.ts +0 -42
  206. package/src/brokenLinks.tsx +0 -152
  207. package/src/callbackServer.ts +0 -64
  208. package/src/cli.tsx +0 -1105
  209. package/src/comingSoon.tsx +0 -29
  210. package/src/config.ts +0 -75
  211. package/src/constants.ts +0 -28
  212. package/src/deploy-base.ts +0 -18
  213. package/src/deploy-github-actions.ts +0 -139
  214. package/src/deploy-github-setup.ts +0 -189
  215. package/src/deploy-instructions.ts +0 -76
  216. package/src/deploy.ts +0 -165
  217. package/src/feedback.tsx +0 -31
  218. package/src/format.tsx +0 -82
  219. package/src/helpers.tsx +0 -279
  220. package/src/idToken.ts +0 -17
  221. package/src/index.ts +0 -109
  222. package/src/init.tsx +0 -237
  223. package/src/instructions.ts +0 -99
  224. package/src/keyring.ts +0 -65
  225. package/src/login.tsx +0 -166
  226. package/src/logout.tsx +0 -8
  227. package/src/mdxAccessibility.ts +0 -134
  228. package/src/mdxLinter.tsx +0 -88
  229. package/src/middlewares/subdomainMiddleware.ts +0 -20
  230. package/src/middlewares/telemetryMiddleware.ts +0 -55
  231. package/src/migrate.ts +0 -76
  232. package/src/og.tsx +0 -185
  233. package/src/openApiCheck.tsx +0 -125
  234. package/src/resolveFiles.ts +0 -101
  235. package/src/score/client.ts +0 -36
  236. package/src/score/index.tsx +0 -205
  237. package/src/score/types.ts +0 -15
  238. package/src/signup.tsx +0 -172
  239. package/src/start.ts +0 -27
  240. package/src/status.tsx +0 -129
  241. package/src/telemetry/client.ts +0 -46
  242. package/src/telemetry/distinctId.ts +0 -70
  243. package/src/telemetry/sessionId.ts +0 -40
  244. package/src/telemetry/track.ts +0 -163
  245. package/src/templates.tsx +0 -143
  246. package/src/tokenRefresh.ts +0 -53
  247. package/src/update.tsx +0 -89
  248. package/src/validate/command.tsx +0 -135
  249. package/src/validate/engine.ts +0 -210
  250. package/src/validate/files.ts +0 -249
  251. package/src/validate/mdx.ts +0 -290
  252. package/src/validate/output.tsx +0 -76
  253. package/src/validate/report.ts +0 -40
  254. package/src/validate/rules/build.ts +0 -146
  255. package/src/validate/rules/content/duplicateH1.ts +0 -78
  256. package/src/validate/rules/content/foreignSyntax.ts +0 -144
  257. package/src/validate/rules/content/katex.ts +0 -33
  258. package/src/validate/rules/content/missingSnippet.ts +0 -36
  259. package/src/validate/rules/content/undefinedVariable.ts +0 -20
  260. package/src/validate/rules/content/unknownComponent.ts +0 -130
  261. package/src/validate/rules/content/voidTags.ts +0 -43
  262. package/src/validate/rules/index.ts +0 -23
  263. package/src/validate/rules/openapi.ts +0 -59
  264. package/src/validate/rules/parseError.ts +0 -9
  265. package/src/validate/site.ts +0 -53
  266. package/src/validate/types.ts +0 -102
  267. package/src/vendor/converter.ts +0 -1
  268. package/src/welcome.ts +0 -154
  269. package/src/workflows/client.ts +0 -39
  270. package/src/workflows/index.tsx +0 -287
  271. package/src/workflows/types.ts +0 -73
  272. package/tsconfig.build.json +0 -4
  273. package/tsconfig.json +0 -10
  274. package/vitest.config.ts +0 -9
@@ -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
- }
@@ -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
- };
@@ -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
- }