feat: update package version to 0.0.42 and add CNB version fetching functionality
- Updated package version in package.json from 0.0.40 to 0.0.42. - Added getCNBVersion function to fetch CNB version information from the API. - Enhanced Issue class with methods for managing comments (list, create, get, update). - Introduced new NPC and comment environment hooks for better context management. - Implemented Docker image synchronization route for CNB. - Added tests for version fetching and issue comment functionalities.
This commit is contained in:
66
agent/routes/build/docker.ts
Normal file
66
agent/routes/build/docker.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { execSync } from 'child_process';
|
||||
import { app, notCNBCheck } from '../../app.ts'
|
||||
import { z } from 'zod'
|
||||
import { title } from 'process';
|
||||
|
||||
app.route({
|
||||
path: 'cnb',
|
||||
key: 'docker-sync',
|
||||
middleware: ['auth'],
|
||||
metadata: {
|
||||
tag: ['opencode'],
|
||||
skill: 'cnb-docker-sync',
|
||||
title: 'CNB Docker 镜像同步',
|
||||
args: {
|
||||
image: z.string().describe('Docker 同步的具体的镜像名称.'),
|
||||
toVersion: z.string().optional().describe('修改后的版本号.'),
|
||||
}
|
||||
}
|
||||
}).define(async (ctx) => {
|
||||
const { image, toVersion } = ctx.args;
|
||||
notCNBCheck(ctx);
|
||||
if (!image) {
|
||||
ctx.body = {
|
||||
message: '请提供 Docker 镜像名称.',
|
||||
data: null,
|
||||
}
|
||||
return;
|
||||
}
|
||||
const config = {
|
||||
registry: 'docker.cnb.cool/kevisual/dev-env',
|
||||
dockers: [{ image, toVersion }]
|
||||
}
|
||||
// docker tag ghcr.io/esm-dev/esm.sh:v137 docker.cnb.cool/kevisual/dev-env/esm.sh:v137
|
||||
// docker push docker.cnb.cool/kevisual/dev-env/esm.sh:v137
|
||||
const run = async () => {
|
||||
const dockers = config.dockers;
|
||||
for (const { image, toVersion } of dockers) {
|
||||
const imageName = image.split(':')[0].split('/').slice(-1)[0]
|
||||
const tag = image.split(':')[1]
|
||||
const newImage = `${config.registry}/${imageName}:${toVersion || tag}`
|
||||
// console.log(`docker tag ${image} ${newImage}`)
|
||||
// console.log(`docker push ${newImage}`)
|
||||
const shell = `docker pull ${image} && docker tag ${image} ${newImage} && docker push ${newImage}`
|
||||
console.log(shell)
|
||||
|
||||
console.log('\n-------------new---------------------------------\n')
|
||||
console.log(`${newImage}`)
|
||||
console.log('\n--------------------------------------------------\n')
|
||||
try {
|
||||
execSync(shell, { stdio: 'inherit' })
|
||||
} catch (error) {
|
||||
console.error(`Error: ${error}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
run().then(() => {
|
||||
// TODO: 通知用户同步完成
|
||||
});;
|
||||
ctx.body = {
|
||||
message: 'Docker 镜像同步任务中,请稍后在目标仓库查看.',
|
||||
data: {
|
||||
registry: config.registry,
|
||||
dockers: config.dockers,
|
||||
}
|
||||
}
|
||||
}).addTo(app);
|
||||
1
agent/routes/build/index.ts
Normal file
1
agent/routes/build/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
import './docker.ts'
|
||||
Reference in New Issue
Block a user