@mintlify/cli 4.0.1813 → 4.1.2

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 +38 -31
  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
package/src/cli.tsx DELETED
@@ -1,1105 +0,0 @@
1
- import {
2
- addLog,
3
- dev,
4
- exportSite,
5
- ErrorLog,
6
- SuccessLog,
7
- Logs,
8
- WarningLog,
9
- } from '@mintlify/previewing';
10
- import { thumbnailOverrideSchema } from '@mintlify/validation';
11
- import { render, Text } from 'ink';
12
- import yargs, { type Argv } from 'yargs';
13
- import { hideBin } from 'yargs/helpers';
14
-
15
- import { accessibilityCheck } from './accessibilityCheck.js';
16
- import { addDomain } from './addDomain.js';
17
- import { claimDeployment, createAgentClaimLink } from './agent-claim.js';
18
- import { SETUP_AGENTS, setupAgent } from './agent-setup.js';
19
- import { analyticsBuilder } from './analytics/index.js';
20
- import { brokenLinksHandler } from './brokenLinks.js';
21
- import { comingSoon } from './comingSoon.js';
22
- import { setTelemetryEnabled } from './config.js';
23
- import { getConfigValue, setConfigValue, clearConfigValue } from './config.js';
24
- import { API_URL } from './constants.js';
25
- import { pushBaseCheckout } from './deploy-base.js';
26
- import { deployFromGithubActions, isGithubActions } from './deploy-github-actions.js';
27
- import { formatGithubSetup, setupGithubDeployment } from './deploy-github-setup.js';
28
- import { DEPLOY_HELP, deploymentInstructions } from './deploy-instructions.js';
29
- import { agentEditorUrl, formatDeployment, prepareAgentDeployment } from './deploy.js';
30
- import { FEEDBACK_CATEGORIES, feedback } from './feedback.js';
31
- import { formatHandler } from './format.js';
32
- import {
33
- checkPort,
34
- checkNodeVersion,
35
- autoUpgradeIfNeeded,
36
- getVersions,
37
- isAI,
38
- suppressConsoleWarnings,
39
- terminate,
40
- } from './helpers.js';
41
- import { init } from './init.js';
42
- import { fetchInstructions, formatTopics } from './instructions.js';
43
- import { getAccessToken } from './keyring.js';
44
- import { login } from './login.js';
45
- import { logout } from './logout.js';
46
- import { mdxLinter } from './mdxLinter.js';
47
- import { createTelemetryMiddleware } from './middlewares/telemetryMiddleware.js';
48
- import {
49
- agents,
50
- listMigrationDocs,
51
- migrateWithAgent,
52
- migrationInstructions,
53
- type AgentName,
54
- } from './migrate.js';
55
- import { ogCommand } from './og.js';
56
- import { buildOverlayRegistryForCheck, checkOpenApiFile } from './openApiCheck.js';
57
- import { scoreHandler } from './score/index.js';
58
- import { signup } from './signup.js';
59
- import { status, getCliSubdomains } from './status.js';
60
- import { trackEvent, trackTelemetryPreferenceChange } from './telemetry/track.js';
61
- import { update } from './update.js';
62
- import { splitList, validateHandler } from './validate/command.js';
63
- import { RULES } from './validate/rules/index.js';
64
- import { PARSE_ERROR } from './validate/rules/parseError.js';
65
- import { GROUPS } from './validate/types.js';
66
- import { renderWelcome } from './welcome.js';
67
- import { workflowsBuilder } from './workflows/index.js';
68
-
69
- // The branded welcome screen replaces yargs' default help, but only for an
70
- // interactive human at a TTY. Piped, scripted, AI, and test callers keep the
71
- // plain yargs help so their output stays parseable and stable.
72
- const shouldShowWelcome = (args: string[]): boolean => {
73
- const interactive =
74
- Boolean(process.stdout.isTTY) && !isAI() && process.env.CLI_TEST_MODE !== 'true';
75
- if (!interactive) return false;
76
- if (args.length === 0) return true;
77
-
78
- const positionals = args.filter((arg) => !arg.startsWith('-'));
79
- const command = positionals[0];
80
- // `help` followed by a subcommand (e.g. `mint help dev`) is a subcommand
81
- // lookup — let yargs handle it rather than intercepting with the welcome screen.
82
- const isTopLevel = command === undefined || (command === 'help' && positionals.length === 1);
83
- const helpRequested = command === 'help' || args.includes('--help') || args.includes('-h');
84
- return isTopLevel && helpRequested;
85
- };
86
-
87
- const showWelcome = async (packageName: string): Promise<void> => {
88
- const { cli: version } = getVersions(packageName);
89
- const subdomain = getConfigValue('subdomain');
90
- let signedIn = false;
91
- try {
92
- signedIn = Boolean(await getAccessToken());
93
- } catch {}
94
-
95
- process.stdout.write(renderWelcome({ packageName, version, signedIn, subdomain }));
96
- await terminate(0);
97
- };
98
-
99
- export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
100
- const commandArguments = hideBin(process.argv);
101
- if (shouldShowWelcome(commandArguments)) {
102
- return showWelcome(packageName);
103
- }
104
-
105
- const telemetryMiddleware = createTelemetryMiddleware();
106
- render(<Logs />);
107
-
108
- return (
109
- yargs(commandArguments)
110
- .scriptName(packageName)
111
- .option('telemetry', {
112
- type: 'boolean',
113
- alias: 't',
114
- description: 'Enable or disable usage telemetry',
115
- })
116
- .middleware(async (argv) => {
117
- if (argv.telemetry !== undefined && argv._.length === 0) {
118
- await setTelemetryEnabled(argv.telemetry);
119
- await trackTelemetryPreferenceChange({ enabled: argv.telemetry });
120
- addLog(<SuccessLog message={`telemetry ${argv.telemetry ? 'enabled' : 'disabled'}`} />);
121
- await terminate(0);
122
- }
123
- }, true)
124
- .middleware(checkNodeVersion)
125
- .middleware(suppressConsoleWarnings)
126
- .middleware(telemetryMiddleware)
127
- .command('agent', 'Set up AI coding agents for Mintlify', (yargs) =>
128
- yargs
129
- .command(
130
- 'setup',
131
- 'Install Mintlify skills and configure Admin MCP',
132
- (yargs) =>
133
- yargs
134
- .exitProcess(false)
135
- .option('agent', {
136
- alias: 'a',
137
- type: 'string',
138
- array: true,
139
- choices: SETUP_AGENTS,
140
- description: 'Agents to configure (defaults to interactive selection)',
141
- })
142
- .option('global', {
143
- alias: 'g',
144
- type: 'boolean',
145
- default: false,
146
- description: 'Set up agents for your user account instead of this project',
147
- })
148
- .example('$0 agent setup', 'Choose agents and set up the current project')
149
- .example(
150
- '$0 agent setup --agent codex --global',
151
- 'Set up Codex for your user account'
152
- )
153
- .epilog(
154
- 'Requires Node.js 22.20 or later and npm. Admin MCP requires a separate OAuth sign-in in each agent.'
155
- ),
156
- async (argv) => {
157
- try {
158
- await setupAgent({ agents: argv.agent, global: argv.global });
159
- await terminate(0);
160
- } catch (error) {
161
- process.stderr.write(
162
- `${error instanceof Error ? error.message : 'Agent setup failed.'}\n`
163
- );
164
- await terminate(1);
165
- }
166
- }
167
- )
168
- .demandCommand(1, 'Run mint agent setup to configure your coding agents.')
169
- )
170
- .command(
171
- 'claim',
172
- 'Claim a site created with mint deploy',
173
- (yargs) =>
174
- yargs
175
- .option('email', { type: 'string', description: 'User email for a claim link' })
176
- .option('code', {
177
- type: 'string',
178
- description: 'Code returned by the user from the claim page',
179
- })
180
- .option('directory', {
181
- type: 'string',
182
- default: '.',
183
- description: 'Original documentation directory used for mint deploy',
184
- })
185
- .conflicts('code', 'email')
186
- .example('$0 claim --email you@example.com', 'Get a claim link for the current site')
187
- .example('$0 claim --code ABCDEFGH', 'Finish the claim with the code from the user')
188
- .epilog(
189
- 'Run from the same directory as mint deploy, or pass --directory. Ask the user to open the claim link and return the code. The CLI reads saved credentials internally; do not read or print keychain secrets. Retry the same command if Mintlify signup fails.'
190
- ),
191
- async (argv) => {
192
- try {
193
- const message = await claimDeployment(
194
- { apiUrl: API_URL, directory: argv.directory, code: argv.code, email: argv.email },
195
- (message) => process.stderr.write(`${message}\n`)
196
- );
197
- process.stdout.write(`${message}\n`);
198
- await terminate(0);
199
- } catch (error) {
200
- process.stderr.write(`${error instanceof Error ? error.message : 'Claim failed.'}\n`);
201
- await terminate(1);
202
- }
203
- }
204
- )
205
- .command(
206
- 'deploy',
207
- 'Provision an anonymous docs site and get Git push instructions',
208
- (yargs) =>
209
- yargs
210
- .option('subdomain', {
211
- type: 'string',
212
- description: 'Requested site name; required for the first deployment or --new',
213
- })
214
- .option('org-name', { type: 'string', description: 'Organization display name' })
215
- .option('directory', {
216
- type: 'string',
217
- default: '.',
218
- description: 'Documentation directory associated with this site',
219
- })
220
- .option('new', {
221
- type: 'boolean',
222
- default: false,
223
- description: 'Create a new registration and site',
224
- })
225
- .option('email', {
226
- type: 'string',
227
- description: 'User email for an optional claim link',
228
- })
229
- .option('github', {
230
- type: 'boolean',
231
- description:
232
- 'Trust this GitHub repository to deploy the site and write a GitHub Actions workflow',
233
- })
234
- .option('force', {
235
- type: 'boolean',
236
- default: false,
237
- description: 'With --github, overwrite an existing .github/workflows/mintlify.yml',
238
- })
239
- .option('base', {
240
- type: 'boolean',
241
- description:
242
- 'Provision a base, edited in the Mintlify editor, instead of a docs site',
243
- })
244
- .option('push', {
245
- type: 'string',
246
- description: 'With --base, rebase this clone onto main and push it to the base',
247
- })
248
- .implies('push', 'base')
249
- .conflicts('push', 'email')
250
- .conflicts('github', 'email')
251
- .conflicts('base', 'github')
252
- .example('$0 deploy --subdomain my-docs', 'Provision a site without signing in')
253
- .example(
254
- '$0 deploy --email you@example.com',
255
- 'Get repository access and a claim link for the current site'
256
- )
257
- .example('$0 deploy --new --subdomain another-site', 'Create another anonymous site')
258
- .example(
259
- '$0 deploy --base --subdomain my-base',
260
- 'Provision a base and get its editor link'
261
- )
262
- .example(
263
- '$0 deploy --github --subdomain my-docs',
264
- 'Deploy the site from GitHub Actions on every push to the default branch'
265
- )
266
- .example(
267
- '$0 deploy --subdomain my-docs',
268
- 'In GitHub Actions with id-token: write, push the current commit to a trusted site'
269
- )
270
- .epilog(DEPLOY_HELP),
271
- async (argv) => {
272
- try {
273
- if (isGithubActions()) {
274
- const siteUrl = await deployFromGithubActions(
275
- { apiUrl: API_URL, directory: argv.directory, subdomain: argv.subdomain },
276
- (message) => process.stderr.write(`${message}\n`)
277
- );
278
- process.stdout.write(
279
- `Pushed to ${argv.subdomain}; the build starts now.\nSite: ${siteUrl}\n`
280
- );
281
- await terminate(0);
282
- return;
283
- }
284
- if (argv.github) {
285
- const setup = await setupGithubDeployment(
286
- {
287
- apiUrl: API_URL,
288
- directory: argv.directory,
289
- subdomain: argv.subdomain,
290
- orgName: argv.orgName,
291
- newSite: argv.new,
292
- force: argv.force,
293
- },
294
- (message) => process.stderr.write(`Warning: ${message}\n`),
295
- (message) => process.stderr.write(`${message}\n`)
296
- );
297
- process.stdout.write(`${formatGithubSetup(setup)}\n`);
298
- await terminate(0);
299
- return;
300
- }
301
- const result = await prepareAgentDeployment(
302
- {
303
- apiUrl: API_URL,
304
- directory: argv.directory,
305
- subdomain: argv.subdomain,
306
- orgName: argv.orgName,
307
- newSite: argv.new,
308
- base: argv.base,
309
- },
310
- (message) => {
311
- process.stderr.write(`Warning: ${message}\n`);
312
- },
313
- (message) => process.stderr.write(`${message}\n`)
314
- );
315
- if (argv.push && result.status === 'ready') {
316
- await pushBaseCheckout(argv.push, result.write);
317
- process.stdout.write(
318
- `Pushed ${argv.push} to the base.\nEditor: ${agentEditorUrl(result.site)}\n`
319
- );
320
- await terminate(0);
321
- return;
322
- }
323
- process.stdout.write(`${formatDeployment(result, API_URL)}\n`);
324
- let claimUrl: string | undefined;
325
- if (argv.email && result.status === 'ready') {
326
- try {
327
- process.stderr.write('Creating the claim link...\n');
328
- claimUrl = await createAgentClaimLink(API_URL, result.credentials, argv.email);
329
- } catch (error) {
330
- const reason = error instanceof Error ? ` ${error.message}` : '';
331
- process.stderr.write(
332
- `Warning: Could not create the claim link.${reason} Your site is provisioned; retry with --email later.\n`
333
- );
334
- }
335
- }
336
- process.stdout.write(`${deploymentInstructions(result, claimUrl)}\n`);
337
- await terminate(0);
338
- } catch (error) {
339
- process.stderr.write(
340
- `${error instanceof Error ? error.message : 'Deployment failed.'}\n`
341
- );
342
- await terminate(1);
343
- }
344
- }
345
- )
346
- .command(
347
- 'dev',
348
- 'Initialize a local preview environment',
349
- (yargs) =>
350
- yargs
351
- .option('open', {
352
- type: 'boolean',
353
- default: true,
354
- description: 'open a local preview in the browser',
355
- })
356
- .option('local-schema', {
357
- type: 'boolean',
358
- default: false,
359
- hidden: true,
360
- description:
361
- 'use a locally hosted schema file (note: only https protocol is supported in production)',
362
- })
363
- .option('client-version', {
364
- type: 'string',
365
- hidden: true,
366
- description: 'the version of the client to use for cli testing',
367
- })
368
- .option('local-client-version', {
369
- type: 'string',
370
- hidden: true,
371
- description: 'path to local client repo to symlink for development',
372
- })
373
- .option('groups', {
374
- type: 'array',
375
- description: 'Mock user groups for local development and testing',
376
- example: '--groups admin user',
377
- })
378
- .option('signed-in', {
379
- type: 'boolean',
380
- default: false,
381
- description: 'Mock a signed-in user with no groups for local development and testing',
382
- })
383
- .option('disable-openapi', {
384
- type: 'boolean',
385
- default: false,
386
- description: 'Disable OpenAPI file generation',
387
- })
388
- .option('disable-prefetch', {
389
- type: 'boolean',
390
- default: false,
391
- description: 'Disable navigation prefetching in the local preview',
392
- })
393
- .option('host', {
394
- type: 'boolean',
395
- default: false,
396
- description: 'Expose the local preview on your network',
397
- })
398
- .option('classic', {
399
- type: 'boolean',
400
- default: false,
401
- description: 'Preview with the classic client',
402
- })
403
- .usage('usage: mintlify dev [options]')
404
- .example('mintlify dev', 'run with default settings (opens in browser)')
405
- .example('mintlify dev --no-open', 'run without opening in browser'),
406
- async (argv) => {
407
- await autoUpgradeIfNeeded();
408
- const port = await checkPort(argv);
409
- const { cli: cliVersion } = getVersions(packageName);
410
- let accessToken: string | undefined;
411
- let subdomain: string | undefined;
412
- try {
413
- accessToken = (await getAccessToken()) ?? undefined;
414
- const configuredSubdomain = getConfigValue('subdomain');
415
- subdomain =
416
- configuredSubdomain ??
417
- (accessToken ? (await getCliSubdomains(accessToken))[0] : undefined);
418
- } catch {}
419
- if (port != undefined) {
420
- await dev({
421
- ...argv,
422
- groups: argv.groups ?? (argv.signedIn ? [] : undefined),
423
- port,
424
- packageName,
425
- cliVersion,
426
- accessToken,
427
- subdomain,
428
- apiUrl: API_URL,
429
- });
430
- } else {
431
- addLog(<ErrorLog message="no available port found" />);
432
- await terminate(1);
433
- }
434
- }
435
- )
436
- .command(
437
- 'validate',
438
- 'Check the docs: content, OpenAPI specs, then a strict build. Exits 0 with no errors, 1 with errors, 2 when validate itself could not run',
439
- (yargs) =>
440
- yargs
441
- .option('local-schema', {
442
- type: 'boolean',
443
- default: false,
444
- hidden: true,
445
- description: 'use a locally hosted schema file',
446
- })
447
- .option('client-version', {
448
- type: 'string',
449
- hidden: true,
450
- description: 'the version of the client to use for cli testing',
451
- })
452
- .option('groups', {
453
- type: 'array',
454
- description: 'Mock user groups for validation',
455
- })
456
- .option('files', {
457
- type: 'string',
458
- array: true,
459
- description:
460
- 'Limit page checks to these files or globs; site-wide checks and the build still cover the whole site',
461
- })
462
- .option('build', {
463
- type: 'boolean',
464
- default: true,
465
- description:
466
- 'Run the strict build after the other checks pass; --no-build skips it, so no client download is needed. Remote OpenAPI specs are still fetched unless openapi rules are disabled',
467
- })
468
- .option('enable', {
469
- type: 'string',
470
- array: true,
471
- coerce: splitList,
472
- description:
473
- 'Turn on rules or groups (comma-separated), for example after --disable all',
474
- })
475
- .option('disable', {
476
- type: 'string',
477
- array: true,
478
- coerce: splitList,
479
- description:
480
- 'Turn off rules or groups (comma-separated), or all; parse errors are still reported',
481
- })
482
- .option('fix', {
483
- type: 'boolean',
484
- default: false,
485
- description: 'Apply the fixes and check again',
486
- })
487
- .option('format', {
488
- type: 'string',
489
- choices: ['text', 'json'] as const,
490
- default: 'text' as const,
491
- description:
492
- 'Output format; json prints one report ({ passed, summary, diagnostics, build }) and nothing else on stdout, and errors to stderr',
493
- })
494
- .usage('usage: mint validate [options]')
495
- .epilogue(
496
- [
497
- `Groups: ${GROUPS.join(', ')}. Rules:`,
498
- ...RULES.map(({ id, description }) => ` ${id} — ${description}`),
499
- ` parse-error — ${PARSE_ERROR.description} (always runs)`,
500
- ].join('\n')
501
- )
502
- .example('mint validate', 'run every check and the build')
503
- .example(
504
- 'mint validate --no-build --format json',
505
- 'fast offline check for scripts and agents'
506
- )
507
- .example(
508
- 'mint validate --files "guides/**/*.mdx" --fix',
509
- 'check some pages and apply fixes'
510
- )
511
- .example(
512
- 'mint validate --disable all --enable content',
513
- 'run the content rules only; missing-file and import-error still run the build'
514
- )
515
- .strict(),
516
- (argv) => validateHandler(argv, packageName)
517
- )
518
- .command(
519
- 'export',
520
- 'Export a static site for air-gapped deployment',
521
- (yargs) =>
522
- yargs
523
- .option('output', {
524
- type: 'string',
525
- default: 'export.zip',
526
- description: 'output zip file path',
527
- })
528
- .option('client-version', {
529
- type: 'string',
530
- hidden: true,
531
- })
532
- .option('local-client-version', {
533
- type: 'string',
534
- hidden: true,
535
- description: 'path to local client repo to symlink for development',
536
- })
537
- .option('groups', {
538
- type: 'array',
539
- description: 'Mock user groups for export',
540
- })
541
- .option('base-path', {
542
- type: 'string',
543
- description: 'path prefix the export will be served under, e.g. /docs',
544
- })
545
- .option('disable-openapi', {
546
- type: 'boolean',
547
- default: false,
548
- description: 'Disable OpenAPI file generation',
549
- })
550
- .option('classic', {
551
- type: 'boolean',
552
- default: false,
553
- description: 'Export with the classic client',
554
- })
555
- .usage('usage: mintlify export [options]')
556
- .example('mintlify export', 'export as export.zip')
557
- .example('mintlify export --output docs.zip', 'export to custom filename')
558
- .example('mintlify export --base-path /docs', 'export for hosting under /docs'),
559
- async (argv) => {
560
- const { cli: cliVersion } = getVersions(packageName);
561
- await exportSite({
562
- ...argv,
563
- packageName,
564
- cliVersion,
565
- });
566
- await terminate(0);
567
- }
568
- )
569
- .command(
570
- 'openapi-check <filename>',
571
- false,
572
- (yargs) =>
573
- yargs
574
- .positional('filename', {
575
- describe:
576
- 'the filename of the OpenAPI spec (e.g. ./openapi.yaml) or the URL to the OpenAPI spec (e.g. https://petstore3.swagger.io/api/v3/openapi.json)',
577
- type: 'string',
578
- demandOption: true,
579
- })
580
- .option('local-schema', {
581
- type: 'boolean',
582
- default: false,
583
- description:
584
- 'use a locally hosted schema file (note: only https protocol is supported in production)',
585
- }),
586
- async ({ filename, 'local-schema': localSchema }) => {
587
- addLog(
588
- <WarningLog message="openapi-check is deprecated, use `mintlify validate` instead" />
589
- );
590
- let overlayRegistry;
591
- try {
592
- overlayRegistry = await buildOverlayRegistryForCheck(localSchema);
593
- } catch (error) {
594
- addLog(<ErrorLog message={error instanceof Error ? error.message : String(error)} />);
595
- await terminate(1);
596
- return;
597
- }
598
- const valid = await checkOpenApiFile(filename, localSchema, overlayRegistry);
599
- await terminate(valid ? 0 : 1);
600
- }
601
- )
602
- .command(
603
- 'broken-links',
604
- 'Check for broken links',
605
- (yargs) =>
606
- yargs
607
- .option('files', {
608
- type: 'string',
609
- array: true,
610
- description: 'Files or globs to check (defaults to the whole site)',
611
- })
612
- .option('check-anchors', {
613
- type: 'boolean',
614
- default: false,
615
- description: 'also validate anchor links (e.g. #section) against heading slugs',
616
- })
617
- .option('check-external', {
618
- type: 'boolean',
619
- default: false,
620
- description: 'also check external links for broken URLs',
621
- })
622
- .option('check-snippets', {
623
- type: 'boolean',
624
- default: false,
625
- description: 'also check links inside <Snippet> components',
626
- })
627
- .option('check-redirects', {
628
- type: 'boolean',
629
- default: false,
630
- description: 'also check that docs.json redirect destinations resolve to valid paths',
631
- })
632
- .example('mint broken-links --files introduction.mdx', 'Check a specific page')
633
- .example('mint broken-links --files "guides/**/*.mdx"', 'Check pages matching a glob'),
634
- (argv) => brokenLinksHandler(argv)
635
- )
636
- .command(
637
- 'instructions [topics..]',
638
- 'Print Mintlify workflow instructions for agents',
639
- (yargs) =>
640
- yargs
641
- .positional('topics', {
642
- type: 'string',
643
- array: true,
644
- default: [] as string[],
645
- description: 'Topic and optional subtopic',
646
- })
647
- .example('mint instructions', 'List topics')
648
- .example('mint instructions publish domain', 'Custom domain instructions'),
649
- async ({ topics }) => {
650
- if (topics.length === 0) {
651
- process.stdout.write(formatTopics());
652
- await terminate(0);
653
- return;
654
- }
655
- let markdown;
656
- try {
657
- markdown = await fetchInstructions(topics);
658
- } catch (error) {
659
- addLog(<ErrorLog message={error instanceof Error ? error.message : String(error)} />);
660
- await terminate(1);
661
- return;
662
- }
663
- await new Promise<void>((resolve) => process.stdout.write(markdown, () => resolve()));
664
- await terminate(0);
665
- }
666
- )
667
- .command(
668
- 'status',
669
- 'View current authentication status',
670
- () => undefined,
671
- async () => {
672
- await status();
673
- await terminate(0);
674
- }
675
- )
676
- .command(
677
- 'logout',
678
- 'Logout of your Mintlify account',
679
- () => undefined,
680
- async () => {
681
- await logout();
682
- await terminate(0);
683
- }
684
- )
685
- .command(
686
- 'login',
687
- 'Authenticate your account to Mintlify',
688
- () => undefined,
689
- async () => {
690
- await login();
691
- await terminate(0);
692
- }
693
- )
694
- .command(
695
- 'signup',
696
- 'Create a new Mintlify account',
697
- (yargs: Argv) =>
698
- yargs
699
- .option('firstName', { type: 'string', description: 'First name' })
700
- .option('lastName', { type: 'string', description: 'Last name' })
701
- .option('company', { type: 'string', description: 'Company name' })
702
- .option('email', { type: 'string', description: 'Email address' })
703
- .epilogue(
704
- 'Note: this command does not return until the user clicks the verification link ' +
705
- 'sent to their email, which can take several minutes. Non-interactive or scripted ' +
706
- 'callers should run it as a background process rather than waiting on it synchronously.'
707
- ),
708
- async (argv) => {
709
- await signup({
710
- firstName: argv.firstName,
711
- lastName: argv.lastName,
712
- company: argv.company,
713
- email: argv.email,
714
- });
715
- await terminate(0);
716
- }
717
- )
718
- .command(
719
- 'add-domain <domain>',
720
- 'Add a custom domain to your deployment',
721
- (yargs: Argv) =>
722
- yargs
723
- .positional('domain', {
724
- type: 'string',
725
- demandOption: true,
726
- description: 'The custom domain to add (e.g. docs.example.com)',
727
- })
728
- .option('basePath', {
729
- type: 'string',
730
- description: 'Serve the docs under a base path (e.g. /docs)',
731
- }),
732
- async (argv) => {
733
- await addDomain(argv.domain, argv.basePath);
734
- await terminate(0);
735
- }
736
- )
737
- .command(
738
- 'feedback <message>',
739
- 'Send feedback to the Mintlify team',
740
- (yargs: Argv) =>
741
- yargs
742
- .positional('message', {
743
- type: 'string',
744
- demandOption: true,
745
- description: 'Feedback to send. Leave out API keys, tokens, and other secrets',
746
- })
747
- .option('client-id', {
748
- type: 'string',
749
- demandOption: true,
750
- description: 'ID for this report, so the team can tell retries apart',
751
- })
752
- .option('category', {
753
- choices: FEEDBACK_CATEGORIES,
754
- demandOption: true,
755
- description: 'Feedback category',
756
- })
757
- .example(
758
- '$0 feedback "mint dev crashes on a missing image" --client-id 7f3a --category bug',
759
- 'Report a bug'
760
- )
761
- .epilog('Never include API keys, tokens, passwords, or other secrets in the message.'),
762
- async (argv) => {
763
- const sent = await feedback({
764
- message: argv.message,
765
- clientId: argv.clientId,
766
- category: argv.category,
767
- });
768
- await terminate(sent ? 0 : 1);
769
- }
770
- )
771
- .command('config', 'Manage CLI configuration', (yargs) =>
772
- yargs
773
- .command(
774
- 'set <key> <value>',
775
- 'Set a configuration value',
776
- (yargs) =>
777
- yargs
778
- .positional('key', {
779
- type: 'string',
780
- demandOption: true,
781
- description: 'Config key (e.g. subdomain)',
782
- })
783
- .positional('value', {
784
- type: 'string',
785
- demandOption: true,
786
- description: 'Config value',
787
- }),
788
- async (argv) => {
789
- const validKeys = ['subdomain', 'dateFrom', 'dateTo'];
790
- if (!validKeys.includes(argv.key)) {
791
- addLog(
792
- <ErrorLog
793
- message={`Unknown config key: "${argv.key}". Valid keys: ${validKeys.join(', ')}`}
794
- />
795
- );
796
- await terminate(1);
797
- return;
798
- }
799
- await setConfigValue(argv.key, argv.value);
800
- addLog(<SuccessLog message={`${argv.key} = "${argv.value}"`} />);
801
- await terminate(0);
802
- }
803
- )
804
- .command(
805
- 'get <key>',
806
- 'Get a configuration value',
807
- (yargs) =>
808
- yargs.positional('key', {
809
- type: 'string',
810
- demandOption: true,
811
- description: 'Config key (e.g. subdomain, dateFrom, dateTo)',
812
- }),
813
- async (argv) => {
814
- const validKeys = ['subdomain', 'dateFrom', 'dateTo'];
815
- if (!validKeys.includes(argv.key)) {
816
- addLog(
817
- <ErrorLog
818
- message={`Unknown config key: "${argv.key}". Valid keys: ${validKeys.join(', ')}`}
819
- />
820
- );
821
- await terminate(1);
822
- return;
823
- }
824
- const val = getConfigValue(argv.key);
825
- addLog(<Text>{val ?? 'not set'}</Text>);
826
- await terminate(0);
827
- }
828
- )
829
- .command(
830
- 'clear <key>',
831
- 'Remove a configuration value',
832
- (yargs) =>
833
- yargs.positional('key', {
834
- type: 'string',
835
- demandOption: true,
836
- description: 'Config key (e.g. subdomain, dateFrom, dateTo)',
837
- }),
838
- async (argv) => {
839
- const validKeys = ['subdomain', 'dateFrom', 'dateTo'];
840
- if (!validKeys.includes(argv.key)) {
841
- addLog(
842
- <ErrorLog
843
- message={`Unknown config key: "${argv.key}". Valid keys: ${validKeys.join(', ')}`}
844
- />
845
- );
846
- await terminate(1);
847
- return;
848
- }
849
- await clearConfigValue(argv.key);
850
- addLog(<SuccessLog message={`${argv.key} cleared`} />);
851
- await terminate(0);
852
- }
853
- )
854
- .demandCommand(1, 'specify a subcommand: set, get, or clear')
855
- )
856
- .command(
857
- 'update',
858
- 'Update the CLI to the latest version',
859
- () => undefined,
860
- async () => {
861
- await update({ packageName });
862
- await terminate(0);
863
- }
864
- )
865
- .command(
866
- ['a11y', 'accessibility-check', 'a11y-check', 'accessibility'],
867
- 'Check for accessibility issues in documentation',
868
- (yargs) =>
869
- yargs
870
- .option('skip-contrast', {
871
- type: 'boolean',
872
- default: false,
873
- description: 'Skip color contrast checks',
874
- })
875
- .option('skip-alt-text', {
876
- type: 'boolean',
877
- default: false,
878
- description: 'Skip alt text checks on images and videos',
879
- })
880
- .check((argv) => {
881
- if (argv.skipContrast && argv.skipAltText) {
882
- throw new Error('Cannot skip both contrast and alt-text checks');
883
- }
884
- return true;
885
- })
886
- .example('mint a11y', 'Run all accessibility checks')
887
- .example('mint a11y --skip-contrast', 'Only check for missing alt text')
888
- .example('mint a11y --skip-alt-text', 'Only check color contrast'),
889
- async (argv) => {
890
- let accessibilityCheckTerminateCode = 0;
891
- let mdxLinterTerminateCode = 0;
892
-
893
- if (!argv.skipContrast) {
894
- accessibilityCheckTerminateCode = await accessibilityCheck();
895
- }
896
-
897
- if (!argv.skipAltText) {
898
- mdxLinterTerminateCode = await mdxLinter();
899
- }
900
-
901
- await terminate(accessibilityCheckTerminateCode || mdxLinterTerminateCode);
902
- }
903
- )
904
- .command(
905
- 'og [page]',
906
- 'Render the social preview (OG) image for a page',
907
- (yargs) =>
908
- yargs
909
- .positional('page', {
910
- type: 'string',
911
- description: 'Page path, such as guides/webhooks. Defaults to index',
912
- })
913
- .option('preset', {
914
- choices: thumbnailOverrideSchema.shape.preset.unwrap().options,
915
- description: 'Try a preset without editing docs.json',
916
- })
917
- .option('surface', {
918
- choices: thumbnailOverrideSchema.shape.surface.unwrap().options,
919
- description: 'Try a surface without editing docs.json',
920
- })
921
- .option('appearance', {
922
- choices: thumbnailOverrideSchema.shape.appearance.unwrap().options,
923
- description: 'Try an appearance without editing docs.json',
924
- })
925
- .option('output', {
926
- type: 'string',
927
- description: 'Where to write the PNG. Defaults to a temporary file',
928
- })
929
- .option('open', {
930
- type: 'boolean',
931
- default: true,
932
- description: 'Open the image after rendering. Use --no-open in CI',
933
- })
934
- .example('mint og guides/webhooks', 'Render one page and open it')
935
- .example('mint og --preset headline --surface brand', 'Try settings on the home page')
936
- .example('mint og --output og.png --no-open', 'Render to a file in CI'),
937
- async (argv) => {
938
- await terminate(await ogCommand(argv));
939
- }
940
- )
941
- .command(
942
- ['version', 'v'],
943
- 'Display the current version of the CLI and client',
944
- () => undefined,
945
- async () => {
946
- const { cli, client } = getVersions(packageName);
947
- addLog(
948
- <Text>
949
- <Text bold color="green">
950
- cli version
951
- </Text>{' '}
952
- {cli}
953
- </Text>
954
- );
955
- addLog(
956
- <Text>
957
- <Text bold color="green">
958
- client version
959
- </Text>{' '}
960
- {client}
961
- </Text>
962
- );
963
- }
964
- )
965
- .command(
966
- 'new [directory]',
967
- 'Create a new Mintlify documentation site',
968
- (yargs) =>
969
- yargs
970
- .positional('directory', {
971
- describe: 'The directory to initialize your documentation',
972
- type: 'string',
973
- default: '.',
974
- })
975
- .option('theme', {
976
- type: 'string',
977
- description: 'Theme for the documentation site',
978
- })
979
- .option('name', {
980
- type: 'string',
981
- description: 'Name of the documentation project',
982
- })
983
- .option('template', {
984
- type: 'string',
985
- description: 'Use a template as a starting point',
986
- })
987
- .option('force', {
988
- type: 'boolean',
989
- default: false,
990
- description: 'Create the documentation in a subdirectory',
991
- }),
992
- async ({ directory, theme, name, force, template }) => {
993
- try {
994
- await init(directory, force, theme, name, template);
995
- await terminate(0);
996
- } catch (error) {
997
- addLog(
998
- <ErrorLog message={error instanceof Error ? error.message : 'error occurred'} />
999
- );
1000
- await terminate(1);
1001
- }
1002
- }
1003
- )
1004
- .command('analytics', 'View analytics for your documentation', analyticsBuilder)
1005
- .command(
1006
- ['automations', 'workflow', 'workflows'],
1007
- 'Create and manage automations',
1008
- workflowsBuilder
1009
- )
1010
- .command(
1011
- 'score [url]',
1012
- 'Run agent readiness checks on a docs site',
1013
- (yargs: Argv) =>
1014
- yargs
1015
- .positional('url', {
1016
- type: 'string',
1017
- description: 'URL of the docs site to check (defaults to your configured subdomain)',
1018
- })
1019
- .option('format', {
1020
- type: 'string',
1021
- choices: ['table', 'plain', 'json'] as const,
1022
- description: 'Output format',
1023
- })
1024
- .example('mint score', 'Run agent readiness checks on your default subdomain')
1025
- .example('mint score docs.example.com', 'Run agent readiness checks on a URL'),
1026
- scoreHandler
1027
- )
1028
- .command(
1029
- 'format',
1030
- 'Format MDX files in the current directory',
1031
- (yargs) =>
1032
- yargs
1033
- .usage('usage: mint format')
1034
- .example('mint format', 'format all MDX files in the current directory'),
1035
- formatHandler
1036
- )
1037
- .command(
1038
- 'migrate',
1039
- 'Print instructions for migrating a docs site to Mintlify',
1040
- (yargs: Argv) =>
1041
- yargs
1042
- .option('from', {
1043
- type: 'string',
1044
- choices: listMigrationDocs('sources'),
1045
- description: 'Include instructions for a source platform',
1046
- })
1047
- .option('topic', {
1048
- type: 'string',
1049
- choices: listMigrationDocs('topics'),
1050
- description: 'Print a single topic',
1051
- })
1052
- .option('agent', {
1053
- type: 'string',
1054
- choices: Object.keys(agents) as AgentName[],
1055
- description: 'Run the migration with a coding agent',
1056
- })
1057
- .option('claude', {
1058
- type: 'boolean',
1059
- description: 'Alias for --agent claude',
1060
- }),
1061
- async (argv) => {
1062
- const agent = argv.agent ?? (argv.claude ? 'claude' : undefined);
1063
- void trackEvent('cli.migrate.executed', {
1064
- from: argv.from,
1065
- topic: argv.topic,
1066
- agent,
1067
- });
1068
- if (agent) {
1069
- try {
1070
- return await terminate(await migrateWithAgent(agent, argv.from));
1071
- } catch (error) {
1072
- addLog(<ErrorLog message={error instanceof Error ? error.message : String(error)} />);
1073
- return await terminate(1);
1074
- }
1075
- }
1076
- await new Promise<void>((resolve) =>
1077
- process.stdout.write(migrationInstructions(argv), () => resolve())
1078
- );
1079
- await terminate(0);
1080
- }
1081
- )
1082
- // Coming soon commands — visible in help, tracked via telemetry to gauge interest.
1083
- .command(
1084
- 'ai',
1085
- '[Coming soon] AI-powered documentation (run mint ai to vote)',
1086
- () => undefined,
1087
- comingSoon('ai', packageName)
1088
- )
1089
- .command(
1090
- 'mcp',
1091
- '[Coming soon] MCP server for documentation (run mint mcp to vote)',
1092
- () => undefined,
1093
- comingSoon('mcp', packageName)
1094
- )
1095
- // Print the help menu when the user enters an invalid command.
1096
- .strictCommands()
1097
- .demandCommand(1, 'unknown command. see above for the list of supported commands.')
1098
-
1099
- // Alias option flags --help = -h, default --version = -v
1100
- .alias('h', 'help')
1101
- .alias('v', 'version')
1102
-
1103
- .parseAsync()
1104
- );
1105
- };