meegle-cli 0.1.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 +215 -0
- package/RELEASE.md +77 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +2056 -0
- package/dist/core/auth-policy.d.ts +14 -0
- package/dist/core/auth-policy.js +37 -0
- package/dist/core/cli-error.d.ts +4 -0
- package/dist/core/cli-error.js +9 -0
- package/dist/core/client-factory.d.ts +3 -0
- package/dist/core/client-factory.js +22 -0
- package/dist/core/command-guard.d.ts +16 -0
- package/dist/core/command-guard.js +38 -0
- package/dist/core/config-store.d.ts +15 -0
- package/dist/core/config-store.js +69 -0
- package/dist/core/error-handler.d.ts +1 -0
- package/dist/core/error-handler.js +52 -0
- package/dist/core/json-file.d.ts +1 -0
- package/dist/core/json-file.js +12 -0
- package/dist/core/output.d.ts +1 -0
- package/dist/core/output.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -0
- package/dist/types/config.d.ts +12 -0
- package/dist/types/config.js +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# meegle-cli (plugin-only)
|
|
2
|
+
|
|
3
|
+
基于 `project-oapi-sdk-typescript` 的命令行工具。
|
|
4
|
+
当前模式:仅支持 `plugin_access_token / virtual_plugin_token`,不支持 `user_access_token`。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
|
|
8
|
+
对外用户安装:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g meegle-cli
|
|
12
|
+
meegle --help
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
仓库内开发安装:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd /Users/linmi/conductor/repos/meego-client/meegle-cli
|
|
19
|
+
npm install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 构建
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run build
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 发布
|
|
29
|
+
|
|
30
|
+
发布说明见 [RELEASE.md](/Users/linmi/conductor/repos/meego-client/meegle-cli/RELEASE.md)。
|
|
31
|
+
|
|
32
|
+
## 初始化
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
node dist/index.js auth init \
|
|
36
|
+
--target-profile default \
|
|
37
|
+
--plugin-id MII_xxx \
|
|
38
|
+
--plugin-secret xxx \
|
|
39
|
+
--base-url https://project.feishu.cn \
|
|
40
|
+
--token-type 0 \
|
|
41
|
+
--default-user-key 123456
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
也可以先放环境变量,再直接初始化:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
export MEEGLE_PLUGIN_ID=MII_xxx
|
|
48
|
+
export MEEGLE_PLUGIN_SECRET=xxx
|
|
49
|
+
export MEEGLE_USER_KEY=123456
|
|
50
|
+
|
|
51
|
+
node dist/index.js auth init --target-profile default
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 入参约定
|
|
55
|
+
|
|
56
|
+
- 常用查询优先走直接参数,不再强制写 JSON 文件
|
|
57
|
+
- 常用写操作也优先走直接参数,例如 `--name`、`--desc`、`--content`
|
|
58
|
+
- 复杂请求体仍可使用 `--body <json>` 或 `--body-file <path>`
|
|
59
|
+
- 复杂查询参数仍可使用 `--query-file <path>`
|
|
60
|
+
- 大多数命令要求 `userKey`:`--user-key` 或 `auth init --default-user-key`
|
|
61
|
+
- 如果 profile 里没存 `defaultUserKey`,运行时也会读取 `MEEGLE_USER_KEY`
|
|
62
|
+
- 自定义字段统一使用 `--field field_key=value`;对象/数组值直接传 JSON
|
|
63
|
+
- 排期参数统一支持 `--start/--end`,可传毫秒时间戳或可解析日期,如 `2025-01-01`
|
|
64
|
+
|
|
65
|
+
## 命令总览
|
|
66
|
+
|
|
67
|
+
- `auth`: `init`, `status`
|
|
68
|
+
- `space`: `list`, `get`, `types`, `team-members`
|
|
69
|
+
- `workitem`: `get`, `meta`, `create`, `update`, `remove`, `freeze`, `unfreeze`, `abort`, `restore`, `op-records`, `update-compound`
|
|
70
|
+
- `workitem search`: `filter`, `filter-across`, `by-params`, `by-relation`, `compositive`, `universal`
|
|
71
|
+
- `workflow`: `query`, `state-change`, `node-operate`, `node-update`, `required-info`, `wbs`
|
|
72
|
+
- `comment`: `list`, `add`, `update`, `remove`
|
|
73
|
+
- `subtask`: `list`, `search`, `create`, `update`, `remove`, `operate`
|
|
74
|
+
- `attachment`: `upload-file`, `upload`, `download`, `delete`
|
|
75
|
+
- `workhour`: `list`, `create`, `update`, `delete`
|
|
76
|
+
- `view`: `list`, `fix-items`, `panoramic-items`, `create-fix`, `update-fix`, `delete`, `create-condition`, `update-condition`
|
|
77
|
+
- `measure`: `charts`, `chart-data`
|
|
78
|
+
- `tenant`: `info`, `entitlement`, `spaces`
|
|
79
|
+
- `user`: `query`, `search`(会被拒绝)
|
|
80
|
+
- `user group`: `create`, `update-members`, `query-members`(会被拒绝)
|
|
81
|
+
|
|
82
|
+
## 真实环境 Smoke(可选)
|
|
83
|
+
|
|
84
|
+
执行:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm run test:smoke:real
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
必填环境变量:
|
|
91
|
+
|
|
92
|
+
- `MEEGLE_SMOKE_PLUGIN_ID`
|
|
93
|
+
- `MEEGLE_SMOKE_PLUGIN_SECRET`
|
|
94
|
+
- `MEEGLE_SMOKE_USER_KEY`
|
|
95
|
+
- `MEEGLE_SMOKE_PROJECT_KEY`
|
|
96
|
+
|
|
97
|
+
可选环境变量:
|
|
98
|
+
|
|
99
|
+
- `MEEGLE_SMOKE_BASE_URL`(默认 `https://project.feishu.cn`)
|
|
100
|
+
- `MEEGLE_SMOKE_WORK_ITEM_TYPE_KEY`(不填时自动取 `space types` 第一项)
|
|
101
|
+
- `MEEGLE_SMOKE_WORK_ITEM_ID`(填了会额外做 `workitem get`)
|
|
102
|
+
|
|
103
|
+
测试链路:
|
|
104
|
+
|
|
105
|
+
- `auth init -> auth status -> space list -> space get -> user query --self -> space types -> workitem meta`
|
|
106
|
+
- 若提供 `MEEGLE_SMOKE_WORK_ITEM_ID`,再执行 `workitem get`
|
|
107
|
+
- 最后验证 user-only 接口在 plugin-only 下被拒绝
|
|
108
|
+
|
|
109
|
+
`MEEGLE_SMOKE_USER_KEY` 获取建议:
|
|
110
|
+
|
|
111
|
+
- 文档建议可在飞书项目空间双击头像获取 `user_key`
|
|
112
|
+
- 如果你在插件前端里调试,JS SDK 文档里有 `window.JSSDK.utils.getAuthCode()`;虽然该方法用于 user token 流程,但同一套文档章节也包含用户身份相关取值指引
|
|
113
|
+
|
|
114
|
+
## plugin-only 拒绝列表(denylist)
|
|
115
|
+
|
|
116
|
+
- `POST /open_api/user/search`
|
|
117
|
+
- `POST /open_api/:project_key/user_group`
|
|
118
|
+
- `PATCH /open_api/:project_key/user_group/members`
|
|
119
|
+
- `POST /open_api/:project_key/user_groups/members/page`
|
|
120
|
+
|
|
121
|
+
## 示例
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# 1) 校验凭证
|
|
125
|
+
node dist/index.js --profile default auth status --json
|
|
126
|
+
|
|
127
|
+
# 2) 列出空间
|
|
128
|
+
node dist/index.js --profile default space list --json
|
|
129
|
+
|
|
130
|
+
# 3) 获取空间详情
|
|
131
|
+
node dist/index.js --profile default space get \
|
|
132
|
+
--project-key your_project \
|
|
133
|
+
--json
|
|
134
|
+
|
|
135
|
+
# 4) 查询当前 userKey 对应的用户
|
|
136
|
+
node dist/index.js --profile default user query \
|
|
137
|
+
--self \
|
|
138
|
+
--json
|
|
139
|
+
|
|
140
|
+
# 5) 查询工作项,常见场景直接传 ID
|
|
141
|
+
node dist/index.js --profile default workitem get \
|
|
142
|
+
--project-key your_project \
|
|
143
|
+
--type story \
|
|
144
|
+
--id 6300034462 \
|
|
145
|
+
--json
|
|
146
|
+
|
|
147
|
+
# 6) 创建工作项,常见字段直接写
|
|
148
|
+
node dist/index.js --profile default workitem create \
|
|
149
|
+
--project-key your_project \
|
|
150
|
+
--type story \
|
|
151
|
+
--name "登录优化" \
|
|
152
|
+
--desc "补齐错误提示" \
|
|
153
|
+
--owner your_user_key \
|
|
154
|
+
--priority P2 \
|
|
155
|
+
--json
|
|
156
|
+
|
|
157
|
+
# 7) 更新工作项,改单个字段不需要写 update_fields
|
|
158
|
+
node dist/index.js --profile default workitem update \
|
|
159
|
+
--project-key your_project \
|
|
160
|
+
--type story \
|
|
161
|
+
--id 6300034462 \
|
|
162
|
+
--name "登录优化(已排期)" \
|
|
163
|
+
--json
|
|
164
|
+
|
|
165
|
+
# 8) 添加评论,支持直接写文本或从文件读
|
|
166
|
+
node dist/index.js --profile default comment add \
|
|
167
|
+
--project-key your_project \
|
|
168
|
+
--type story \
|
|
169
|
+
--id 6300034462 \
|
|
170
|
+
--content "收到,开始处理" \
|
|
171
|
+
--json
|
|
172
|
+
|
|
173
|
+
# 9) 创建子任务
|
|
174
|
+
node dist/index.js --profile default subtask create \
|
|
175
|
+
--project-key your_project \
|
|
176
|
+
--type story \
|
|
177
|
+
--id 6300034462 \
|
|
178
|
+
--node-id doing \
|
|
179
|
+
--name "需求分析" \
|
|
180
|
+
--note "补齐边界条件" \
|
|
181
|
+
--assignee your_user_key \
|
|
182
|
+
--points 3 \
|
|
183
|
+
--start 2025-01-01 \
|
|
184
|
+
--end 2025-01-02 \
|
|
185
|
+
--json
|
|
186
|
+
|
|
187
|
+
# 10) 状态流转
|
|
188
|
+
node dist/index.js --profile default workflow state-change \
|
|
189
|
+
--project-key your_project \
|
|
190
|
+
--type story \
|
|
191
|
+
--id 6300034462 \
|
|
192
|
+
--transition-id 12345 \
|
|
193
|
+
--field description="流转补充说明" \
|
|
194
|
+
--json
|
|
195
|
+
|
|
196
|
+
# 11) 节点完成/回滚
|
|
197
|
+
node dist/index.js --profile default workflow node-operate \
|
|
198
|
+
--project-key your_project \
|
|
199
|
+
--type story \
|
|
200
|
+
--id 6300034462 \
|
|
201
|
+
--node-id dev \
|
|
202
|
+
--action rollback \
|
|
203
|
+
--rollback-reason "需要返工" \
|
|
204
|
+
--json
|
|
205
|
+
|
|
206
|
+
# 12) 复杂场景再回退到原始请求体
|
|
207
|
+
node dist/index.js --profile default workitem get \
|
|
208
|
+
--project-key your_project \
|
|
209
|
+
--type story \
|
|
210
|
+
--body '{"work_item_ids":[6300034462],"fields":["name","priority"]}' \
|
|
211
|
+
--json
|
|
212
|
+
|
|
213
|
+
# 13) user-only 接口会被直接拒绝
|
|
214
|
+
node dist/index.js user search --query test
|
|
215
|
+
```
|
package/RELEASE.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# meegle-cli Release
|
|
2
|
+
|
|
3
|
+
## 当前结论
|
|
4
|
+
|
|
5
|
+
- 包名:`meegle-cli`
|
|
6
|
+
- 可执行命令:`meegle`
|
|
7
|
+
- 2026-03-17 验证结果:
|
|
8
|
+
- `meeglesdk@0.1.7` 已存在于 npm registry
|
|
9
|
+
- `meegle-cli` 当前未在 npm registry 上占用
|
|
10
|
+
|
|
11
|
+
## 发布前检查
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd /Users/linmi/conductor/repos/meego-client/meegle-cli
|
|
15
|
+
npm install
|
|
16
|
+
npm run release:check
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`release:check` 会执行:
|
|
20
|
+
|
|
21
|
+
1. `npm test`
|
|
22
|
+
2. `npm run build`
|
|
23
|
+
3. `npm pack --dry-run`
|
|
24
|
+
|
|
25
|
+
目标是确保:
|
|
26
|
+
|
|
27
|
+
- 测试通过
|
|
28
|
+
- 发布包只包含 `dist/README.md/RELEASE.md`
|
|
29
|
+
- 不再携带 `src/` 和测试产物
|
|
30
|
+
|
|
31
|
+
## 首次发布
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd /Users/linmi/conductor/repos/meego-client/meegle-cli
|
|
35
|
+
npm login
|
|
36
|
+
npm publish
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
发布成功后,外部用户安装方式:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g meegle-cli
|
|
43
|
+
meegle --help
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 后续版本发布
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd /Users/linmi/conductor/repos/meego-client/meegle-cli
|
|
50
|
+
npm version patch
|
|
51
|
+
npm publish
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
也可以把 `patch` 改成 `minor` 或 `major`。
|
|
55
|
+
|
|
56
|
+
## 本地联调 SDK
|
|
57
|
+
|
|
58
|
+
对外发布时,CLI 依赖的是 npm 上的 `meeglesdk@0.1.7`。
|
|
59
|
+
如果你在本仓库内同时修改 SDK 和 CLI,建议显式切回本地安装:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd /Users/linmi/conductor/repos/meego-client/meegle-cli
|
|
63
|
+
npm install ../project-oapi-sdk-typescript
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
联调结束后,发布前再恢复:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cd /Users/linmi/conductor/repos/meego-client/meegle-cli
|
|
70
|
+
npm install meeglesdk@0.1.7
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 风险提醒
|
|
74
|
+
|
|
75
|
+
- `pluginId/pluginSecret` 不能写进 README 示例或测试默认环境变量
|
|
76
|
+
- `test:smoke:real` 依赖真实凭证,不能挂到 `prepublishOnly`
|
|
77
|
+
- 如果后续需要私有 scope,再补 `publishConfig.access=public`
|
package/dist/cli.d.ts
ADDED