yunxiao-code 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -0
- package/bin/yunxiao-code-darwin-amd64 +0 -0
- package/bin/yunxiao-code-darwin-arm64 +0 -0
- package/bin/yunxiao-code-linux-amd64 +0 -0
- package/bin/yunxiao-code.js +34 -0
- package/package.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# yunxiao-code
|
|
2
|
+
|
|
3
|
+
阿里云云效 CLI 工具,支持 Git 提交、推送、克隆及创建合并请求。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
### npm 安装(推荐)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g yunxiao-code
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 从源码编译
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git clone <repo-url>
|
|
17
|
+
cd yunxiao-code
|
|
18
|
+
go build -o yunxiao-code .
|
|
19
|
+
sudo mv yunxiao-code /usr/local/bin/
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 配置
|
|
23
|
+
|
|
24
|
+
### 1. 初始化配置文件
|
|
25
|
+
|
|
26
|
+
在你的项目目录下运行:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
yunxiao-code init
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
会在当前目录生成 `.yunxiao.yaml`:
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
# 云效合并请求 CLI 配置
|
|
36
|
+
domain: openapi-rdc.aliyuncs.com
|
|
37
|
+
organization_id: ""
|
|
38
|
+
token: ""
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
填写 `organization_id` 和 `token`(个人访问令牌)。
|
|
42
|
+
|
|
43
|
+
### 2. 配置项说明
|
|
44
|
+
|
|
45
|
+
| 字段 | 说明 | 默认值 |
|
|
46
|
+
|------|------|--------|
|
|
47
|
+
| `domain` | 云效 API 域名 | `openapi-rdc.aliyuncs.com` |
|
|
48
|
+
| `organization_id` | 组织 ID | 无,必填 |
|
|
49
|
+
| `token` | 个人访问令牌 | 无,必填 |
|
|
50
|
+
|
|
51
|
+
### 3. 环境变量配置
|
|
52
|
+
|
|
53
|
+
也可以通过环境变量配置:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# 设置环境变量
|
|
57
|
+
export YUNXIAO_DOMAIN="openapi-rdc.aliyuncs.com"
|
|
58
|
+
export YUNXIAO_ORGANIZATION_ID="your-org-id"
|
|
59
|
+
export YUNXIAO_TOKEN="your-token"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 4. 配置优先级(从低到高)
|
|
63
|
+
|
|
64
|
+
1. 默认值
|
|
65
|
+
2. `.yunxiao.yaml` 配置文件(从当前目录向上逐级查找)
|
|
66
|
+
3. 环境变量:`YUNXIAO_DOMAIN`、`YUNXIAO_ORGANIZATION_ID`、`YUNXIAO_TOKEN`
|
|
67
|
+
4. CLI 参数:`--domain`、`--org`、`--token`
|
|
68
|
+
|
|
69
|
+
## 使用
|
|
70
|
+
|
|
71
|
+
### 克隆仓库并创建新分支
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
yunxiao-code clone <git-url> -b <分支名>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
自动检测主分支(main/master),从主分支拉出新分支。
|
|
78
|
+
|
|
79
|
+
可选参数:
|
|
80
|
+
- `-p <路径>` — 指定克隆目标路径
|
|
81
|
+
|
|
82
|
+
### 提交代码
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
yunxiao-code commit -m "提交信息"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
执行 `git add .` 并提交。
|
|
89
|
+
|
|
90
|
+
### 推送到远程
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
yunxiao-code push
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
推送当前分支到远程仓库。
|
|
97
|
+
|
|
98
|
+
### 创建合并请求
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
yunxiao-code mr -m "MR 标题"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
向云效创建合并请求,目标分支为 `develop`。
|
|
105
|
+
|
|
106
|
+
可选参数:
|
|
107
|
+
- `-d <描述>` — MR 描述
|
|
108
|
+
|
|
109
|
+
### 全局参数
|
|
110
|
+
|
|
111
|
+
所有子命令支持以下参数,用于覆盖配置文件:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
yunxiao-code <command> --domain <域名> --org <组织ID> --token <令牌>
|
|
115
|
+
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
const platform = os.platform();
|
|
7
|
+
const arch = os.arch();
|
|
8
|
+
|
|
9
|
+
let binary;
|
|
10
|
+
if (platform === 'darwin' && arch === 'arm64') {
|
|
11
|
+
binary = 'yunxiao-code-darwin-arm64';
|
|
12
|
+
} else if (platform === 'darwin' && arch === 'x64') {
|
|
13
|
+
binary = 'yunxiao-code-darwin-amd64';
|
|
14
|
+
} else if (platform === 'linux' && arch === 'x64') {
|
|
15
|
+
binary = 'yunxiao-code-linux-amd64';
|
|
16
|
+
} else {
|
|
17
|
+
console.error(`Unsupported platform: ${platform}/${arch}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const binaryPath = path.join(__dirname, binary);
|
|
22
|
+
const args = process.argv.slice(2).map(arg => {
|
|
23
|
+
// Escape quotes and wrap in quotes if contains spaces
|
|
24
|
+
if (arg.includes(' ')) {
|
|
25
|
+
return `"${arg.replace(/"/g, '\\"')}"`;
|
|
26
|
+
}
|
|
27
|
+
return arg;
|
|
28
|
+
}).join(' ');
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
execSync(`"${binaryPath}" ${args}`, { stdio: 'inherit' });
|
|
32
|
+
} catch (error) {
|
|
33
|
+
process.exit(error.status);
|
|
34
|
+
}
|
package/package.json
ADDED