cloudcc-cli 2.3.4 → 2.3.6

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.
Files changed (244) hide show
  1. package/.claude/settings.json +22 -1
  2. package/.cursor/skills/cloudcc-cli-dev/SKILL.md +175 -0
  3. package/.cursor/skills/cloudcc-dev-skill/SKILL.md +71 -0
  4. package/README.md +81 -6
  5. package/bin/cc.js +106 -28
  6. package/bin/index.js +54 -55
  7. package/mcp/cliRunner.js +11 -4
  8. package/mcp/index.js +12 -2
  9. package/mcp/tools/Application Creator/handler.js +1 -1
  10. package/mcp/tools/Approval/handler.js +3 -3
  11. package/mcp/tools/Class Creator/handler.js +2 -2
  12. package/mcp/tools/Class Detail Retriever/handler.js +1 -1
  13. package/mcp/tools/Class Editor Guide/handler.js +1 -1
  14. package/mcp/tools/Class List Retriever/handler.js +1 -1
  15. package/mcp/tools/Class Publisher/handler.js +1 -1
  16. package/mcp/tools/Class Puller/handler.js +1 -1
  17. package/mcp/tools/Client Script Detail Retriever/handler.js +1 -1
  18. package/mcp/tools/Client Script Editor Guide/handler.js +1 -1
  19. package/mcp/tools/Client Script List Retriever/handler.js +1 -1
  20. package/mcp/tools/Client Script Publisher/handler.js +1 -1
  21. package/mcp/tools/Client Script Puller/handler.js +2 -2
  22. package/mcp/tools/CloudCC Development Overview/handler.js +2 -2
  23. package/mcp/tools/Component Creator/handler.js +1 -1
  24. package/mcp/tools/Component Detail Retriever/handler.js +1 -1
  25. package/mcp/tools/Component Editor Guide/handler.js +1 -1
  26. package/mcp/tools/Component List Retriever/handler.js +1 -1
  27. package/mcp/tools/Component Publisher/handler.js +2 -2
  28. package/mcp/tools/Component Puller/handler.js +1 -1
  29. package/mcp/tools/Dev Environment Creator/handler.js +1 -1
  30. package/mcp/tools/Dev Environment Validator/handler.js +1 -1
  31. package/mcp/tools/Developer Key Setup Guide/handler.js +1 -1
  32. package/mcp/tools/JSP Migrator/handler.js +46 -0
  33. package/mcp/tools/Menu Creator/handler.js +1 -1
  34. package/mcp/tools/Object Creator/handler.js +2 -2
  35. package/mcp/tools/Object Fields Creator/handler.js +1 -1
  36. package/mcp/tools/Object Fields Retriever/handler.js +1 -1
  37. package/mcp/tools/Object List Retriever/handler.js +1 -1
  38. package/mcp/tools/Scheduled Class Creator/handler.js +1 -1
  39. package/mcp/tools/Scheduled Class Detail Retriever/handler.js +1 -1
  40. package/mcp/tools/Scheduled Class List Retriever/handler.js +1 -1
  41. package/mcp/tools/Scheduled Class Publisher/handler.js +1 -1
  42. package/mcp/tools/Scheduled Class Puller/handler.js +1 -1
  43. package/mcp/tools/Trigger Creator/handler.js +1 -1
  44. package/mcp/tools/Trigger Detail Retriever/handler.js +1 -1
  45. package/mcp/tools/Trigger Editor Guide/handler.js +1 -1
  46. package/mcp/tools/Trigger List Retriever/handler.js +1 -1
  47. package/mcp/tools/Trigger Publisher/handler.js +1 -1
  48. package/mcp/tools/Trigger Puller/handler.js +1 -1
  49. package/package.json +3 -3
  50. package/src/application/create.js +2 -2
  51. package/src/application/delete.js +2 -2
  52. package/src/application/doc.js +2 -2
  53. package/src/application/docs/devguide.md +25 -25
  54. package/src/application/docs/introduction.md +2 -2
  55. package/src/button/create.js +169 -0
  56. package/src/button/delete.js +35 -0
  57. package/src/button/doc.js +36 -0
  58. package/src/button/docs/devguide.md +133 -0
  59. package/src/button/docs/introduction.md +60 -0
  60. package/src/button/get.js +60 -0
  61. package/src/button/index.js +20 -0
  62. package/src/classes/create.js +1 -1
  63. package/src/classes/delete.js +1 -1
  64. package/src/classes/detail.js +1 -1
  65. package/src/classes/doc.js +2 -2
  66. package/src/classes/docs/devguide.md +21 -21
  67. package/src/classes/docs/introduction.md +0 -20
  68. package/src/classes/get.js +1 -1
  69. package/src/classes/publish.js +1 -1
  70. package/src/classes/pull.js +1 -1
  71. package/src/classes/pullList.js +1 -1
  72. package/src/config/doc.js +2 -2
  73. package/src/config/docs/devguide.md +15 -15
  74. package/src/customPage/create.js +2 -2
  75. package/src/customPage/delete.js +2 -2
  76. package/src/customPage/doc.js +2 -2
  77. package/src/customPage/docs/devguide.md +27 -27
  78. package/src/customPage/get.js +1 -1
  79. package/src/customSetting/create.js +1 -1
  80. package/src/customSetting/delete.js +1 -1
  81. package/src/customSetting/deleteCustomSettingField.js +1 -1
  82. package/src/customSetting/detail.js +1 -1
  83. package/src/customSetting/docs/devguide.md +9 -9
  84. package/src/customSetting/editCustomSettingField.js +1 -1
  85. package/src/customSetting/get.js +1 -1
  86. package/src/customSetting/modify.js +1 -1
  87. package/src/customSetting/saveCustomSettingField.js +1 -1
  88. package/src/fields/delete.js +2 -2
  89. package/src/fields/docs/devguide.md +14 -14
  90. package/src/fields/docs/introduction.md +3 -3
  91. package/src/globalSelectList/create.js +1 -1
  92. package/src/globalSelectList/delete.js +1 -1
  93. package/src/globalSelectList/detail.js +1 -1
  94. package/src/globalSelectList/doc.js +2 -2
  95. package/src/globalSelectList/docs/devguide.md +7 -7
  96. package/src/globalSelectList/get.js +1 -1
  97. package/src/identityProvider/create.js +78 -0
  98. package/src/identityProvider/delete.js +61 -0
  99. package/src/identityProvider/doc.js +46 -0
  100. package/src/identityProvider/docs/devguide.md +107 -0
  101. package/src/identityProvider/docs/introduction.md +31 -0
  102. package/src/identityProvider/download.js +105 -0
  103. package/src/identityProvider/get.js +70 -0
  104. package/src/identityProvider/index.js +12 -0
  105. package/src/menu/create-object.js +2 -2
  106. package/src/menu/create-page.js +2 -2
  107. package/src/menu/create-script.js +2 -2
  108. package/src/menu/create-site.js +2 -2
  109. package/src/menu/create.js +11 -11
  110. package/src/menu/delete.js +2 -2
  111. package/src/menu/doc.js +2 -2
  112. package/src/menu/docs/devguide.md +13 -13
  113. package/src/menu/docs/introduction.md +3 -3
  114. package/src/menu/get.js +1 -1
  115. package/src/object/create.js +2 -2
  116. package/src/object/delete.js +2 -2
  117. package/src/object/docs/devguide.md +11 -11
  118. package/src/pagelayout/create.js +6 -6
  119. package/src/pagelayout/delete.js +4 -4
  120. package/src/pagelayout/doc.js +2 -2
  121. package/src/pagelayout/docs/devguide.md +9 -9
  122. package/src/pagelayout/docs/introduction.md +1 -1
  123. package/src/pagelayout/get.js +4 -4
  124. package/src/permission/add.js +164 -0
  125. package/src/permission/assign.js +84 -0
  126. package/src/permission/docs/devguide.md +238 -0
  127. package/src/permission/docs/introduction.md +200 -0
  128. package/src/permission/get.js +107 -0
  129. package/src/permission/index.js +10 -0
  130. package/src/permission/remove.js +145 -0
  131. package/src/plugin/delete.js +2 -2
  132. package/src/plugin/doc.js +2 -2
  133. package/src/plugin/docs/devguide.md +29 -29
  134. package/src/profile/create.js +5 -5
  135. package/src/profile/delete.js +2 -2
  136. package/src/profile/doc.js +2 -2
  137. package/src/profile/docs/devguide.md +8 -8
  138. package/src/profile/docs/introduction.md +12 -12
  139. package/src/profile/get.js +1 -1
  140. package/src/project/docs/devguide.md +9 -8
  141. package/src/recordType/create.js +1 -1
  142. package/src/recordType/delete.js +1 -1
  143. package/src/recordType/doc.js +2 -2
  144. package/src/recordType/docs/devguide.md +10 -10
  145. package/src/recordType/editInfo.js +1 -1
  146. package/src/recordType/editSave.js +1 -1
  147. package/src/recordType/getList.js +1 -1
  148. package/src/recordType/newInfo.js +1 -1
  149. package/src/recordType/validDelete.js +1 -1
  150. package/src/res.md +1 -1
  151. package/src/role/create.js +6 -6
  152. package/src/role/delete.js +2 -2
  153. package/src/role/doc.js +2 -2
  154. package/src/role/docs/devguide.md +9 -9
  155. package/src/role/docs/introduction.md +13 -13
  156. package/src/role/get.js +1 -1
  157. package/src/scheduleJob/doc.js +1 -1
  158. package/src/scheduleJob/docs/devguide.md +6 -6
  159. package/src/scheduleJob/docs/introduction.md +6 -6
  160. package/src/script/docs/devguide.md +18 -18
  161. package/src/singleSignOn/delete.js +61 -0
  162. package/src/singleSignOn/doc.js +46 -0
  163. package/src/singleSignOn/docs/devguide.md +61 -0
  164. package/src/singleSignOn/docs/introduction.md +3 -0
  165. package/src/singleSignOn/get.js +70 -0
  166. package/src/singleSignOn/index.js +10 -0
  167. package/src/staticResource/count.js +1 -1
  168. package/src/staticResource/create.js +1 -1
  169. package/src/staticResource/delete.js +1 -1
  170. package/src/staticResource/detail.js +1 -1
  171. package/src/staticResource/docs/devguide.md +11 -11
  172. package/src/staticResource/docs/introduction.md +44 -1
  173. package/src/staticResource/get.js +1 -1
  174. package/src/timer/create.js +1 -1
  175. package/src/timer/delete.js +1 -1
  176. package/src/timer/detail.js +1 -1
  177. package/src/timer/doc.js +2 -2
  178. package/src/timer/docs/devguide.md +19 -19
  179. package/src/timer/get.js +1 -1
  180. package/src/timer/publish.js +1 -1
  181. package/src/timer/pull.js +1 -1
  182. package/src/timer/pullList.js +1 -1
  183. package/src/triggers/detail.js +1 -1
  184. package/src/triggers/doc.js +2 -2
  185. package/src/triggers/docs/devguide.md +23 -23
  186. package/src/triggers/get.js +1 -1
  187. package/src/triggers/pullList.js +1 -1
  188. package/src/user/create.js +2 -2
  189. package/src/user/delete.js +2 -2
  190. package/src/user/doc.js +2 -2
  191. package/src/user/docs/devguide.md +13 -13
  192. package/src/user/docs/introduction.md +12 -12
  193. package/src/user/get.js +1 -1
  194. package/src/user/update.js +3 -3
  195. package/src/user/view.js +2 -2
  196. package/src/validationRule/create.js +7 -7
  197. package/src/validationRule/delete.js +2 -2
  198. package/src/validationRule/doc.js +2 -2
  199. package/src/validationRule/docs/devguide.md +7 -7
  200. package/src/validationRule/docs/introduction.md +11 -11
  201. package/src/validationRule/get.js +1 -1
  202. package/src/version/actionHelp.js +25 -0
  203. package/src/version/docs.js +26 -0
  204. package/src/version/doctor.js +25 -0
  205. package/src/version/get.js +1 -1
  206. package/src/version/help.js +48 -0
  207. package/src/version/index.js +9 -2
  208. package/src/version/initHelp.js +13 -0
  209. package/src/version/listModuleCommands.js +241 -0
  210. package/src/version/stats.js +44 -0
  211. package/src/version/uninstall.js +30 -0
  212. package/src/version/update.js +13 -0
  213. package/test/application.cli.test.js +1 -1
  214. package/test/classes.cli.test.js +1 -1
  215. package/test/customSetting.cli.test.js +1 -1
  216. package/test/fields.cli.test.js +2 -2
  217. package/test/globalSelectList.cli.test.js +1 -1
  218. package/test/menu-script.cli.test.js +1 -1
  219. package/test/menu.cli.test.js +1 -1
  220. package/test/object.cli.test.js +1 -1
  221. package/test/plugin.cli.test.js +1 -1
  222. package/test/scheduleJob.cli.test.js +1 -1
  223. package/test/script.cli.test.js +1 -1
  224. package/test/staticResource.cli.test.js +1 -1
  225. package/test/timer.cli.test.js +1 -1
  226. package/test/trigger.cli.test.js +1 -1
  227. package/utils/checkVersion.js +27 -2
  228. package/utils/commandStats.js +94 -0
  229. package/utils/formatReleaseNotes.js +312 -0
  230. package/utils/readmeReleases.js +69 -0
  231. package/.cloudcc-cache.json +0 -54
  232. package/.cursor/skills/cloudcc-cli-dev.zip +0 -0
  233. package/.cursor/skills/cloudcc-dev-usage/SKILL.md +0 -68
  234. package/build/component-cc-cc-dd.common.js +0 -831
  235. package/build/component-cc-cc-dd.common.js.map +0 -1
  236. package/build/component-cc-cc-dd.css +0 -1
  237. package/build/component-cc-cc-dd.umd.js +0 -874
  238. package/build/component-cc-cc-dd.umd.js.map +0 -1
  239. package/build/component-cc-cc-dd.umd.min.js +0 -8
  240. package/build/component-cc-cc-dd.umd.min.js.map +0 -1
  241. package/build/demo.html +0 -1
  242. package/plugins/cc-cc-dd/cc-cc-dd.vue +0 -32
  243. package/plugins/cc-cc-dd/components/HelloWorld.vue +0 -11
  244. package/plugins/cc-cc-dd/config.json +0 -6
