doccupine 0.0.140 → 0.0.142

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 (145) hide show
  1. package/README.md +14 -7
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +191 -0
  4. package/dist/index.d.ts +3 -7
  5. package/dist/index.js +5 -1894
  6. package/dist/lib/config-manager.d.ts +1 -0
  7. package/dist/lib/config-manager.js +63 -3
  8. package/dist/lib/generated-artifacts.d.ts +26 -0
  9. package/dist/lib/generated-artifacts.js +147 -0
  10. package/dist/lib/layout.js +30 -30
  11. package/dist/lib/metadata.js +58 -30
  12. package/dist/lib/openapi-types.d.ts +2 -2
  13. package/dist/lib/openapi.d.ts +6 -3
  14. package/dist/lib/openapi.js +330 -50
  15. package/dist/lib/output-safety.d.ts +15 -0
  16. package/dist/lib/output-safety.js +428 -0
  17. package/dist/lib/structures.js +11 -0
  18. package/dist/lib/utils.d.ts +10 -5
  19. package/dist/lib/utils.js +108 -5
  20. package/dist/mdx-to-nextjs-generator.d.ts +166 -0
  21. package/dist/mdx-to-nextjs-generator.js +2229 -0
  22. package/dist/templates/app/api/gate/route.d.ts +1 -1
  23. package/dist/templates/app/api/gate/route.js +18 -6
  24. package/dist/templates/app/api/mcp/route.d.ts +1 -1
  25. package/dist/templates/app/api/mcp/route.js +181 -111
  26. package/dist/templates/app/api/playground/route.d.ts +1 -1
  27. package/dist/templates/app/api/playground/route.js +45 -13
  28. package/dist/templates/app/api/rag/route.d.ts +1 -1
  29. package/dist/templates/app/api/rag/route.js +72 -20
  30. package/dist/templates/app/api/search/route.d.ts +1 -1
  31. package/dist/templates/app/api/search/route.js +5 -0
  32. package/dist/templates/app/robots.d.ts +1 -1
  33. package/dist/templates/app/robots.js +1 -26
  34. package/dist/templates/app/theme.d.ts +1 -1
  35. package/dist/templates/app/theme.js +31 -19
  36. package/dist/templates/components/Chat.d.ts +1 -1
  37. package/dist/templates/components/Chat.js +342 -34
  38. package/dist/templates/components/SearchDocs.d.ts +1 -1
  39. package/dist/templates/components/SearchDocs.js +63 -11
  40. package/dist/templates/components/SearchModalContent.d.ts +1 -1
  41. package/dist/templates/components/SearchModalContent.js +191 -49
  42. package/dist/templates/components/SideBar.d.ts +1 -1
  43. package/dist/templates/components/SideBar.js +8 -2
  44. package/dist/templates/components/layout/Accordion.d.ts +1 -1
  45. package/dist/templates/components/layout/Accordion.js +26 -3
  46. package/dist/templates/components/layout/Badge.d.ts +1 -1
  47. package/dist/templates/components/layout/Badge.js +1 -1
  48. package/dist/templates/components/layout/Button.d.ts +1 -1
  49. package/dist/templates/components/layout/Button.js +4 -4
  50. package/dist/templates/components/layout/Callout.d.ts +1 -1
  51. package/dist/templates/components/layout/Callout.js +6 -6
  52. package/dist/templates/components/layout/Card.d.ts +1 -1
  53. package/dist/templates/components/layout/Card.js +9 -4
  54. package/dist/templates/components/layout/CherryThemeProvider.d.ts +1 -1
  55. package/dist/templates/components/layout/CherryThemeProvider.js +63 -12
  56. package/dist/templates/components/layout/Code.d.ts +1 -1
  57. package/dist/templates/components/layout/Code.js +5 -5
  58. package/dist/templates/components/layout/CopyButton.d.ts +1 -1
  59. package/dist/templates/components/layout/CopyButton.js +1 -1
  60. package/dist/templates/components/layout/DemoTheme.d.ts +1 -1
  61. package/dist/templates/components/layout/DemoTheme.js +8 -28
  62. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  63. package/dist/templates/components/layout/DocsComponents.js +57 -6
  64. package/dist/templates/components/layout/GlobalStyles.d.ts +1 -1
  65. package/dist/templates/components/layout/GlobalStyles.js +15 -9
  66. package/dist/templates/components/layout/Prompt.d.ts +1 -1
  67. package/dist/templates/components/layout/Prompt.js +4 -7
  68. package/dist/templates/components/layout/Steps.d.ts +1 -1
  69. package/dist/templates/components/layout/Steps.js +7 -1
  70. package/dist/templates/components/layout/Tabs.d.ts +1 -1
  71. package/dist/templates/components/layout/Tabs.js +108 -19
  72. package/dist/templates/env.example.d.ts +1 -1
  73. package/dist/templates/env.example.js +11 -0
  74. package/dist/templates/eslint.config.d.ts +1 -1
  75. package/dist/templates/eslint.config.js +20 -0
  76. package/dist/templates/gitignore.d.ts +1 -1
  77. package/dist/templates/gitignore.js +4 -3
  78. package/dist/templates/lib/access.d.ts +1 -0
  79. package/dist/templates/lib/access.js +41 -0
  80. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  81. package/dist/templates/mdx/ai-assistant.mdx.js +17 -1
  82. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  83. package/dist/templates/mdx/api-playground.mdx.js +5 -3
  84. package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
  85. package/dist/templates/mdx/authentication.mdx.js +5 -3
  86. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  87. package/dist/templates/mdx/commands.mdx.js +20 -6
  88. package/dist/templates/mdx/components.mdx.d.ts +1 -1
  89. package/dist/templates/mdx/components.mdx.js +3 -0
  90. package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
  91. package/dist/templates/mdx/deployment-and-hosting.mdx.js +2 -2
  92. package/dist/templates/mdx/globals.mdx.d.ts +1 -1
  93. package/dist/templates/mdx/globals.mdx.js +14 -11
  94. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  95. package/dist/templates/mdx/model-context-protocol.mdx.js +22 -35
  96. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  97. package/dist/templates/mdx/platform/ai-assistant.mdx.js +23 -0
  98. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
  99. package/dist/templates/mdx/platform/api-playground.mdx.js +7 -0
  100. package/dist/templates/mdx/platform/authentication.mdx.d.ts +1 -0
  101. package/dist/templates/mdx/platform/authentication.mdx.js +63 -0
  102. package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -1
  103. package/dist/templates/mdx/platform/import-from-github.mdx.js +2 -2
  104. package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
  105. package/dist/templates/mdx/platform/index.mdx.js +1 -0
  106. package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
  107. package/dist/templates/mdx/platform/mcp.mdx.js +2 -1
  108. package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
  109. package/dist/templates/mdx/platform/navigation-settings.mdx.js +12 -1
  110. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  111. package/dist/templates/mdx/platform/publishing.mdx.js +43 -10
  112. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
  113. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +48 -9
  114. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  115. package/dist/templates/mdx/sections.mdx.js +4 -0
  116. package/dist/templates/mdx/space.mdx.d.ts +1 -0
  117. package/dist/templates/mdx/space.mdx.js +125 -0
  118. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  119. package/dist/templates/mdx/tabs.mdx.js +4 -0
  120. package/dist/templates/next.config.js +20 -8
  121. package/dist/templates/package.js +3 -3
  122. package/dist/templates/prettierignore.d.ts +1 -1
  123. package/dist/templates/prettierignore.js +1 -0
  124. package/dist/templates/proxy.js +47 -19
  125. package/dist/templates/scripts/build-docs-index.d.ts +1 -1
  126. package/dist/templates/scripts/build-docs-index.js +1 -0
  127. package/dist/templates/services/mcp/docsContentStub.d.ts +1 -0
  128. package/dist/templates/services/mcp/docsContentStub.js +1 -0
  129. package/dist/templates/services/mcp/server.d.ts +1 -1
  130. package/dist/templates/services/mcp/server.js +140 -83
  131. package/dist/templates/services/mcp/tools.d.ts +1 -1
  132. package/dist/templates/services/mcp/tools.js +65 -137
  133. package/dist/templates/utils/playgroundAllowlist.d.ts +1 -1
  134. package/dist/templates/utils/playgroundAllowlist.js +13 -4
  135. package/dist/templates/utils/rateLimit.d.ts +1 -1
  136. package/dist/templates/utils/rateLimit.js +40 -3
  137. package/dist/templates/utils/requestBody.d.ts +1 -0
  138. package/dist/templates/utils/requestBody.js +56 -0
  139. package/dist/templates/utils/ssrfGuard.d.ts +1 -1
  140. package/dist/templates/utils/ssrfGuard.js +138 -33
  141. package/package.json +13 -5
  142. package/dist/lib/mdxToMarkdown.d.ts +0 -1
  143. package/dist/lib/mdxToMarkdown.js +0 -134
  144. package/dist/templates/mdx/image-and-embeds.mdx.d.ts +0 -1
  145. package/dist/templates/mdx/image-and-embeds.mdx.js +0 -118
