收敛客户端静态发布链路
This commit is contained in:
@@ -14,8 +14,6 @@ import {
|
||||
type RevertOpencodeSessionMessageInput,
|
||||
type SendOpencodeSessionMessageInput,
|
||||
} from '../../opencode/client';
|
||||
import { readWorksPublishFile } from '../../opencode/works-publish-file';
|
||||
import { readWorksDeployCheck } from '../../opencode/works-square-deploy-check';
|
||||
import {
|
||||
buildOpencodeRuntimeConfigSummaryFromNianCodeProviders,
|
||||
type OpencodeRuntimeConfigSummary,
|
||||
@@ -1128,67 +1126,6 @@ export async function handleOpencodeRoutes(
|
||||
return true;
|
||||
}
|
||||
|
||||
const worksPublishMatch = url.pathname.match(/^\/api\/opencode\/projects\/([^/]+)\/works-publish$/);
|
||||
if (worksPublishMatch && req.method === 'GET') {
|
||||
try {
|
||||
const projectId = decodeURIComponent(worksPublishMatch[1] ?? '');
|
||||
if (!projectId) throw new Error('Missing project id');
|
||||
const project = await findProjectById(ctx, projectId);
|
||||
if (!project) throw new Error('Project not found');
|
||||
sendJson(res, 200, await readWorksPublishFile(project.path));
|
||||
} catch (error) {
|
||||
sendJson(res, 500, {
|
||||
status: 'invalid',
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const worksDeployCheckMatch = url.pathname.match(/^\/api\/opencode\/projects\/([^/]+)\/works-deploy-check$/);
|
||||
if (worksDeployCheckMatch && req.method === 'GET') {
|
||||
try {
|
||||
const projectId = decodeURIComponent(worksDeployCheckMatch[1] ?? '');
|
||||
if (!projectId) throw new Error('Missing project id');
|
||||
const project = await findProjectById(ctx, projectId);
|
||||
if (!project) throw new Error('Project not found');
|
||||
const publish = await readWorksPublishFile(project.path);
|
||||
sendJson(
|
||||
res,
|
||||
200,
|
||||
await readWorksDeployCheck(project.path, publish.status === 'ready' ? publish.publish : null),
|
||||
);
|
||||
} catch (error) {
|
||||
sendJson(res, 500, {
|
||||
status: 'invalid',
|
||||
filePath: '',
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const worksCloudDeployMatch = url.pathname.match(/^\/api\/opencode\/projects\/([^/]+)\/works-cloud-deploy$/);
|
||||
if (worksCloudDeployMatch && (req.method === 'GET' || req.method === 'POST')) {
|
||||
try {
|
||||
const projectId = decodeURIComponent(worksCloudDeployMatch[1] ?? '');
|
||||
if (!projectId) throw new Error('Missing project id');
|
||||
if (!ctx.worksCloudDeployment) throw new Error('Cloud deployment coordinator is unavailable');
|
||||
if (req.method === 'POST') {
|
||||
const deployment = await ctx.worksCloudDeployment.arm(projectId);
|
||||
sendJson(res, 202, { success: true, deployment });
|
||||
} else {
|
||||
sendJson(res, 200, { success: true, deployment: await ctx.worksCloudDeployment.get(projectId) });
|
||||
}
|
||||
} catch (error) {
|
||||
sendJson(res, 500, {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (url.pathname === '/api/opencode/projects/remove' && req.method === 'POST') {
|
||||
try {
|
||||
const body = await parseJsonBody<{ projectId?: string }>(req);
|
||||
|
||||
Reference in New Issue
Block a user