@@ -0,0 +1,200 @@
1
+ # Permission(权限集管理)
2
+
3
+ Permission 模块用于管理 CloudCC 权限集的分配功能,包括查看权限集列表、查看已分配用户、添加分配用户和删除分配用户。
4
+
5
+ ## 功能介绍
6
+
7
+ - **查看权限集列表**: 获取系统中的所有权限集
8
+ - **查看已分配用户**: 查看指定权限集已分配的用户列表
9
+ - **添加分配用户**: 为指定权限集分配用户
10
+ - **删除分配用户**: 从指定权限集中移除用户
11
+
12
+ ## 命令
13
+
14
+ 命令统一为 **`cloudcc <动作> <资源> …`**;本模块资源名为 **`permission`**。
15
+
16
+ ### 获取权限集列表
17
+
18
+ ```bash
19
+ cloudcc get permission <path> [viewId] [page] [pageSize] [searchKeyWord]
20
+ ```
21
+
22
+ **参数说明:**
23
+ - `path` - 项目路径(可选,默认为当前目录)
24
+ - `viewId` - 视图ID(可选,不传则自动获取)
25
+ - `page` - 页码(可选,默认为1)
26
+ - `pageSize` - 每页数量(可选,默认为100000)
27
+ - `searchKeyWord` - 搜索关键词(可选)
28
+
29
+ **示例:**
30
+
31
+ ```bash
32
+ # 获取所有权限集列表
33
+ cloudcc get permission .
34
+
35
+ # 使用指定视图获取权限集
36
+ cloudcc get permission . "00000000000000000000"
37
+
38
+ # 搜索权限集
39
+ cloudcc get permission . "" 1 100 "测试"
40
+ ```
41
+
42
+ ### 查看已分配用户
43
+
44
+ ```bash
45
+ cloudcc assign permission <path> <permsetId>
46
+ ```
47
+
48
+ **参数说明:**
49
+ - `path` - 项目路径(可选,默认为当前目录)
50
+ - `permsetId` - 权限集ID(必需)
51
+
52
+ **示例:**
53
+
54
+ ```bash
55
+ # 查看指定权限集的已分配用户
56
+ cloudcc assign permission . "cac20258F0E4ABBnTxwi"
57
+ ```
58
+
59
+ **输出示例:**
60
+
61
+ ```
62
+ 权限集: 古语云
63
+ ID: cac20258F0E4ABBnTxwi
64
+
65
+ 已分配 6 个用户:
66
+
67
+ 用户ID 姓名 登录名 简档 角色
68
+ -------------------- -------- -------------------- ---------------- ----------------
69
+ 00520263DB1540FTPmXK 我重新注册 421865903teet@qq.com Cloudcc Partner 简档 青青草原艾艾合作伙伴用户
70
+ 005202652FF2FA8dltk1 auto行 autoTest@cloudcc.com 系统管理员 测试
71
+ ...
72
+ ```
73
+
74
+ ### 添加分配用户
75
+
76
+ ```bash
77
+ cloudcc add permission <path> <permsetId> [userIds...]
78
+ ```
79
+
80
+ **参数说明:**
81
+ - `path` - 项目路径(可选,默认为当前目录)
82
+ - `permsetId` - 权限集ID(必需)
83
+ - `userIds` - 要分配的用户ID列表(可选,不传则进入交互式选择)
84
+
85
+ **示例:**
86
+
87
+ ```bash
88
+ # 交互式选择用户进行分配
89
+ cloudcc add permission . "cac20258F0E4ABBnTxwi"
90
+
91
+ # 直接指定用户ID进行分配(多个用户用空格分隔)
92
+ cloudcc add permission . "cac20258F0E4ABBnTxwi" "00520260C00C6FEfsMnT" "0052026C0A60504jNcbV"
93
+ ```
94
+
95
+ **交互式选择模式:**
96
+
97
+ 如果不指定 userIds,命令会进入交互式选择模式,展示所有可用用户供选择:
98
+
99
+ ```
100
+ ? 请选择要分配的用户(使用空格键选择,回车确认): (Press <space> to select, <a> to toggle all, <i> to invert selection)
101
+ ❯◯ 张三 (zhangsan@example.com) - 00520260C00C6FEfsMnT
102
+ ◯ 李四 (lisi@example.com) - 0052026C0A60504jNcbV
103
+ ◯ 王五 (wangwu@example.com) - 0052026D0A60504jNcbW
104
+ ```
105
+
106
+ ### 删除分配用户
107
+
108
+ ```bash
109
+ cloudcc remove permission <path> <permsetId> [userIds...]
110
+ ```
111
+
112
+ **参数说明:**
113
+ - `path` - 项目路径(可选,默认为当前目录)
114
+ - `permsetId` - 权限集ID(必需)
115
+ - `userIds` - 要移除的用户ID列表(可选,不传则进入交互式选择)
116
+
117
+ **示例:**
118
+
119
+ ```bash
120
+ # 交互式选择用户进行移除
121
+ cloudcc remove permission . "cac20258F0E4ABBnTxwi"
122
+
123
+ # 直接指定用户ID进行移除(多个用户用空格分隔)
124
+ cloudcc remove permission . "cac20258F0E4ABBnTxwi" "00520260C00C6FEfsMnT" "0052026C0A60504jNcbV"
125
+ ```
126
+
127
+ **交互式选择模式:**
128
+
129
+ 如果不指定 userIds,命令会进入交互式选择模式,展示当前已分配的用户供选择:
130
+
131
+ ```
132
+ ? 请选择要删除的用户(使用空格键选择,回车确认): (Press <space> to select, <a> to toggle all, <i> to invert selection)
133
+ ❯◯ 张三 (zhangsan@example.com) - 00520260C00C6FEfsMnT
134
+ ◯ 李四 (lisi@example.com) - 0052026C0A60504jNcbV
135
+
136
+ ? 确定要从权限集中移除 2 个用户吗? (y/N)
137
+ ```
138
+
139
+ ## 完整使用流程示例
140
+
141
+ ```bash
142
+ # 1. 查看所有权限集
143
+ cloudcc get permission .
144
+
145
+ # 2. 查看某个权限集的已分配用户
146
+ cloudcc assign permission . "cac20258F0E4ABBnTxwi"
147
+
148
+ # 3. 为权限集添加用户(交互式选择)
149
+ cloudcc add permission . "cac20258F0E4ABBnTxwi"
150
+
151
+ # 4. 再次查看已分配用户,确认添加成功
152
+ cloudcc assign permission . "cac20258F0E4ABBnTxwi"
153
+
154
+ # 5. 移除某些用户(交互式选择)
155
+ cloudcc remove permission . "cac20258F0E4ABBnTxwi"
156
+ ```
157
+
158
+ ## 数据结构
159
+
160
+ ### 权限集对象
161
+
162
+ ```json
163
+ {
164
+ "name": "古语云",
165
+ "licence": "CloudCC 用户",
166
+ "id": "cac20258F0E4ABBnTxwi",
167
+ "sysadmin": "0"
168
+ }
169
+ ```
170
+
171
+ **字段说明:**
172
+ - `name` - 权限集名称
173
+ - `licence` - 许可证类型
174
+ - `id` - 权限集唯一标识
175
+ - `sysadmin` - 是否为系统管理员权限("1"表示是,"0"表示否)
176
+
177
+ ### 用户对象
178
+
179
+ ```json
180
+ {
181
+ "loginname": "421865903teet@qq.com",
182
+ "profileid": "aaa000002",
183
+ "rolename": "青青草原艾艾合作伙伴用户",
184
+ "roleid": "2026A3D78466C42UokMO",
185
+ "profilename": "Cloudcc Partner 简档",
186
+ "name": "我重新注册",
187
+ "alias": null,
188
+ "id": "00520263DB1540FTPmXK"
189
+ }
190
+ ```
191
+
192
+ **字段说明:**
193
+ - `id` - 用户唯一标识
194
+ - `name` - 用户姓名
195
+ - `loginname` - 登录名(邮箱)
196
+ - `profilename` - 简档名称
197
+ - `profileid` - 简档ID
198
+ - `rolename` - 角色名称
199
+ - `roleid` - 角色ID
200
+ - `alias` - 别名
@@ -0,0 +1,107 @@
1
+ const chalk = require('chalk');
2
+ const { postClass } = require("../../utils/http");
3
+ const { getPackageJson } = require("../../utils/config");
4
+
5
+ /**
6
+ * 获取权限集视图ID
7
+ * @param {Object} config - 项目配置
8
+ * @returns {Promise<string>} 视图ID
9
+ */
10
+ async function getPermsetViewId(config) {
11
+ const res = await postClass(
12
+ config.setupSvc + "/api/permissionGroup/queryPermsetsList",
13
+ {},
14
+ config.accessToken
15
+ );
16
+
17
+ if (res && res.result && res.data) {
18
+ // 优先使用返回的 viewId
19
+ if (res.data.viewId) {
20
+ return res.data.viewId;
21
+ }
22
+ // 否则使用 viewList 中的第一个
23
+ if (Array.isArray(res.data.viewList) && res.data.viewList.length > 0) {
24
+ return res.data.viewList[0].id;
25
+ }
26
+ }
27
+
28
+ throw new Error("未找到权限集视图");
29
+ }
30
+
31
+ /**
32
+ * 获取权限集列表
33
+ * 用法:cloudcc get permission <projectPath> [viewId] [page] [pageSize] [searchKeyWord]
34
+ * @param {Array} argvs - 命令行参数数组
35
+ * @param {boolean} isMcp - 是否为MCP模式
36
+ * @returns {Promise<Array>} 权限集列表
37
+ */
38
+ async function get(argvs, isMcp = false) {
39
+ try {
40
+ const projectPath = argvs[2] || process.cwd();
41
+ const viewId = argvs[3] || '';
42
+ const page = parseInt(argvs[4]) || 1;
43
+ const pageSize = parseInt(argvs[5]) || 100000;
44
+ const searchKeyWord = argvs[6] || '';
45
+
46
+ const config = await getPackageJson(projectPath);
47
+
48
+ // 如果没有指定 viewId,先获取视图ID
49
+ let finalViewId = viewId;
50
+ if (!finalViewId) {
51
+ try {
52
+ finalViewId = await getPermsetViewId(config);
53
+ } catch (error) {
54
+ console.error(chalk.yellow("Warning: " + error.message));
55
+ throw error;
56
+ }
57
+ }
58
+
59
+ const res = await postClass(
60
+ config.setupSvc + "/api/permissionGroup/listAJAX",
61
+ {
62
+ viewId: finalViewId,
63
+ page: page,
64
+ pageSize: pageSize,
65
+ searchKeyWord: searchKeyWord
66
+ },
67
+ config.accessToken
68
+ );
69
+
70
+ if (res && res.result && res.data) {
71
+ const list = res.data.list || [];
72
+
73
+ if (!isMcp) {
74
+ if (list.length === 0) {
75
+ console.log(chalk.yellow("未找到权限集"));
76
+ } else {
77
+ console.log(chalk.green(`找到 ${list.length} 个权限集:`));
78
+ console.log();
79
+ // 表格形式输出
80
+ const idWidth = Math.max(20, ...list.map(item => item.id?.length || 0));
81
+ const nameWidth = Math.max(15, ...list.map(item => item.name?.length || 0));
82
+
83
+ console.log(chalk.cyan(` ${'ID'.padEnd(idWidth)} ${'名称'.padEnd(nameWidth)} 许可证 系统管理员`));
84
+ console.log(chalk.cyan(` ${'-'.repeat(idWidth)} ${'-'.repeat(nameWidth)} ---------------- ----------`));
85
+
86
+ list.forEach(item => {
87
+ const sysAdminStr = item.sysadmin === '1' ? '是' : '否';
88
+ console.log(` ${(item.id || '').padEnd(idWidth)} ${(item.name || '').padEnd(nameWidth)} ${(item.licence || '').padEnd(16)} ${sysAdminStr}`);
89
+ });
90
+ console.log();
91
+ }
92
+ }
93
+ return list;
94
+ }
95
+
96
+ const msg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
97
+ throw new Error("获取权限集列表失败: " + msg);
98
+
99
+ } catch (error) {
100
+ if (!isMcp) {
101
+ console.error(chalk.red("Error: " + error.message));
102
+ }
103
+ throw error;
104
+ }
105
+ }
106
+
107
+ module.exports = get;
@@ -0,0 +1,10 @@
1
+ const cc = {}
2
+ cc.get = require("./get")
3
+ cc.assign = require("./assign")
4
+ cc.add = require("./add")
5
+ cc.remove = require("./remove")
6
+ async function main(action, argvs) {
7
+ await cc[action](argvs)
8
+ }
9
+
10
+ module.exports = main;
@@ -0,0 +1,145 @@
1
+ const chalk = require('chalk');
2
+ const { postClass } = require("../../utils/http");
3
+ const { getPackageJson } = require("../../utils/config");
4
+ const inquirer = require('inquirer');
5
+
6
+ /**
7
+ * 获取权限集已分配的用户列表
8
+ * @param {Object} config - 项目配置
9
+ * @param {string} permsetId - 权限集ID
10
+ * @returns {Promise<Array>} 已分配用户列表
11
+ */
12
+ async function getAssignedUsers(config, permsetId) {
13
+ const res = await postClass(
14
+ config.setupSvc + "/api/permissionGroup/queryUserlistBypermsetsid",
15
+ { id: permsetId },
16
+ config.accessToken
17
+ );
18
+
19
+ if (res && res.result && res.data) {
20
+ return res.data.userlist || [];
21
+ }
22
+
23
+ throw new Error("获取已分配用户列表失败");
24
+ }
25
+
26
+ /**
27
+ * 删除权限集分配用户
28
+ * 用法:cloudcc remove permission <projectPath> <permsetId> [userIds...]
29
+ * 如果不指定 userIds,会进入交互式选择
30
+ * @param {Array} argvs - 命令行参数数组
31
+ * @param {boolean} isMcp - 是否为MCP模式
32
+ * @returns {Promise<Object>} 删除结果
33
+ */
34
+ async function remove(argvs, isMcp = false) {
35
+ try {
36
+ const projectPath = argvs[2] || process.cwd();
37
+ const permsetId = argvs[3];
38
+ // 从第4个参数开始是用户ID
39
+ let userIds = argvs.slice(4);
40
+
41
+ if (!permsetId) {
42
+ console.error();
43
+ console.error(chalk.red('Error: 缺少权限集ID'));
44
+ console.error('用法: cloudcc remove permission <path> <permsetId> [userId1] [userId2] ...');
45
+ console.error('示例:');
46
+ console.error(' cloudcc remove permission . "cac20258F0E4ABBnTxwi" # 交互式选择用户');
47
+ console.error(' cloudcc remove permission . "cac20258F0E4ABBnTxwi" "00520260C00C6FEfsMnT" # 直接指定用户ID');
48
+ console.error();
49
+ throw new Error('缺少必需参数: permsetId');
50
+ }
51
+
52
+ const config = await getPackageJson(projectPath);
53
+
54
+ // 如果没有指定用户ID,进入交互式选择
55
+ if (userIds.length === 0) {
56
+ console.log();
57
+ console.log(chalk.blue('正在获取已分配用户列表...'));
58
+
59
+ const userList = await getAssignedUsers(config, permsetId);
60
+
61
+ if (userList.length === 0) {
62
+ console.log(chalk.yellow("该权限集没有分配任何用户"));
63
+ return { success: false, message: "该权限集没有分配任何用户" };
64
+ }
65
+
66
+ // 交互式选择用户
67
+ const choices = userList.map(user => ({
68
+ name: `${user.name || '未命名'} (${user.loginname || ''}) - ${user.id}`,
69
+ value: user.id,
70
+ short: user.name || user.id
71
+ }));
72
+
73
+ const { selectedUsers } = await inquirer.prompt([
74
+ {
75
+ type: 'checkbox',
76
+ name: 'selectedUsers',
77
+ message: '请选择要删除的用户(使用空格键选择,回车确认):',
78
+ choices: choices,
79
+ validate: (input) => input.length > 0 || '请至少选择一个用户'
80
+ }
81
+ ]);
82
+
83
+ userIds = selectedUsers;
84
+ }
85
+
86
+ if (userIds.length === 0) {
87
+ console.log(chalk.yellow("未选择任何用户"));
88
+ return { success: false, message: "未选择任何用户" };
89
+ }
90
+
91
+ // 确认删除
92
+ const { confirm } = await inquirer.prompt([
93
+ {
94
+ type: 'confirm',
95
+ name: 'confirm',
96
+ message: `确定要从权限集中移除 ${userIds.length} 个用户吗?`,
97
+ default: false
98
+ }
99
+ ]);
100
+
101
+ if (!confirm) {
102
+ console.log(chalk.yellow("已取消操作"));
103
+ return { success: false, message: "用户取消操作" };
104
+ }
105
+
106
+ console.log();
107
+ console.log(chalk.blue(`正在从权限集 ${permsetId} 移除 ${userIds.length} 个用户...`));
108
+
109
+ const res = await postClass(
110
+ config.setupSvc + "/api/permissionGroup/deleteUsersetup",
111
+ {
112
+ id: permsetId,
113
+ ids: userIds.join(',')
114
+ },
115
+ config.accessToken
116
+ );
117
+
118
+ if (res && res.result) {
119
+ if (!isMcp) {
120
+ console.log();
121
+ console.log(chalk.green('✓ 用户移除成功'));
122
+ console.log(` 权限集ID: ${permsetId}`);
123
+ console.log(` 移除用户数: ${userIds.length}`);
124
+ console.log();
125
+ }
126
+ return {
127
+ success: true,
128
+ permsetId: permsetId,
129
+ userCount: userIds.length,
130
+ userIds: userIds
131
+ };
132
+ }
133
+
134
+ const msg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
135
+ throw new Error("移除用户失败: " + msg);
136
+
137
+ } catch (error) {
138
+ if (!isMcp) {
139
+ console.error(chalk.red("Error: " + error.message));
140
+ }
141
+ throw error;
142
+ }
143
+ }
144
+
145
+ module.exports = remove;
@@ -11,7 +11,7 @@ const BaseUrl = "https://developer.apis.cloudcc.cn";
11
11
  * - 传组件名时:从本地 plugins/<name>/config.json 读取 id 后删除
