@aravindc26/velu 0.12.9 → 0.12.10

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.9",
3
+ "version": "0.12.10",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -511,30 +511,37 @@ function previewServerEnv(): NodeJS.ProcessEnv {
511
511
  }
512
512
 
513
513
  async function previewServer(port: number) {
514
- const runtimeDir = join(PACKAGE_ROOT, ".preview-out");
514
+ // Allow Docker to pre-populate the runtime dir via PREVIEW_RUNTIME_DIR
515
+ const runtimeDir = process.env.PREVIEW_RUNTIME_DIR || join(PACKAGE_ROOT, ".preview-out");
515
516
 
516
- // Clean and copy MAIN ENGINE to runtime dir
517
- try { rmSync(runtimeDir, { recursive: true, force: true }); } catch {}
518
- copyDirMerge(PREVIEW_ENGINE_DIR, runtimeDir);
517
+ // Skip engine copy if the runtime dir is already set up (e.g. Docker pre-copy)
518
+ const runtimeAppDir = join(runtimeDir, "app");
519
+ if (existsSync(runtimeAppDir) && process.env.PREVIEW_RUNTIME_DIR) {
520
+ // Runtime dir already exists and was explicitly set — skip copy
521
+ } else {
522
+ // Clean and copy MAIN ENGINE to runtime dir
523
+ try { rmSync(runtimeDir, { recursive: true, force: true }); } catch {}
524
+ copyDirMerge(PREVIEW_ENGINE_DIR, runtimeDir);
519
525
 
520
- // Copy engine-core for shared components, CSS, and plugins (@core/* imports)
521
- copyDirMerge(ENGINE_CORE_DIR, join(runtimeDir, "engine-core"));
526
+ // Copy engine-core for shared components, CSS, and plugins (@core/* imports)
527
+ copyDirMerge(ENGINE_CORE_DIR, join(runtimeDir, "engine-core"));
528
+ }
522
529
 
523
- // Activate preview routes: move _preview/* to app root
530
+ // Activate preview routes: move _preview/* to app root (idempotent — skips if already done)
524
531
  const appDir = join(runtimeDir, "app");
525
532
  const previewDir = join(appDir, "_preview");
526
533
 
527
- // Remove production-only routes that don't apply to preview
528
- for (const dir of ["(docs)", "sitemap.xml", "robots.txt", "og", "llms-file", "llms-full-file", "md-file", "rss-file", "_md"]) {
529
- try { rmSync(join(appDir, dir), { recursive: true, force: true }); } catch {}
530
- }
531
- // Remove production root layout/page (preview has its own in _preview/)
532
- for (const file of ["layout.tsx", "page.tsx"]) {
533
- try { rmSync(join(appDir, file), { force: true }); } catch {}
534
- }
535
-
536
- // Move preview routes to app root
537
534
  if (existsSync(previewDir)) {
535
+ // Remove production-only routes that don't apply to preview
536
+ for (const dir of ["(docs)", "sitemap.xml", "robots.txt", "og", "llms-file", "llms-full-file", "md-file", "rss-file", "_md"]) {
537
+ try { rmSync(join(appDir, dir), { recursive: true, force: true }); } catch {}
538
+ }
539
+ // Remove production root layout/page (preview has its own in _preview/)
540
+ for (const file of ["layout.tsx", "page.tsx"]) {
541
+ try { rmSync(join(appDir, file), { force: true }); } catch {}
542
+ }
543
+
544
+ // Move preview routes to app root
538
545
  copyDirMerge(previewDir, appDir);
539
546
  rmSync(previewDir, { recursive: true, force: true });
540
547
  }
@@ -22,19 +22,15 @@ const WORKSPACE_DIR = process.env.WORKSPACE_DIR || '/mnt/nfs_share/editor_sessio
22
22
  const PRIMARY_CONFIG_NAME = 'docs.json';
23
23
  const LEGACY_CONFIG_NAME = 'velu.json';
24
24
 
25
- const STATIC_EXTENSIONS = new Set([
26
- '.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.ico',
27
- '.mp4', '.webm',
28
- '.mp3', '.wav',
29
- '.json', '.yaml', '.yml',
30
- '.css',
31
- ]);
32
-
33
25
  /**
34
- * Copy static assets (images, JSON specs, etc.) from workspace to public/
35
- * so that OpenAPI spec files and images are resolvable by components.
26
+ * Copy only spec files (JSON/YAML) from workspace to public/ so the
27
+ * OpenAPI component can resolve them. Images and other assets are served
28
+ * on-demand through the session assets API route, so we skip them here
29
+ * to keep session init fast.
36
30
  */
37
- function copyStaticAssets(docsDir: string): void {
31
+ const SPEC_EXTENSIONS = new Set(['.json', '.yaml', '.yml']);
32
+
33
+ function copySpecFiles(docsDir: string): void {
38
34
  const publicDir = resolve('public');
39
35
 
40
36
  function walk(dir: string): void {
@@ -49,7 +45,7 @@ function copyStaticAssets(docsDir: string): void {
49
45
  continue;
50
46
  }
51
47
  const ext = extname(entry.name).toLowerCase();
52
- if (!STATIC_EXTENSIONS.has(ext)) continue;
48
+ if (!SPEC_EXTENSIONS.has(ext)) continue;
53
49
  const rel = relative(docsDir, srcPath);
54
50
  const destPath = join(publicDir, rel);
55
51
  mkdirSync(dirname(destPath), { recursive: true });
@@ -622,8 +618,8 @@ export function generateSessionContent(sessionId: string): {
622
618
  }
623
619
  mkdirSync(outputDir, { recursive: true });
624
620
 
625
- // Copy static assets (images, OpenAPI specs, etc.) to public/ so components can resolve them
626
- copyStaticAssets(workspaceDir);
621
+ // Copy spec files (JSON/YAML) to public/ so the OpenAPI component can resolve them
622
+ copySpecFiles(workspaceDir);
627
623
 
628
624
  const { config, variables } = loadConfig(workspaceDir);
629
625
  const navLanguages = config.navigation?.languages;