package/README.md CHANGED
@@ -35,11 +35,14 @@ Doccupine will prompt you for:
35
35
 
36
36
  It then scaffolds the app, installs dependencies, and starts the dev server. Open http://localhost:3000 to view your docs.
37
37
 
38
+ The source and output directories must not overlap. To prevent accidental data loss, Doccupine only claims an empty output directory, one containing harmless local metadata such as `.DS_Store` or `.env.local`, or an existing Doccupine-generated app. Run `doccupine config --reset` if an older configuration no longer passes validation.
39
+
38
40
  ## CLI Commands
39
41
 
40
42
  ```bash
41
43
  doccupine watch [options] # Default. Watch MDX files and start dev server
42
- doccupine build [options] # One-time build without starting the server
44
+ doccupine build [options] # Generate the site without installing or serving it
45
+ doccupine generate [options] # Alias for build
43
46
  doccupine config --show # Show current configuration
44
47
  doccupine config --reset # Re-prompt for configuration
45
48
  ```
@@ -53,6 +56,7 @@ doccupine config --reset # Re-prompt for configuration
53
56
  | `--port <port>` | Port for the dev server (default: `3000`). Auto-increments if taken. |
54
57
  | `--verbose` | Show all Next.js output including compilation details |
55
58
  | `--reset` | Re-prompt for watch/output directories |
