feat: add license files for JavaScript assets and implement DocItem component

- Added LICENSE.txt file for JavaScript assets in the build directory, including licenses for NProgress and React libraries.
- Introduced a new runtime JavaScript file for handling module loading.
- Created a new DocItem component to manage document rendering and metadata handling in the Docusaurus theme.
- Implemented tests for the docs proxy server to ensure proper routing to the configured docsPort.
This commit is contained in:
catlog22
2026-02-06 10:25:24 +08:00
parent f9188eb0b6
commit a9b9ec48f1
91 changed files with 780 additions and 217 deletions

View File

@@ -65,6 +65,7 @@ interface ServerOptions {
open?: boolean;
frontend?: 'js' | 'react' | 'both';
reactPort?: number;
docsPort?: number;
}
type PostHandler = PostRequestHandler;
@@ -448,12 +449,13 @@ export async function startServer(options: ServerOptions = {}): Promise<http.Ser
const host = options.host ?? '127.0.0.1';
const frontend = options.frontend || 'js';
const reactPort = options.reactPort || serverPort + 1;
const docsPort = options.docsPort || 3001;
// Log frontend configuration
console.log(`[Server] Frontend mode: ${frontend}`);
if (frontend === 'react' || frontend === 'both') {
console.log(`[Server] React proxy configured: /react/* -> http://localhost:${reactPort}`);
console.log(`[Server] Docs proxy configured: /docs/* -> http://localhost:3001`);
console.log(`[Server] Docs proxy configured: /docs/* -> http://localhost:${docsPort}`);
}
const tokenManager = getTokenManager();
@@ -837,7 +839,6 @@ export async function startServer(options: ServerOptions = {}): Promise<http.Ser
// Proxy /docs/* requests to Docusaurus
if (pathname.startsWith('/docs/')) {
const docsPort = 3001;
// Preserve the /docs prefix when forwarding to Docusaurus
const docsUrl = `http://localhost:${docsPort}${pathname}${url.search}`;
@@ -957,11 +958,16 @@ export async function startServer(options: ServerOptions = {}): Promise<http.Ser
// Start cache warmup asynchronously (non-blocking)
// Uses setImmediate to not delay server startup response
setImmediate(() => {
warmupCaches(initialPath).catch((err) => {
console.warn('[WARMUP] Cache warmup failed:', err);
const warmupDisabled = ['1', 'true', 'yes'].includes(
(process.env.CCW_DISABLE_WARMUP ?? '').trim().toLowerCase(),
);
if (!warmupDisabled) {
setImmediate(() => {
warmupCaches(initialPath).catch((err) => {
console.warn('[WARMUP] Cache warmup failed:', err);
});
});
});
}
resolve(server);
});