12
12
  * - 传 ID 时:直接通过 ID 删除
13
13
  *
14
- * 用法:cc delete plugin <pluginNameOrId> [projectPath]
14
+ * 用法:cloudcc delete plugin <pluginNameOrId> [projectPath]
15
15
  */
16
16
  async function deletePlugin(argvs) {
17
17
  const input = argvs[2];
@@ -20,7 +20,7 @@ async function deletePlugin(argvs) {
20
20
  if (!input) {
21
21
  console.error();
22
22
  console.error(chalk.red('Error: Plugin name or ID is required'));
23
- console.error(chalk.yellow('Usage: cc delete plugin <pluginNameOrId> [projectPath]'));
23
+ console.error(chalk.yellow('Usage: cloudcc delete plugin <pluginNameOrId> [projectPath]'));
24
24
  console.error();
25
25
  return;
26
26
  }
package/src/plugin/doc.js CHANGED
@@ -32,14 +32,14 @@ function getDevGuideDoc() {
32
32
  }
33
33
 
34
34
  /**
35
- * cc doc plugin <introduction|devguide>
35
+ * cloudcc doc plugin <introduction|devguide>
36
36
  * @param {string[]} argvs [doc, type, introduction|devguide, ...]
37
37
  */
38
38
  function doc(argvs) {
39
39
  const subType = argvs[2];
40
40
  const key = String(subType || "").trim().toLowerCase();
41
41
  if (!key) {
42
- throw new Error("cc doc plugin 需要子命令:introduction 或 devguide");
42
+ throw new Error("cloudcc doc plugin 需要子命令:introduction 或 devguide");
43
43
  }
44
44
  if (key === "introduction") {
45
45
  const content = getIntroductionDoc();
@@ -11,19 +11,19 @@
11
11
 
12
12
  **允许的做法**:在 CLI 已生成的目录内用 IDE 编辑 `.vue`、子组件与 `utils/` 等源码;与云端列表、详情、拉取、删除、发布相关的操作一律走命令。
13
13
 
14
- 执行命令前请确认:已完成 `cc doc project devguide` 中的环境初始化,项目根目录配置可用且具备 `accessToken`(发布流程还会使用 `pluginToken` / 账号密钥等,以你项目配置为准)。
14
+ 执行命令前请确认:已完成 `cloudcc doc project devguide` 中的环境初始化,项目根目录配置可用且具备 `accessToken`(发布流程还会使用 `pluginToken` / 账号密钥等,以你项目配置为准)。
15
15
 
16
16
  ### 命令总览(以代码实现为准)
17
17
 
18
18
  ```bash
19
- cc create plugin <name>
20
- cc publish plugin <name>
21
- cc get plugin [projectPath]
22
- cc detail plugin <pluginName> [pluginId] [projectPath]
23
- cc detail plugin "" <pluginId> [projectPath]
24
- cc pull plugin <pluginNameOrId> [projectPath]
25
- cc delete plugin <pluginNameOrId> [projectPath]
26
- cc doc plugin <introduction|devguide>
19
+ cloudcc create plugin <name>
20
+ cloudcc publish plugin <name>
21
+ cloudcc get plugin [projectPath]
22
+ cloudcc detail plugin <pluginName> [pluginId] [projectPath]
23
+ cloudcc detail plugin "" <pluginId> [projectPath]
24
+ cloudcc pull plugin <pluginNameOrId> [projectPath]
25
+ cloudcc delete plugin <pluginNameOrId> [projectPath]
26
+ cloudcc doc plugin <introduction|devguide>
27
27
  ```
28
28
 
29
29
  参数约定:
@@ -31,7 +31,7 @@ cc doc plugin <introduction|devguide>
31
31
  - `name` / `pluginName`:插件目录名,与 `plugins/<name>/` 一致。
32
32
  - `projectPath`:项目根路径;不传则使用当前工作目录。`get` 的第一个可选参数即为 `projectPath`。
33
33
  - `pluginNameOrId`:本地目录名,或云端组件 ID;若本地存在 `config.json` 且含 `id`,`pull` / `delete` 会优先使用该 `id`。
34
- - `pluginId`:`detail` 仅查云端时,将 `pluginName` 置空:`cc detail plugin "" <pluginId>`。
34
+ - `pluginId`:`detail` 仅查云端时,将 `pluginName` 置空:`cloudcc detail plugin "" <pluginId>`。
35
35
 
36
36
  ### 命令作用摘要
37
37
 
@@ -49,20 +49,20 @@ cc doc plugin <introduction|devguide>
49
49
 
50
50
  ```bash
51
51
  # 1) 查看云端已有组件(可选)
52
- cc get plugin .
52
+ cloudcc get plugin .
53
53
 
54
54
  # 2) 仅通过 create 生成目录与模板
55
- cc create plugin my_plugin
55
+ cloudcc create plugin my_plugin
56
56
 
57
57
  # 3) 本地调试后发布(勿跳过 CLI 发布流程)
58
- cc publish plugin my_plugin
58
+ cloudcc publish plugin my_plugin
59
59
 
60
60
  # 4) 与云端对齐或迁移机器时拉取
61
- cc pull plugin my_plugin
62
- # 或已知云端 ID:cc pull plugin <id> .
61
+ cloudcc pull plugin my_plugin
62
+ # 或已知云端 ID:cloudcc pull plugin <id> .
63
63
 
64
64
  # 5) 不再使用时删除云端组件
65
- cc delete plugin my_plugin
65
+ cloudcc delete plugin my_plugin
66
66
  ```
67
67
 
68
68
  ---
@@ -162,7 +162,7 @@ npm run serve
162
162
 
163
163
  ### 1.2 创建组件
164
164
 
165
- - **使用本 CLI 时**:在项目根执行 `cc create plugin <name>`,会在 `plugins/<name>/` 生成标准模板(推荐)。
165
+ - **使用本 CLI 时**:在项目根执行 `cloudcc create plugin <name>`,会在 `plugins/<name>/` 生成标准模板(推荐)。
166
166
  - 或在模板工程中手动新建入口文件,**组件名称必须满足 DOM 命名规则**,例如:`cc-com-demo.vue`
167
167
  - 推荐遵循:以 `cc-` 开头,后续使用小写单词和 `-` 连接。
168
168
 
@@ -181,7 +181,7 @@ npm run serve
181
181
  **推荐(与仓库、CI 一致)**:在项目根目录执行:
182
182
 
183
183
  ```bash
184
- cc publish plugin <与目录名一致的 name>
184
+ cloudcc publish plugin <与目录名一致的 name>
185
185
  ```
186
186
 
187
187
  CLI 会编译 `plugins/<name>/<name>.vue` 并上传;首次成功且接口返回 `id` 时可能写回 `plugins/<name>/config.json`。
@@ -913,7 +913,7 @@ componentInfo: {
913
913
 
914
914
  ## 13. 自定义组件开发 Checklist
915
915
 
916
- - [ ] 插件目录与云端同步仅通过 `cc create` / `cc publish` / `cc pull` / `cc delete` 等命令操作,不整包复制他人 `plugins/` 或手改 `config.json` 的 `id`
916
+ - [ ] 插件目录与云端同步仅通过 `cloudcc create` / `cloudcc publish` / `cloudcc pull` / `cloudcc delete` 等命令操作,不整包复制他人 `plugins/` 或手改 `config.json` 的 `id`
917
917
  - [ ] 组件文件名与 `componentInfo.component` 命名符合规范(小写 + `-`
918
918
  分隔,全局唯一)
919
919
  - [ ] 样式默认使用 `lang="scss" scoped`,避免样式污染
@@ -934,7 +934,7 @@ componentInfo: {
934
934
  ### 14.1 create
935
935
 
936
936
  ```bash
937
- cc create plugin <name>
937
+ cloudcc create plugin <name>
938
938
  ```
939
939
 
940
940
  - 创建 `plugins/<name>/` 目录、入口 `<name>.vue`、`components/` 与 `config.json` 模板。
@@ -942,7 +942,7 @@ cc create plugin <name>
942
942
  ### 14.2 publish
943
943
 
944
944
  ```bash
945
- cc publish plugin <name>
945
+ cloudcc publish plugin <name>
946
946
  ```
947
947
 
948
948
  - 以 `plugins/<name>/<name>.vue` 为入口编译(`vue-cli-service build --target lib`),再上传到云端。
@@ -951,7 +951,7 @@ cc publish plugin <name>
951
951
  ### 14.3 get
952
952
 
953
953
  ```bash
954
- cc get plugin [projectPath]
954
+ cloudcc get plugin [projectPath]
955
955
  ```
956
956
 
957
957
  - 分页请求云端组件列表,标准输出为 JSON 数组。
@@ -960,18 +960,18 @@ cc get plugin [projectPath]
960
960
  ### 14.4 detail
961
961
 
962
962
  ```bash
963
- cc detail plugin <pluginName> [pluginId] [projectPath]
964
- cc detail plugin "" <pluginId> [projectPath]
963
+ cloudcc detail plugin <pluginName> [pluginId] [projectPath]
964
+ cloudcc detail plugin "" <pluginId> [projectPath]
965
965
  ```
966
966
 
967
967
  - 提供 `pluginName`(且非空):读取本地 `plugins/<pluginName>/` 的 `config.json` 与入口 `.vue`。
968
968
  - 将 `pluginName` 置为空并传 `pluginId`:仅从云端查询详情(`projectPath` 仍用于配置)。
969
- - 需要指定项目根且保留「仅本地名」时,可用占位:`cc detail plugin <pluginName> "" <projectPath>`(中间空串表示无 `pluginId`)。
969
+ - 需要指定项目根且保留「仅本地名」时,可用占位:`cloudcc detail plugin <pluginName> "" <projectPath>`(中间空串表示无 `pluginId`)。
970
970
 
971
971
  ### 14.5 pull
972
972
 
973
973
  ```bash
974
- cc pull plugin <pluginNameOrId> [projectPath]
974
+ cloudcc pull plugin <pluginNameOrId> [projectPath]
975
975
  ```
976
976
 
977
977
  - 若 `plugins/<输入>/config.json` 存在且含 `id`,按该 `id` 拉取。
@@ -980,7 +980,7 @@ cc pull plugin <pluginNameOrId> [projectPath]
980
980
  ### 14.6 delete
981
981
 
982
982
  ```bash
983
- cc delete plugin <pluginNameOrId> [projectPath]
983
+ cloudcc delete plugin <pluginNameOrId> [projectPath]
984
984
  ```
985
985
 
986
986
  - 若本地 `plugins/<name>/config.json` 存在且含 `id`,优先按该 `id` 调删除接口。
@@ -989,8 +989,8 @@ cc delete plugin <pluginNameOrId> [projectPath]
989
989
  ### 14.7 doc
990
990
 
991
991
  ```bash
992
- cc doc plugin introduction
993
- cc doc plugin devguide
992
+ cloudcc doc plugin introduction
993
+ cloudcc doc plugin devguide
994
994
  ```
995
995
 
996
996
  - 仅支持 `introduction` 与 `devguide`;`devguide` 会在正文后拼接附录「CCDK SDK 速查」。
@@ -4,7 +4,7 @@ const { getPackageJson } = require("../../utils/config");
4
4
 
5
5
  /**
6
6
  * 创建简档
7
- * 用法:cc create profile <path> <profileName> [description]
7
+ * 用法:cloudcc create profile <path> <profileName> [description]
8
8
  * 流程:1. 调用 /profile/copyProfile 获取现有简档列表
9
9
  * 2. 选择第一个简档作为复制来源
10
10
  * 3. 调用 /profile/newProfile 创建新简档
@@ -13,7 +13,7 @@ const { getPackageJson } = require("../../utils/config");
13
13
  */
14
14
  async function create(argvs) {
15
15
  try {
16
- // 命令行参数格式:cc create profile <path> <profileName> [description]
16
+ // 命令行参数格式:cloudcc create profile <path> <profileName> [description]
17
17
  const projectPath = argvs[2] || process.cwd();
18
18
  const profileName = argvs[3];
19
19
  const description = argvs[4] || '';
@@ -21,10 +21,10 @@ async function create(argvs) {
21
21
  if (!profileName) {
22
22
  console.error();
23
23
  console.error(chalk.red('Error: 缺少简档名称'));
24
- console.error('用法: cc create profile <path> <profileName> [description]');
24
+ console.error('用法: cloudcc create profile <path> <profileName> [description]');
25
25
  console.error('示例:');
26
- console.error(' cc create profile . "销售经理简档"');
27
- console.error(' cc create profile . "销售代表简档" "适用于销售团队的权限配置"');
26
+ console.error(' cloudcc create profile . "销售经理简档"');
27
+ console.error(' cloudcc create profile . "销售代表简档" "适用于销售团队的权限配置"');
28
28
  console.error();
29
29
  throw new Error('缺少必需参数: profileName');
30
30
  }