59
+ | `--skip-install` | Generate and serve without running the dependency installer (installs are skipped automatically when `package.json` is unchanged) |
56
60
  | `--package-manager <name>` | Package manager for the generated app: `pnpm` or `npm` (default: auto-detect). Overrides the `packageManager` field in `doccupine.json`. |
57
61
 
58
62
  `build`:
@@ -149,7 +153,7 @@ Each entry has:
149
153
 
150
154
  ## API Reference
151
155
 
152
- Point Doccupine at an OpenAPI document (`.json`, `.yaml`, or `.yml`, OpenAPI 3.0/3.1) and it generates an interactive API reference: one page per operation, each with a live playground for sending requests. Set the `openapi` field in `doccupine.json`:
156
+ Point Doccupine at an OpenAPI document (`.json`, `.yaml`, or `.yml`, OpenAPI 3.0/3.1) and it generates an interactive API reference: a directory at `/api-reference` linking every operation, plus one page per operation with a live playground for sending requests. Set the `openapi` field in `doccupine.json`:
153
157
 
154
158
  ```json
155
159
  {
@@ -209,7 +213,7 @@ Doccupine generates `robots.ts` automatically for every site. When you set a `ur
209
213
  }
210
214
  ```
211
215
 
212
- You can override the URL at deploy time by setting the `NEXT_PUBLIC_SITE_URL` environment variable. When no URL is configured (neither in `config.json` nor via env), the sitemap is skipped and `robots.txt` is emitted without a sitemap reference.
216
+ You can override the URL at deploy time by setting the `NEXT_PUBLIC_SITE_URL` environment variable. When no URL is configured, `/sitemap.xml` is still served but stays empty, and `robots.txt` omits its sitemap reference until a public URL is available. The variable is baked in at build time, so changing it needs a redeploy.
213
217
 
214
218
  ## llms.txt
215
219
 
@@ -223,7 +227,7 @@ Doccupine generates [llms.txt](https://llmstxt.org) artifacts so AI agents can d
223
227
 
224
228
  The site name and description used in `llms.txt` come from `config.json` (`name`, `description`). Page URLs are absolute when `url` is set in `config.json` (or via `NEXT_PUBLIC_SITE_URL`), and root-relative otherwise.
225
229
 
226
- A `.doccupine-llms-manifest.json` file in the generated app tracks which per-page mirrors were emitted so renamed or deleted pages get cleaned up on the next regeneration. Don't commit this file — it's regenerated automatically.
230
+ A `.doccupine-artifacts.json` file in the generated app tracks generated route ownership and per-page mirrors so renamed or deleted sources clean up only their own outputs. Don't commit this file; it is regenerated automatically.
227
231
 
228
232
  ## AI Chat Setup
229
233
 
@@ -250,10 +254,13 @@ LLM_EMBEDDING_MODEL=text-embedding-3-small # Override the default embedding mod
250
254
  LLM_TEMPERATURE=0 # Set temperature (0-1, default: 0)
251
255
  LLM_EMBEDDING_DIMS=512 # Dimensions for the prebuilt search index (default: 512)
252
256
  RAG_RUNTIME_EMBED_MAX_CHUNKS=400 # Max chunks embedded on demand in production (default: 400; 0 requires a prebuilt index)
257
+ # RAG_API_KEY=... # Optional bearer auth for direct /api/rag requests
253
258
  ```
