@aravindc26/velu 0.12.9 → 0.12.11
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 +1 -1
- package/src/cli.ts +24 -17
- package/src/engine/lib/preview-content.ts +10 -14
- package/src/engine/{middleware.ts → proxy.ts} +1 -1
package/package.json
CHANGED
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
|
-
|
|
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
|
-
//
|
|
517
|
-
|
|
518
|
-
|
|
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
|
-
|
|
521
|
-
|
|
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
|
|
35
|
-
*
|
|
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
|
-
|
|
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 (!
|
|
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
|
|
626
|
-
|
|
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;
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
const compiledRedirects = compileRedirectRules(normalizeRedirectRules(redirectRules));
|
|
12
12
|
|
|
13
|
-
export function
|
|
13
|
+
export function proxy(request: NextRequest) {
|
|
14
14
|
const { pathname } = request.nextUrl;
|
|
15
15
|
|
|
16
16
|
if (pathname.startsWith('/rss-file')) {
|