@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,186 +0,0 @@
1
- import { isBuiltInComponent } from '@mintlify/common';
2
- import { addLog } from '@mintlify/previewing';
3
- import { spawn, type ChildProcess } from 'node:child_process';
4
- import { EventEmitter } from 'node:events';
5
- import { readdirSync, readFileSync } from 'node:fs';
6
- import path from 'node:path';
7
- import { mockProcessExit } from 'vitest-mock-process';
8
-
9
- import { windowsCompatibleSpawnOptions } from '../src/helpers.js';
10
- import {
11
- agentArgs,
12
- agents,
13
- listMigrationDocs,
14
- migrateWithAgent,
15
- migrationInstructions,
16
- } from '../src/migrate.js';
17
- import { runCommand } from './utils.js';
18
-
19
- vi.mock('node:child_process', async (importOriginal) => ({
20
- ...(await importOriginal<typeof import('node:child_process')>()),
21
- spawn: vi.fn(),
22
- }));
23
- vi.mock('@mintlify/previewing', async (importOriginal) => ({
24
- ...(await importOriginal<typeof import('@mintlify/previewing')>()),
25
- addLog: vi.fn(),
26
- }));
27
-
28
- const spawnMock = vi.mocked(spawn);
29
- const child = (emit: (child: EventEmitter) => void) => {
30
- spawnMock.mockImplementationOnce(() => {
31
- const proc = new EventEmitter();
32
- setImmediate(() => emit(proc));
33
- return proc as ChildProcess;
34
- });
35
- };
36
- const enoent = (proc: EventEmitter) =>
37
- proc.emit('error', Object.assign(new Error('spawn ENOENT'), { code: 'ENOENT' }));
38
-
39
- const root = path.join(__dirname, '../migrate');
40
- const names = (section: string) =>
41
- readdirSync(path.join(root, section))
42
- .filter((file) => file.endsWith('.md'))
43
- .map((file) => file.slice(0, -3));
44
- const read = (...segments: string[]) => readFileSync(path.join(root, ...segments), 'utf8');
45
- const docs = [
46
- 'index.md',
47
- ...names('topics').map((name) => `topics/${name}.md`),
48
- ...names('sources').map((name) => `sources/${name}.md`),
49
- ];
50
- const prose = (markdown: string) => markdown.replace(/^(`{3,}).*\n[\s\S]*?^\1\s*$/gm, '');
51
-
52
- const template = [
53
- '## Detect',
54
- '## Get the source',
55
- '### From the repo',
56
- '### From an export',
57
- '### From the live site',
58
- '## Config → docs.json',
59
- '## Navigation',
60
- '## Content conversion',
61
- '## Assets',
62
- '## URLs and redirects',
63
- '## Known gaps',
64
- ];
65
-
66
- const components = (text: string) => [...text.matchAll(/<([A-Z][\w.]+)/g)].map(([, name]) => name!);
67
- const targets = (markdown: string) =>
68
- prose(markdown)
69
- .split('\n')
70
- .flatMap((line) =>
71
- line.startsWith('|')
72
- ? [line.split('|').slice(1)]
73
- : line.split(/[;.] /).map((clause) => clause.split('→'))
74
- )
75
- .flatMap(([source = '', ...rest]) =>
76
- components(rest.join(' ')).filter((name) => !components(source).includes(name))
77
- );
78
-
79
- const exit = mockProcessExit();
80
-
81
- describe('migrate', () => {
82
- it('lists topics and sources from disk', () => {
83
- expect(listMigrationDocs('topics')).toEqual(names('topics').sort());
84
- expect(listMigrationDocs('sources')).toEqual(names('sources').sort());
85
- expect(listMigrationDocs('sources')).toContain('nuxt');
86
- });
87
-
88
- it('prints the overview with every topic and source', () => {
89
- const output = migrationInstructions({});
90
- expect(output.startsWith(read('index.md').trimEnd())).toBe(true);
91
- expect(output).toContain(`Topics: ${names('topics').sort().join(', ')}.`);
92
- expect(output).toContain(`Sources: ${names('sources').sort().join(', ')}.`);
93
- });
94
-
95
- it('appends the source guide to the overview', () => {
96
- const output = migrationInstructions({ from: 'nuxt' });
97
- expect(output.startsWith(read('index.md').trimEnd())).toBe(true);
98
- expect(output.endsWith(read('sources', 'nuxt.md'))).toBe(true);
99
- });
100
-
101
- it('prints only the topic', () => {
102
- expect(migrationInstructions({ topic: 'verify' })).toBe(read('topics', 'verify.md'));
103
- });
104
-
105
- it.each(names('sources'))('source %s follows the template', (name) => {
106
- const headings = prose(read('sources', `${name}.md`)).match(/^#{1,3} .*/gm) ?? [];
107
- expect(headings[0]).toMatch(/^# \S/);
108
- expect(headings.slice(1)).toEqual(template);
109
- });
110
-
111
- it.each(docs)('%s references only existing topics and sources', (doc) => {
112
- for (const [, flag, name] of read(doc).matchAll(/--(topic|from) ([a-z][\w-]*)/g)) {
113
- expect(names(flag === 'topic' ? 'topics' : 'sources'), `${doc}: --${flag} ${name}`).toContain(
114
- name
115
- );
116
- }
117
- });
118
-
119
- it.each(docs)('%s maps only to Mintlify components', (doc) => {
120
- expect(targets(read(doc)).filter((name) => !isBuiltInComponent(name))).toEqual([]);
121
- });
122
-
123
- it('rejects unknown values with the valid choices', async () => {
124
- const stderr = vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
125
- await runCommand('migrate', '--from', 'nope').catch(() => undefined);
126
- const output = stderr.mock.calls.map(([chunk]) => String(chunk)).join('');
127
- expect(output).toContain('nope');
128
- expect(output).toContain('nuxt');
129
- stderr.mockRestore();
130
- });
131
-
132
- it('offers every agent as an --agent choice', async () => {
133
- const stderr = vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
134
- await runCommand('migrate', '--agent', 'nope').catch(() => undefined);
135
- const output = stderr.mock.calls.map(([chunk]) => String(chunk)).join('');
136
- expect(output).toContain(
137
- `Choices: ${Object.keys(agents)
138
- .map((name) => `"${name}"`)
139
- .join(', ')}`
140
- );
141
- stderr.mockRestore();
142
- });
143
-
144
- const base = 'Migrate a documentation site to Mintlify in the current directory. Run';
145
- const plain = `${base} \`mint migrate\` and follow the instructions it prints.`;
146
- const nuxt = `${base} \`mint migrate --from nuxt\` and follow the instructions it prints.`;
147
-
148
- it.each([
149
- ['claude', [plain], [nuxt]],
150
- ['codex', [plain], [nuxt]],
151
- ['cursor', [plain], [nuxt]],
152
- ['gemini', ['-i', plain], ['-i', nuxt]],
153
- ] as const)('%s builds its argv', (name, without, withFrom) => {
154
- expect(agentArgs(name)).toEqual(without);
155
- expect(agentArgs(name, 'nuxt')).toEqual(withFrom);
156
- });
157
-
158
- it('--claude runs claude', async () => {
159
- child((proc) => proc.emit('close', 0));
160
- await runCommand('migrate', '--claude', '--from', 'nuxt');
161
- expect(spawnMock).toHaveBeenCalledWith(
162
- 'claude',
163
- [windowsCompatibleSpawnOptions.shell ? `"${nuxt}"` : nuxt],
164
- expect.objectContaining({ stdio: 'inherit' })
165
- );
166
- expect(exit).toHaveBeenCalledWith(0);
167
- });
168
-
169
- it('rejects a missing binary with its install command', async () => {
170
- child(enoent);
171
- await expect(migrateWithAgent('gemini')).rejects.toThrow(
172
- `gemini not found. Install it with: ${agents.gemini.install}`
173
- );
174
- });
175
-
176
- it('prints the install command and exits nonzero for a missing binary', async () => {
177
- child(enoent);
178
- await runCommand('migrate', '--agent', 'cursor');
179
- expect(vi.mocked(addLog)).toHaveBeenCalledWith(
180
- expect.objectContaining({
181
- props: { message: `cursor-agent not found. Install it with: ${agents.cursor.install}` },
182
- })
183
- );
184
- expect(exit).toHaveBeenCalledWith(1);
185
- });
186
- });
@@ -1,185 +0,0 @@
1
- import { getOpenApiDocumentFromUrl, isAllowedLocalSchemaUrl, validate } from '@mintlify/common';
2
- import { addLog } from '@mintlify/previewing';
3
- import { mockProcessExit } from 'vitest-mock-process';
4
-
5
- import { readLocalOpenApiFile } from '../src/helpers.js';
6
- import { getOpenApiFilenamesFromDocsConfig } from '../src/openApiCheck.js';
7
- import { mockValidOpenApiDocument, runCommand } from './utils.js';
8
-
9
- vi.mock('@mintlify/common', async (importOriginal) => {
10
- const mod = await importOriginal<typeof import('@mintlify/common')>();
11
- return {
12
- ...mod,
13
- getOpenApiDocumentFromUrl: vi.fn(),
14
- isAllowedLocalSchemaUrl: vi.fn(),
15
- validate: vi.fn(),
16
- };
17
- });
18
-
19
- vi.mock('@mintlify/prebuild', async (importOriginal) => {
20
- const mod = await importOriginal<typeof import('@mintlify/prebuild')>();
21
- return {
22
- ...mod,
23
- getMintIgnore: vi.fn(async () => []),
24
- discoverOverlayFiles: vi.fn(async () => []),
25
- };
26
- });
27
-
28
- vi.mock('@mintlify/previewing', async (importOriginal) => {
29
- const mod = await importOriginal<typeof import('@mintlify/previewing')>();
30
- return { ...mod, addLog: vi.fn() };
31
- });
32
-
33
- vi.mock('../src/helpers.js', async (importOriginal) => {
34
- const originalModule = await importOriginal<typeof import('../src/helpers.js')>();
35
- return {
36
- ...originalModule,
37
- readLocalOpenApiFile: vi.fn(),
38
- };
39
- });
40
-
41
- const addLogSpy = vi.mocked(addLog);
42
- const processExitMock = mockProcessExit();
43
-
44
- describe('getOpenApiFilenamesFromDocsConfig', () => {
45
- it('reads api.openapi string', () => {
46
- expect(
47
- getOpenApiFilenamesFromDocsConfig({
48
- api: { openapi: 'https://example.com/openapi.yaml' },
49
- })
50
- ).toEqual(['https://example.com/openapi.yaml']);
51
- });
52
-
53
- it('reads api.openapi array and object source form', () => {
54
- expect(
55
- getOpenApiFilenamesFromDocsConfig({
56
- api: { openapi: ['https://a.com/o.yaml', 'https://b.com/o.yaml'] },
57
- })
58
- ).toEqual(['https://a.com/o.yaml', 'https://b.com/o.yaml']);
59
- expect(
60
- getOpenApiFilenamesFromDocsConfig({
61
- api: { openapi: { source: 'https://c.com/o.yaml' } },
62
- })
63
- ).toEqual(['https://c.com/o.yaml']);
64
- });
65
-
66
- it('returns empty when api or openapi is missing', () => {
67
- expect(getOpenApiFilenamesFromDocsConfig({})).toEqual([]);
68
- expect(getOpenApiFilenamesFromDocsConfig({ api: {} })).toEqual([]);
69
- });
70
- });
71
-
72
- describe('openApiCheck', () => {
73
- beforeEach(() => {
74
- vi.clearAllMocks();
75
- });
76
-
77
- afterEach(() => {
78
- vi.clearAllMocks();
79
- });
80
-
81
- const expectDeprecationWarning = () => {
82
- expect(addLogSpy).toHaveBeenNthCalledWith(
83
- 1,
84
- expect.objectContaining({
85
- props: { message: 'openapi-check is deprecated, use `mintlify validate` instead' },
86
- })
87
- );
88
- };
89
-
90
- it('valid openApi file from url', async () => {
91
- vi.mocked(isAllowedLocalSchemaUrl).mockReturnValueOnce(true);
92
- vi.mocked(getOpenApiDocumentFromUrl).mockResolvedValueOnce(mockValidOpenApiDocument);
93
-
94
- await runCommand('openapi-check', 'https://petstore3.swagger.io/api/v3/openapi.json');
95
-
96
- expectDeprecationWarning();
97
- expect(addLogSpy).toHaveBeenCalledWith(
98
- expect.objectContaining({
99
- props: { message: 'OpenAPI definition is valid.' },
100
- })
101
- );
102
- expect(processExitMock).toHaveBeenCalledWith(0);
103
- });
104
-
105
- it('invalid openApi file from url', async () => {
106
- vi.mocked(isAllowedLocalSchemaUrl).mockReturnValueOnce(true);
107
- vi.mocked(getOpenApiDocumentFromUrl).mockRejectedValueOnce(
108
- new Error('Could not parse OpenAPI document.')
109
- );
110
-
111
- await runCommand('openapi-check', 'https://petstore3.swagger.io/api/v3/openapi.json');
112
-
113
- expectDeprecationWarning();
114
- expect(addLogSpy).toHaveBeenCalledWith(
115
- expect.objectContaining({
116
- props: { message: 'Could not parse OpenAPI document.' },
117
- })
118
- );
119
- expect(processExitMock).toHaveBeenCalledWith(1);
120
- });
121
-
122
- it('valid openApi file from localhost', async () => {
123
- vi.mocked(isAllowedLocalSchemaUrl).mockReturnValueOnce(true);
124
- vi.mocked(getOpenApiDocumentFromUrl).mockResolvedValueOnce(mockValidOpenApiDocument);
125
-
126
- await runCommand('openapi-check', 'http://localhost:3000/openapi.json');
127
-
128
- expectDeprecationWarning();
129
- expect(addLogSpy).toHaveBeenCalledWith(
130
- expect.objectContaining({
131
- props: { message: 'OpenAPI definition is valid.' },
132
- })
133
- );
134
- expect(processExitMock).toHaveBeenCalledWith(0);
135
- });
136
-
137
- it('invalid openApi file from localhost', async () => {
138
- vi.mocked(isAllowedLocalSchemaUrl).mockReturnValueOnce(false);
139
-
140
- await runCommand('openapi-check', 'http://localhost:3000/openapi.json');
141
-
142
- expectDeprecationWarning();
143
- expect(addLogSpy).toHaveBeenCalledWith(
144
- expect.objectContaining({
145
- props: { message: 'include the --local-schema flag to check locally hosted OpenAPI files' },
146
- })
147
- );
148
- expect(processExitMock).toHaveBeenCalledWith(0);
149
- });
150
-
151
- it('valid openApi file from local file', async () => {
152
- vi.mocked(isAllowedLocalSchemaUrl).mockReturnValueOnce(false);
153
- vi.mocked(readLocalOpenApiFile).mockResolvedValueOnce(mockValidOpenApiDocument);
154
- vi.mocked(validate).mockResolvedValueOnce({
155
- valid: true,
156
- errors: [],
157
- });
158
-
159
- await runCommand('openapi-check', 'test/openapi.yaml');
160
-
161
- expectDeprecationWarning();
162
- expect(addLogSpy).toHaveBeenCalledWith(
163
- expect.objectContaining({
164
- props: { message: 'OpenAPI definition is valid.' },
165
- })
166
- );
167
- expect(processExitMock).toHaveBeenCalledWith(0);
168
- });
169
-
170
- it('invalid openApi file from local file', async () => {
171
- vi.mocked(isAllowedLocalSchemaUrl).mockReturnValueOnce(false);
172
- vi.mocked(readLocalOpenApiFile).mockResolvedValueOnce(mockValidOpenApiDocument);
173
- vi.mocked(validate).mockRejectedValueOnce(new Error('some schema parsing error'));
174
-
175
- await runCommand('openapi-check', 'test/openapi.yaml');
176
-
177
- expectDeprecationWarning();
178
- expect(addLogSpy).toHaveBeenCalledWith(
179
- expect.objectContaining({
180
- props: { message: 'some schema parsing error' },
181
- })
182
- );
183
- expect(processExitMock).toHaveBeenCalledWith(1);
184
- });
185
- });
@@ -1,25 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { readLocalOpenApiFile } from '../src/helpers.js';
4
-
5
- describe('readLocalOpenApiFile', () => {
6
- describe('path traversal prevention', () => {
7
- it('rejects path traversal with ../', async () => {
8
- await expect(readLocalOpenApiFile('../etc/passwd')).rejects.toThrow(
9
- 'path: ../etc/passwd is outside the current directory'
10
- );
11
- });
12
-
13
- it('rejects absolute paths', async () => {
14
- await expect(readLocalOpenApiFile('/etc/passwd')).rejects.toThrow(
15
- 'path: /etc/passwd is outside the current directory'
16
- );
17
- });
18
-
19
- it('rejects deep path traversal', async () => {
20
- await expect(readLocalOpenApiFile('../../secret.yaml')).rejects.toThrow(
21
- 'path: ../../secret.yaml is outside the current directory'
22
- );
23
- });
24
- });
25
- });
@@ -1,70 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
-
5
- import { resolveExplicitFiles } from '../src/resolveFiles.js';
6
-
7
- let baseDir: string;
8
-
9
- async function writeFixture(rel: string) {
10
- const filePath = path.join(baseDir, rel);
11
- await fs.mkdir(path.dirname(filePath), { recursive: true });
12
- await fs.writeFile(filePath, '# fixture\n');
13
- }
14
-
15
- beforeEach(async () => {
16
- baseDir = await fs.mkdtemp(path.join(os.tmpdir(), 'resolve-files-test-'));
17
- });
18
-
19
- afterEach(async () => {
20
- await fs.rm(baseDir, { recursive: true, force: true });
21
- });
22
-
23
- describe('resolveExplicitFiles', () => {
24
- it('resolves literal paths', async () => {
25
- await writeFixture('docs/a.mdx');
26
- await expect(resolveExplicitFiles(baseDir, ['docs/a.mdx'])).resolves.toEqual(['docs/a.mdx']);
27
- });
28
-
29
- it('normalizes leading ./', async () => {
30
- await writeFixture('docs/a.md');
31
- await expect(resolveExplicitFiles(baseDir, ['./docs/a.md'])).resolves.toEqual(['docs/a.md']);
32
- });
33
-
34
- it('errors listing paths that matched nothing', async () => {
35
- await writeFixture('docs/a.mdx');
36
- await expect(
37
- resolveExplicitFiles(baseDir, ['docs/a.mdx', 'docs/missing.mdx', 'nope/*.mdx'])
38
- ).rejects.toThrow('No matching files for: docs/missing.mdx, nope/*.mdx');
39
- });
40
-
41
- it('accepts existing literal paths regardless of extension', async () => {
42
- await writeFixture('README.txt');
43
- await expect(resolveExplicitFiles(baseDir, ['README.txt'])).resolves.toEqual(['README.txt']);
44
- });
45
-
46
- it('rejects a directory passed as a literal path', async () => {
47
- await fs.mkdir(path.join(baseDir, 'docs'), { recursive: true });
48
- await expect(resolveExplicitFiles(baseDir, ['docs'])).rejects.toThrow('No matching files');
49
- });
50
-
51
- it('expands globs recursively and keeps only docs files', async () => {
52
- await writeFixture('docs/a.mdx');
53
- await writeFixture('docs/nested/deep/b.mdx');
54
- await writeFixture('docs/nested/notes.txt');
55
- await writeFixture('top.md');
56
-
57
- await expect(resolveExplicitFiles(baseDir, ['docs/**/*.mdx'])).resolves.toEqual([
58
- 'docs/a.mdx',
59
- 'docs/nested/deep/b.mdx',
60
- ]);
61
- await expect(resolveExplicitFiles(baseDir, ['*.md'])).resolves.toEqual(['top.md']);
62
- });
63
-
64
- it('dedupes overlapping literal and glob matches', async () => {
65
- await writeFixture('docs/a.mdx');
66
- await expect(resolveExplicitFiles(baseDir, ['docs/a.mdx', 'docs/*.mdx'])).resolves.toEqual([
67
- 'docs/a.mdx',
68
- ]);
69
- });
70
- });
@@ -1,46 +0,0 @@
1
- import fs from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { beforeEach, describe, expect, it, vi } from 'vitest';
5
-
6
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'mint-session-'));
7
- vi.mock('../src/constants.js', () => ({ CONFIG_DIR: dir }));
8
-
9
- const file = path.join(dir, 'telemetry-session.json');
10
- const now = Date.parse('2026-11-02T12:00:00.000Z');
11
- const minutes = (n: number) => n * 60 * 1000;
12
- const load = async () => (await import('../src/telemetry/sessionId.js')).getSessionId;
13
- const save = (lastSeenAt: number) =>
14
- fs.writeFileSync(file, JSON.stringify({ id: 'saved', lastSeenAt }));
15
-
16
- beforeEach(() => {
17
- vi.resetModules();
18
- fs.rmSync(file, { force: true });
19
- });
20
-
21
- describe('getSessionId', () => {
22
- it('starts a UUIDv7 session and saves it', async () => {
23
- const id = (await load())(now);
24
- expect(id).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
25
- expect(parseInt(id.replace(/-/g, '').slice(0, 12), 16)).toBe(now);
26
- expect(JSON.parse(fs.readFileSync(file, 'utf-8'))).toEqual({ id, lastSeenAt: now });
27
- });
28
-
29
- it('resumes a session active in the last 30 minutes', async () => {
30
- save(now - minutes(29));
31
- expect((await load())(now)).toBe('saved');
32
- expect(JSON.parse(fs.readFileSync(file, 'utf-8')).lastSeenAt).toBe(now);
33
- });
34
-
35
- it('rotates after 30 minutes idle', async () => {
36
- save(now - minutes(31));
37
- expect((await load())(now)).not.toBe('saved');
38
- });
39
-
40
- it('keeps one id per process and refreshes activity', async () => {
41
- const getSessionId = await load();
42
- const id = getSessionId(now);
43
- expect(getSessionId(now + minutes(60))).toBe(id);
44
- expect(JSON.parse(fs.readFileSync(file, 'utf-8')).lastSeenAt).toBe(now + minutes(60));
45
- });
46
- });
@@ -1,36 +0,0 @@
1
- import { afterEach, describe, expect, it, vi } from 'vitest';
2
-
3
- import { AUTH_MD_URL, signup } from '../src/signup.js';
4
-
5
- vi.mock('../src/helpers.js', async (importOriginal) => ({
6
- ...(await importOriginal<typeof import('../src/helpers.js')>()),
7
- isAI: () => true,
8
- }));
9
-
10
- afterEach(() => {
11
- vi.unstubAllGlobals();
12
- vi.restoreAllMocks();
13
- });
14
-
15
- describe('signup for agents', () => {
16
- it('prints auth.md instead of starting the email signup', async () => {
17
- const request = vi.fn().mockResolvedValue(new Response('# auth.md body'));
18
- vi.stubGlobal('fetch', request);
19
- const write = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
20
-
21
- await signup({ firstName: 'A', lastName: 'B', company: 'C', email: 'a@example.com' });
22
-
23
- expect(request).toHaveBeenCalledTimes(1);
24
- expect(request.mock.calls[0]?.[0]).toBe(AUTH_MD_URL);
25
- expect(write).toHaveBeenCalledWith('# auth.md body\n');
26
- });
27
-
28
- it('does not print a failed auth.md response', async () => {
29
- vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response('nope', { status: 502 })));
30
- const write = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
31
-
32
- await signup();
33
-
34
- expect(write).not.toHaveBeenCalledWith('nope\n');
35
- });
36
- });
@@ -1,117 +0,0 @@
1
- import * as previewing from '@mintlify/previewing';
2
-
3
- import {
4
- getLatestCliVersion,
5
- getVersions,
6
- execFileAsync,
7
- windowsCompatibleSpawnOptions,
8
- } from '../src/helpers.js';
9
- import { update } from '../src/update.js';
10
-
11
- vi.mock('@mintlify/previewing', async () => {
12
- const originalModule =
13
- await vi.importActual<typeof import('@mintlify/previewing')>('@mintlify/previewing');
14
- return {
15
- ...originalModule,
16
- getClientVersion: vi.fn().mockReturnValue('1.0.0'),
17
- getLatestClientVersion: vi.fn().mockResolvedValue('2.0.0'),
18
- downloadTargetMint: vi.fn().mockResolvedValue(undefined),
19
- };
20
- });
21
-
22
- vi.mock('../src/helpers.js', async () => {
23
- const originalModule =
24
- await vi.importActual<typeof import('../src/helpers.js')>('../src/helpers.js');
25
- return {
26
- ...originalModule,
27
- execFileAsync: vi.fn(),
28
- getLatestCliVersion: vi.fn(),
29
- getVersions: vi.fn().mockReturnValue({
30
- cli: '1.0.0',
31
- client: '1.0.0',
32
- }),
33
- };
34
- });
35
-
36
- const addLogSpy = vi.spyOn(previewing, 'addLog');
37
- const addErrorLogSpy = vi.spyOn(previewing, 'addErrorLog');
38
-
39
- describe('update', () => {
40
- beforeEach(() => {
41
- vi.clearAllMocks();
42
- });
43
-
44
- afterEach(() => {
45
- vi.resetAllMocks();
46
- });
47
-
48
- it('should update the cli successfully', async () => {
49
- vi.mocked(getVersions).mockReturnValue({
50
- cli: '1.0.0',
51
- client: '1.0.0',
52
- });
53
- vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
54
- vi.mocked(execFileAsync).mockResolvedValue({ stdout: '', stderr: '' });
55
- vi.mocked(previewing.downloadTargetMint).mockResolvedValue();
56
-
57
- await update({ packageName: 'mintlify' });
58
-
59
- expect(execFileAsync).toHaveBeenCalledWith(
60
- 'npm',
61
- ['install', '-g', 'mintlify@latest', '--silent'],
62
- windowsCompatibleSpawnOptions
63
- );
64
- expect(previewing.downloadTargetMint).toHaveBeenCalledWith({
65
- targetVersion: '2.0.0',
66
- existingVersion: '1.0.0',
67
- });
68
- expect(addLogSpy).toHaveBeenCalledWith(
69
- expect.objectContaining({
70
- props: { message: 'updated mintlify to the latest version: 2.0.0' },
71
- })
72
- );
73
- });
74
-
75
- it('should return when already up to date', async () => {
76
- vi.mocked(getVersions).mockReturnValue({
77
- cli: '1.0.0',
78
- client: '1.0.0',
79
- });
80
- vi.mocked(getLatestCliVersion).mockReturnValue('1.0.0');
81
- vi.mocked(previewing.getLatestClientVersion).mockResolvedValue('1.0.0');
82
- vi.mocked(previewing.getClientVersion).mockReturnValue('1.0.0');
83
-
84
- await update({ packageName: 'mintlify' });
85
-
86
- expect(execFileAsync).not.toHaveBeenCalled();
87
- expect(previewing.downloadTargetMint).not.toHaveBeenCalled();
88
- expect(addLogSpy).toHaveBeenCalledWith(
89
- expect.objectContaining({ props: { message: 'already up to date' } })
90
- );
91
- });
92
-
93
- it('should handle cli update failure', async () => {
94
- vi.mocked(getVersions).mockReturnValue({
95
- cli: '1.0.0',
96
- client: '1.0.0',
97
- });
98
- vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
99
- vi.mocked(execFileAsync).mockRejectedValue(new Error('Update failed'));
100
-
101
- await update({ packageName: 'mintlify' });
102
-
103
- expect(addLogSpy).toHaveBeenCalledTimes(2);
104
- expect(addLogSpy).toHaveBeenCalledWith(
105
- expect.objectContaining({ props: { message: 'updating...' } })
106
- );
107
- expect(addLogSpy).toHaveBeenCalledWith(
108
- expect.objectContaining({ props: { message: 'updating mintlify package...' } })
109
- );
110
- expect(addErrorLogSpy).toHaveBeenCalledTimes(1);
111
- expect(addErrorLogSpy).toHaveBeenCalledWith(
112
- expect.objectContaining({
113
- props: { message: 'Failed to update mintlify@2.0.0 using npm: Update failed' },
114
- })
115
- );
116
- });
117
- });