@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,121 +0,0 @@
1
- import { collectPatternNames, collectExportedNames, getAST, isBuiltInComponent, JSX_EXTENSIONS, visitReferences, } from '@mintlify/common';
2
- import { visit } from 'unist-util-visit';
3
- const getDeclared = (context) => {
4
- const declared = new Set();
5
- visit(context.tree, 'mdxjsEsm', (node) => {
6
- var _a, _b, _c;
7
- for (const statement of (_c = (_b = (_a = node.data) === null || _a === void 0 ? void 0 : _a.estree) === null || _b === void 0 ? void 0 : _b.body) !== null && _c !== void 0 ? _c : []) {
8
- if (statement.type === 'ImportDeclaration') {
9
- for (const specifier of statement.specifiers) {
10
- collectPatternNames(specifier.local, declared);
11
- }
12
- }
13
- else if (statement.type === 'ExportNamedDeclaration') {
14
- const declaration = statement.declaration;
15
- if ((declaration === null || declaration === void 0 ? void 0 : declaration.type) === 'VariableDeclaration') {
16
- for (const declarator of declaration.declarations) {
17
- collectPatternNames(declarator.id, declared);
18
- }
19
- }
20
- else if (declaration) {
21
- collectPatternNames(declaration.id, declared);
22
- }
23
- for (const specifier of statement.specifiers) {
24
- collectPatternNames(specifier.local, declared);
25
- collectPatternNames(specifier.exported, declared);
26
- }
27
- }
28
- else if (statement.type === 'ExportDefaultDeclaration') {
29
- const declaration = statement.declaration;
30
- if (declaration.type === 'FunctionDeclaration' || declaration.type === 'ClassDeclaration') {
31
- collectPatternNames(declaration.id, declared);
32
- }
33
- }
34
- }
35
- });
36
- return declared;
37
- };
38
- const getImportPosition = (context) => {
39
- var _a, _b;
40
- const frontmatter = context.tree.children.find((child) => ['yaml', 'toml'].includes(child.type));
41
- return (_b = (_a = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.position) === null || _a === void 0 ? void 0 : _a.end.offset) !== null && _b !== void 0 ? _b : 0;
42
- };
43
- const getSpecifier = (snippet, file, name) => {
44
- let exported;
45
- try {
46
- exported = collectExportedNames(getAST(snippet, file));
47
- }
48
- catch (_a) {
49
- return undefined;
50
- }
51
- if (exported.has(name))
52
- return `{ ${name} }`;
53
- return exported.has('default') ? name : undefined;
54
- };
55
- export const unknownComponent = {
56
- id: 'unknown-component',
57
- group: 'content',
58
- severity: 'error',
59
- scope: 'file',
60
- description: 'JSX components that are not built in, imported or exported',
61
- pagesOnly: true,
62
- check: (context) => {
63
- var _a, _b;
64
- const declared = getDeclared(context);
65
- const reported = new Set();
66
- const issues = [];
67
- const insertAt = getImportPosition(context);
68
- const prefix = insertAt === 0 ? '' : '\n\n';
69
- const following = (_b = (_a = /^\n*/.exec(context.content.slice(insertAt))) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
70
- const suffix = '\n'.repeat(Math.max(0, 2 - following));
71
- const check = (tag, position) => {
72
- var _a;
73
- const name = tag === null || tag === void 0 ? void 0 : tag.split('.')[0];
74
- if (!tag || !name || !/^[A-Z]/.test(name))
75
- return;
76
- if (declared.has(name) || reported.has(tag) || isBuiltInComponent(tag))
77
- return;
78
- reported.add(tag);
79
- const file = JSX_EXTENSIONS.map((extension) => `snippets/${name}${extension}`).find((candidate) => { var _a; return ((_a = context.readFile) === null || _a === void 0 ? void 0 : _a.call(context, candidate)) !== undefined; });
80
- const source = file && ((_a = context.readFile) === null || _a === void 0 ? void 0 : _a.call(context, file));
81
- const specifier = file && source !== undefined && tag === name ? getSpecifier(source, file, name) : undefined;
82
- issues.push({
83
- line: position === null || position === void 0 ? void 0 : position.line,
84
- column: position === null || position === void 0 ? void 0 : position.column,
85
- message: `<${tag}> is not built in, imported or exported on this page`,
86
- edit: specifier
87
- ? {
88
- start: insertAt,
89
- end: insertAt,
90
- text: `${prefix}import ${specifier} from "/${file}";${suffix}`,
91
- }
92
- : undefined,
93
- });
94
- };
95
- const checkJsxInExpression = (estree, fallback) => visitReferences(estree, new Set(), {
96
- reference: (identifier) => {
97
- var _a;
98
- if (identifier.type !== 'JSXIdentifier')
99
- return;
100
- const loc = identifier.loc;
101
- check(String(identifier.name), (_a = loc === null || loc === void 0 ? void 0 : loc.start) !== null && _a !== void 0 ? _a : fallback);
102
- },
103
- });
104
- visit(context.tree, (node) => {
105
- var _a, _b, _c, _d, _e;
106
- if (node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') {
107
- check(node.name, (_a = node.position) === null || _a === void 0 ? void 0 : _a.start);
108
- for (const attribute of node.attributes) {
109
- const value = attribute.type === 'mdxJsxAttribute' ? attribute.value : attribute;
110
- if (value && typeof value === 'object') {
111
- checkJsxInExpression((_b = value.data) === null || _b === void 0 ? void 0 : _b.estree, (_c = node.position) === null || _c === void 0 ? void 0 : _c.start);
112
- }
113
- }
114
- }
115
- else if (node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') {
116
- checkJsxInExpression((_d = node.data) === null || _d === void 0 ? void 0 : _d.estree, (_e = node.position) === null || _e === void 0 ? void 0 : _e.start);
117
- }
118
- });
119
- return issues;
120
- },
121
- };
@@ -1,38 +0,0 @@
1
- import { htmlVoidElements } from 'html-void-elements';
2
- import { maskNonMarkup } from '../../mdx.js';
3
- const VOID_TAG_NAMES = htmlVoidElements.filter((tag) => tag !== 'image');
4
- const ATTRIBUTE = String.raw `"[^"]*"|'[^']*'|\{[^{}]*\}|[^<>"'{}]`;
5
- const VOID_TAG = new RegExp(String.raw `<(${VOID_TAG_NAMES.join('|')})(?=[\s/>])(?:${ATTRIBUTE})*?(\/?)>`, 'g');
6
- export const voidTags = {
7
- id: 'void-tags',
8
- group: 'content',
9
- severity: 'error',
10
- scope: 'file',
11
- description: "self-close void HTML tags (<br>, <img>, <source>, …); MDX can't parse them unclosed",
12
- raw: true,
13
- check: ({ content }) => {
14
- var _a, _b;
15
- const masked = maskNonMarkup(content);
16
- const issues = [];
17
- for (const match of masked.matchAll(VOID_TAG)) {
18
- if (match[2])
19
- continue;
20
- const start = match.index;
21
- const end = start + match[0].length;
22
- if (new RegExp(`^\\s*</${match[1]}\\s*>`).test(masked.slice(end)))
23
- continue;
24
- const before = content.slice(0, start).split('\n');
25
- issues.push({
26
- line: before.length,
27
- column: ((_b = (_a = before.pop()) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) + 1,
28
- message: `<${match[1]}> must be self-closed`,
29
- edit: {
30
- start,
31
- end,
32
- text: `${content.slice(start, end - 1).trimEnd()} />`,
33
- },
34
- });
35
- }
36
- return issues;
37
- },
38
- };
@@ -1,21 +0,0 @@
1
- import { BUILD_RULES } from './build.js';
2
- import { duplicateH1 } from './content/duplicateH1.js';
3
- import { foreignSyntax } from './content/foreignSyntax.js';
4
- import { katexRule } from './content/katex.js';
5
- import { missingSnippet } from './content/missingSnippet.js';
6
- import { undefinedVariable } from './content/undefinedVariable.js';
7
- import { unknownComponent } from './content/unknownComponent.js';
8
- import { voidTags } from './content/voidTags.js';
9
- import { openApiSpec } from './openapi.js';
10
- /** Every check mint validate runs, in report order. */
11
- export const RULES = [
12
- voidTags,
13
- duplicateH1,
14
- unknownComponent,
15
- undefinedVariable,
16
- missingSnippet,
17
- katexRule,
18
- foreignSyntax,
19
- openApiSpec,
20
- ...BUILD_RULES,
21
- ];
@@ -1,50 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import fs from 'node:fs/promises';
11
- import path from 'node:path';
12
- import { errorMessage } from '../../helpers.js';
13
- import { buildOverlayRegistryForCheck, checkOpenApiFile, getOpenApiFilenamesFromDocsConfig, } from '../../openApiCheck.js';
14
- export const openApiSpec = {
15
- id: 'openapi-spec',
16
- group: 'openapi',
17
- severity: 'error',
18
- scope: 'site',
19
- description: "OpenAPI specs in docs.json or mint.json that don't parse or validate, with overlays applied",
20
- check: (site) => __awaiter(void 0, void 0, void 0, function* () {
21
- let filenames = [];
22
- try {
23
- const config = JSON.parse(yield fs.readFile(path.join(site.baseDir, site.configFile), 'utf-8'));
24
- // mint.json lists its specs under a top-level openapi key
25
- filenames = getOpenApiFilenamesFromDocsConfig(site.configFile === 'mint.json' ? { api: { openapi: config.openapi } } : config);
26
- }
27
- catch (_a) {
28
- // A missing or invalid config file is the build's to report
29
- }
30
- if (filenames.length === 0)
31
- return [];
32
- let overlayRegistry;
33
- try {
34
- overlayRegistry = yield buildOverlayRegistryForCheck(site.localSchema);
35
- }
36
- catch (error) {
37
- return [{ file: site.configFile, message: `OpenAPI overlays: ${errorMessage(error)}` }];
38
- }
39
- const perFile = yield Promise.all(filenames.map((file) => __awaiter(void 0, void 0, void 0, function* () {
40
- const messages = [];
41
- yield checkOpenApiFile(file, site.localSchema, overlayRegistry, (message) => messages.push(message));
42
- return messages.flatMap(({ level, message }) => level === 'error'
43
- ? [{ file, message }]
44
- : level === 'warning'
45
- ? [{ file, message, severity: 'warning' }]
46
- : []);
47
- })));
48
- return perFile.flat();
49
- }),
50
- };
@@ -1,7 +0,0 @@
1
- /** The engine's built-in diagnostic for files neither parser can parse; not a selectable rule. */
2
- export const PARSE_ERROR = {
3
- id: 'parse-error',
4
- group: 'content',
5
- severity: 'error',
6
- description: "files MDX can't parse; other checks skip them",
7
- };
@@ -1,57 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import fs from 'node:fs';
11
- import path from 'node:path';
12
- import { readSiteFiles } from './files.js';
13
- import { toPosition } from './mdx.js';
14
- const readVariables = (config) => {
15
- try {
16
- const { variables } = JSON.parse(config);
17
- return variables && typeof variables === 'object'
18
- ? variables
19
- : undefined;
20
- }
21
- catch (_a) {
22
- return undefined;
23
- }
24
- };
25
- /** Lists the site's pages and snippets; locate reads files from disk on demand. */
26
- export const loadSite = (baseDir_1, _a) => __awaiter(void 0, [baseDir_1, _a], void 0, function* (baseDir, { selected, localSchema }) {
27
- var _b;
28
- const files = yield readSiteFiles(baseDir);
29
- const byPath = new Map();
30
- const configFile = fs.existsSync(path.join(baseDir, 'docs.json')) ? 'docs.json' : 'mint.json';
31
- const read = (file) => {
32
- if (!byPath.has(file)) {
33
- try {
34
- byPath.set(file, fs.readFileSync(path.join(baseDir, file), 'utf-8'));
35
- }
36
- catch (_a) {
37
- byPath.set(file, undefined);
38
- }
39
- }
40
- return byPath.get(file);
41
- };
42
- return {
43
- baseDir,
44
- files,
45
- selected,
46
- configFile,
47
- variables: readVariables((_b = read(configFile)) !== null && _b !== void 0 ? _b : ''),
48
- localSchema,
49
- read,
50
- locate: (file, text) => {
51
- var _a;
52
- const content = (_a = read(file)) !== null && _a !== void 0 ? _a : '';
53
- const offset = text ? content.indexOf(text) : -1;
54
- return offset === -1 ? {} : toPosition(content, offset);
55
- },
56
- };
57
- });
@@ -1 +0,0 @@
1
- export const GROUPS = ['content', 'nav', 'config', 'openapi'];