@lukoweb/apitogo 0.2.60 → 0.2.61
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/cli/cli.js +893 -527
- package/docs/cli/commands.md +6 -6
- package/docs/cli/go-live.md +12 -12
- package/docs/cli/overview.md +26 -27
- package/docs/cli/setup.md +38 -46
- package/docs/cli/shape.md +32 -35
- package/docs/cli/walkthrough.md +19 -19
- package/docs/components/slot.mdx +116 -116
- package/docs/configuration/api-reference.md +1 -1
- package/docs/configuration/authentication.md +3 -3
- package/docs/configuration/footer.mdx +89 -89
- package/docs/configuration/gateway.md +8 -8
- package/docs/configuration/make-config.mdx +20 -10
- package/docs/configuration/overview.md +3 -3
- package/docs/configuration/plans.md +5 -5
- package/docs/configuration/portal.md +36 -0
- package/docs/customization/colors-theme.mdx +255 -255
- package/docs/customization/fonts.md +105 -105
- package/docs/customization/landing-page.md +1 -1
- package/docs/deploy/apitogo.md +3 -3
- package/docs/deployment.md +3 -3
- package/docs/guides/custom-pages.md +3 -3
- package/docs/guides/customer-account.md +1 -1
- package/docs/guides/stripe-setup.mdx +9 -9
- package/docs/markdown/frontmatter.md +2 -2
- package/docs/mcp/go-live.md +7 -7
- package/docs/mcp/overview.md +58 -58
- package/docs/mcp/setup.md +6 -6
- package/docs/mcp/shape.md +2 -2
- package/docs/mcp/tools.md +57 -57
- package/docs/quickstart.md +6 -4
- package/docs/writing.mdx +68 -68
- package/package.json +1 -1
- package/src/config/apitogo-config-core.ts +11 -1
- package/src/config/v2/resolve.ts +19 -0
- package/src/config/v2/rules.ts +88 -0
- package/src/config/v2/schema.ts +28 -0
- package/src/config/v2/wrapper.ts +76 -13
- package/src/vite/config.ts +278 -273
- package/src/vite/markdown-output-path.ts +48 -0
- package/src/vite/plugin-markdown-export.ts +210 -214
- package/src/vite/prerender/prerender.ts +4 -4
- package/src/vite/watch-ignore.ts +19 -0
|
@@ -1,214 +1,210 @@
|
|
|
1
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { matchPath } from "react-router";
|
|
4
|
-
import type { Plugin } from "vite";
|
|
5
|
-
import { getCurrentConfig } from "../config/loader.js";
|
|
6
|
-
import { ProtectedRoutesSchema } from "../config/validators/ProtectedRoutesSchema.js";
|
|
7
|
-
import { joinUrl } from "../lib/util/joinUrl.js";
|
|
8
|
-
import { readFrontmatter } from "../lib/util/readFrontmatter.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* -
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
llmsConfig?.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
llmsConfig?.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
res.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
llmsConfig?.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export default viteMarkdownExportPlugin;
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { matchPath } from "react-router";
|
|
4
|
+
import type { Plugin } from "vite";
|
|
5
|
+
import { getCurrentConfig } from "../config/loader.js";
|
|
6
|
+
import { ProtectedRoutesSchema } from "../config/validators/ProtectedRoutesSchema.js";
|
|
7
|
+
import { joinUrl } from "../lib/util/joinUrl.js";
|
|
8
|
+
import { readFrontmatter } from "../lib/util/readFrontmatter.js";
|
|
9
|
+
import { markdownOutputPath } from "./markdown-output-path.js";
|
|
10
|
+
import {
|
|
11
|
+
globMarkdownFiles,
|
|
12
|
+
resolveCustomNavigationPaths,
|
|
13
|
+
} from "./plugin-docs.js";
|
|
14
|
+
|
|
15
|
+
export type MarkdownFileInfo = {
|
|
16
|
+
filePath: string;
|
|
17
|
+
routePath: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
content: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const processMarkdownFile = async (
|
|
24
|
+
filePath: string,
|
|
25
|
+
): Promise<{ content: string; title?: string; description?: string }> => {
|
|
26
|
+
const { content: markdownContent, data: frontmatter } =
|
|
27
|
+
await readFrontmatter(filePath);
|
|
28
|
+
|
|
29
|
+
let finalMarkdown = markdownContent;
|
|
30
|
+
if (frontmatter.title) {
|
|
31
|
+
// Add title as H1 at the beginning, matching the behavior in MdxPage.tsx
|
|
32
|
+
finalMarkdown = `# ${frontmatter.title}\n${markdownContent}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
content: finalMarkdown,
|
|
37
|
+
title: frontmatter.title,
|
|
38
|
+
description: frontmatter.description,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* This plugin exports markdown files (.md) for each document during the build process.
|
|
44
|
+
* In development mode, you can access documents at their URL path with .md extension
|
|
45
|
+
* (e.g., /foo/hello.md) to get the raw markdown without frontmatter.
|
|
46
|
+
*
|
|
47
|
+
* Markdown files are generated when:
|
|
48
|
+
* - publishMarkdown is enabled (for copy button functionality)
|
|
49
|
+
* - llmsTxt or llmsTxtFull is enabled (for generating llms.txt files)
|
|
50
|
+
*
|
|
51
|
+
* It also writes metadata to markdown-info.json used by the llms.txt generator.
|
|
52
|
+
*/
|
|
53
|
+
const viteMarkdownExportPlugin = (): Plugin => {
|
|
54
|
+
let markdownFiles: Record<string, string> = {};
|
|
55
|
+
let markdownFileInfos: MarkdownFileInfo[] = [];
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
name: "zudoku-markdown-export-plugin",
|
|
59
|
+
applyToEnvironment(env) {
|
|
60
|
+
return env.name === "ssr";
|
|
61
|
+
},
|
|
62
|
+
async buildStart() {
|
|
63
|
+
const config = getCurrentConfig();
|
|
64
|
+
const llmsConfig = config.docs?.llms;
|
|
65
|
+
|
|
66
|
+
const needsMdFiles =
|
|
67
|
+
config.docs?.publishMarkdown ||
|
|
68
|
+
llmsConfig?.llmsTxt ||
|
|
69
|
+
llmsConfig?.llmsTxtFull;
|
|
70
|
+
|
|
71
|
+
if (config.__meta.mode === "standalone" || !needsMdFiles) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
markdownFiles = await resolveCustomNavigationPaths(
|
|
76
|
+
config,
|
|
77
|
+
await globMarkdownFiles(config, { absolute: true }),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// Filter out protected routes unless `includeProtected` is true
|
|
81
|
+
if (!llmsConfig?.includeProtected) {
|
|
82
|
+
const protectedRoutes = ProtectedRoutesSchema.parse(
|
|
83
|
+
config.protectedRoutes,
|
|
84
|
+
);
|
|
85
|
+
if (protectedRoutes) {
|
|
86
|
+
const isProtectedRoute = (routePath: string): boolean => {
|
|
87
|
+
return Object.keys(protectedRoutes).some((route) =>
|
|
88
|
+
matchPath({ path: route, end: true }, routePath),
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Remove protected routes from the mapping
|
|
93
|
+
for (const routePath of Object.keys(markdownFiles)) {
|
|
94
|
+
if (isProtectedRoute(routePath)) {
|
|
95
|
+
delete markdownFiles[routePath];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
async configureServer(server) {
|
|
102
|
+
const config = getCurrentConfig();
|
|
103
|
+
const llmsConfig = config.docs?.llms;
|
|
104
|
+
|
|
105
|
+
// Serve .md files if markdown export is needed
|
|
106
|
+
const needsMdFiles =
|
|
107
|
+
config.docs?.publishMarkdown ||
|
|
108
|
+
llmsConfig?.llmsTxt ||
|
|
109
|
+
llmsConfig?.llmsTxtFull;
|
|
110
|
+
|
|
111
|
+
if (!needsMdFiles) return;
|
|
112
|
+
|
|
113
|
+
markdownFiles = await resolveCustomNavigationPaths(
|
|
114
|
+
config,
|
|
115
|
+
await globMarkdownFiles(config, { absolute: true }),
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
server.middlewares.use(async (req, res, next) => {
|
|
119
|
+
if (req.method !== "GET" || !req.url?.endsWith(".md")) {
|
|
120
|
+
return next();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const basePath = joinUrl(config.basePath);
|
|
124
|
+
const routePath = joinUrl(
|
|
125
|
+
req.url.slice(basePath.length).replace(/\.mdx?$/, ""),
|
|
126
|
+
);
|
|
127
|
+
const filePath = markdownFiles[routePath];
|
|
128
|
+
|
|
129
|
+
if (!filePath) return next();
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const { content } = await processMarkdownFile(filePath);
|
|
133
|
+
res.setHeader("Content-Type", "text/markdown; charset=utf-8");
|
|
134
|
+
res.end(content);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
// biome-ignore lint/suspicious/noConsole: Logging allowed here
|
|
137
|
+
console.warn(`Failed to serve markdown for ${routePath}:`, error);
|
|
138
|
+
return next();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
async closeBundle() {
|
|
143
|
+
const config = getCurrentConfig();
|
|
144
|
+
const llmsConfig = config.docs?.llms;
|
|
145
|
+
|
|
146
|
+
const needsMdFiles =
|
|
147
|
+
config.docs?.publishMarkdown ||
|
|
148
|
+
llmsConfig?.llmsTxt ||
|
|
149
|
+
llmsConfig?.llmsTxtFull;
|
|
150
|
+
|
|
151
|
+
if (
|
|
152
|
+
process.env.NODE_ENV !== "production" ||
|
|
153
|
+
Object.keys(markdownFiles).length === 0 ||
|
|
154
|
+
!needsMdFiles
|
|
155
|
+
) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// During build, write .md files to the dist directory
|
|
160
|
+
const distDir = path.join(
|
|
161
|
+
config.__meta.rootDir,
|
|
162
|
+
"dist",
|
|
163
|
+
config.basePath ?? "",
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
markdownFileInfos = [];
|
|
167
|
+
|
|
168
|
+
for (const [routePath, filePath] of Object.entries(markdownFiles)) {
|
|
169
|
+
try {
|
|
170
|
+
const {
|
|
171
|
+
content: finalMarkdown,
|
|
172
|
+
title,
|
|
173
|
+
description,
|
|
174
|
+
} = await processMarkdownFile(filePath);
|
|
175
|
+
|
|
176
|
+
markdownFileInfos.push({
|
|
177
|
+
filePath,
|
|
178
|
+
routePath,
|
|
179
|
+
title,
|
|
180
|
+
description,
|
|
181
|
+
content: finalMarkdown,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const outputPath = markdownOutputPath(distDir, routePath);
|
|
185
|
+
|
|
186
|
+
await mkdir(path.dirname(outputPath), { recursive: true });
|
|
187
|
+
|
|
188
|
+
await writeFile(outputPath, finalMarkdown, "utf-8");
|
|
189
|
+
} catch (error) {
|
|
190
|
+
// biome-ignore lint/suspicious/noConsole: Logging allowed here
|
|
191
|
+
console.warn(`Failed to export markdown for ${routePath}:`, error);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (config.docs?.llms?.llmsTxt || config.docs?.llms?.llmsTxtFull) {
|
|
196
|
+
const markdownInfoPath = path.join(
|
|
197
|
+
config.__meta.rootDir,
|
|
198
|
+
"node_modules/.apitogo/markdown-info.json",
|
|
199
|
+
);
|
|
200
|
+
await writeFile(
|
|
201
|
+
markdownInfoPath,
|
|
202
|
+
JSON.stringify(markdownFileInfos, null, 2),
|
|
203
|
+
"utf-8",
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export default viteMarkdownExportPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFile
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -13,6 +13,7 @@ import type { ZudokuConfig } from "../../config/validators/ZudokuConfig.js";
|
|
|
13
13
|
import { runPluginTransformConfig } from "../../lib/core/transform-config.js";
|
|
14
14
|
import invariant from "../../lib/util/invariant.js";
|
|
15
15
|
import { joinUrl } from "../../lib/util/joinUrl.js";
|
|
16
|
+
import { removeExportedMarkdown } from "../markdown-output-path.js";
|
|
16
17
|
import type { MarkdownFileInfo } from "../plugin-markdown-export.js";
|
|
17
18
|
import { isTTY, throttle, writeLine } from "../reporter.js";
|
|
18
19
|
import { generateSitemap } from "../sitemap.js";
|
|
@@ -231,10 +232,9 @@ export const prerender = async ({
|
|
|
231
232
|
});
|
|
232
233
|
}
|
|
233
234
|
|
|
235
|
+
// The .md copies were only written for llms.txt: remove them from dist again.
|
|
234
236
|
if (!docsConfig.publishMarkdown) {
|
|
235
|
-
await
|
|
236
|
-
markdownFileInfos.map((info) => rm(info.filePath).catch(() => {})),
|
|
237
|
-
);
|
|
237
|
+
await removeExportedMarkdown(distDir, markdownFileInfos);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
|
package/src/vite/watch-ignore.ts
CHANGED
|
@@ -69,6 +69,25 @@ export function stateIgnore(
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/** A state folder (`.apitogo/` or `apitogo/.state/`) anywhere in a path relative to the site root. */
|
|
73
|
+
const STATE_FOLDER = /(?:^|[\\/])(?:\.apitogo|apitogo[\\/]\.state)(?:[\\/]|$)/;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* What the dev server's watcher must leave alone below the site root of any project: the state folder of a config
|
|
77
|
+
* version 2 project kept inside it (a test project in a subfolder, say). Its `generated/content` links back to that
|
|
78
|
+
* project's folder, so a watcher that follows the link walks `content/apitogo/.state/generated/content/...` forever
|
|
79
|
+
* and keeps a CPU core busy, and every page waits seconds for the server. Paths outside the site root are left to
|
|
80
|
+
* {@link stateIgnore}.
|
|
81
|
+
*/
|
|
82
|
+
export function nestedStateIgnore(root: string): (file: string) => boolean {
|
|
83
|
+
const resolvedRoot = path.resolve(root);
|
|
84
|
+
return (file) => {
|
|
85
|
+
const relative = path.relative(resolvedRoot, path.resolve(file));
|
|
86
|
+
if (relative.startsWith("..") || path.isAbsolute(relative)) return false;
|
|
87
|
+
return STATE_FOLDER.test(relative);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
/**
|
|
73
92
|
* The folders the dev server may serve files from. The site root of a config version 2 workspace sits inside the
|
|
74
93
|
* state folder, so the package (`node_modules`) and the tenant's pages are outside it. Without them the page's main
|