@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.
- 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/welcome.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
const MINT_GREEN = '#18E299';
|
|
4
|
-
|
|
5
|
-
const mint = chalk.hex(MINT_GREEN);
|
|
6
|
-
|
|
7
|
-
interface CommandEntry {
|
|
8
|
-
name: string;
|
|
9
|
-
description: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface CommandGroup {
|
|
13
|
-
title: string;
|
|
14
|
-
commands: CommandEntry[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const GROUPS: CommandGroup[] = [
|
|
18
|
-
{
|
|
19
|
-
title: 'Preview',
|
|
20
|
-
commands: [
|
|
21
|
-
{ name: 'dev', description: 'Start a local preview of your site' },
|
|
22
|
-
{ name: 'new', description: 'Scaffold a new documentation site' },
|
|
23
|
-
{
|
|
24
|
-
name: 'deploy',
|
|
25
|
-
description: 'Provision a docs site without login; get Git push instructions',
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
title: 'Quality',
|
|
31
|
-
commands: [
|
|
32
|
-
{ name: 'validate', description: 'Validate the site build (strict)' },
|
|
33
|
-
{
|
|
34
|
-
name: 'broken-links',
|
|
35
|
-
description: 'Find broken links before you ship',
|
|
36
|
-
},
|
|
37
|
-
{ name: 'a11y', description: 'Check site for accessibility issues' },
|
|
38
|
-
{ name: 'score', description: 'Run agent-readiness checks' },
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: 'Insights',
|
|
43
|
-
commands: [
|
|
44
|
-
{ name: 'analytics', description: 'View analytics for your site' },
|
|
45
|
-
{ name: 'automations', description: 'Create and manage automations' },
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
title: 'Account',
|
|
50
|
-
commands: [
|
|
51
|
-
{ name: 'login', description: 'Authenticate with Mintlify' },
|
|
52
|
-
{ name: 'claim', description: 'Claim a site created with mint deploy' },
|
|
53
|
-
{ name: 'logout', description: 'Sign out on this device' },
|
|
54
|
-
{ name: 'status', description: 'View authentication status' },
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
title: 'CLI',
|
|
59
|
-
commands: [
|
|
60
|
-
{ name: 'agent setup', description: 'Install Mintlify skills and configure Admin MCP' },
|
|
61
|
-
{ name: 'config', description: 'Manage CLI configuration' },
|
|
62
|
-
{ name: 'instructions', description: 'Print Mintlify workflow instructions' },
|
|
63
|
-
{ name: 'update', description: 'Update to the latest version' },
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
const EXAMPLES: CommandEntry[] = [
|
|
69
|
-
{ name: 'dev', description: 'Start a local preview of your site' },
|
|
70
|
-
{ name: 'new docs', description: 'Scaffold a new site in ./docs' },
|
|
71
|
-
{
|
|
72
|
-
name: 'claim --email you@example.com',
|
|
73
|
-
description: 'Get a claim link; use the deployment directory',
|
|
74
|
-
},
|
|
75
|
-
{ name: 'claim --code <code>', description: 'Finish the claim in the same directory' },
|
|
76
|
-
{ name: 'validate', description: 'Validate your site before shipping' },
|
|
77
|
-
{ name: 'broken-links', description: 'Find broken links across your site' },
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
const COMMAND_NAME_WIDTH =
|
|
81
|
-
GROUPS.flatMap((group) => group.commands).reduce(
|
|
82
|
-
(max, command) => Math.max(max, command.name.length),
|
|
83
|
-
0
|
|
84
|
-
) + 2;
|
|
85
|
-
|
|
86
|
-
// `name description`, name padded to a shared column and colored mint. Padding
|
|
87
|
-
// is computed on the raw name so ANSI codes don't throw off the alignment.
|
|
88
|
-
const commandRow = (name: string, description: string, nameWidth: number, indent: number): string =>
|
|
89
|
-
' '.repeat(indent) + mint(name.padEnd(nameWidth)) + chalk.dim(description);
|
|
90
|
-
|
|
91
|
-
export interface WelcomeOptions {
|
|
92
|
-
packageName: string;
|
|
93
|
-
version?: string;
|
|
94
|
-
signedIn: boolean;
|
|
95
|
-
subdomain?: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Builds the branded welcome / help screen as a ready-to-print string: the
|
|
100
|
-
* Mintlify leaf beside an identity block, then grouped examples and commands.
|
|
101
|
-
*/
|
|
102
|
-
export function renderWelcome({
|
|
103
|
-
packageName,
|
|
104
|
-
version,
|
|
105
|
-
signedIn,
|
|
106
|
-
subdomain,
|
|
107
|
-
}: WelcomeOptions): string {
|
|
108
|
-
const title = `${packageName.charAt(0).toUpperCase()}${packageName.slice(1)} CLI`;
|
|
109
|
-
// Only prefix "v" for real semver versions; the linked-dev build reports a
|
|
110
|
-
// descriptive string ("linked to local package").
|
|
111
|
-
const versionLabel = version ? (/^\d/.test(version) ? `v${version}` : version) : undefined;
|
|
112
|
-
|
|
113
|
-
const identity: string[] = [
|
|
114
|
-
chalk.bold(title) + (versionLabel ? chalk.dim(` ${versionLabel}`) : ''),
|
|
115
|
-
'',
|
|
116
|
-
signedIn
|
|
117
|
-
? chalk.dim('Signed in to Mintlify')
|
|
118
|
-
: chalk.dim('Run ') + mint(`${packageName} login`) + chalk.dim(' to sign in'),
|
|
119
|
-
...(subdomain ? [chalk.dim(`Project ${subdomain}`)] : []),
|
|
120
|
-
];
|
|
121
|
-
|
|
122
|
-
const lines: string[] = [''];
|
|
123
|
-
|
|
124
|
-
lines.push(...identity);
|
|
125
|
-
|
|
126
|
-
// Examples.
|
|
127
|
-
const exampleWidth =
|
|
128
|
-
EXAMPLES.reduce((max, example) => Math.max(max, `${packageName} ${example.name}`.length), 0) +
|
|
129
|
-
2;
|
|
130
|
-
lines.push('', ' ' + chalk.bold('EXAMPLES'));
|
|
131
|
-
for (const example of EXAMPLES) {
|
|
132
|
-
lines.push(commandRow(`${packageName} ${example.name}`, example.description, exampleWidth, 3));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Commands, grouped.
|
|
136
|
-
lines.push('', ' ' + chalk.bold('COMMANDS'));
|
|
137
|
-
for (const group of GROUPS) {
|
|
138
|
-
lines.push('', ' ' + chalk.bold(group.title));
|
|
139
|
-
for (const command of group.commands) {
|
|
140
|
-
lines.push(commandRow(command.name, command.description, COMMAND_NAME_WIDTH, 5));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
lines.push(
|
|
145
|
-
'',
|
|
146
|
-
' ' +
|
|
147
|
-
chalk.dim('Run ') +
|
|
148
|
-
mint(`${packageName} <command> --help`) +
|
|
149
|
-
chalk.dim(' for details on any command.'),
|
|
150
|
-
''
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
return lines.join('\n') + '\n';
|
|
154
|
-
}
|
package/src/workflows/client.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { authenticatedFetch } from '../authenticatedFetch.js';
|
|
2
|
-
import { API_URL } from '../constants.js';
|
|
3
|
-
import type { Workflow, WorkflowBody } from './types.js';
|
|
4
|
-
|
|
5
|
-
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
|
6
|
-
const res = await authenticatedFetch(`${API_URL}/api/cli/workflows${path}`, {
|
|
7
|
-
...init,
|
|
8
|
-
headers: { Accept: 'application/json', ...init?.headers },
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
if (!res.ok) {
|
|
12
|
-
const body = await res.text().catch(() => '');
|
|
13
|
-
throw new Error(`API error (${res.status}): ${body || res.statusText}`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return res.json() as Promise<T>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function createWorkflow(subdomain: string, body: WorkflowBody): Promise<Workflow> {
|
|
20
|
-
return request<Workflow>(`/${encodeURIComponent(subdomain)}`, {
|
|
21
|
-
method: 'POST',
|
|
22
|
-
headers: { 'Content-Type': 'application/json' },
|
|
23
|
-
body: JSON.stringify(body),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function listWorkflows(subdomain: string): Promise<Workflow[]> {
|
|
28
|
-
return request<Workflow[]>(`/${encodeURIComponent(subdomain)}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function deleteWorkflow(
|
|
32
|
-
subdomain: string,
|
|
33
|
-
workflowSchemaId: string
|
|
34
|
-
): Promise<{ success: boolean }> {
|
|
35
|
-
return request<{ success: boolean }>(
|
|
36
|
-
`/${encodeURIComponent(subdomain)}/${encodeURIComponent(workflowSchemaId)}`,
|
|
37
|
-
{ method: 'DELETE' }
|
|
38
|
-
);
|
|
39
|
-
}
|
package/src/workflows/index.tsx
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { addLog, ErrorLog, SpinnerLog, SuccessLog, removeLastLog } from '@mintlify/previewing';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { Text } from 'ink';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
5
|
-
import fs from 'node:fs/promises';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import type { Argv } from 'yargs';
|
|
8
|
-
|
|
9
|
-
import { CMD_EXEC_PATH, terminate } from '../helpers.js';
|
|
10
|
-
import { subdomainMiddleware } from '../middlewares/subdomainMiddleware.js';
|
|
11
|
-
import { trackEvent } from '../telemetry/track.js';
|
|
12
|
-
import { createWorkflow, deleteWorkflow, listWorkflows } from './client.js';
|
|
13
|
-
import {
|
|
14
|
-
WORKFLOW_TYPES,
|
|
15
|
-
type Workflow,
|
|
16
|
-
type WorkflowBody,
|
|
17
|
-
type WorkflowTrigger,
|
|
18
|
-
type WorkflowType,
|
|
19
|
-
} from './types.js';
|
|
20
|
-
|
|
21
|
-
type CreateArgs = {
|
|
22
|
-
subdomain?: string;
|
|
23
|
-
name?: string;
|
|
24
|
-
prompt?: string;
|
|
25
|
-
type?: string;
|
|
26
|
-
cron?: string;
|
|
27
|
-
pushRepo?: (string | number)[];
|
|
28
|
-
contextRepo?: (string | number)[];
|
|
29
|
-
automerge?: boolean;
|
|
30
|
-
file?: string;
|
|
31
|
-
format?: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
type OutputFormat = 'table' | 'json';
|
|
35
|
-
|
|
36
|
-
function resolveFormat(argv: { format?: string }): OutputFormat {
|
|
37
|
-
return argv.format === 'json' ? 'json' : 'table';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function output(format: OutputFormat, text: string) {
|
|
41
|
-
if (format === 'table') {
|
|
42
|
-
addLog(<Text>{text}</Text>);
|
|
43
|
-
} else {
|
|
44
|
-
process.stdout.write(text + '\n');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function requireSubdomain(subdomain: string | undefined): string {
|
|
49
|
-
if (!subdomain) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
'No subdomain set. Pass --subdomain, or run `mint config set subdomain <name>`.'
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
return subdomain;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function readWorkflowFile(filePath: string): Promise<unknown> {
|
|
58
|
-
const resolved = path.isAbsolute(filePath) ? filePath : path.join(CMD_EXEC_PATH, filePath);
|
|
59
|
-
const contents = await fs.readFile(resolved, 'utf-8');
|
|
60
|
-
if (/\.ya?ml$/i.test(resolved)) return yaml.load(contents);
|
|
61
|
-
return JSON.parse(contents);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function buildTriggerFromFlags(argv: CreateArgs): WorkflowTrigger {
|
|
65
|
-
const repos = (argv.pushRepo ?? []).map(String).filter(Boolean);
|
|
66
|
-
if (argv.cron && repos.length > 0) {
|
|
67
|
-
throw new Error('Specify either --cron or --push-repo, not both.');
|
|
68
|
-
}
|
|
69
|
-
if (argv.cron) return { cron: argv.cron };
|
|
70
|
-
if (repos.length > 0) return { push: repos.map((repo) => ({ repo })) };
|
|
71
|
-
throw new Error('A trigger is required. Pass --cron <expr> or --push-repo <owner/repo>.');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function buildBodyFromFlags(argv: CreateArgs): WorkflowBody {
|
|
75
|
-
if (!argv.name) {
|
|
76
|
-
throw new Error('--name is required when --file is not provided.');
|
|
77
|
-
}
|
|
78
|
-
const type = argv.type;
|
|
79
|
-
if (type !== undefined && !WORKFLOW_TYPES.includes(type as WorkflowType)) {
|
|
80
|
-
throw new Error(`Invalid --type "${type}". Valid types: ${WORKFLOW_TYPES.join(', ')}`);
|
|
81
|
-
}
|
|
82
|
-
const body: WorkflowBody = {
|
|
83
|
-
name: argv.name,
|
|
84
|
-
on: buildTriggerFromFlags(argv),
|
|
85
|
-
};
|
|
86
|
-
if (argv.prompt) body.prompt = argv.prompt;
|
|
87
|
-
if (type) body.type = type as WorkflowType;
|
|
88
|
-
if (argv.automerge !== undefined) body.automerge = argv.automerge;
|
|
89
|
-
const contextRepos = (argv.contextRepo ?? []).map(String).filter(Boolean);
|
|
90
|
-
if (contextRepos.length > 0) body.context = contextRepos.map((repo) => ({ repo }));
|
|
91
|
-
return body;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function describeTrigger(trigger: WorkflowTrigger): string {
|
|
95
|
-
if ('webhook' in trigger) return 'webhook';
|
|
96
|
-
if ('cron' in trigger) return `cron(${trigger.cron})`;
|
|
97
|
-
if ('push' in trigger) return `push(${trigger.push.map((p) => p.repo).join(', ')})`;
|
|
98
|
-
return `composio(${trigger.composio.toolkit}:${trigger.composio.triggerSlug})`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function renderWorkflow(workflow: Workflow): string {
|
|
102
|
-
const lines: string[] = [];
|
|
103
|
-
lines.push(chalk.bold(`\nAutomation ${workflow.name}`));
|
|
104
|
-
lines.push(` ${chalk.dim('ID')} ${workflow._id}`);
|
|
105
|
-
lines.push(` ${chalk.dim('Status')} ${workflow.status}`);
|
|
106
|
-
if (workflow.type) lines.push(` ${chalk.dim('Type')} ${workflow.type}`);
|
|
107
|
-
lines.push(` ${chalk.dim('Trigger')} ${describeTrigger(workflow.trigger)}`);
|
|
108
|
-
if (workflow.automerge !== undefined) {
|
|
109
|
-
lines.push(` ${chalk.dim('Automerge')} ${workflow.automerge}`);
|
|
110
|
-
}
|
|
111
|
-
return lines.join('\n');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function renderList(workflows: Workflow[]): string {
|
|
115
|
-
if (workflows.length === 0) return 'No automations found.';
|
|
116
|
-
const rows = workflows.map((w) => [
|
|
117
|
-
w._id,
|
|
118
|
-
w.name,
|
|
119
|
-
w.type ?? '—',
|
|
120
|
-
describeTrigger(w.trigger),
|
|
121
|
-
w.status,
|
|
122
|
-
]);
|
|
123
|
-
const headers = ['ID', 'Name', 'Type', 'Trigger', 'Status'];
|
|
124
|
-
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => String(r[i]).length)));
|
|
125
|
-
const fmt = (cells: string[]) => cells.map((c, i) => c.padEnd(widths[i]!)).join(' ');
|
|
126
|
-
return [chalk.bold(fmt(headers)), ...rows.map(fmt)].join('\n');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const withSubdomain = <T extends object>(yargs: Argv<T>) =>
|
|
130
|
-
yargs.option('subdomain', {
|
|
131
|
-
type: 'string' as const,
|
|
132
|
-
description: 'Documentation subdomain (default: mint config set subdomain)',
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const withFormat = <T extends object>(yargs: Argv<T>) =>
|
|
136
|
-
yargs.option('format', {
|
|
137
|
-
type: 'string' as const,
|
|
138
|
-
choices: ['table', 'json'] as const,
|
|
139
|
-
description: 'Output format (table=pretty, json=raw)',
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
export const workflowsBuilder = (yargs: Argv) =>
|
|
143
|
-
yargs
|
|
144
|
-
.middleware(subdomainMiddleware)
|
|
145
|
-
.command(
|
|
146
|
-
'create',
|
|
147
|
-
'Create a new automation',
|
|
148
|
-
(yargs) =>
|
|
149
|
-
withFormat(
|
|
150
|
-
withSubdomain(yargs)
|
|
151
|
-
.option('name', { type: 'string', description: 'Automation name' })
|
|
152
|
-
.option('prompt', { type: 'string', description: 'Automation prompt' })
|
|
153
|
-
.option('type', {
|
|
154
|
-
type: 'string',
|
|
155
|
-
choices: WORKFLOW_TYPES,
|
|
156
|
-
description: 'Automation type',
|
|
157
|
-
})
|
|
158
|
-
.option('cron', {
|
|
159
|
-
type: 'string',
|
|
160
|
-
description: 'Cron expression for a scheduled trigger',
|
|
161
|
-
})
|
|
162
|
-
.option('push-repo', {
|
|
163
|
-
type: 'string',
|
|
164
|
-
array: true,
|
|
165
|
-
description: 'Repository (owner/repo) for a push trigger (repeatable)',
|
|
166
|
-
})
|
|
167
|
-
.option('context-repo', {
|
|
168
|
-
type: 'string',
|
|
169
|
-
array: true,
|
|
170
|
-
description: 'Additional context repository (repeatable)',
|
|
171
|
-
})
|
|
172
|
-
.option('automerge', {
|
|
173
|
-
type: 'boolean',
|
|
174
|
-
description: 'Automatically merge PRs opened by this automation',
|
|
175
|
-
})
|
|
176
|
-
.option('file', {
|
|
177
|
-
type: 'string',
|
|
178
|
-
description: 'Path to a JSON or YAML file with the full automation body',
|
|
179
|
-
})
|
|
180
|
-
)
|
|
181
|
-
.example(
|
|
182
|
-
'mint automations create --name Translations --cron "0 6 * * *" --type translations',
|
|
183
|
-
''
|
|
184
|
-
)
|
|
185
|
-
.example('mint automations create --file automation.yaml', ''),
|
|
186
|
-
async (argv) => {
|
|
187
|
-
const format = resolveFormat(argv);
|
|
188
|
-
try {
|
|
189
|
-
const subdomain = requireSubdomain(argv.subdomain);
|
|
190
|
-
const body: WorkflowBody = argv.file
|
|
191
|
-
? ((await readWorkflowFile(argv.file)) as WorkflowBody)
|
|
192
|
-
: buildBodyFromFlags(argv as CreateArgs);
|
|
193
|
-
|
|
194
|
-
if (format === 'table') addLog(<SpinnerLog message="Creating automation..." />);
|
|
195
|
-
const created = await createWorkflow(subdomain, body);
|
|
196
|
-
if (format === 'table') removeLastLog();
|
|
197
|
-
|
|
198
|
-
void trackEvent('cli.automation.created', {
|
|
199
|
-
subdomain,
|
|
200
|
-
type: created.type,
|
|
201
|
-
triggerKind: describeTrigger(created.trigger).split('(')[0],
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
if (format === 'json') {
|
|
205
|
-
output(format, JSON.stringify(created, null, 2));
|
|
206
|
-
} else {
|
|
207
|
-
addLog(<SuccessLog message={`Created automation ${created._id}`} />);
|
|
208
|
-
output(format, renderWorkflow(created));
|
|
209
|
-
}
|
|
210
|
-
await terminate(0);
|
|
211
|
-
} catch (err) {
|
|
212
|
-
if (format === 'table') removeLastLog();
|
|
213
|
-
const message = err instanceof Error ? err.message : 'unknown error';
|
|
214
|
-
if (format === 'json') {
|
|
215
|
-
process.stderr.write(`Error: ${message}\n`);
|
|
216
|
-
} else {
|
|
217
|
-
addLog(<ErrorLog message={message} />);
|
|
218
|
-
}
|
|
219
|
-
await terminate(1);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
.command(
|
|
224
|
-
'list',
|
|
225
|
-
'List automations for the current deployment',
|
|
226
|
-
(yargs) => withFormat(withSubdomain(yargs)),
|
|
227
|
-
async (argv) => {
|
|
228
|
-
const format = resolveFormat(argv);
|
|
229
|
-
try {
|
|
230
|
-
const subdomain = requireSubdomain(argv.subdomain);
|
|
231
|
-
if (format === 'table') addLog(<SpinnerLog message="Fetching automations..." />);
|
|
232
|
-
const workflows = await listWorkflows(subdomain);
|
|
233
|
-
if (format === 'table') removeLastLog();
|
|
234
|
-
|
|
235
|
-
if (format === 'json') {
|
|
236
|
-
output(format, JSON.stringify(workflows, null, 2));
|
|
237
|
-
} else {
|
|
238
|
-
output(format, renderList(workflows));
|
|
239
|
-
}
|
|
240
|
-
await terminate(0);
|
|
241
|
-
} catch (err) {
|
|
242
|
-
if (format === 'table') removeLastLog();
|
|
243
|
-
const message = err instanceof Error ? err.message : 'unknown error';
|
|
244
|
-
if (format === 'json') {
|
|
245
|
-
process.stderr.write(`Error: ${message}\n`);
|
|
246
|
-
} else {
|
|
247
|
-
addLog(<ErrorLog message={message} />);
|
|
248
|
-
}
|
|
249
|
-
await terminate(1);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
)
|
|
253
|
-
.command(
|
|
254
|
-
'delete <id>',
|
|
255
|
-
'Delete an automation by ID',
|
|
256
|
-
(yargs) =>
|
|
257
|
-
withFormat(withSubdomain(yargs)).positional('id', {
|
|
258
|
-
type: 'string',
|
|
259
|
-
demandOption: true,
|
|
260
|
-
description: 'Automation schema ID',
|
|
261
|
-
}),
|
|
262
|
-
async (argv) => {
|
|
263
|
-
const format = resolveFormat(argv);
|
|
264
|
-
try {
|
|
265
|
-
const subdomain = requireSubdomain(argv.subdomain);
|
|
266
|
-
if (format === 'table') addLog(<SpinnerLog message="Deleting automation..." />);
|
|
267
|
-
await deleteWorkflow(subdomain, argv.id);
|
|
268
|
-
if (format === 'table') removeLastLog();
|
|
269
|
-
if (format === 'json') {
|
|
270
|
-
output(format, JSON.stringify({ success: true, id: argv.id }, null, 2));
|
|
271
|
-
} else {
|
|
272
|
-
addLog(<SuccessLog message={`Deleted automation ${argv.id}`} />);
|
|
273
|
-
}
|
|
274
|
-
await terminate(0);
|
|
275
|
-
} catch (err) {
|
|
276
|
-
if (format === 'table') removeLastLog();
|
|
277
|
-
const message = err instanceof Error ? err.message : 'unknown error';
|
|
278
|
-
if (format === 'json') {
|
|
279
|
-
process.stderr.write(`Error: ${message}\n`);
|
|
280
|
-
} else {
|
|
281
|
-
addLog(<ErrorLog message={message} />);
|
|
282
|
-
}
|
|
283
|
-
await terminate(1);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
)
|
|
287
|
-
.demandCommand(1, 'specify a subcommand: create, list, or delete');
|
package/src/workflows/types.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export const WORKFLOW_TYPES = [
|
|
2
|
-
'changelog',
|
|
3
|
-
'source-code-agent',
|
|
4
|
-
'translations',
|
|
5
|
-
'writing-style',
|
|
6
|
-
'typo-check',
|
|
7
|
-
'broken-link-detection',
|
|
8
|
-
'seo-metadata-audit',
|
|
9
|
-
'assistant-docs-updates',
|
|
10
|
-
'contextual-feedback-docs-updates',
|
|
11
|
-
] as const;
|
|
12
|
-
export type WorkflowType = (typeof WORKFLOW_TYPES)[number];
|
|
13
|
-
|
|
14
|
-
export type WorkflowCronTrigger = { cron: string };
|
|
15
|
-
export type WorkflowWebhookTrigger = { webhook: true };
|
|
16
|
-
export type WorkflowPushTrigger = { push: { repo: string; branch?: string }[] };
|
|
17
|
-
export type WorkflowComposioTrigger = {
|
|
18
|
-
composio: {
|
|
19
|
-
toolkit: string;
|
|
20
|
-
triggerSlug: string;
|
|
21
|
-
composioTriggerId?: string;
|
|
22
|
-
triggerConfig?: Record<string, unknown>;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type WorkflowTrigger =
|
|
27
|
-
| WorkflowCronTrigger
|
|
28
|
-
| WorkflowPushTrigger
|
|
29
|
-
| WorkflowComposioTrigger
|
|
30
|
-
| WorkflowWebhookTrigger;
|
|
31
|
-
|
|
32
|
-
export type WorkflowContextItem = {
|
|
33
|
-
repo: string;
|
|
34
|
-
public?: boolean;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type WorkflowNotify = {
|
|
38
|
-
slack?: {
|
|
39
|
-
channels?: string[];
|
|
40
|
-
channel_ids?: string[];
|
|
41
|
-
users?: string[];
|
|
42
|
-
user_ids?: string[];
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type WorkflowBody = {
|
|
47
|
-
name: string;
|
|
48
|
-
on: WorkflowTrigger;
|
|
49
|
-
prompt?: string;
|
|
50
|
-
type?: WorkflowType;
|
|
51
|
-
context?: WorkflowContextItem[];
|
|
52
|
-
automerge?: boolean;
|
|
53
|
-
notify?: WorkflowNotify;
|
|
54
|
-
config?: { translations?: { targetLanguages: string[] } };
|
|
55
|
-
tools?: { composio?: { toolkit: string }[] };
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type Workflow = {
|
|
59
|
-
_id: string;
|
|
60
|
-
deploymentId: string;
|
|
61
|
-
subdomain: string;
|
|
62
|
-
name: string;
|
|
63
|
-
prompt?: string;
|
|
64
|
-
type?: WorkflowType;
|
|
65
|
-
trigger: WorkflowTrigger;
|
|
66
|
-
status: 'active' | 'disabled' | 'deleted';
|
|
67
|
-
automerge?: boolean;
|
|
68
|
-
context?: WorkflowContextItem[];
|
|
69
|
-
notify?: WorkflowNotify;
|
|
70
|
-
createdAt: string;
|
|
71
|
-
updatedAt: string;
|
|
72
|
-
lastRanAt?: string;
|
|
73
|
-
};
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED