@mintlify/cli 4.0.1813 → 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.
- package/dist/assets/export-scripts/README.classic.md +15 -0
- package/dist/assets/export-scripts/README.md +14 -0
- package/dist/assets/export-scripts/serve.js +114 -0
- package/dist/assets/export-scripts/start-docs.bat +10 -0
- package/dist/assets/export-scripts/start-docs.sh +9 -0
- package/dist/assets/og/Inter-Bold.ttf +0 -0
- package/dist/assets/og/Inter-Medium.ttf +0 -0
- package/dist/assets/og/Inter-Regular.ttf +0 -0
- package/dist/assets/og/Inter-SemiBold.ttf +0 -0
- package/dist/assets/og/PaperMono-Regular.ttf +0 -0
- package/dist/assets/og/index_bg.wasm +0 -0
- package/dist/assets/openChrome.applescript +94 -0
- package/dist/assets/socket.io/socket.io.esm.min.js +7 -0
- package/dist/assets/socket.io/socket.io.esm.min.js.map +1 -0
- package/dist/assets/socket.io/socket.io.js +4907 -0
- package/dist/assets/socket.io/socket.io.js.map +1 -0
- package/dist/assets/socket.io/socket.io.min.js +7 -0
- package/dist/assets/socket.io/socket.io.min.js.map +1 -0
- package/dist/assets/socket.io/socket.io.msgpack.min.js +7 -0
- package/dist/assets/socket.io/socket.io.msgpack.min.js.map +1 -0
- package/dist/assets/xdg-open +1066 -0
- package/dist/assets/yargs-locales/be.json +46 -0
- package/dist/assets/yargs-locales/cs.json +51 -0
- package/dist/assets/yargs-locales/de.json +46 -0
- package/dist/assets/yargs-locales/en.json +55 -0
- package/dist/assets/yargs-locales/es.json +46 -0
- package/dist/assets/yargs-locales/fi.json +49 -0
- package/dist/assets/yargs-locales/fr.json +53 -0
- package/dist/assets/yargs-locales/hi.json +49 -0
- package/dist/assets/yargs-locales/hu.json +46 -0
- package/dist/assets/yargs-locales/id.json +50 -0
- package/dist/assets/yargs-locales/it.json +46 -0
- package/dist/assets/yargs-locales/ja.json +51 -0
- package/dist/assets/yargs-locales/ko.json +49 -0
- package/dist/assets/yargs-locales/nb.json +44 -0
- package/dist/assets/yargs-locales/nl.json +49 -0
- package/dist/assets/yargs-locales/nn.json +44 -0
- package/dist/assets/yargs-locales/pirate.json +13 -0
- package/dist/assets/yargs-locales/pl.json +49 -0
- package/dist/assets/yargs-locales/pt.json +45 -0
- package/dist/assets/yargs-locales/pt_BR.json +48 -0
- package/dist/assets/yargs-locales/ru.json +51 -0
- package/dist/assets/yargs-locales/th.json +46 -0
- package/dist/assets/yargs-locales/tr.json +48 -0
- package/dist/assets/yargs-locales/uk_UA.json +51 -0
- package/dist/assets/yargs-locales/uz.json +52 -0
- package/dist/assets/yargs-locales/zh_CN.json +48 -0
- package/dist/assets/yargs-locales/zh_TW.json +51 -0
- package/dist/converter-d8O3xkdU.js +102 -0
- package/dist/devtools-CGNZQKFV.js +24 -0
- package/dist/index.js +8 -0
- package/dist/rolldown-runtime-CEAe2Uac.js +7 -0
- package/dist/schemas-CBsmCNpK.js +372 -0
- package/dist/start.js +2310 -0
- package/package.json +38 -31
- package/.oxlintrc.json +0 -5
- package/.prettierignore +0 -2
- package/.turbo/turbo-build.log +0 -1
- package/CONTRIBUTING.md +0 -45
- package/__test__/agent-auth.test.ts +0 -114
- package/__test__/agent-claim.test.ts +0 -164
- package/__test__/agent-credentials.test.ts +0 -149
- package/__test__/agent-deployment.test.ts +0 -106
- package/__test__/agent-setup-config.test.ts +0 -324
- package/__test__/agent-setup.test.ts +0 -207
- package/__test__/agent.test.ts +0 -64
- package/__test__/analytics/client.test.ts +0 -180
- package/__test__/analytics/dates.test.ts +0 -12
- package/__test__/analytics/filters.test.ts +0 -116
- package/__test__/analytics/format.test.ts +0 -137
- package/__test__/authenticatedFetch.test.ts +0 -182
- package/__test__/brokenLinks.test.ts +0 -283
- package/__test__/checkPort.test.ts +0 -92
- package/__test__/deploy-github-actions.test.ts +0 -202
- package/__test__/deploy-github-setup.test.ts +0 -240
- package/__test__/deploy-instructions.test.ts +0 -155
- package/__test__/deploy.test.ts +0 -202
- package/__test__/feedback.test.ts +0 -34
- package/__test__/foreignSyntax.test.ts +0 -73
- package/__test__/format.test.ts +0 -72
- package/__test__/helpers.test.ts +0 -52
- package/__test__/init.test.ts +0 -119
- package/__test__/instructions.test.ts +0 -53
- package/__test__/keyring.test.ts +0 -82
- package/__test__/mdxAccessibility.test.ts +0 -81
- package/__test__/migrate.test.ts +0 -186
- package/__test__/openApiCheck.test.ts +0 -185
- package/__test__/pathValidation.test.ts +0 -25
- package/__test__/resolveFiles.test.ts +0 -70
- package/__test__/sessionId.test.ts +0 -46
- package/__test__/signup.test.ts +0 -36
- package/__test__/update.test.ts +0 -117
- package/__test__/utils.ts +0 -25
- package/__test__/validateCommand.test.ts +0 -647
- package/__test__/validateEngine.test.ts +0 -245
- package/__test__/validateRules.test.ts +0 -1275
- package/__test__/welcome.test.ts +0 -15
- package/__test__/workflows/client.test.ts +0 -126
- package/bin/accessibility.js +0 -111
- package/bin/accessibilityCheck.js +0 -82
- package/bin/addDomain.js +0 -130
- package/bin/agent-auth.js +0 -104
- package/bin/agent-claim.js +0 -97
- package/bin/agent-credentials.js +0 -124
- package/bin/agent-deployment.js +0 -96
- package/bin/agent-http.js +0 -45
- package/bin/agent-setup-config.js +0 -141
- package/bin/agent-setup.js +0 -146
- package/bin/agent.js +0 -42
- package/bin/analytics/client.js +0 -60
- package/bin/analytics/dates.js +0 -6
- package/bin/analytics/filters.js +0 -27
- package/bin/analytics/format.js +0 -13
- package/bin/analytics/index.js +0 -496
- package/bin/analytics/output.js +0 -75
- package/bin/analytics/types.js +0 -1
- package/bin/authenticatedFetch.js +0 -46
- package/bin/brokenLinks.js +0 -122
- package/bin/callbackServer.js +0 -65
- package/bin/cli.js +0 -813
- package/bin/comingSoon.js +0 -26
- package/bin/config.js +0 -78
- package/bin/constants.js +0 -16
- package/bin/deploy-base.js +0 -20
- package/bin/deploy-github-actions.js +0 -102
- package/bin/deploy-github-setup.js +0 -165
- package/bin/deploy-instructions.js +0 -71
- package/bin/deploy.js +0 -123
- package/bin/feedback.js +0 -36
- package/bin/format.js +0 -121
- package/bin/helpers.js +0 -238
- package/bin/idToken.js +0 -14
- package/bin/index.js +0 -102
- package/bin/init.js +0 -182
- package/bin/instructions.js +0 -101
- package/bin/keyring.js +0 -78
- package/bin/login.js +0 -123
- package/bin/logout.js +0 -18
- package/bin/mdxAccessibility.js +0 -113
- package/bin/mdxLinter.js +0 -55
- package/bin/middlewares/subdomainMiddleware.js +0 -28
- package/bin/middlewares/telemetryMiddleware.js +0 -61
- package/bin/migrate.js +0 -54
- package/bin/og.js +0 -145
- package/bin/openApiCheck.js +0 -99
- package/bin/resolveFiles.js +0 -114
- package/bin/score/client.js +0 -40
- package/bin/score/index.js +0 -211
- package/bin/score/types.js +0 -1
- package/bin/signup.js +0 -118
- package/bin/start.js +0 -36
- package/bin/status.js +0 -106
- package/bin/telemetry/client.js +0 -53
- package/bin/telemetry/distinctId.js +0 -68
- package/bin/telemetry/sessionId.js +0 -36
- package/bin/telemetry/track.js +0 -149
- package/bin/templates.js +0 -127
- package/bin/tokenRefresh.js +0 -50
- package/bin/tsconfig.build.tsbuildinfo +0 -1
- package/bin/update.js +0 -65
- package/bin/validate/command.js +0 -127
- package/bin/validate/engine.js +0 -154
- package/bin/validate/files.js +0 -163
- package/bin/validate/mdx.js +0 -238
- package/bin/validate/output.js +0 -44
- package/bin/validate/report.js +0 -11
- package/bin/validate/rules/build.js +0 -102
- package/bin/validate/rules/content/duplicateH1.js +0 -57
- package/bin/validate/rules/content/foreignSyntax.js +0 -120
- package/bin/validate/rules/content/katex.js +0 -34
- package/bin/validate/rules/content/missingSnippet.js +0 -34
- package/bin/validate/rules/content/undefinedVariable.js +0 -13
- package/bin/validate/rules/content/unknownComponent.js +0 -121
- package/bin/validate/rules/content/voidTags.js +0 -38
- package/bin/validate/rules/index.js +0 -21
- package/bin/validate/rules/openapi.js +0 -50
- package/bin/validate/rules/parseError.js +0 -7
- package/bin/validate/site.js +0 -57
- package/bin/validate/types.js +0 -1
- package/bin/vendor/converter.js +0 -30882
- package/bin/welcome.js +0 -108
- package/bin/workflows/client.js +0 -34
- package/bin/workflows/index.js +0 -269
- package/bin/workflows/types.js +0 -11
- package/scripts/bundle-converter.mjs +0 -26
- package/scripts/generate-logo.mjs +0 -79
- package/src/accessibility.ts +0 -180
- package/src/accessibilityCheck.tsx +0 -150
- package/src/addDomain.tsx +0 -206
- package/src/agent-auth.ts +0 -119
- package/src/agent-claim.ts +0 -124
- package/src/agent-credentials.ts +0 -104
- package/src/agent-deployment.ts +0 -116
- package/src/agent-http.ts +0 -34
- package/src/agent-setup-config.ts +0 -144
- package/src/agent-setup.ts +0 -165
- package/src/agent.ts +0 -56
- package/src/analytics/client.ts +0 -153
- package/src/analytics/dates.ts +0 -6
- package/src/analytics/filters.ts +0 -50
- package/src/analytics/format.ts +0 -13
- package/src/analytics/index.tsx +0 -599
- package/src/analytics/output.ts +0 -99
- package/src/analytics/types.ts +0 -145
- package/src/authenticatedFetch.ts +0 -42
- package/src/brokenLinks.tsx +0 -152
- package/src/callbackServer.ts +0 -64
- package/src/cli.tsx +0 -1105
- package/src/comingSoon.tsx +0 -29
- package/src/config.ts +0 -75
- package/src/constants.ts +0 -28
- package/src/deploy-base.ts +0 -18
- package/src/deploy-github-actions.ts +0 -139
- package/src/deploy-github-setup.ts +0 -189
- package/src/deploy-instructions.ts +0 -76
- package/src/deploy.ts +0 -165
- package/src/feedback.tsx +0 -31
- package/src/format.tsx +0 -82
- package/src/helpers.tsx +0 -279
- package/src/idToken.ts +0 -17
- package/src/index.ts +0 -109
- package/src/init.tsx +0 -237
- package/src/instructions.ts +0 -99
- package/src/keyring.ts +0 -65
- package/src/login.tsx +0 -166
- package/src/logout.tsx +0 -8
- package/src/mdxAccessibility.ts +0 -134
- package/src/mdxLinter.tsx +0 -88
- package/src/middlewares/subdomainMiddleware.ts +0 -20
- package/src/middlewares/telemetryMiddleware.ts +0 -55
- package/src/migrate.ts +0 -76
- package/src/og.tsx +0 -185
- package/src/openApiCheck.tsx +0 -125
- package/src/resolveFiles.ts +0 -101
- package/src/score/client.ts +0 -36
- package/src/score/index.tsx +0 -205
- package/src/score/types.ts +0 -15
- package/src/signup.tsx +0 -172
- package/src/start.ts +0 -27
- package/src/status.tsx +0 -129
- package/src/telemetry/client.ts +0 -46
- package/src/telemetry/distinctId.ts +0 -70
- package/src/telemetry/sessionId.ts +0 -40
- package/src/telemetry/track.ts +0 -163
- package/src/templates.tsx +0 -143
- package/src/tokenRefresh.ts +0 -53
- package/src/update.tsx +0 -89
- package/src/validate/command.tsx +0 -135
- package/src/validate/engine.ts +0 -210
- package/src/validate/files.ts +0 -249
- package/src/validate/mdx.ts +0 -290
- package/src/validate/output.tsx +0 -76
- package/src/validate/report.ts +0 -40
- package/src/validate/rules/build.ts +0 -146
- package/src/validate/rules/content/duplicateH1.ts +0 -78
- package/src/validate/rules/content/foreignSyntax.ts +0 -144
- package/src/validate/rules/content/katex.ts +0 -33
- package/src/validate/rules/content/missingSnippet.ts +0 -36
- package/src/validate/rules/content/undefinedVariable.ts +0 -20
- package/src/validate/rules/content/unknownComponent.ts +0 -130
- package/src/validate/rules/content/voidTags.ts +0 -43
- package/src/validate/rules/index.ts +0 -23
- package/src/validate/rules/openapi.ts +0 -59
- package/src/validate/rules/parseError.ts +0 -9
- package/src/validate/site.ts +0 -53
- package/src/validate/types.ts +0 -102
- package/src/vendor/converter.ts +0 -1
- package/src/welcome.ts +0 -154
- package/src/workflows/client.ts +0 -39
- package/src/workflows/index.tsx +0 -287
- package/src/workflows/types.ts +0 -73
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -10
- package/vitest.config.ts +0 -9
package/src/comingSoon.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { addLog, SuccessLog, WarningLog } from '@mintlify/previewing';
|
|
2
|
-
import { Text } from 'ink';
|
|
3
|
-
|
|
4
|
-
import { isTelemetryEnabled } from './config.js';
|
|
5
|
-
import { terminate } from './helpers.js';
|
|
6
|
-
|
|
7
|
-
export function comingSoon(command: string, packageName: string) {
|
|
8
|
-
return async () => {
|
|
9
|
-
if (!isTelemetryEnabled()) {
|
|
10
|
-
addLog(
|
|
11
|
-
<WarningLog
|
|
12
|
-
message={`Telemetry is disabled, so your vote won't be counted. Enable it with: ${packageName} --telemetry=true`}
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
} else {
|
|
16
|
-
addLog(
|
|
17
|
-
<SuccessLog
|
|
18
|
-
message={`Thanks for your interest in "${packageName} ${command}"! Your vote has been counted.`}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
addLog(
|
|
23
|
-
<Text dimColor>
|
|
24
|
-
This feature is currently in development. Learn more at https://mintlify.com/docs
|
|
25
|
-
</Text>
|
|
26
|
-
);
|
|
27
|
-
await terminate(0);
|
|
28
|
-
};
|
|
29
|
-
}
|
package/src/config.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { ensureDir } from 'fs-extra';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
import { CLI_CONFIG_FILE, CONFIG_DIR } from './constants.js';
|
|
6
|
-
|
|
7
|
-
interface MintlifyConfig {
|
|
8
|
-
telemetryEnabled?: boolean;
|
|
9
|
-
subdomain?: string;
|
|
10
|
-
dateFrom?: string;
|
|
11
|
-
dateTo?: string;
|
|
12
|
-
publishPromptShown?: string[];
|
|
13
|
-
agentSites?: Record<string, { registrationId: string; subdomain: string }>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const agentSiteMetadataSchema = z.object({ registrationId: z.string(), subdomain: z.string() });
|
|
17
|
-
|
|
18
|
-
export function getAgentSiteMetadata(key: string) {
|
|
19
|
-
const parsed = agentSiteMetadataSchema.safeParse(readConfig().agentSites?.[key]);
|
|
20
|
-
return parsed.success ? parsed.data : undefined;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function setAgentSiteMetadata(
|
|
24
|
-
key: string,
|
|
25
|
-
site: z.infer<typeof agentSiteMetadataSchema>
|
|
26
|
-
) {
|
|
27
|
-
await writeConfig({ agentSites: { ...readConfig().agentSites, [key]: site } });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function readConfig(): MintlifyConfig {
|
|
31
|
-
try {
|
|
32
|
-
const raw = fs.readFileSync(CLI_CONFIG_FILE, 'utf-8');
|
|
33
|
-
return JSON.parse(raw) as MintlifyConfig;
|
|
34
|
-
} catch {
|
|
35
|
-
return {};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function writeConfig(updates: Partial<MintlifyConfig>): Promise<void> {
|
|
40
|
-
await ensureDir(CONFIG_DIR);
|
|
41
|
-
const existing = readConfig();
|
|
42
|
-
fs.writeFileSync(CLI_CONFIG_FILE, JSON.stringify({ ...existing, ...updates }, null, 2));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function isTelemetryEnabled(): boolean {
|
|
46
|
-
if (process.env.CLI_TEST_MODE === 'true') return false;
|
|
47
|
-
if (process.env.MINTLIFY_TELEMETRY_DISABLED === '1') return false;
|
|
48
|
-
if (process.env.DO_NOT_TRACK === '1') return false;
|
|
49
|
-
return readConfig().telemetryEnabled !== false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export async function setTelemetryEnabled(enabled: boolean): Promise<void> {
|
|
53
|
-
await writeConfig({ telemetryEnabled: enabled });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getConfigValue(key: string): string | undefined {
|
|
57
|
-
const config = readConfig();
|
|
58
|
-
return config[key as keyof MintlifyConfig] as string | undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function setConfigValue(key: string, value: string): Promise<void> {
|
|
62
|
-
await writeConfig({ [key]: value });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export async function clearConfigValue(key: string): Promise<void> {
|
|
66
|
-
await writeConfig({ [key]: undefined });
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function hasShownPublishPrompt(dir: string): boolean {
|
|
70
|
-
return readConfig().publishPromptShown?.includes(dir) ?? false;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function markPublishPromptShown(dir: string): Promise<void> {
|
|
74
|
-
await writeConfig({ publishPromptShown: [...(readConfig().publishPromptShown ?? []), dir] });
|
|
75
|
-
}
|
package/src/constants.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { LOCAL_LINKED_CLI_VERSION } from '@mintlify/previewing';
|
|
2
|
-
import os from 'os';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
|
|
5
|
-
import { getCliVersion } from './helpers.js';
|
|
6
|
-
|
|
7
|
-
export const HOME_DIR = os.homedir();
|
|
8
|
-
|
|
9
|
-
export const CONFIG_DIR = path.join(HOME_DIR, '.config', 'mintlify');
|
|
10
|
-
export const CLI_CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
11
|
-
export const TELEMETRY_ASYNC_TIMEOUT_MS = 10_000;
|
|
12
|
-
export const TELEMETRY_IDENTITY_TIMEOUT_MS = 3_000;
|
|
13
|
-
|
|
14
|
-
export const CALLBACK_PORT = 11582;
|
|
15
|
-
|
|
16
|
-
const IS_LOCAL_BUILD =
|
|
17
|
-
process.env.CLI_TEST_MODE === 'true' ? true : getCliVersion() == LOCAL_LINKED_CLI_VERSION;
|
|
18
|
-
|
|
19
|
-
export const API_URL =
|
|
20
|
-
process.env.MINTLIFY_API_URL ??
|
|
21
|
-
(IS_LOCAL_BUILD ? 'http://localhost:5000' : 'https://leaves.mintlify.com');
|
|
22
|
-
export const DASHBOARD_URL =
|
|
23
|
-
process.env.MINTLIFY_DASHBOARD_URL ??
|
|
24
|
-
(IS_LOCAL_BUILD ? 'http://localhost:3000' : 'https://app.mintlify.com');
|
|
25
|
-
|
|
26
|
-
export const TOKEN_ENDPOINT = `${API_URL}/api/oauth-token/cli`;
|
|
27
|
-
|
|
28
|
-
export const CUSTOM_DOMAIN_CNAME_TARGET = 'cname.mintlify.builders';
|
package/src/deploy-base.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AgentWriteToken } from './agent-deployment.js';
|
|
2
|
-
import { git } from './deploy-github-actions.js';
|
|
3
|
-
|
|
4
|
-
export async function pushBaseCheckout(checkout: string, write: AgentWriteToken): Promise<void> {
|
|
5
|
-
const env = {
|
|
6
|
-
...process.env,
|
|
7
|
-
GIT_CONFIG_COUNT: '1',
|
|
8
|
-
GIT_CONFIG_KEY_0: `http.${write.remote}.extraHeader`,
|
|
9
|
-
GIT_CONFIG_VALUE_0: `Authorization: Bearer ${write.token}`,
|
|
10
|
-
};
|
|
11
|
-
await git(['fetch', write.remote, write.branch], checkout, env);
|
|
12
|
-
await git(['rebase', 'FETCH_HEAD'], checkout, env).catch(() => {
|
|
13
|
-
throw new Error(
|
|
14
|
-
`Could not rebase ${checkout} onto the latest ${write.branch}. Resolve the conflicts, run git rebase --continue, then rerun mint deploy --base --push ${checkout}.`
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
await git(['push', write.remote, `HEAD:refs/heads/${write.branch}`], checkout, env);
|
|
18
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
import { getGithubActionsWriteToken, type AgentWriteToken } from './agent-deployment.js';
|
|
6
|
-
import { AgentApiError } from './agent-http.js';
|
|
7
|
-
import { agentSiteUrl } from './deploy.js';
|
|
8
|
-
|
|
9
|
-
const oidcSchema = z.object({ value: z.string().min(1) });
|
|
10
|
-
|
|
11
|
-
export type GithubActionsDeployOptions = {
|
|
12
|
-
apiUrl: string;
|
|
13
|
-
directory: string;
|
|
14
|
-
subdomain?: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function isGithubActions(env: NodeJS.ProcessEnv = process.env): boolean {
|
|
18
|
-
return env.GITHUB_ACTIONS === 'true';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function getGithubOidcToken(env: NodeJS.ProcessEnv, audience: string): Promise<string> {
|
|
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(
|
|
26
|
-
'GitHub Actions did not provide an OIDC token. Add `permissions: id-token: write` to the workflow or job.'
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
let response: Response;
|
|
30
|
-
try {
|
|
31
|
-
response = await fetch(`${requestUrl}&audience=${encodeURIComponent(audience)}`, {
|
|
32
|
-
headers: { Authorization: `Bearer ${requestToken}` },
|
|
33
|
-
signal: AbortSignal.timeout(30_000),
|
|
34
|
-
});
|
|
35
|
-
} catch {
|
|
36
|
-
throw new Error('Could not request a GitHub Actions OIDC token. Retry the workflow.');
|
|
37
|
-
}
|
|
38
|
-
const parsed = oidcSchema.safeParse(await response.json().catch(() => null));
|
|
39
|
-
if (!response.ok || !parsed.success) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
`Could not get a GitHub Actions OIDC token (HTTP ${response.status}). Check that the workflow has \`permissions: id-token: write\`.`
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return parsed.data.value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function git(args: string[], cwd: string, env: NodeJS.ProcessEnv): Promise<string> {
|
|
48
|
-
return new Promise((resolve, reject) => {
|
|
49
|
-
const child = spawn('git', args, { cwd, env, stdio: ['ignore', 'pipe', 'inherit'] });
|
|
50
|
-
let out = '';
|
|
51
|
-
child.stdout.on('data', (chunk: Buffer) => (out += chunk.toString()));
|
|
52
|
-
child.on('error', reject);
|
|
53
|
-
child.on('close', (code) =>
|
|
54
|
-
code === 0 ? resolve(out.trim()) : reject(new Error(`git ${args[0]} failed`))
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function commitDirectory(directory: string, env: NodeJS.ProcessEnv): Promise<string> {
|
|
60
|
-
const prefix = await git(['rev-parse', '--show-prefix'], directory, env);
|
|
61
|
-
const tree = await git(['rev-parse', `HEAD:${prefix}`], directory, env);
|
|
62
|
-
const [name = '', email = '', date = '', sha = '', subject = ''] = (
|
|
63
|
-
await git(['log', '-1', '--format=%an%n%ae%n%aI%n%H%n%s'], directory, env)
|
|
64
|
-
).split('\n');
|
|
65
|
-
const repository = env.GITHUB_REPOSITORY ? `${env.GITHUB_REPOSITORY}@` : '';
|
|
66
|
-
return git(
|
|
67
|
-
['commit-tree', tree, '-m', subject, '-m', `Deployed from ${repository}${sha}`],
|
|
68
|
-
directory,
|
|
69
|
-
{
|
|
70
|
-
...env,
|
|
71
|
-
GIT_AUTHOR_NAME: name,
|
|
72
|
-
GIT_AUTHOR_EMAIL: email,
|
|
73
|
-
GIT_AUTHOR_DATE: date,
|
|
74
|
-
GIT_COMMITTER_NAME: name,
|
|
75
|
-
GIT_COMMITTER_EMAIL: email,
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function pushCommit(
|
|
81
|
-
directory: string,
|
|
82
|
-
commit: string,
|
|
83
|
-
write: AgentWriteToken,
|
|
84
|
-
env: NodeJS.ProcessEnv
|
|
85
|
-
): Promise<void> {
|
|
86
|
-
const index = Number(env.GIT_CONFIG_COUNT) || 0;
|
|
87
|
-
const credentials = Buffer.from(`x-access-token:${write.token}`).toString('base64');
|
|
88
|
-
return new Promise((resolve, reject) => {
|
|
89
|
-
const child = spawn(
|
|
90
|
-
'git',
|
|
91
|
-
['push', '--force', write.remote, `${commit}:refs/heads/${write.branch}`],
|
|
92
|
-
{
|
|
93
|
-
cwd: directory,
|
|
94
|
-
stdio: ['ignore', 'inherit', 'inherit'],
|
|
95
|
-
env: {
|
|
96
|
-
...env,
|
|
97
|
-
GIT_CONFIG_COUNT: String(index + 1),
|
|
98
|
-
[`GIT_CONFIG_KEY_${index}`]: `http.${write.remote}.extraHeader`,
|
|
99
|
-
[`GIT_CONFIG_VALUE_${index}`]: `Authorization: Basic ${credentials}`,
|
|
100
|
-
},
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
const failed = () => reject(new Error('git push to the site repository failed.'));
|
|
104
|
-
child.on('error', failed);
|
|
105
|
-
child.on('close', (code) => (code === 0 ? resolve() : failed()));
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export async function deployFromGithubActions(
|
|
110
|
-
options: GithubActionsDeployOptions,
|
|
111
|
-
progress: (message: string) => void = () => {},
|
|
112
|
-
env: NodeJS.ProcessEnv = process.env
|
|
113
|
-
): Promise<string> {
|
|
114
|
-
const { apiUrl, subdomain } = options;
|
|
115
|
-
if (!subdomain) throw new Error('Pass the site name with --subdomain <name>.');
|
|
116
|
-
const directory = path.resolve(options.directory);
|
|
117
|
-
const commit = await commitDirectory(directory, env).catch(() => {
|
|
118
|
-
throw new Error(
|
|
119
|
-
`Could not read ${options.directory} from the checked-out commit. Run mint deploy after actions/checkout, with --directory inside the repository.`
|
|
120
|
-
);
|
|
121
|
-
});
|
|
122
|
-
progress('Requesting a GitHub Actions identity token...');
|
|
123
|
-
const oidcToken = await getGithubOidcToken(env, apiUrl);
|
|
124
|
-
progress('Getting repository write access...');
|
|
125
|
-
let write: AgentWriteToken;
|
|
126
|
-
try {
|
|
127
|
-
write = await getGithubActionsWriteToken(apiUrl, oidcToken, subdomain);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
if (error instanceof AgentApiError && error.status === 403) {
|
|
130
|
-
throw new Error(
|
|
131
|
-
`This repository/branch isn't trusted to deploy ${subdomain}. Run \`mint deploy --github\` locally from this repository to trust it.`
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
progress('Pushing to the site repository...');
|
|
137
|
-
await pushCommit(directory, commit, write, env);
|
|
138
|
-
return agentSiteUrl(apiUrl, subdomain);
|
|
139
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import fs from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
import { trustGithubRepo } from './agent-deployment.js';
|
|
7
|
-
import { CLAIM_INSTRUCTIONS } from './deploy-instructions.js';
|
|
8
|
-
import { agentSiteUrl, prepareAgentDeployment, type DeployOptions } from './deploy.js';
|
|
9
|
-
|
|
10
|
-
const githubRepoSchema = z.object({
|
|
11
|
-
id: z.number().int().positive(),
|
|
12
|
-
full_name: z.string().regex(/^[\w.-]+\/[\w.-]+$/),
|
|
13
|
-
default_branch: z.string().min(1),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export type GithubRepo = z.infer<typeof githubRepoSchema>;
|
|
17
|
-
|
|
18
|
-
export const GITHUB_WORKFLOW_PATH = path.join('.github', 'workflows', 'mintlify.yml');
|
|
19
|
-
|
|
20
|
-
function run(command: string, args: string[], cwd: string): Promise<string> {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
execFile(command, args, { cwd }, (error, stdout) =>
|
|
23
|
-
error ? reject(error) : resolve(String(stdout).trim())
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function parseGithubRemote(remote: string): { owner: string; repo: string } | null {
|
|
29
|
-
const match = remote
|
|
30
|
-
.trim()
|
|
31
|
-
.match(
|
|
32
|
-
/^(?:https:\/\/(?:[^@/]+@)?github\.com\/|ssh:\/\/git@github\.com(?::\d+)?\/|git@github\.com:)([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/
|
|
33
|
-
);
|
|
34
|
-
return match?.[1] && match[2] ? { owner: match[1], repo: match[2] } : null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function githubWorkflow(branch: string, subdomain: string, docsPath = ''): string {
|
|
38
|
-
const directory = /^[\w./-]+$/.test(docsPath) ? docsPath : JSON.stringify(docsPath);
|
|
39
|
-
return [
|
|
40
|
-
'name: Deploy to Mintlify',
|
|
41
|
-
'on:',
|
|
42
|
-
' push:',
|
|
43
|
-
` branches: [${JSON.stringify(branch)}]`,
|
|
44
|
-
...(docsPath
|
|
45
|
-
? [` paths: [${JSON.stringify(`${docsPath}/**`)}, ".github/workflows/mintlify.yml"]`]
|
|
46
|
-
: []),
|
|
47
|
-
'permissions:',
|
|
48
|
-
' id-token: write',
|
|
49
|
-
' contents: read',
|
|
50
|
-
'concurrency:',
|
|
51
|
-
' group: mintlify-deploy',
|
|
52
|
-
' cancel-in-progress: true',
|
|
53
|
-
'jobs:',
|
|
54
|
-
' deploy:',
|
|
55
|
-
' runs-on: ubuntu-latest',
|
|
56
|
-
' steps:',
|
|
57
|
-
' - uses: actions/checkout@v4',
|
|
58
|
-
` - run: npx mint@latest deploy --subdomain ${subdomain}${docsPath ? ` --directory ${directory}` : ''}`,
|
|
59
|
-
'',
|
|
60
|
-
].join('\n');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function readFileIfExists(file: string): Promise<string | undefined> {
|
|
64
|
-
return fs.readFile(file, 'utf8').catch((error: NodeJS.ErrnoException) => {
|
|
65
|
-
if (error.code === 'ENOENT') return undefined;
|
|
66
|
-
throw error;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export async function writeGithubWorkflow(
|
|
71
|
-
root: string,
|
|
72
|
-
contents: string,
|
|
73
|
-
force = false
|
|
74
|
-
): Promise<'created' | 'unchanged' | 'updated'> {
|
|
75
|
-
const file = path.join(root, GITHUB_WORKFLOW_PATH);
|
|
76
|
-
const existing = await readFileIfExists(file);
|
|
77
|
-
if (existing === contents) return 'unchanged';
|
|
78
|
-
if (existing !== undefined && !force) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`${GITHUB_WORKFLOW_PATH} already exists with different contents. Pass --force to overwrite it.`
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
84
|
-
await fs.writeFile(file, contents);
|
|
85
|
-
return existing === undefined ? 'created' : 'updated';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export async function findGitRoot(directory: string): Promise<string> {
|
|
89
|
-
try {
|
|
90
|
-
return await run('git', ['rev-parse', '--show-toplevel'], directory);
|
|
91
|
-
} catch {
|
|
92
|
-
throw new Error('--github requires a Git repository. Run it inside your docs repository.');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export async function resolveGithubRepo(root: string): Promise<GithubRepo> {
|
|
97
|
-
const remote = await run('git', ['remote', 'get-url', 'origin'], root).catch(() => {
|
|
98
|
-
throw new Error('This repository has no origin remote. Add a github.com origin and retry.');
|
|
99
|
-
});
|
|
100
|
-
const parsed = parseGithubRemote(remote);
|
|
101
|
-
if (!parsed) throw new Error(`The origin remote (${remote}) is not a github.com repository.`);
|
|
102
|
-
const output = await run(
|
|
103
|
-
'gh',
|
|
104
|
-
[
|
|
105
|
-
'api',
|
|
106
|
-
`repos/${parsed.owner}/${parsed.repo}`,
|
|
107
|
-
'--jq',
|
|
108
|
-
'{id: .id, full_name: .full_name, default_branch: .default_branch}',
|
|
109
|
-
],
|
|
110
|
-
root
|
|
111
|
-
).catch((error: NodeJS.ErrnoException) => {
|
|
112
|
-
if (error.code === 'ENOENT')
|
|
113
|
-
throw new Error('The GitHub CLI (gh) is required. Install it and run `gh auth login`.');
|
|
114
|
-
throw new Error(
|
|
115
|
-
`Could not read ${parsed.owner}/${parsed.repo} with gh. Run \`gh auth login\` with access to the repository and retry.`
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
try {
|
|
119
|
-
return githubRepoSchema.parse(JSON.parse(output));
|
|
120
|
-
} catch {
|
|
121
|
-
throw new Error('gh returned an unexpected repository response.');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export type GithubSetupResult = {
|
|
126
|
-
siteUrl: string;
|
|
127
|
-
subdomain: string;
|
|
128
|
-
repository: string;
|
|
129
|
-
branch: string;
|
|
130
|
-
workflowPath: string;
|
|
131
|
-
workflow: 'created' | 'unchanged' | 'updated';
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export async function setupGithubDeployment(
|
|
135
|
-
options: DeployOptions & { force?: boolean },
|
|
136
|
-
warn: (message: string) => void,
|
|
137
|
-
progress: (message: string) => void = () => {}
|
|
138
|
-
): Promise<GithubSetupResult> {
|
|
139
|
-
const directory = path.resolve(options.directory);
|
|
140
|
-
const root = await findGitRoot(directory);
|
|
141
|
-
const [realRoot, realDirectory] = await Promise.all([fs.realpath(root), fs.realpath(directory)]);
|
|
142
|
-
const docsPath = path.relative(realRoot, realDirectory).split(path.sep).join('/');
|
|
143
|
-
if (!(await readFileIfExists(path.join(directory, 'docs.json')))) {
|
|
144
|
-
throw new Error(`No docs.json in ${directory}. Pass the docs folder with --directory.`);
|
|
145
|
-
}
|
|
146
|
-
progress('Resolving the GitHub repository...');
|
|
147
|
-
const repo = await resolveGithubRepo(root);
|
|
148
|
-
const result = await prepareAgentDeployment(options, warn, progress);
|
|
149
|
-
if (result.status === 'claimed') {
|
|
150
|
-
throw new Error(
|
|
151
|
-
'This site has been claimed. Setting up GitHub deploys for claimed sites is not supported yet; connect the repository from the Mintlify dashboard.'
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
const accessToken = result.credentials.accessToken;
|
|
155
|
-
if (!accessToken) throw new Error('Agent authentication did not return an access token.');
|
|
156
|
-
progress(`Trusting ${repo.full_name}@${repo.default_branch} to deploy...`);
|
|
157
|
-
await trustGithubRepo(options.apiUrl, accessToken, {
|
|
158
|
-
repositoryId: String(repo.id),
|
|
159
|
-
repository: repo.full_name,
|
|
160
|
-
branch: repo.default_branch,
|
|
161
|
-
});
|
|
162
|
-
const workflow = await writeGithubWorkflow(
|
|
163
|
-
root,
|
|
164
|
-
githubWorkflow(repo.default_branch, result.site.subdomain, docsPath),
|
|
165
|
-
options.force
|
|
166
|
-
);
|
|
167
|
-
return {
|
|
168
|
-
siteUrl: agentSiteUrl(options.apiUrl, result.site.subdomain),
|
|
169
|
-
subdomain: result.site.subdomain,
|
|
170
|
-
repository: repo.full_name,
|
|
171
|
-
branch: repo.default_branch,
|
|
172
|
-
workflowPath: GITHUB_WORKFLOW_PATH,
|
|
173
|
-
workflow,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export function formatGithubSetup(result: GithubSetupResult): string {
|
|
178
|
-
return [
|
|
179
|
-
`Site: ${result.siteUrl}`,
|
|
180
|
-
`Trusted repository: ${result.repository} (branch ${result.branch})`,
|
|
181
|
-
`Workflow: ${result.workflowPath} (${result.workflow})`,
|
|
182
|
-
'',
|
|
183
|
-
'Next steps:',
|
|
184
|
-
`1. Commit and push ${result.workflowPath} to ${result.branch}.`,
|
|
185
|
-
`2. Every push to ${result.branch} then deploys ${result.subdomain} through GitHub Actions. No secrets are stored in the repository.`,
|
|
186
|
-
'',
|
|
187
|
-
...CLAIM_INSTRUCTIONS,
|
|
188
|
-
].join('\n');
|
|
189
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { DeployResult } from './deploy.js';
|
|
2
|
-
|
|
3
|
-
export const DEPLOY_HELP = [
|
|
4
|
-
'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.',
|
|
5
|
-
'Run from your documentation directory, or pass --directory. Put docs.json, pages, and assets at the hosted repository root.',
|
|
6
|
-
'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.',
|
|
7
|
-
'Claimed sites are managed in the dashboard. Confirmed expired sites start a new anonymous registration.',
|
|
8
|
-
'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.',
|
|
9
|
-
'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.',
|
|
10
|
-
'The output contains a short-lived write token. Do not paste it into public logs or save it in a Git remote.',
|
|
11
|
-
'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.',
|
|
12
|
-
'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.',
|
|
13
|
-
'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.',
|
|
14
|
-
].join('\n\n');
|
|
15
|
-
|
|
16
|
-
export const CLAIM_INSTRUCTIONS = [
|
|
17
|
-
'Ask the user for the email address they want to use to claim this site. Never invent an email address.',
|
|
18
|
-
'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.',
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const baseClaimStep = (claimUrl?: string) =>
|
|
22
|
-
claimUrl
|
|
23
|
-
? [
|
|
24
|
-
`3. Claim the base last. Send the user this link: ${claimUrl}`,
|
|
25
|
-
' They sign in and get a code. When they give it to you, run: mint claim --code <code>',
|
|
26
|
-
]
|
|
27
|
-
: [
|
|
28
|
-
'3. Claim the base last. Ask the user for their email (never invent one), then run:',
|
|
29
|
-
' mint deploy --base --email <their-email>',
|
|
30
|
-
' 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>',
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
function baseInstructions(result: Extract<DeployResult, { status: 'ready' }>, claimUrl?: string) {
|
|
34
|
-
const { site, write } = result;
|
|
35
|
-
const checkout = site.subdomain;
|
|
36
|
-
return [
|
|
37
|
-
'\nNext steps:',
|
|
38
|
-
`1. Clone the base into ./${checkout}:`,
|
|
39
|
-
` git -c http.${write.remote}.extraHeader="Authorization: Bearer ${write.token}" clone ${write.remote} ${checkout}`,
|
|
40
|
-
` The clone command works until ${write.tokenExpiresAt}. Run mint deploy --base again for a fresh one.`,
|
|
41
|
-
`2. Commit your changes in ./${checkout}, then publish them:`,
|
|
42
|
-
` mint deploy --base --push ${checkout}`,
|
|
43
|
-
' This rebases onto the latest main and pushes. Do not run git push yourself.',
|
|
44
|
-
...baseClaimStep(claimUrl),
|
|
45
|
-
' 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.',
|
|
46
|
-
'Run every mint command from this directory (or repeat --directory).',
|
|
47
|
-
].join('\n');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function deploymentInstructions(result: DeployResult, claimUrl?: string): string {
|
|
51
|
-
if (result.status !== 'ready') return '';
|
|
52
|
-
if (result.projectType === 'workspace') return baseInstructions(result, claimUrl);
|
|
53
|
-
return [
|
|
54
|
-
'\nNext steps:',
|
|
55
|
-
'1. Clone the hosted repository into a separate directory. Do not replace the user’s existing Git remote.',
|
|
56
|
-
'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.',
|
|
57
|
-
'3. Commit the documentation. For subsequent updates, fetch the hosted main branch and commit on top of it. Do not force-push.',
|
|
58
|
-
'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.',
|
|
59
|
-
'5. If the write token expires, run mint deploy again from the same documentation directory to obtain a fresh token.',
|
|
60
|
-
'A successful push starts the normal build. Provisioning and Git success do not confirm build success.',
|
|
61
|
-
'',
|
|
62
|
-
'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.',
|
|
63
|
-
'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"',
|
|
64
|
-
'After copying and committing the documentation:',
|
|
65
|
-
'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',
|
|
66
|
-
'These settings apply only to that Git process. Use the same authentication settings for later fetches.',
|
|
67
|
-
'',
|
|
68
|
-
...(claimUrl
|
|
69
|
-
? [
|
|
70
|
-
`Claim link for the user: ${claimUrl}`,
|
|
71
|
-
'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.',
|
|
72
|
-
'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.',
|
|
73
|
-
]
|
|
74
|
-
: CLAIM_INSTRUCTIONS),
|
|
75
|
-
].join('\n');
|
|
76
|
-
}
|