mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-14 02:42:04 +08:00
refactor: decouple docs-site from ccw monorepo
- Remove docs-frontend.ts utility and docs proxy from server.ts - Remove docs startup logic from serve.ts - Delete HelpPage.tsx and /help route from frontend - Remove help navigation entry from Sidebar.tsx - Clean /docs proxy from vite.config.ts - Remove docs-related scripts from package.json files - Delete help.spec.ts E2E tests - Remove docs-site directory (migrated to D:\ccw-doc) The docs-site has been moved to D:\ccw-doc as a standalone Docusaurus project with baseUrl='/' for static hosting deployment (GitHub Pages/Netlify).
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* Docs proxy (dashboard server) - configured docsPort plumbing
|
||||
*
|
||||
* Runs against the shipped runtime in `ccw/dist`.
|
||||
*/
|
||||
|
||||
import { afterEach, describe, it, mock } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import http from 'node:http';
|
||||
import { mkdtempSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const ORIGINAL_ENV = { ...process.env };
|
||||
|
||||
const serverUrl = new URL('../dist/core/server.js', import.meta.url);
|
||||
serverUrl.searchParams.set('t', String(Date.now()));
|
||||
|
||||
function httpGetText(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = http.get(url, (res) => {
|
||||
let data = '';
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', (chunk) => (data += chunk));
|
||||
res.on('end', () => resolve({ statusCode: res.statusCode ?? 0, body: data }));
|
||||
});
|
||||
req.on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
describe('docs proxy port', () => {
|
||||
afterEach(() => {
|
||||
mock.restoreAll();
|
||||
process.env = ORIGINAL_ENV;
|
||||
});
|
||||
|
||||
it('proxies /docs/* to the configured docsPort', async () => {
|
||||
const ccwHome = mkdtempSync(join(tmpdir(), 'ccw-docs-proxy-home-'));
|
||||
process.env = { ...ORIGINAL_ENV, CCW_DATA_DIR: ccwHome, CCW_DISABLE_WARMUP: '1' };
|
||||
|
||||
const serverMod = await import(serverUrl.href);
|
||||
|
||||
let proxiedToUrl = null;
|
||||
mock.method(globalThis, 'fetch', async (url) => {
|
||||
proxiedToUrl = String(url);
|
||||
return new Response('ok', {
|
||||
status: 200,
|
||||
headers: { 'content-type': 'text/plain; charset=utf-8' },
|
||||
});
|
||||
});
|
||||
|
||||
const server = await serverMod.startServer({
|
||||
port: 0,
|
||||
initialPath: process.cwd(),
|
||||
frontend: 'react',
|
||||
reactPort: 65530,
|
||||
docsPort: 39999,
|
||||
});
|
||||
|
||||
try {
|
||||
const addr = server.address();
|
||||
assert.equal(typeof addr, 'object');
|
||||
assert.ok(addr);
|
||||
|
||||
const { statusCode, body } = await httpGetText(`http://127.0.0.1:${addr.port}/docs/zh/`);
|
||||
assert.equal(statusCode, 200);
|
||||
assert.equal(body, 'ok');
|
||||
assert.equal(proxiedToUrl, 'http://localhost:39999/docs/zh/');
|
||||
} finally {
|
||||
await new Promise((resolve) => server.close(resolve));
|
||||
rmSync(ccwHome, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user