@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
package/bin/comingSoon.js DELETED
@@ -1,26 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import { addLog, SuccessLog, WarningLog } from '@mintlify/previewing';
12
- import { Text } from 'ink';
13
- import { isTelemetryEnabled } from './config.js';
14
- import { terminate } from './helpers.js';
15
- export function comingSoon(command, packageName) {
16
- return () => __awaiter(this, void 0, void 0, function* () {
17
- if (!isTelemetryEnabled()) {
18
- addLog(_jsx(WarningLog, { message: `Telemetry is disabled, so your vote won't be counted. Enable it with: ${packageName} --telemetry=true` }));
19
- }
20
- else {
21
- addLog(_jsx(SuccessLog, { message: `Thanks for your interest in "${packageName} ${command}"! Your vote has been counted.` }));
22
- }
23
- addLog(_jsx(Text, { dimColor: true, children: "This feature is currently in development. Learn more at https://mintlify.com/docs" }));
24
- yield terminate(0);
25
- });
26
- }
package/bin/config.js DELETED
@@ -1,78 +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 'fs';
11
- import { ensureDir } from 'fs-extra';
12
- import { z } from 'zod';
13
- import { CLI_CONFIG_FILE, CONFIG_DIR } from './constants.js';
14
- const agentSiteMetadataSchema = z.object({ registrationId: z.string(), subdomain: z.string() });
15
- export function getAgentSiteMetadata(key) {
16
- var _a;
17
- const parsed = agentSiteMetadataSchema.safeParse((_a = readConfig().agentSites) === null || _a === void 0 ? void 0 : _a[key]);
18
- return parsed.success ? parsed.data : undefined;
19
- }
20
- export function setAgentSiteMetadata(key, site) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- yield writeConfig({ agentSites: Object.assign(Object.assign({}, readConfig().agentSites), { [key]: site }) });
23
- });
24
- }
25
- function readConfig() {
26
- try {
27
- const raw = fs.readFileSync(CLI_CONFIG_FILE, 'utf-8');
28
- return JSON.parse(raw);
29
- }
30
- catch (_a) {
31
- return {};
32
- }
33
- }
34
- function writeConfig(updates) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- yield ensureDir(CONFIG_DIR);
37
- const existing = readConfig();
38
- fs.writeFileSync(CLI_CONFIG_FILE, JSON.stringify(Object.assign(Object.assign({}, existing), updates), null, 2));
39
- });
40
- }
41
- export function isTelemetryEnabled() {
42
- if (process.env.CLI_TEST_MODE === 'true')
43
- return false;
44
- if (process.env.MINTLIFY_TELEMETRY_DISABLED === '1')
45
- return false;
46
- if (process.env.DO_NOT_TRACK === '1')
47
- return false;
48
- return readConfig().telemetryEnabled !== false;
49
- }
50
- export function setTelemetryEnabled(enabled) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- yield writeConfig({ telemetryEnabled: enabled });
53
- });
54
- }
55
- export function getConfigValue(key) {
56
- const config = readConfig();
57
- return config[key];
58
- }
59
- export function setConfigValue(key, value) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- yield writeConfig({ [key]: value });
62
- });
63
- }
64
- export function clearConfigValue(key) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- yield writeConfig({ [key]: undefined });
67
- });
68
- }
69
- export function hasShownPublishPrompt(dir) {
70
- var _a, _b;
71
- return (_b = (_a = readConfig().publishPromptShown) === null || _a === void 0 ? void 0 : _a.includes(dir)) !== null && _b !== void 0 ? _b : false;
72
- }
73
- export function markPublishPromptShown(dir) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- var _a;
76
- yield writeConfig({ publishPromptShown: [...((_a = readConfig().publishPromptShown) !== null && _a !== void 0 ? _a : []), dir] });
77
- });
78
- }
package/bin/constants.js DELETED
@@ -1,16 +0,0 @@
1
- var _a, _b;
2
- import { LOCAL_LINKED_CLI_VERSION } from '@mintlify/previewing';
3
- import os from 'os';
4
- import path from 'path';
5
- import { getCliVersion } from './helpers.js';
6
- export const HOME_DIR = os.homedir();
7
- export const CONFIG_DIR = path.join(HOME_DIR, '.config', 'mintlify');
8
- export const CLI_CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
9
- export const TELEMETRY_ASYNC_TIMEOUT_MS = 10000;
10
- export const TELEMETRY_IDENTITY_TIMEOUT_MS = 3000;
11
- export const CALLBACK_PORT = 11582;
12
- const IS_LOCAL_BUILD = process.env.CLI_TEST_MODE === 'true' ? true : getCliVersion() == LOCAL_LINKED_CLI_VERSION;
13
- export const API_URL = (_a = process.env.MINTLIFY_API_URL) !== null && _a !== void 0 ? _a : (IS_LOCAL_BUILD ? 'http://localhost:5000' : 'https://leaves.mintlify.com');
14
- export const DASHBOARD_URL = (_b = process.env.MINTLIFY_DASHBOARD_URL) !== null && _b !== void 0 ? _b : (IS_LOCAL_BUILD ? 'http://localhost:3000' : 'https://app.mintlify.com');
15
- export const TOKEN_ENDPOINT = `${API_URL}/api/oauth-token/cli`;
16
- export const CUSTOM_DOMAIN_CNAME_TARGET = 'cname.mintlify.builders';
@@ -1,20 +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 { git } from './deploy-github-actions.js';
11
- export function pushBaseCheckout(checkout, write) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- const env = Object.assign(Object.assign({}, process.env), { GIT_CONFIG_COUNT: '1', GIT_CONFIG_KEY_0: `http.${write.remote}.extraHeader`, GIT_CONFIG_VALUE_0: `Authorization: Bearer ${write.token}` });
14
- yield git(['fetch', write.remote, write.branch], checkout, env);
15
- yield git(['rebase', 'FETCH_HEAD'], checkout, env).catch(() => {
16
- throw new Error(`Could not rebase ${checkout} onto the latest ${write.branch}. Resolve the conflicts, run git rebase --continue, then rerun mint deploy --base --push ${checkout}.`);
17
- });
18
- yield git(['push', write.remote, `HEAD:refs/heads/${write.branch}`], checkout, env);
19
- });
20
- }
@@ -1,102 +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 { spawn } from 'node:child_process';
11
- import path from 'node:path';
12
- import { z } from 'zod';
13
- import { getGithubActionsWriteToken } from './agent-deployment.js';
14
- import { AgentApiError } from './agent-http.js';
15
- import { agentSiteUrl } from './deploy.js';
16
- const oidcSchema = z.object({ value: z.string().min(1) });
17
- export function isGithubActions(env = process.env) {
18
- return env.GITHUB_ACTIONS === 'true';
19
- }
20
- function getGithubOidcToken(env, audience) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const requestUrl = env.ACTIONS_ID_TOKEN_REQUEST_URL;
23
- const requestToken = env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
24
- if (!requestUrl || !requestToken) {
25
- throw new Error('GitHub Actions did not provide an OIDC token. Add `permissions: id-token: write` to the workflow or job.');
26
- }
27
- let response;
28
- try {
29
- response = yield fetch(`${requestUrl}&audience=${encodeURIComponent(audience)}`, {
30
- headers: { Authorization: `Bearer ${requestToken}` },
31
- signal: AbortSignal.timeout(30000),
32
- });
33
- }
34
- catch (_a) {
35
- throw new Error('Could not request a GitHub Actions OIDC token. Retry the workflow.');
36
- }
37
- const parsed = oidcSchema.safeParse(yield response.json().catch(() => null));
38
- if (!response.ok || !parsed.success) {
39
- throw new Error(`Could not get a GitHub Actions OIDC token (HTTP ${response.status}). Check that the workflow has \`permissions: id-token: write\`.`);
40
- }
41
- return parsed.data.value;
42
- });
43
- }
44
- export function git(args, cwd, env) {
45
- return new Promise((resolve, reject) => {
46
- const child = spawn('git', args, { cwd, env, stdio: ['ignore', 'pipe', 'inherit'] });
47
- let out = '';
48
- child.stdout.on('data', (chunk) => (out += chunk.toString()));
49
- child.on('error', reject);
50
- child.on('close', (code) => code === 0 ? resolve(out.trim()) : reject(new Error(`git ${args[0]} failed`)));
51
- });
52
- }
53
- function commitDirectory(directory, env) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- const prefix = yield git(['rev-parse', '--show-prefix'], directory, env);
56
- const tree = yield git(['rev-parse', `HEAD:${prefix}`], directory, env);
57
- const [name = '', email = '', date = '', sha = '', subject = ''] = (yield git(['log', '-1', '--format=%an%n%ae%n%aI%n%H%n%s'], directory, env)).split('\n');
58
- const repository = env.GITHUB_REPOSITORY ? `${env.GITHUB_REPOSITORY}@` : '';
59
- return git(['commit-tree', tree, '-m', subject, '-m', `Deployed from ${repository}${sha}`], directory, Object.assign(Object.assign({}, env), { GIT_AUTHOR_NAME: name, GIT_AUTHOR_EMAIL: email, GIT_AUTHOR_DATE: date, GIT_COMMITTER_NAME: name, GIT_COMMITTER_EMAIL: email }));
60
- });
61
- }
62
- function pushCommit(directory, commit, write, env) {
63
- const index = Number(env.GIT_CONFIG_COUNT) || 0;
64
- const credentials = Buffer.from(`x-access-token:${write.token}`).toString('base64');
65
- return new Promise((resolve, reject) => {
66
- const child = spawn('git', ['push', '--force', write.remote, `${commit}:refs/heads/${write.branch}`], {
67
- cwd: directory,
68
- stdio: ['ignore', 'inherit', 'inherit'],
69
- env: Object.assign(Object.assign({}, env), { GIT_CONFIG_COUNT: String(index + 1), [`GIT_CONFIG_KEY_${index}`]: `http.${write.remote}.extraHeader`, [`GIT_CONFIG_VALUE_${index}`]: `Authorization: Basic ${credentials}` }),
70
- });
71
- const failed = () => reject(new Error('git push to the site repository failed.'));
72
- child.on('error', failed);
73
- child.on('close', (code) => (code === 0 ? resolve() : failed()));
74
- });
75
- }
76
- export function deployFromGithubActions(options_1) {
77
- return __awaiter(this, arguments, void 0, function* (options, progress = () => { }, env = process.env) {
78
- const { apiUrl, subdomain } = options;
79
- if (!subdomain)
80
- throw new Error('Pass the site name with --subdomain <name>.');
81
- const directory = path.resolve(options.directory);
82
- const commit = yield commitDirectory(directory, env).catch(() => {
83
- throw new Error(`Could not read ${options.directory} from the checked-out commit. Run mint deploy after actions/checkout, with --directory inside the repository.`);
84
- });
85
- progress('Requesting a GitHub Actions identity token...');
86
- const oidcToken = yield getGithubOidcToken(env, apiUrl);
87
- progress('Getting repository write access...');
88
- let write;
89
- try {
90
- write = yield getGithubActionsWriteToken(apiUrl, oidcToken, subdomain);
91
- }
92
- catch (error) {
93
- if (error instanceof AgentApiError && error.status === 403) {
94
- throw new Error(`This repository/branch isn't trusted to deploy ${subdomain}. Run \`mint deploy --github\` locally from this repository to trust it.`);
95
- }
96
- throw error;
97
- }
98
- progress('Pushing to the site repository...');
99
- yield pushCommit(directory, commit, write, env);
100
- return agentSiteUrl(apiUrl, subdomain);
101
- });
102
- }
@@ -1,165 +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 { execFile } from 'node:child_process';
11
- import fs from 'node:fs/promises';
12
- import path from 'node:path';
13
- import { z } from 'zod';
14
- import { trustGithubRepo } from './agent-deployment.js';
15
- import { CLAIM_INSTRUCTIONS } from './deploy-instructions.js';
16
- import { agentSiteUrl, prepareAgentDeployment } from './deploy.js';
17
- const githubRepoSchema = z.object({
18
- id: z.number().int().positive(),
19
- full_name: z.string().regex(/^[\w.-]+\/[\w.-]+$/),
20
- default_branch: z.string().min(1),
21
- });
22
- export const GITHUB_WORKFLOW_PATH = path.join('.github', 'workflows', 'mintlify.yml');
23
- function run(command, args, cwd) {
24
- return new Promise((resolve, reject) => {
25
- execFile(command, args, { cwd }, (error, stdout) => error ? reject(error) : resolve(String(stdout).trim()));
26
- });
27
- }
28
- export function parseGithubRemote(remote) {
29
- const match = remote
30
- .trim()
31
- .match(/^(?:https:\/\/(?:[^@/]+@)?github\.com\/|ssh:\/\/git@github\.com(?::\d+)?\/|git@github\.com:)([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/);
32
- return (match === null || match === void 0 ? void 0 : match[1]) && match[2] ? { owner: match[1], repo: match[2] } : null;
33
- }
34
- export function githubWorkflow(branch, subdomain, docsPath = '') {
35
- const directory = /^[\w./-]+$/.test(docsPath) ? docsPath : JSON.stringify(docsPath);
36
- return [
37
- 'name: Deploy to Mintlify',
38
- 'on:',
39
- ' push:',
40
- ` branches: [${JSON.stringify(branch)}]`,
41
- ...(docsPath
42
- ? [` paths: [${JSON.stringify(`${docsPath}/**`)}, ".github/workflows/mintlify.yml"]`]
43
- : []),
44
- 'permissions:',
45
- ' id-token: write',
46
- ' contents: read',
47
- 'concurrency:',
48
- ' group: mintlify-deploy',
49
- ' cancel-in-progress: true',
50
- 'jobs:',
51
- ' deploy:',
52
- ' runs-on: ubuntu-latest',
53
- ' steps:',
54
- ' - uses: actions/checkout@v4',
55
- ` - run: npx mint@latest deploy --subdomain ${subdomain}${docsPath ? ` --directory ${directory}` : ''}`,
56
- '',
57
- ].join('\n');
58
- }
59
- function readFileIfExists(file) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- return fs.readFile(file, 'utf8').catch((error) => {
62
- if (error.code === 'ENOENT')
63
- return undefined;
64
- throw error;
65
- });
66
- });
67
- }
68
- export function writeGithubWorkflow(root_1, contents_1) {
69
- return __awaiter(this, arguments, void 0, function* (root, contents, force = false) {
70
- const file = path.join(root, GITHUB_WORKFLOW_PATH);
71
- const existing = yield readFileIfExists(file);
72
- if (existing === contents)
73
- return 'unchanged';
74
- if (existing !== undefined && !force) {
75
- throw new Error(`${GITHUB_WORKFLOW_PATH} already exists with different contents. Pass --force to overwrite it.`);
76
- }
77
- yield fs.mkdir(path.dirname(file), { recursive: true });
78
- yield fs.writeFile(file, contents);
79
- return existing === undefined ? 'created' : 'updated';
80
- });
81
- }
82
- export function findGitRoot(directory) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- try {
85
- return yield run('git', ['rev-parse', '--show-toplevel'], directory);
86
- }
87
- catch (_a) {
88
- throw new Error('--github requires a Git repository. Run it inside your docs repository.');
89
- }
90
- });
91
- }
92
- export function resolveGithubRepo(root) {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- const remote = yield run('git', ['remote', 'get-url', 'origin'], root).catch(() => {
95
- throw new Error('This repository has no origin remote. Add a github.com origin and retry.');
96
- });
97
- const parsed = parseGithubRemote(remote);
98
- if (!parsed)
99
- throw new Error(`The origin remote (${remote}) is not a github.com repository.`);
100
- const output = yield run('gh', [
101
- 'api',
102
- `repos/${parsed.owner}/${parsed.repo}`,
103
- '--jq',
104
- '{id: .id, full_name: .full_name, default_branch: .default_branch}',
105
- ], root).catch((error) => {
106
- if (error.code === 'ENOENT')
107
- throw new Error('The GitHub CLI (gh) is required. Install it and run `gh auth login`.');
108
- throw new Error(`Could not read ${parsed.owner}/${parsed.repo} with gh. Run \`gh auth login\` with access to the repository and retry.`);
109
- });
110
- try {
111
- return githubRepoSchema.parse(JSON.parse(output));
112
- }
113
- catch (_a) {
114
- throw new Error('gh returned an unexpected repository response.');
115
- }
116
- });
117
- }
118
- export function setupGithubDeployment(options_1, warn_1) {
119
- return __awaiter(this, arguments, void 0, function* (options, warn, progress = () => { }) {
120
- const directory = path.resolve(options.directory);
121
- const root = yield findGitRoot(directory);
122
- const [realRoot, realDirectory] = yield Promise.all([fs.realpath(root), fs.realpath(directory)]);
123
- const docsPath = path.relative(realRoot, realDirectory).split(path.sep).join('/');
124
- if (!(yield readFileIfExists(path.join(directory, 'docs.json')))) {
125
- throw new Error(`No docs.json in ${directory}. Pass the docs folder with --directory.`);
126
- }
127
- progress('Resolving the GitHub repository...');
128
- const repo = yield resolveGithubRepo(root);
129
- const result = yield prepareAgentDeployment(options, warn, progress);
130
- if (result.status === 'claimed') {
131
- throw new Error('This site has been claimed. Setting up GitHub deploys for claimed sites is not supported yet; connect the repository from the Mintlify dashboard.');
132
- }
133
- const accessToken = result.credentials.accessToken;
134
- if (!accessToken)
135
- throw new Error('Agent authentication did not return an access token.');
136
- progress(`Trusting ${repo.full_name}@${repo.default_branch} to deploy...`);
137
- yield trustGithubRepo(options.apiUrl, accessToken, {
138
- repositoryId: String(repo.id),
139
- repository: repo.full_name,
140
- branch: repo.default_branch,
141
- });
142
- const workflow = yield writeGithubWorkflow(root, githubWorkflow(repo.default_branch, result.site.subdomain, docsPath), options.force);
143
- return {
144
- siteUrl: agentSiteUrl(options.apiUrl, result.site.subdomain),
145
- subdomain: result.site.subdomain,
146
- repository: repo.full_name,
147
- branch: repo.default_branch,
148
- workflowPath: GITHUB_WORKFLOW_PATH,
149
- workflow,
150
- };
151
- });
152
- }
153
- export function formatGithubSetup(result) {
154
- return [
155
- `Site: ${result.siteUrl}`,
156
- `Trusted repository: ${result.repository} (branch ${result.branch})`,
157
- `Workflow: ${result.workflowPath} (${result.workflow})`,
158
- '',
159
- 'Next steps:',
160
- `1. Commit and push ${result.workflowPath} to ${result.branch}.`,
161
- `2. Every push to ${result.branch} then deploys ${result.subdomain} through GitHub Actions. No secrets are stored in the repository.`,
162
- '',
163
- ...CLAIM_INSTRUCTIONS,
164
- ].join('\n');
165
- }
@@ -1,71 +0,0 @@
1
- export const DEPLOY_HELP = [
2
- 'No login is required. This command provisions a temporary site and returns repository access. Commit and push the documentation yourself; the CLI does not upload files.',
3
- 'Run from your documentation directory, or pass --directory. Put docs.json, pages, and assets at the hosted repository root.',
4
- 'Run again from the same documentation directory for the current anonymous site and a fresh write token. Use --new --subdomain <name> to create another site.',
5
- 'Claimed sites are managed in the dashboard. Confirmed expired sites start a new anonymous registration.',
6
- 'Pass --email to obtain a claim link for the user. If it is absent, ask the user for their email and rerun with --email from the same directory. Never invent an email address.',
7
- 'To claim an existing site without provisioning, run mint claim --email <email>. Show the link to the user and ask them to return the displayed code. Then run mint claim --code <code>. Use the original documentation directory for both commands, or pass --directory.',
8
- 'The output contains a short-lived write token. Do not paste it into public logs or save it in a Git remote.',
9
- 'Pass --github from the root of a GitHub repository to deploy on every push: it trusts the repository (via the gh CLI and the origin remote) to deploy the site and writes .github/workflows/mintlify.yml. Commit and push that workflow. Pass --directory to deploy a docs subdirectory of the repository as the site root. Use --force to overwrite a different existing workflow.',
10
- 'Pass --base to provision a base instead of a docs site. The output has the claim steps, a clone command, and the editor link; there is no site URL. Commit in the clone, then run mint deploy --base --push <clone-directory> to publish. --base cannot be combined with --github.',
11
- 'In GitHub Actions (GITHUB_ACTIONS=true), no agent credentials are used: the workflow needs `permissions: id-token: write`, --subdomain is required, and the current commit is force-pushed to the site from a trusted repository and branch.',
12
- ].join('\n\n');
13
- export const CLAIM_INSTRUCTIONS = [
14
- 'Ask the user for the email address they want to use to claim this site. Never invent an email address.',
15
- 'After they provide it, run mint deploy --email <their-email> from the same documentation directory (or repeat --directory). This reuses the site and returns its claim link.',
16
- ];
17
- const baseClaimStep = (claimUrl) => claimUrl
18
- ? [
19
- `3. Claim the base last. Send the user this link: ${claimUrl}`,
20
- ' They sign in and get a code. When they give it to you, run: mint claim --code <code>',
21
- ]
22
- : [
23
- '3. Claim the base last. Ask the user for their email (never invent one), then run:',
24
- ' mint deploy --base --email <their-email>',
25
- ' Send the user the claim link it prints. They sign in and get a code. When they give it to you, run: mint claim --code <code>',
26
- ];
27
- function baseInstructions(result, claimUrl) {
28
- const { site, write } = result;
29
- const checkout = site.subdomain;
30
- return [
31
- '\nNext steps:',
32
- `1. Clone the base into ./${checkout}:`,
33
- ` git -c http.${write.remote}.extraHeader="Authorization: Bearer ${write.token}" clone ${write.remote} ${checkout}`,
34
- ` The clone command works until ${write.tokenExpiresAt}. Run mint deploy --base again for a fresh one.`,
35
- `2. Commit your changes in ./${checkout}, then publish them:`,
36
- ` mint deploy --base --push ${checkout}`,
37
- ' This rebases onto the latest main and pushes. Do not run git push yourself.',
38
- ...baseClaimStep(claimUrl),
39
- ' After the claim, the user opens the base at the editor link above and edits it there. The CLI can no longer push to it.',
40
- 'Run every mint command from this directory (or repeat --directory).',
41
- ].join('\n');
42
- }
43
- export function deploymentInstructions(result, claimUrl) {
44
- if (result.status !== 'ready')
45
- return '';
46
- if (result.projectType === 'workspace')
47
- return baseInstructions(result, claimUrl);
48
- return [
49
- '\nNext steps:',
50
- '1. Clone the hosted repository into a separate directory. Do not replace the user’s existing Git remote.',
51
- '2. Copy the selected documentation into its root, including docs.json, .md/.mdx pages, images, and other required assets. Exclude credentials, .env files, node_modules, and .git.',
52
- '3. Commit the documentation. For subsequent updates, fetch the hosted main branch and commit on top of it. Do not force-push.',
53
- '4. Push to main. Supply the write token as an HTTP Authorization: Bearer header for this Git operation only; never embed it in the remote URL or persist it in Git config.',
54
- '5. If the write token expires, run mint deploy again from the same documentation directory to obtain a fresh token.',
55
- 'A successful push starts the normal build. Provisioning and Git success do not confirm build success.',
56
- '',
57
- 'Git examples (POSIX shell): set REPOSITORY_URL and WRITE_TOKEN from the output above. Set CHECKOUT_DIR to a new directory outside the source documentation directory. Keep the token private and do not enable shell tracing.',
58
- 'GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.${REPOSITORY_URL}.extraHeader" GIT_CONFIG_VALUE_0="Authorization: Bearer ${WRITE_TOKEN}" git clone "$REPOSITORY_URL" "$CHECKOUT_DIR"',
59
- 'After copying and committing the documentation:',
60
- 'GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.${REPOSITORY_URL}.extraHeader" GIT_CONFIG_VALUE_0="Authorization: Bearer ${WRITE_TOKEN}" git -C "$CHECKOUT_DIR" push origin HEAD:main',
61
- 'These settings apply only to that Git process. Use the same authentication settings for later fetches.',
62
- '',
63
- ...(claimUrl
64
- ? [
65
- `Claim link for the user: ${claimUrl}`,
66
- 'Show this link to the user. Ask them to open it, sign in, and return the displayed code. Do not sign in on their behalf.',
67
- 'After the user returns the code, run mint claim --code <code> from the same documentation directory (or repeat --directory). The CLI completes the claim using its saved credentials.',
68
- ]
69
- : CLAIM_INSTRUCTIONS),
70
- ].join('\n');
71
- }
package/bin/deploy.js DELETED
@@ -1,123 +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 path from 'node:path';
11
- import { discoverAgentAuth, exchangeAgentToken, getAgentIdentity, registerAgent, } from './agent-auth.js';
12
- import { loadAgentCredentials, saveAgentCredentials, } from './agent-credentials.js';
13
- import { getAgentWriteToken, provisionAgentSite, } from './agent-deployment.js';
14
- import { getAgentSiteMetadata, setAgentSiteMetadata } from './config.js';
15
- import { DASHBOARD_URL } from './constants.js';
16
- import { trackEvent } from './telemetry/track.js';
17
- export function prepareAgentDeployment(options_1, warn_1) {
18
- return __awaiter(this, arguments, void 0, function* (options, warn, progress = () => { }) {
19
- var _a;
20
- const { apiUrl } = options;
21
- const directory = path.resolve(options.directory);
22
- const metadataKey = JSON.stringify([new URL(apiUrl).origin, directory]);
23
- const previous = getAgentSiteMetadata(metadataKey);
24
- progress('Authenticating agent...');
25
- let saved = options.newSite
26
- ? null
27
- : yield loadAgentCredentials(apiUrl, directory).catch(() => {
28
- if (previous)
29
- throw new Error('Could not read this site’s saved credentials. Unlock your keyring or use --new for another site.');
30
- warn('Could not read the keyring. Continuing with a new registration for this run.');
31
- return null;
32
- });
33
- const subdomain = (_a = options.subdomain) !== null && _a !== void 0 ? _a : (options.newSite ? undefined : previous === null || previous === void 0 ? void 0 : previous.subdomain);
34
- if (!subdomain)
35
- throw new Error('Choose a site name with --subdomain <name>.');
36
- const discovery = yield discoverAgentAuth(apiUrl);
37
- const projectType = options.base ? 'workspace' : 'site';
38
- const save = (credentials) => saveAgentCredentials(apiUrl, directory, credentials);
39
- for (let attempt = 0; attempt < 2; attempt++) {
40
- const credentials = saved !== null && saved !== void 0 ? saved : (yield registerAgent(discovery));
41
- void trackEvent('agent_signup.discovered', { registration_id: credentials.registrationId });
42
- if (!saved)
43
- void trackEvent('agent_signup.registered', { registration_id: credentials.registrationId });
44
- yield save(credentials);
45
- const authenticated = yield exchangeAgentToken(discovery, credentials);
46
- yield save(authenticated);
47
- const identity = yield getAgentIdentity(apiUrl, authenticated.accessToken);
48
- if (identity.registrationId !== credentials.registrationId)
49
- throw new Error('Agent identity does not match the saved registration.');
50
- if (identity.identityType === 'user_bound')
51
- return { status: 'claimed' };
52
- progress(`Provisioning the ${options.base ? 'base' : 'site'} and repository...`);
53
- const site = yield provisionAgentSite(apiUrl, authenticated.accessToken, Object.assign({ subdomain, orgName: options.orgName }, (options.base && { projectType })));
54
- if (site.status === 'expired') {
55
- warn('The previous anonymous site expired. Creating a new registration and site.');
56
- saved = null;
57
- continue;
58
- }
59
- void trackEvent('cli.deploy.provisioned', {
60
- registration_id: credentials.registrationId,
61
- deployment_id: site.deploymentId,
62
- subdomain: site.subdomain,
63
- created: site.created,
64
- });
65
- yield setAgentSiteMetadata(metadataKey, {
66
- registrationId: credentials.registrationId,
67
- subdomain: site.subdomain,
68
- }).catch(() => warn('Could not save the site name locally. Provide --subdomain on your next invocation.'));
69
- progress('Getting repository write access...');
70
- const write = yield getAgentWriteToken(apiUrl, authenticated.accessToken);
71
- if (write.remote !== site.remote)
72
- throw new Error('Repository credentials do not match the provisioned site.');
73
- return {
74
- status: 'ready',
75
- projectType,
76
- site,
77
- write,
78
- created: site.created,
79
- credentials: authenticated,
80
- };
81
- }
82
- throw new Error('The new anonymous site is already expired. Please retry later.');
83
- });
84
- }
85
- export function agentSiteUrl(apiUrl, subdomain) {
86
- const domain = new URL(apiUrl).hostname === 'leaves-dev.mintlify.com'
87
- ? 'mint-dev.mintlify.me'
88
- : 'mintlify.site';
89
- return new URL(`https://${subdomain}.${domain}`).toString();
90
- }
91
- export function agentEditorUrl(site) {
92
- return site.orgSlug
93
- ? new URL(`/${site.orgSlug}/${site.subdomain}/editor`, DASHBOARD_URL).toString()
94
- : new URL(DASHBOARD_URL).toString();
95
- }
96
- export function formatDeployment(result, apiUrl) {
97
- if (result.status === 'claimed')
98
- return 'This site has been claimed. Manage it in the Mintlify dashboard. Use mint deploy --new --subdomain <name> to create another site.';
99
- const { site, write } = result;
100
- const access = [
101
- `Repository: ${site.remote}`,
102
- `Branch: ${site.branch}`,
103
- `Write token: ${write.token}`,
104
- `Write token expires: ${write.tokenExpiresAt}`,
105
- ];
106
- if (result.projectType === 'workspace')
107
- return [
108
- result.created ? 'Base provisioned.' : 'Using the existing anonymous base.',
109
- `Editor: ${agentEditorUrl(site)}`,
110
- `Expires: ${site.expiresAt}. Claim it before then or it is deleted.`,
111
- ].join('\n');
112
- const siteUrl = agentSiteUrl(apiUrl, site.subdomain);
113
- return [
114
- result.created
115
- ? 'Repository provisioned; push required to build the site.'
116
- : 'Using the existing anonymous repository; push any changes to build the site.',
117
- `Site: ${siteUrl}`,
118
- `Expires: ${site.expiresAt}`,
119
- ...access,
120
- 'Commit and push your documentation to this repository to start the build.',
121
- 'The site link becomes available after the push and build complete.',
122
- ].join('\n');
123
- }
package/bin/feedback.js DELETED
@@ -1,36 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import { addLog, ErrorLog, SuccessLog } from '@mintlify/previewing';
12
- import { API_URL } from './constants.js';
13
- export const FEEDBACK_CATEGORIES = ['bug', 'docs', 'idea'];
14
- export function sendFeedback(input) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- let res;
17
- try {
18
- res = yield fetch(`${API_URL}/api/cli/feedback`, {
19
- method: 'POST',
20
- headers: { 'Content-Type': 'application/json' },
21
- body: JSON.stringify(Object.assign(Object.assign({}, input), { source: 'cli' })),
22
- });
23
- }
24
- catch (_a) {
25
- return 'could not reach the server';
26
- }
27
- return res.ok ? undefined : `could not send feedback (HTTP ${res.status})`;
28
- });
29
- }
30
- export function feedback(input) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const error = yield sendFeedback(input);
33
- addLog(error ? _jsx(ErrorLog, { message: error }) : _jsx(SuccessLog, { message: "feedback sent" }));
34
- return !error;
35
- });
36
- }