feat: 添加云端构建功能,支持参数配置和环境变量

This commit is contained in:
2026-03-10 01:18:27 +08:00
parent 7d227d3913
commit d08345d81c
6 changed files with 281 additions and 22 deletions

View File

@@ -43,6 +43,27 @@ app.route({
}
}).addTo(app);
app.route({
path: 'cnb',
key: 'get-repo',
description: '获取代码仓库详情, 参数name',
middleware: ['auth'],
metadata: {
args: {
name: tool.schema.string().describe('代码仓库名称, 如 my-user/my-repo'),
}
}
}).define(async (ctx) => {
const cnb = await cnbManager.getContext(ctx);
const name = ctx.query?.name;
if (!name) {
ctx.throw(400, '缺少参数 name');
}
const res = await cnb.repo.getRepo(name);
ctx.forward(res);
}).addTo(app);
app.route({
path: 'cnb',
key: 'create-repo-file',
@@ -106,7 +127,56 @@ app.route({
if (!name) {
ctx.throw(400, '缺少参数 name');
}
try {
const resCookie = await cnb.user.checkCookieValid()
if (resCookie.code !== 200) {
ctx.throw(401, 'Cookie 无效或已过期');
}
const res = await cnb.repo.deleteRepoCookie(name);
ctx.forward(res);
} catch (error) {
ctx.code = 200
ctx.body = { content: '已经删除' }
}
}).addTo(app);
const res = await cnb.repo.deleteRepoCookie(name);
app.route({
path: 'cnb',
key: 'update-repo-info',
description: '更新代码仓库信息, 参数name, description',
middleware: ['auth'],
metadata: {
tags: ['opencode'],
...createSkill({
skill: 'update-repo-info',
title: '更新代码仓库信息',
args: {
name: tool.schema.string().describe('代码仓库名称'),
description: tool.schema.string().describe('代码仓库描述'),
license: tool.schema.string().describe('代码仓库许可证类型,如 MIT').optional(),
site: tool.schema.string().describe('代码仓库主页链接').optional(),
topics: tool.schema.array(tool.schema.string()).describe('代码仓库话题标签列表').optional(),
},
summary: '更新代码仓库的信息',
})
}
}).define(async (ctx) => {
const cnb = await cnbManager.getContext(ctx);
const name = ctx.query?.name;
const description = ctx.query?.description;
const license = ctx.query?.license;
const site = ctx.query?.site;
const topics = ctx.query?.topics;
if (!name) {
ctx.throw(400, '缺少参数 name');
}
if (!description) {
ctx.throw(400, '缺少参数 description');
}
const res = await cnb.repo.updateRepoInfo(name, { description, license, site, topics });
ctx.forward(res);
}).addTo(app);
}).addTo(app);