@aravindc26/velu 0.12.13 → 0.12.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aravindc26/velu",
3
- "version": "0.12.13",
3
+ "version": "0.12.14",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,12 +1,17 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { existsSync, utimesSync, statSync } from 'node:fs';
2
+ import { existsSync, readFileSync, writeFileSync, statSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
4
  import { generateSessionContent } from '@/lib/preview-content';
5
5
  import { verifyApiSecret, unauthorizedResponse } from '@/lib/preview-auth';
6
6
 
7
+ const RELOAD_MARKER = '\n// __RELOAD_TRIGGER__\n';
8
+
7
9
  /**
8
- * Touch source.config.ts to trigger fumadocs-mdx rescan,
10
+ * Modify source.config.ts content to trigger fumadocs-mdx rescan,
9
11
  * then wait for the .source output to regenerate.
12
+ *
13
+ * Just touching mtime is not enough — chokidar detects content changes,
14
+ * not mtime changes. We toggle a comment to force a real content change.
10
15
  */
11
16
  async function triggerMdxRegeneration(): Promise<void> {
12
17
  const configPath = resolve(process.cwd(), 'source.config.ts');
@@ -17,16 +22,26 @@ async function triggerMdxRegeneration(): Promise<void> {
17
22
  ? statSync(sourceDir).mtimeMs
18
23
  : 0;
19
24
 
20
- // Touch source.config.ts to trigger chokidar fumadocs-mdx full reload
21
- const now = new Date();
22
- utimesSync(configPath, now, now);
25
+ // Toggle a comment in source.config.ts to force a real content change.
26
+ // chokidar detects this on local filesystem via inotify, which triggers
27
+ // fumadocs-mdx to fully re-scan the content directory (even on NFS).
28
+ const content = readFileSync(configPath, 'utf-8');
29
+ const newContent = content.includes(RELOAD_MARKER)
30
+ ? content.replace(RELOAD_MARKER, '\n')
31
+ : content + RELOAD_MARKER;
32
+ writeFileSync(configPath, newContent, 'utf-8');
33
+
34
+ console.log('[PREVIEW] Triggered source.config.ts content change, waiting for MDX regeneration...');
23
35
 
24
36
  // Wait for .source directory to be updated (up to 30s)
25
37
  for (let i = 0; i < 300; i++) {
26
38
  await new Promise((r) => setTimeout(r, 100));
27
39
  if (existsSync(sourceDir)) {
28
40
  const currentMtime = statSync(sourceDir).mtimeMs;
29
- if (currentMtime > beforeMtime) return;
41
+ if (currentMtime > beforeMtime) {
42
+ console.log(`[PREVIEW] MDX regeneration detected after ${(i + 1) * 100}ms`);
43
+ return;
44
+ }
30
45
  }
31
46
  }
32
47
  console.warn('[PREVIEW] MDX regeneration timed out after 30s');