254
259
 
255
260
  `LLM_EMBEDDING_DIMS` Matryoshka-truncates document vectors so the prebuilt search index stays small; lower values shrink the index at a slight cost to recall. `RAG_RUNTIME_EMBED_MAX_CHUNKS` caps how many chunks the chat will embed on demand in production before requiring a prebuilt index (it's unlimited under `next dev`).
256
261
 
262
+ Public documentation leaves browser chat available by default. Setting `RAG_API_KEY` requires a bearer token for `/api/rag` and is intended for server-to-server use; the built-in browser cannot safely hold that secret. Use `SITE_PASSWORD` instead when authenticated browser visitors should retain chat access.
263
+
257
264
  Default models per provider:
258
265
 
259
266
  | Provider | Chat model | Embedding model |
@@ -270,7 +277,7 @@ The generated app exposes an MCP endpoint at `/api/mcp` with three tools:
270
277
  - `get_doc` - retrieve a specific document by path
271
278
  - `list_docs` - list all available documents
272
279
 
273
- This lets AI agents (Claude, ChatGPT, etc.) query your docs programmatically. Requires the AI chat setup above for embeddings.
280
+ This lets AI agents (Claude, ChatGPT, etc.) query your docs programmatically. Semantic `search_docs` requires the AI setup above for embeddings; `get_doc` and `list_docs` work from the generated content manifest without an embedding provider.
274
281
 
275
282
  ## Password Protection
276
283
 
@@ -283,12 +290,12 @@ SITE_PASSWORD=choose-a-strong-shared-password
283
290
  When set, every visitor sees a login screen until they enter the password. Protection is enforced across three layers:
284
291
 
285
292
  - **Pages** are gated behind the login screen.
286
- - **Content APIs** (`/api/rag` chat and `/api/search`) return `401` without a valid session, so the docs can't be scraped around the login.
293
+ - **Content APIs** (`/api/rag` chat, `/api/search`, and the `/api/playground` proxy) return `401` without a valid session, so the docs can't be scraped and the proxy can't relay anonymous requests around the login. Each route re-checks the session itself, not just the middleware.
287
294
  - **Search engines and crawlers** are blocked: `robots.txt` disallows everything, pages carry a `noindex, nofollow` tag, and responses include an `X-Robots-Tag` header.
288
295
 
289
296
  A successful login sets a signed, `httpOnly` cookie that lasts 30 days. The cookie stores an HMAC of the password, never the password itself. Leave `SITE_PASSWORD` unset (the default) to keep the site fully public. Documentation pages stay statically rendered either way - the gate is enforced in middleware.
290
297
 
291
- > **Note:** The [MCP endpoint](#mcp-server) uses its own `DOCS_API_KEY` bearer token and is not affected by `SITE_PASSWORD`.
298
+ > **Note:** The [MCP endpoint](#mcp-server) uses `DOCS_API_KEY` bearer authentication when configured. Without an API key, a password-protected site requires the normal gate session for MCP as well.
292
299
 
293
300
  ## License
294
301
 
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function runCli(argv?: string[]): Promise<void>;
package/dist/cli.js ADDED
@@ -0,0 +1,191 @@
1
+ import { spawn } from "child_process";
2
+ import { createHash } from "crypto";
3
+ import { fileURLToPath } from "url";
4
+ import { Command } from "commander";
5
+ import fs from "fs-extra";
6
+ import path from "path";
7
+ import chalk from "chalk";
8
+ import { ConfigManager, normalizeOpenApiConfig } from "./lib/config-manager.js";
9
+ import { findAvailablePort, resolvePackageManager, writeFileAtomic, } from "./lib/utils.js";
10
+ import { MDXToNextJSGenerator } from "./mdx-to-nextjs-generator.js";
11
+ async function dependencyFingerprint(outputDir, packageManager) {
12
+ const packageJson = await fs.readFile(path.join(outputDir, "package.json"), "utf8");
13
+ return createHash("sha256")
14
+ .update(packageManager)
15
+ .update("\0")
16
+ .update(packageJson)
17
+ .digest("hex");
18
+ }
19
+ async function needsDependencyInstall(outputDir, packageManager) {
20
+ if (!(await fs.pathExists(path.join(outputDir, "node_modules"))))
21
+ return true;
22
+ const stampPath = path.join(outputDir, ".doccupine-install");
23
+ try {
24
+ const expected = await dependencyFingerprint(outputDir, packageManager);
25
+ return (await fs.readFile(stampPath, "utf8")).trim() !== expected;
26
+ }
27
+ catch {
28
+ return true;
29
+ }
30
+ }
31
+ async function recordDependencyInstall(outputDir, packageManager) {
32
+ const fingerprint = await dependencyFingerprint(outputDir, packageManager);
33
+ await writeFileAtomic(path.join(outputDir, ".doccupine-install"), `${fingerprint}\n`);
34
+ }
35
+ export async function runCli(argv) {
36
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
37
+ const packageJson = JSON.parse(await fs.readFile(path.join(__dirname, "..", "package.json"), "utf8"));
38
+ const program = new Command();
39
+ program
40
+ .name("doccupine")
41
+ .description("Watch MDX files and generate Next.js documentation pages automatically")
42
+ .version(packageJson.version);
43
+ program
44
+ .command("watch", { isDefault: true })
45
+ .description("Watch a directory for MDX changes and generate Next.js app")
46
+ .option("--port <port>", "Port for Next.js dev server")
47
+ .option("--verbose", "Show verbose output")
48
+ .option("--reset", "Reset configuration and prompt for new directories")
49
+ .option("--skip-install", "Skip dependency installation")
50
+ .option("--package-manager <name>", "Package manager for the generated app: pnpm or npm (default: auto-detect)")
51
+ .action(async (options) => {
52
+ const configManager = new ConfigManager();
53
+ const config = await configManager.getConfig({
54
+ reset: options.reset,
55
+ port: options.port,
56
+ });
57
+ const generator = new MDXToNextJSGenerator(config.watchDir, config.outputDir, normalizeOpenApiConfig(config.openapi));
58
+ // Config paths are project-relative; child processes get an absolute cwd.
59
+ const outputDir = path.resolve(process.cwd(), config.outputDir);
60
+ await generator.init();
61
+ let devServer = null;
62
+ // Prefer pnpm (the generated app ships a pnpm workspace) and fall back to
63
+ // npm. A --package-manager flag or a "packageManager" field in
64
+ // doccupine.json overrides detection; the flag wins.
65
+ const packageManager = resolvePackageManager(options.packageManager ?? config.packageManager);
66
+ console.log(chalk.blue(`šŸ“¦ Using ${packageManager.name}...`));
67
+ if (options.skipInstall) {
68
+ console.log(chalk.yellow("ā­ļø Skipping dependency installation"));
69
+ }
70
+ else if (await needsDependencyInstall(outputDir, packageManager.name)) {
71
+ console.log(chalk.blue("šŸ“¦ Installing dependencies..."));
72
+ const install = spawn(packageManager.bin, ["install"], {
73
+ cwd: outputDir,
74
+ stdio: "inherit",
75
+ });
76
+ await new Promise((resolve, reject) => {
77
+ install.on("close", (code) => {
78
+ if (code === 0) {
79
+ resolve(void 0);
80
+ }
81
+ else {
82
+ reject(new Error(`${packageManager.name} install failed with code ${code}`));
83
+ }
84
+ });
85
+ install.on("error", reject);
86
+ });
87
+ await recordDependencyInstall(outputDir, packageManager.name);
88
+ console.log(chalk.green("āœ… Dependencies installed"));
89
+ }
90
+ else {
91
+ console.log(chalk.green("āœ… Dependencies are already up to date"));
92
+ }
93
+ const requestedPort = Number(config.port);
94
+ const port = await findAvailablePort(requestedPort);
95
+ if (port !== requestedPort) {
96
+ console.log(chalk.yellow(`āš ļø Port ${config.port} is in use, using port ${port} instead`));
97
+ }
98
+ console.log(chalk.blue(`šŸš€ Starting Next.js dev server on port ${port}...`));
99
+ const portStr = String(port);
100
+ const devArgs = packageManager.name === "npm"
101
+ ? ["run", "dev", "--", "--port", portStr]
102
+ : ["run", "dev", "--port", portStr];
103
+ devServer = spawn(packageManager.bin, devArgs, {
104
+ cwd: outputDir,
105
+ stdio: ["ignore", "pipe", "pipe"],
106
+ });
107
+ devServer.stdout?.on("data", (data) => {
108
+ const output = data.toString();
109
+ if (output.includes("Ready") || output.includes("started")) {
110
+ console.log(chalk.green(`🌐 Next.js ready at http://localhost:${port}`));
111
+ }
112
+ if (options.verbose) {
113
+ process.stdout.write(chalk.gray("[Next.js] ") + output);
114
+ }
115
+ else if (output.includes("compiled") ||
116
+ output.includes("error") ||
117
+ output.includes("Ready")) {
118
+ process.stdout.write(chalk.gray("[Next.js] ") + output);
119
+ }
120
+ });
121
+ devServer.stderr?.on("data", (data) => {
122
+ const output = data.toString();
123
+ if (options.verbose ||
124
+ output.includes("Error") ||
125
+ output.includes("error")) {
126
+ process.stderr.write(chalk.red("[Next.js] ") + output);
127
+ }
128
+ });
129
+ devServer.on("error", (error) => {
130
+ console.error(chalk.red("āŒ Error starting dev server:"), error);
131
+ });
132
+ devServer.on("close", (code) => {
133
+ if (code && code !== 0) {
134
+ console.error(chalk.red(`āŒ Next.js dev server exited with code ${code}`));
135
+ }
136
+ });
137
+ await generator.startWatching();
138
+ process.on("SIGINT", async () => {
139
+ console.log(chalk.yellow("\nšŸ›‘ Shutting down..."));
140
+ await generator.stop();
141
+ if (devServer) {
142
+ devServer.kill();
143
+ }
144
+ process.exit(0);
145
+ });
146
+ console.log(chalk.green("šŸŽ‰ Generator is running! Press Ctrl+C to stop."));
147
+ console.log(chalk.cyan(`šŸ“ Edit your MDX files in: ${config.watchDir}`));
148
+ });
149
+ program
150
+ .command("build")
151
+ .alias("generate")
152
+ .description("Generate the Next.js app once without running its build")
153
+ .option("--reset", "Reset configuration and prompt for new directories")
154
+ .action(async (options) => {
155
+ const configManager = new ConfigManager();
156
+ const config = await configManager.getConfig({
157
+ reset: options.reset,
158
+ });
159
+ const generator = new MDXToNextJSGenerator(config.watchDir, config.outputDir, normalizeOpenApiConfig(config.openapi));
160
+ await generator.init();
161
+ console.log(chalk.green("šŸŽ‰ Generation complete!"));
162
+ });
163
+ program
164
+ .command("config")
165
+ .description("Show or reset configuration")
166
+ .option("--show", "Show current configuration")
167
+ .option("--reset", "Reset configuration")
168
+ .action(async (options) => {
169
+ const configManager = new ConfigManager();
170
+ if (options.show) {
171
+ const config = await configManager.loadConfig();
172
+ if (config) {
173
+ console.log(chalk.blue("šŸ“„ Current configuration:"));
174
+ console.log(chalk.white("Watch Directory:"), chalk.cyan(path.relative(process.cwd(), config.watchDir)));
175
+ console.log(chalk.white("Output Directory:"), chalk.cyan(path.relative(process.cwd(), config.outputDir)));
176
+ console.log(chalk.white("Port:"), chalk.cyan(config.port || "3000"));
177
+ }
178
+ else {
179
+ console.log(chalk.yellow("āš ļø No configuration file found"));
180
+ }
181
+ }
182
+ else if (options.reset) {
183
+ await configManager.getConfig({ reset: true });
184
+ console.log(chalk.green("āœ… Configuration reset"));
185
+ }
186
+ else {
187
+ console.log(chalk.blue("Use --show to display configuration or --reset to reset it"));
188
+ }
189
+ });
190
+ await program.parseAsync(argv ?? process.argv);
191
+ }
package/dist/index.d.ts CHANGED
@@ -1,13 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  export { generateSlug, getFullSlug, escapeTemplateContent, toJsStringLiteral, } from "./lib/utils.js";
3
+ export { MDXToNextJSGenerator } from "./mdx-to-nextjs-generator.js";
3
4
  /**
4
5
  * True when this file is what node was asked to run, rather than a module some
5
- * other process imported. The test suite imports this file for its exported
6
- * helpers; without this guard, that import parses argv, falls through to the
7
- * default `watch` command, and prompts for config / starts file watchers.
8
- *
9
- * Compares realpaths because npm installs the bin as a symlink
10
- * (`node_modules/.bin/doccupine` -> `dist/index.js`), so `process.argv[1]` and
11
- * `import.meta.url` can name the same file by different paths.
6
+ * other process imported. Compares realpaths because npm installs the bin as a
7
+ * symlink (`node_modules/.bin/doccupine` -> `dist/index.js`).
12
8
  */
13
9
  export declare function isProcessEntrypoint(entry?: string | undefined, self?: string): boolean;