This commit is contained in:
2025-12-04 20:38:08 +08:00
parent 780172e9b4
commit 501ceede27
5 changed files with 45 additions and 15790 deletions

1
docs/index.html Normal file
View File

@@ -0,0 +1 @@
this is a test page

View File

@@ -3,4 +3,9 @@
### 代码同步
1. 从cnb同步到本地gitea
2. 从本地gitea同步到cnb
2. 从本地gitea同步到cnb
## 启动环境
https://docs.cnb.cool/zh/workspaces/custom-dev-env.html

View File

@@ -27,6 +27,10 @@ export interface ListParams {
status?: 'running' | 'closed';
}
/**
* 云原生开发环境管理模块
* https://api.cnb.cool/#/operations/GetWorkspaceDetail
*/
export class Workspace extends CNBCore {
constructor(token: string) {
super({ token });
@@ -137,8 +141,10 @@ export type ResultList<T> = {
export interface WorkspaceInfo {
/** 分支名例如main */
branch: string;
/** 业务 ID */
business_id: string;
/** 备份的 commit 数 */
commit_count: number;
commit_count: number | null;
/** 开发环境创建时间例如2024-12-02T03:20:22.000Z */
create_time: string;
/** 开发环境持续时间单位ms非实时更新 */
@@ -147,24 +153,36 @@ export interface WorkspaceInfo {
file_count: number;
/** 备份的文件列表,仅前五个备份文件相对路径 */
file_list: string;
/** 是否为预览环境0: 否1: 是 */
is_preview: number;
/** JetBrains IDE 列表 */
jetbrainsList: any[];
/** 环境销毁时远程最新的 commit short hash */
latest_sha: string;
latest_sha: string | null;
/** 创建环境的子流水线 id */
pipeline_id: string;
/** 备份的 stash 数 */
remote_stash_count: number;
remote_stash_count: number | null;
/** 仓库 ID */
repo_id: string;
/** 仓库地址 */
repo_url: string;
/** 恢复备份代码的流水线 id如果有值表示备份代码已被恢复重建环境时会恢复备份代码 */
restore_id: string;
restore_id: string | null;
/** 单个 stash 标识1: 是0: 否 */
single_stash: number;
/** 仓库路径例如groupname/reponame */
slug: string;
/** 创建开发环境的流水线 sn */
sn: string;
/** 开发环境是否支持 ssh 链接 */
ssh: boolean;
/** 本地 stash 数 */
stash_count: number;
/** 工作区状态running: 开发环境已启动closed开发环境已关闭 */
status: string;
/** 用户名 */
user_name: string;
/** 开发环境默认工作区路径 */
workspace: string;
}

15781
swagger.json

File diff suppressed because it is too large Load Diff

View File

@@ -5,10 +5,22 @@ const cnb = new CNB(process.env.CNB_TOKEN || "");
const worksaceList = await cnb.workspace.list();
// console.log("worksaceList", worksaceList);
console.log("worksaceList", worksaceList);
const sn = 'cnb-0eg-1jbkjj615-001'
// const sn = 'cnb-o18-1jbklfuoh'
const worksace = await cnb.workspace.getDetail('kevisual/node24', sn)
console.log("worksace", worksace);
// const worksace = await cnb.workspace.getDetail('kevisual/cnb', sn)
// console.log("worksace", worksace);
// const stop = await cnb.workspace.stopWorkspace({ sn })
// console.log("stop", stop);
// exebqzp8sc
// const start = await cnb.workspace.startWorkspace('kevisual/cnb', {
// branch: 'main',
// });
// console.log("start", start);