cloudcc-cli 2.2.2 → 2.2.4
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/.vscode/settings.json +3 -0
- package/README.md +47 -0
- package/bin/cc.js +11 -35
- package/bin/index.js +33 -0
- package/bin/mcp-svc.js +13 -0
- package/bin/mcp.js +18 -0
- package/java/com/cloudcc/core/TriggerInvoker.java +17 -1
- package/package.json +16 -7
- package/pom.xml +1 -0
- package/prompt/DevelopmentEnvironmentConstruction.ts +133 -0
- package/prompt/ccdk.ts +1190 -0
- package/prompt/ccprompt.ts +8 -0
- package/prompt/cloudccdev.ts +109 -0
- package/prompt/index.ts +52 -0
- package/prompt/objectInfo.ts +94 -0
- package/prompt/objectList.ts +25 -0
- package/prompt/openapi.ts +310 -0
- package/prompt/system.ts +14 -0
- package/prompt/vscodeExtension.ts +27 -0
- package/src/approval/approve.js +105 -0
- package/src/approval/get.js +245 -0
- package/src/approval/index.js +11 -0
- package/src/approval/reject.js +105 -0
- package/src/brief/get.js +51 -0
- package/src/brief/index.js +7 -0
- package/src/config/get.js +1 -1
- package/src/fields/create.js +204 -0
- package/src/fields/fields/A.js +23 -0
- package/src/fields/fields/AD.js +25 -0
- package/src/fields/fields/B.js +28 -0
- package/src/fields/fields/C.js +28 -0
- package/src/fields/fields/D.js +27 -0
- package/src/fields/fields/E.js +28 -0
- package/src/fields/fields/ENC.js +28 -0
- package/src/fields/fields/ENCD.js +28 -0
- package/src/fields/fields/F.js +27 -0
- package/src/fields/fields/FL.js +25 -0
- package/src/fields/fields/H.js +27 -0
- package/src/fields/fields/IMG.js +27 -0
- package/src/fields/fields/J.js +26 -0
- package/src/fields/fields/L.js +32 -0
- package/src/fields/fields/LT.js +28 -0
- package/src/fields/fields/M.js +29 -0
- package/src/fields/fields/MR.js +24 -0
- package/src/fields/fields/N.js +30 -0
- package/src/fields/fields/P.js +28 -0
- package/src/fields/fields/Q.js +35 -0
- package/src/fields/fields/S.js +30 -0
- package/src/fields/fields/SCORE.js +24 -0
- package/src/fields/fields/T.js +27 -0
- package/src/fields/fields/U.js +28 -0
- package/src/fields/fields/X.js +28 -0
- package/src/fields/fields/Y.js +33 -0
- package/src/fields/get.js +36 -0
- package/src/fields/index.js +9 -0
- package/src/mcp/MCP/345/234/272/346/231/257/346/250/241/346/213/237.md +8 -0
- package/src/mcp/index-sse-svc.js +126 -0
- package/src/mcp/index-streamable-svc.js +180 -0
- package/src/mcp/index.js +631 -0
- package/src/mcp/readme.md +137 -0
- package/src/mcp/tools/Approval/handler.js +349 -0
- package/src/mcp/tools/Class Creator/handler.js +37 -0
- package/src/mcp/tools/Class Detail Retriever/handler.js +33 -0
- package/src/mcp/tools/Class Detail Retriever/prompt.js +37 -0
- package/src/mcp/tools/Class Editor Guide/handler.js +72 -0
- package/src/mcp/tools/Class Editor Guide/prompt.js +468 -0
- package/src/mcp/tools/Class List Retriever/handler.js +36 -0
- package/src/mcp/tools/Class Publisher/handler.js +29 -0
- package/src/mcp/tools/Class Publisher/prompt.js +40 -0
- package/src/mcp/tools/Class Puller/handler.js +86 -0
- package/src/mcp/tools/Class Puller/prompt.js +49 -0
- package/src/mcp/tools/Client Script Creator/handler.js +179 -0
- package/src/mcp/tools/Client Script Detail Retriever/handler.js +53 -0
- package/src/mcp/tools/Client Script Editor Guide/handler.js +633 -0
- package/src/mcp/tools/Client Script List Retriever/handler.js +68 -0
- package/src/mcp/tools/Client Script Publisher/handler.js +54 -0
- package/src/mcp/tools/Client Script Puller/handler.js +73 -0
- package/src/mcp/tools/CloudCC Development Overview/handler.js +48 -0
- package/src/mcp/tools/CloudCC Development Overview/prompt.js +870 -0
- package/src/mcp/tools/Component Creator/handler.js +44 -0
- package/src/mcp/tools/Component Detail Retriever/handler.js +38 -0
- package/src/mcp/tools/Component Editor Guide/handler.js +76 -0
- package/src/mcp/tools/Component Editor Guide/prompt.js +519 -0
- package/src/mcp/tools/Component List Retriever/handler.js +43 -0
- package/src/mcp/tools/Component Publisher/handler.js +18 -0
- package/src/mcp/tools/Component Publisher/prompt.js +659 -0
- package/src/mcp/tools/Component Puller/handler.js +63 -0
- package/src/mcp/tools/Dev Environment Creator/fetcher.js +500 -0
- package/src/mcp/tools/Dev Environment Creator/handler.js +92 -0
- package/src/mcp/tools/Dev Environment Creator/prompt.js +273 -0
- package/src/mcp/tools/Dev Environment Validator/handler.js +88 -0
- package/src/mcp/tools/Dev Environment Validator/prompt.js +193 -0
- package/src/mcp/tools/Developer Key Setup Guide/fetcher.js +278 -0
- package/src/mcp/tools/Developer Key Setup Guide/handler.js +43 -0
- package/src/mcp/tools/Developer Key Setup Guide/prompt.js +71 -0
- package/src/mcp/tools/Object Creator/handler.js +34 -0
- package/src/mcp/tools/Object Fields Creator/handler.js +64 -0
- package/src/mcp/tools/Object Fields Retriever/handler.js +37 -0
- package/src/mcp/tools/Object Fields Retriever/prompt.js +10 -0
- package/src/mcp/tools/Object List Retriever/handler.js +43 -0
- package/src/mcp/tools/Object List Retriever/prompt.js +10 -0
- package/src/mcp/tools/Scheduled Class Creator/handler.js +37 -0
- package/src/mcp/tools/Scheduled Class Detail Retriever/handler.js +34 -0
- package/src/mcp/tools/Scheduled Class List Retriever/handler.js +52 -0
- package/src/mcp/tools/Scheduled Class Publisher/handler.js +30 -0
- package/src/mcp/tools/Scheduled Class Puller/handler.js +92 -0
- package/src/mcp/tools/Trigger Creator/handler.js +53 -0
- package/src/mcp/tools/Trigger Detail Retriever/handler.js +33 -0
- package/src/mcp/tools/Trigger Editor Guide/handler.js +58 -0
- package/src/mcp/tools/Trigger List Retriever/handler.js +49 -0
- package/src/mcp/tools/Trigger Publisher/handler.js +34 -0
- package/src/mcp/tools/Trigger Puller/handler.js +40 -0
- package/src/mcp/tools/ccdk/fetcher.js +18 -0
- package/src/mcp/tools/ccdk/handler.js +98 -0
- package/src/mcp/tools/ccdk/prompt.js +453 -0
- package/src/mcp/tools/index.js +23 -0
- package/src/object/create.js +105 -0
- package/src/object/get.js +43 -4
- package/src/object/index.js +2 -1
- package/src/plugin/create.js +1 -2
- package/src/plugin/create1.js +9 -9
- package/src/plugin/detail.js +91 -0
- package/src/plugin/get.js +79 -0
- package/src/plugin/index.js +4 -1
- package/src/plugin/publish.js +13 -13
- package/src/plugin/publish1.js +33 -24
- package/src/plugin/pull.js +173 -0
- package/src/project/create.js +9 -9
- package/src/project/create1.js +31 -17
- package/src/recordType/get.js +4 -2
- package/src/script/create.js +7 -7
- package/src/script/detail.js +95 -0
- package/src/script/get.js +4 -2
- package/src/script/index.js +1 -0
- package/src/script/publish.js +14 -14
- package/src/script/pull.js +12 -12
- package/src/script/pullList.js +5 -3
- package/src/timer/create.js +7 -7
- package/src/timer/detail.js +84 -0
- package/src/timer/get.js +6 -3
- package/src/timer/publish.js +7 -7
- package/src/timer/pull.js +8 -8
- package/src/timer/pullList.js +5 -3
- package/src/token/get.js +1 -1
- package/src/triggers/create.js +7 -7
- package/src/triggers/detail.js +90 -0
- package/src/triggers/get.js +4 -2
- package/src/triggers/index.js +1 -0
- package/src/triggers/publish.js +7 -7
- package/src/triggers/pull.js +8 -8
- package/src/triggers/pullList.js +5 -3
- package/src/version/get.js +3 -3
- package/target/ccopenapi-0.0.3-classes.jar +0 -0
- package/target/ccopenapi-0.0.3.jar +0 -0
- package/target/maven-archiver/pom.properties +3 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +18 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +19 -0
- package/template/Appvue +452 -12
- package/template/index.js +30 -19
- package/tool/branch/index.js +1 -1
- package/tool/checkLange/checkLang.js +6 -6
- package/tool/checkLange/clearLang.js +1 -1
- package/utils/accessClass.js +23 -0
- package/utils/checkVersion.js +22 -20
- package/utils/config.js +18 -3
- package/utils/http.js +10 -10
- package/utils/utils.js +128 -40
- package/java/com/cloudcc/core/CCTriggerDemo.java +0 -25
- package/src/classes/create.js +0 -65
- package/src/classes/get.js +0 -21
- package/src/classes/index.js +0 -11
- package/src/classes/publish.js +0 -50
- package/src/classes/pull.js +0 -54
- package/src/classes/pullList.js +0 -44
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin 工具知识库
|
|
3
|
+
* 提供 Vue 插件模板、配置结构、API 文档和错误信息
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Vue 插件模板示例
|
|
8
|
+
*/
|
|
9
|
+
const vuePluginTemplate = {
|
|
10
|
+
name: 'Vue插件组件模板',
|
|
11
|
+
description: 'CloudCC Vue 自定义组件的标准结构,支持自定义元素和组件注册',
|
|
12
|
+
mainComponent: `<template>
|
|
13
|
+
<div class="cc-container">
|
|
14
|
+
<HelloWorld />
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import HelloWorld from "./components/HelloWorld.vue";
|
|
20
|
+
export default {
|
|
21
|
+
components: {
|
|
22
|
+
HelloWorld,
|
|
23
|
+
},
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
componentInfo: {
|
|
27
|
+
// 组件唯一标识符
|
|
28
|
+
component: "component-{pluginName}",
|
|
29
|
+
// 组件显示名称
|
|
30
|
+
compName: "compName-{pluginName}",
|
|
31
|
+
// 组件描述信息
|
|
32
|
+
compDesc: "Component description information",
|
|
33
|
+
// 业务类型(可选)
|
|
34
|
+
bizType: "",
|
|
35
|
+
// 分类(可选)
|
|
36
|
+
category: "",
|
|
37
|
+
// 加载模式:lazy(懒加载)或 eager(立即加载)
|
|
38
|
+
loadModel: "lazy",
|
|
39
|
+
// 所属组织标识
|
|
40
|
+
belongOrgFlag: "custom"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
<style lang="scss" scoped>
|
|
47
|
+
.cc-container {
|
|
48
|
+
text-align: center;
|
|
49
|
+
padding: 8px;
|
|
50
|
+
}
|
|
51
|
+
</style>`,
|
|
52
|
+
subComponent: `<template>
|
|
53
|
+
<div>Hello world</div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
export default {};
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<style lang="scss" scoped>
|
|
61
|
+
</style>`,
|
|
62
|
+
notes: [
|
|
63
|
+
'所有 <style> 标签必须包含 scoped 属性,避免样式全局污染',
|
|
64
|
+
'componentInfo.component 必须唯一,建议使用 "component-" 前缀',
|
|
65
|
+
'componentInfo.compName 是在界面上显示的名称,支持国际化',
|
|
66
|
+
'loadModel 为 "lazy" 时组件按需加载,为 "eager" 时立即加载',
|
|
67
|
+
'belongOrgFlag 默认为 "custom",表示自定义组件'
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* config.json 配置文件结构
|
|
73
|
+
*/
|
|
74
|
+
const configStructure = {
|
|
75
|
+
name: 'config.json配置结构',
|
|
76
|
+
description: '每个插件目录下的配置文件',
|
|
77
|
+
fields: {
|
|
78
|
+
component: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
required: true,
|
|
81
|
+
description: '组件唯一标识符,必须以 "component-" 开头'
|
|
82
|
+
},
|
|
83
|
+
compName: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
required: true,
|
|
86
|
+
description: '组件显示名称'
|
|
87
|
+
},
|
|
88
|
+
compDesc: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
required: true,
|
|
91
|
+
description: '组件描述信息'
|
|
92
|
+
},
|
|
93
|
+
bizType: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
required: false,
|
|
96
|
+
description: '业务类型标识'
|
|
97
|
+
},
|
|
98
|
+
category: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
required: false,
|
|
101
|
+
description: '组件分类'
|
|
102
|
+
},
|
|
103
|
+
loadModel: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
required: false,
|
|
106
|
+
description: '加载模式:lazy(懒加载)或 eager(立即加载)',
|
|
107
|
+
default: 'lazy'
|
|
108
|
+
},
|
|
109
|
+
belongOrgFlag: {
|
|
110
|
+
type: 'string',
|
|
111
|
+
required: false,
|
|
112
|
+
description: '所属组织标识',
|
|
113
|
+
default: 'custom'
|
|
114
|
+
},
|
|
115
|
+
destroyTimeout: {
|
|
116
|
+
type: 'number',
|
|
117
|
+
required: false,
|
|
118
|
+
description: '组件销毁超时时间(毫秒)',
|
|
119
|
+
default: 1200000
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
example: {
|
|
123
|
+
component: 'component-MyPlugin',
|
|
124
|
+
compName: 'compName-MyPlugin',
|
|
125
|
+
compDesc: 'Component description information'
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* CloudCC 组件数据结构
|
|
131
|
+
*/
|
|
132
|
+
const componentDataStructure = {
|
|
133
|
+
name: '组件数据结构',
|
|
134
|
+
description: 'Vue 组件 data() 中返回的 CloudCC 标准结构',
|
|
135
|
+
fields: {
|
|
136
|
+
componentInfo: {
|
|
137
|
+
description: '组件基本信息(必需)',
|
|
138
|
+
required: true,
|
|
139
|
+
fields: {
|
|
140
|
+
component: '组件唯一标识',
|
|
141
|
+
compName: '组件名称',
|
|
142
|
+
compDesc: '组件描述',
|
|
143
|
+
bizType: '业务类型(可选)',
|
|
144
|
+
category: '分类(可选)',
|
|
145
|
+
loadModel: '加载模式(可选)',
|
|
146
|
+
belongOrgFlag: '组织标识(可选)'
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
propObj: {
|
|
150
|
+
description: '组件属性对象',
|
|
151
|
+
required: false,
|
|
152
|
+
example: {
|
|
153
|
+
title: '默认标题',
|
|
154
|
+
size: 'medium'
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
propOption: {
|
|
158
|
+
description: '属性配置选项',
|
|
159
|
+
required: false,
|
|
160
|
+
example: {
|
|
161
|
+
title: {
|
|
162
|
+
label: '标题',
|
|
163
|
+
type: 'input'
|
|
164
|
+
},
|
|
165
|
+
size: {
|
|
166
|
+
label: '尺寸',
|
|
167
|
+
type: 'option',
|
|
168
|
+
options: [
|
|
169
|
+
{ value: 'small', label: '小' },
|
|
170
|
+
{ value: 'medium', label: '中' },
|
|
171
|
+
{ value: 'large', label: '大' }
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
events: {
|
|
177
|
+
description: '组件事件对象',
|
|
178
|
+
required: false
|
|
179
|
+
},
|
|
180
|
+
eventsOption: {
|
|
181
|
+
description: '事件配置选项',
|
|
182
|
+
required: false
|
|
183
|
+
},
|
|
184
|
+
style: {
|
|
185
|
+
description: '组件样式配置',
|
|
186
|
+
required: false,
|
|
187
|
+
default: {
|
|
188
|
+
unit: 'px',
|
|
189
|
+
width: 72,
|
|
190
|
+
height: 38,
|
|
191
|
+
top: 0,
|
|
192
|
+
left: 0,
|
|
193
|
+
rotate: 0,
|
|
194
|
+
opacity: 1
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
styleOption: {
|
|
198
|
+
description: '样式配置选项',
|
|
199
|
+
required: false
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 插件发布流程
|
|
206
|
+
*/
|
|
207
|
+
const publishWorkflow = {
|
|
208
|
+
name: '插件发布工作流',
|
|
209
|
+
steps: [
|
|
210
|
+
'1. 收集组件信息(从 Vue 文件的 data() 函数中提取 componentInfo)',
|
|
211
|
+
'2. 收集所有依赖文件(递归分析 import 语句)',
|
|
212
|
+
'3. 编译构建(使用 vue-cli-service 构建为 UMD 格式)',
|
|
213
|
+
'4. 上传到服务器(包含编译后的 JS 和所有依赖源码)'
|
|
214
|
+
],
|
|
215
|
+
buildCommand: 'npx vue-cli-service build --target lib --name {component} --dest build plugins/{tempEntry}.js',
|
|
216
|
+
uploadEndpoint: '/devconsole/custom/pc/1.0/post/insertCustomComp',
|
|
217
|
+
uploadData: {
|
|
218
|
+
compLabel: '组件名称',
|
|
219
|
+
compUniName: '组件唯一标识',
|
|
220
|
+
compContentJs: '编译后的 UMD JS 内容',
|
|
221
|
+
compContentVue: '已废弃,现在用 dependencies 字段',
|
|
222
|
+
vueData: '组件 data() 的 JSON 字符串',
|
|
223
|
+
bizType: '业务类型',
|
|
224
|
+
compDesc: '组件描述',
|
|
225
|
+
category: '分类',
|
|
226
|
+
loadModel: '加载模式',
|
|
227
|
+
belongOrgFlag: '组织标识',
|
|
228
|
+
dependencies: '所有依赖文件的 JSON 字符串(key: 相对路径, value: 文件内容)'
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 项目配置文件
|
|
234
|
+
*/
|
|
235
|
+
const projectConfigFiles = {
|
|
236
|
+
name: '项目配置文件',
|
|
237
|
+
description: '插件发布时需要的项目级配置文件',
|
|
238
|
+
files: {
|
|
239
|
+
'package.json': {
|
|
240
|
+
description: 'NPM 包配置文件',
|
|
241
|
+
requiredFields: {
|
|
242
|
+
username: '开发者用户名',
|
|
243
|
+
secretKey: '开发者密钥',
|
|
244
|
+
baseUrl: 'CloudCC API 基础 URL(可选,默认 https://developer.apis.cloudcc.cn)',
|
|
245
|
+
version: '版本类型(private 表示私有部署)',
|
|
246
|
+
pluginToken: '插件令牌(优先使用)',
|
|
247
|
+
source: '来源标识(默认 cloudcc_cli)',
|
|
248
|
+
devSvcDispatch: '开发服务路径(默认 /devconsole)',
|
|
249
|
+
belongOrgFlag: '组织标识(默认 custom)',
|
|
250
|
+
destroyTimeout: '销毁超时时间(默认 1200000ms)'
|
|
251
|
+
},
|
|
252
|
+
example: {
|
|
253
|
+
name: 'my-plugin-project',
|
|
254
|
+
version: '1.0.0',
|
|
255
|
+
username: 'developer@example.com',
|
|
256
|
+
secretKey: 'your-secret-key',
|
|
257
|
+
baseUrl: 'https://developer.apis.cloudcc.cn'
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
'cloudcc-cli.config.js': {
|
|
261
|
+
description: 'CloudCC CLI 配置文件',
|
|
262
|
+
optional: true,
|
|
263
|
+
note: '发布时会自动收集此文件(如果存在)'
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 依赖收集机制
|
|
270
|
+
*/
|
|
271
|
+
const dependencyCollection = {
|
|
272
|
+
name: '依赖收集机制',
|
|
273
|
+
description: '自动分析和收集组件的所有依赖文件',
|
|
274
|
+
process: [
|
|
275
|
+
'1. 从入口文件({pluginName}.vue)开始',
|
|
276
|
+
'2. 使用正则表达式解析 import/require 语句',
|
|
277
|
+
'3. 递归处理每个依赖文件',
|
|
278
|
+
'4. 构建依赖树,避免重复收集',
|
|
279
|
+
'5. 收集项目根目录的配置文件(package.json、cloudcc-cli.config.js)',
|
|
280
|
+
'6. 将所有文件内容打包为 JSON 对象'
|
|
281
|
+
],
|
|
282
|
+
importPatterns: [
|
|
283
|
+
'import ... from "..."',
|
|
284
|
+
'import("...")',
|
|
285
|
+
'require("...")'
|
|
286
|
+
],
|
|
287
|
+
supportedExtensions: ['.vue', '.js', '.ts', '.json', '.css', '.scss', '.sass', '.less'],
|
|
288
|
+
output: {
|
|
289
|
+
format: 'JSON 对象',
|
|
290
|
+
structure: {
|
|
291
|
+
'relative/path/to/file.vue': '文件内容字符串',
|
|
292
|
+
'relative/path/to/component.js': '文件内容字符串',
|
|
293
|
+
'package.json': '根目录配置文件内容',
|
|
294
|
+
'cloudcc-cli.config.js': '根目录配置文件内容(如果存在)'
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 样式作用域最佳实践
|
|
301
|
+
*/
|
|
302
|
+
const styleScopedBestPractices = {
|
|
303
|
+
name: '样式作用域最佳实践',
|
|
304
|
+
description: '避免样式污染的关键规则',
|
|
305
|
+
rules: [
|
|
306
|
+
'✓ 必须:所有 <style> 标签都要加 scoped 属性',
|
|
307
|
+
'✓ 推荐:使用 BEM 命名规范(Block__Element--Modifier)',
|
|
308
|
+
'✓ 推荐:使用唯一的类名前缀(如组件名)',
|
|
309
|
+
'✗ 避免:直接修改全局标签样式(如 div、span)',
|
|
310
|
+
'✗ 避免:使用 !important 强制覆盖样式'
|
|
311
|
+
],
|
|
312
|
+
goodExample: `<style lang="scss" scoped>
|
|
313
|
+
.my-component {
|
|
314
|
+
padding: 8px;
|
|
315
|
+
|
|
316
|
+
&__header {
|
|
317
|
+
font-size: 16px;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
&__content {
|
|
321
|
+
margin-top: 10px;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
</style>`,
|
|
325
|
+
badExample: `<style lang="scss">
|
|
326
|
+
/* 没有 scoped,会污染全局 */
|
|
327
|
+
div {
|
|
328
|
+
padding: 8px;
|
|
329
|
+
}
|
|
330
|
+
</style>`
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 使用指南
|
|
335
|
+
*/
|
|
336
|
+
const usageGuide = {
|
|
337
|
+
name: '插件开发使用指南',
|
|
338
|
+
workflow: [
|
|
339
|
+
'1. 创建插件:cc plugin create <pluginName>',
|
|
340
|
+
'2. 开发组件:编辑 plugins/<pluginName>/<pluginName>.vue',
|
|
341
|
+
'3. 测试组件:在本地开发环境中测试',
|
|
342
|
+
'4. 发布插件:cc plugin publish <pluginName>',
|
|
343
|
+
'5. 验证发布:登录 CloudCC 开发者控制台查看'
|
|
344
|
+
],
|
|
345
|
+
bestPractices: [
|
|
346
|
+
'始终在 <style> 标签上添加 scoped 属性',
|
|
347
|
+
'在 componentInfo 中提供清晰的组件描述',
|
|
348
|
+
'使用有意义的组件标识符(component 字段)',
|
|
349
|
+
'合理设置 loadModel(页面加载性能相关)',
|
|
350
|
+
'在发布前确保配置了正确的 username 和 secretKey',
|
|
351
|
+
'使用 propObj 和 propOption 让组件可配置',
|
|
352
|
+
'为组件添加适当的事件支持(events/eventsOption)'
|
|
353
|
+
]
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* 常见问题
|
|
358
|
+
*/
|
|
359
|
+
const faq = [
|
|
360
|
+
{
|
|
361
|
+
question: '为什么发布时提示 "style scoped 缺失"?',
|
|
362
|
+
answer: '这是警告信息,不会阻止发布。但强烈建议添加 scoped 属性避免样式污染。将 <style> 改为 <style scoped> 即可。'
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
question: '如何配置开发者密钥?',
|
|
366
|
+
answer: '在项目根目录的 package.json 中添加 username 和 secretKey 字段。这些信息用于身份认证和插件发布。'
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
question: '插件创建后在哪里?',
|
|
370
|
+
answer: '插件会创建在项目根目录下的 plugins/<pluginName>/ 目录中,包含主组件文件、子组件目录和配置文件。'
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
question: 'componentInfo 和 config.json 的关系?',
|
|
374
|
+
answer: 'componentInfo 在 Vue 文件中定义(优先级更高),config.json 作为备选配置。发布时优先使用 componentInfo。'
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
question: '如何引入第三方库?',
|
|
378
|
+
answer: '正常使用 npm install 安装,然后在组件中 import 即可。依赖收集机制会自动处理 node_modules 中的依赖。'
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
question: 'loadModel 应该选 lazy 还是 eager?',
|
|
382
|
+
answer: 'lazy(懒加载)适合大型组件或不常用组件;eager(立即加载)适合核心组件或小型组件。默认推荐 lazy。'
|
|
383
|
+
}
|
|
384
|
+
];
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* 错误信息和解决方案
|
|
388
|
+
*/
|
|
389
|
+
const errorMessages = {
|
|
390
|
+
MISSING_CONFIG: {
|
|
391
|
+
message: '缺少配置文件或配置不完整',
|
|
392
|
+
solution: '检查 package.json 中是否配置了 username 和 secretKey,或者 config.json 是否存在且格式正确'
|
|
393
|
+
},
|
|
394
|
+
COMPILATION_FAILED: {
|
|
395
|
+
message: '编译失败',
|
|
396
|
+
solution: '检查 Vue 组件语法是否正确,确保所有依赖都已安装(npm install)。查看详细错误信息定位问题'
|
|
397
|
+
},
|
|
398
|
+
UPLOAD_FAILED: {
|
|
399
|
+
message: '上传到服务器失败',
|
|
400
|
+
solution: '检查网络连接、验证 baseUrl 是否正确、确认 username 和 secretKey 是否有效、查看返回的错误信息'
|
|
401
|
+
},
|
|
402
|
+
AUTH_FAILED: {
|
|
403
|
+
message: '身份认证失败',
|
|
404
|
+
solution: '验证 username 和 secretKey 是否正确,或者检查 pluginToken 是否过期'
|
|
405
|
+
},
|
|
406
|
+
INVALID_COMPONENT_NAME: {
|
|
407
|
+
message: '组件名称不合法',
|
|
408
|
+
solution: 'component 字段必须唯一,建议使用 "component-" 前缀加上有意义的名称'
|
|
409
|
+
},
|
|
410
|
+
MISSING_SCOPED: {
|
|
411
|
+
message: 'style 标签缺少 scoped 属性',
|
|
412
|
+
solution: '这是警告而非错误。建议在所有 <style> 标签上添加 scoped 属性:<style lang="scss" scoped>'
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* API 参考
|
|
418
|
+
*/
|
|
419
|
+
const apiReference = {
|
|
420
|
+
name: 'CloudCC 插件 API 参考',
|
|
421
|
+
description: '插件开发过程中可用的 CloudCC 特定 API',
|
|
422
|
+
note: '插件运行在浏览器环境中,可以使用所有标准的 Vue API 和浏览器 API。以下是 CloudCC 平台特有的扩展。',
|
|
423
|
+
platformApis: {
|
|
424
|
+
componentInfo: {
|
|
425
|
+
description: '组件元信息配置',
|
|
426
|
+
usage: '在 data() 中定义 componentInfo 对象',
|
|
427
|
+
fields: [
|
|
428
|
+
'component: 组件唯一标识(必需)',
|
|
429
|
+
'compName: 组件显示名称(必需)',
|
|
430
|
+
'compDesc: 组件描述(必需)',
|
|
431
|
+
'bizType: 业务类型(可选)',
|
|
432
|
+
'category: 分类(可选)',
|
|
433
|
+
'loadModel: 加载模式(可选,默认 lazy)',
|
|
434
|
+
'belongOrgFlag: 组织标识(可选,默认 custom)'
|
|
435
|
+
]
|
|
436
|
+
},
|
|
437
|
+
propObj: {
|
|
438
|
+
description: '组件可配置属性',
|
|
439
|
+
usage: '在 data() 中定义 propObj 对象,用户可在配置界面修改这些属性'
|
|
440
|
+
},
|
|
441
|
+
propOption: {
|
|
442
|
+
description: '属性配置界面定义',
|
|
443
|
+
usage: '在 data() 中定义 propOption 对象,定义 propObj 中每个属性的配置界面'
|
|
444
|
+
},
|
|
445
|
+
events: {
|
|
446
|
+
description: '组件事件定义',
|
|
447
|
+
usage: '在 data() 中定义 events 对象,定义组件可触发的事件'
|
|
448
|
+
},
|
|
449
|
+
style: {
|
|
450
|
+
description: '组件样式配置',
|
|
451
|
+
usage: '在 data() 中定义 style 对象,控制组件的尺寸、位置等'
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* 获取编辑指南
|
|
458
|
+
*/
|
|
459
|
+
function getEditGuide(topic = 'overview') {
|
|
460
|
+
const guides = {
|
|
461
|
+
overview: `## Vue 插件编辑指南概览
|
|
462
|
+
|
|
463
|
+
${vuePluginTemplate.name}
|
|
464
|
+
${vuePluginTemplate.description}
|
|
465
|
+
|
|
466
|
+
### 快速导航
|
|
467
|
+
- component-structure: 组件结构说明
|
|
468
|
+
- config: 配置文件详解
|
|
469
|
+
- data-structure: 数据结构规范
|
|
470
|
+
- style-scoped: 样式作用域最佳实践
|
|
471
|
+
- publish-workflow: 发布流程详解
|
|
472
|
+
- dependency: 依赖收集机制
|
|
473
|
+
- api: API 参考文档
|
|
474
|
+
|
|
475
|
+
### 核心概念
|
|
476
|
+
1. **组件唯一标识**: componentInfo.component 必须全局唯一
|
|
477
|
+
2. **样式隔离**: 所有样式必须使用 scoped 避免污染
|
|
478
|
+
3. **依赖收集**: 发布时自动收集所有依赖文件
|
|
479
|
+
4. **加载模式**: lazy(懒加载)vs eager(立即加载)
|
|
480
|
+
|
|
481
|
+
### 注意事项
|
|
482
|
+
${vuePluginTemplate.notes.map(note => `- ${note}`).join('\n')}
|
|
483
|
+
`,
|
|
484
|
+
'component-structure': `## 组件结构详解
|
|
485
|
+
|
|
486
|
+
### 主组件模板
|
|
487
|
+
\`\`\`vue
|
|
488
|
+
${vuePluginTemplate.mainComponent}
|
|
489
|
+
\`\`\`
|
|
490
|
+
|
|
491
|
+
### 子组件模板
|
|
492
|
+
\`\`\`vue
|
|
493
|
+
${vuePluginTemplate.subComponent}
|
|
494
|
+
\`\`\`
|
|
495
|
+
|
|
496
|
+
### 关键点说明
|
|
497
|
+
${vuePluginTemplate.notes.map(note => `- ${note}`).join('\n')}
|
|
498
|
+
`,
|
|
499
|
+
config: `## 配置文件详解
|
|
500
|
+
|
|
501
|
+
### ${configStructure.name}
|
|
502
|
+
${configStructure.description}
|
|
503
|
+
|
|
504
|
+
### 配置字段
|
|
505
|
+
${Object.entries(configStructure.fields).map(([key, field]) =>
|
|
506
|
+
`- **${key}** (${field.type}${field.required ? ', 必需' : ', 可选'}): ${field.description}${field.default ? `\n 默认值: ${field.default}` : ''}`
|
|
507
|
+
).join('\n')}
|
|
508
|
+
|
|
509
|
+
### 示例
|
|
510
|
+
\`\`\`json
|
|
511
|
+
${JSON.stringify(configStructure.example, null, 2)}
|
|
512
|
+
\`\`\`
|
|
513
|
+
`,
|
|
514
|
+
'data-structure': `## 数据结构规范
|
|
515
|
+
|
|
516
|
+
### ${componentDataStructure.name}
|
|
517
|
+
${componentDataStructure.description}
|
|
518
|
+
|
|
519
|
+
${Object.entries(componentDataStructure.fields).map(([key, field]) => `
|
|
520
|
+
### ${key}
|
|
521
|
+
**描述**: ${field.description}
|
|
522
|
+
**必需**: ${field.required ? '是' : '否'}
|
|
523
|
+
${field.example ? `**示例**:\n\`\`\`json\n${JSON.stringify(field.example, null, 2)}\n\`\`\`` : ''}
|
|
524
|
+
${field.default ? `**默认值**:\n\`\`\`json\n${JSON.stringify(field.default, null, 2)}\n\`\`\`` : ''}
|
|
525
|
+
${field.fields ? `**字段**:\n${Object.entries(field.fields).map(([k, v]) => `- ${k}: ${v}`).join('\n')}` : ''}
|
|
526
|
+
`).join('\n')}
|
|
527
|
+
`,
|
|
528
|
+
'style-scoped': `## 样式作用域最佳实践
|
|
529
|
+
|
|
530
|
+
### ${styleScopedBestPractices.name}
|
|
531
|
+
${styleScopedBestPractices.description}
|
|
532
|
+
|
|
533
|
+
### 规则清单
|
|
534
|
+
${styleScopedBestPractices.rules.map(rule => rule).join('\n')}
|
|
535
|
+
|
|
536
|
+
### ✓ 正确示例
|
|
537
|
+
\`\`\`vue
|
|
538
|
+
${styleScopedBestPractices.goodExample}
|
|
539
|
+
\`\`\`
|
|
540
|
+
|
|
541
|
+
### ✗ 错误示例
|
|
542
|
+
\`\`\`vue
|
|
543
|
+
${styleScopedBestPractices.badExample}
|
|
544
|
+
\`\`\`
|
|
545
|
+
`,
|
|
546
|
+
'publish-workflow': `## 发布流程详解
|
|
547
|
+
|
|
548
|
+
### ${publishWorkflow.name}
|
|
549
|
+
|
|
550
|
+
${publishWorkflow.steps.map(step => step).join('\n')}
|
|
551
|
+
|
|
552
|
+
### 构建命令
|
|
553
|
+
\`\`\`bash
|
|
554
|
+
${publishWorkflow.buildCommand}
|
|
555
|
+
\`\`\`
|
|
556
|
+
|
|
557
|
+
### 上传接口
|
|
558
|
+
- **端点**: ${publishWorkflow.uploadEndpoint}
|
|
559
|
+
- **方法**: POST
|
|
560
|
+
|
|
561
|
+
### 上传数据字段
|
|
562
|
+
${Object.entries(publishWorkflow.uploadData).map(([key, desc]) => `- **${key}**: ${desc}`).join('\n')}
|
|
563
|
+
`,
|
|
564
|
+
dependency: `## 依赖收集机制
|
|
565
|
+
|
|
566
|
+
### ${dependencyCollection.name}
|
|
567
|
+
${dependencyCollection.description}
|
|
568
|
+
|
|
569
|
+
### 收集流程
|
|
570
|
+
${dependencyCollection.process.map(step => step).join('\n')}
|
|
571
|
+
|
|
572
|
+
### 支持的 Import 模式
|
|
573
|
+
${dependencyCollection.importPatterns.map(pattern => `- ${pattern}`).join('\n')}
|
|
574
|
+
|
|
575
|
+
### 支持的文件扩展名
|
|
576
|
+
${dependencyCollection.supportedExtensions.map(ext => `- ${ext}`).join('\n')}
|
|
577
|
+
|
|
578
|
+
### 输出格式
|
|
579
|
+
**格式**: ${dependencyCollection.output.format}
|
|
580
|
+
|
|
581
|
+
**结构示例**:
|
|
582
|
+
\`\`\`json
|
|
583
|
+
${JSON.stringify(dependencyCollection.output.structure, null, 2)}
|
|
584
|
+
\`\`\`
|
|
585
|
+
`,
|
|
586
|
+
'project-config': `## 项目配置文件
|
|
587
|
+
|
|
588
|
+
### ${projectConfigFiles.name}
|
|
589
|
+
${projectConfigFiles.description}
|
|
590
|
+
|
|
591
|
+
${Object.entries(projectConfigFiles.files).map(([filename, config]) => `
|
|
592
|
+
### ${filename}
|
|
593
|
+
**描述**: ${config.description}
|
|
594
|
+
${config.optional ? '**可选**: 是' : '**必需**: 是'}
|
|
595
|
+
${config.note ? `**注意**: ${config.note}` : ''}
|
|
596
|
+
|
|
597
|
+
${config.requiredFields ? `**必需字段**:\n${Object.entries(config.requiredFields).map(([key, desc]) => `- **${key}**: ${desc}`).join('\n')}` : ''}
|
|
598
|
+
|
|
599
|
+
${config.example ? `**示例**:\n\`\`\`json\n${JSON.stringify(config.example, null, 2)}\n\`\`\`` : ''}
|
|
600
|
+
`).join('\n')}
|
|
601
|
+
`,
|
|
602
|
+
api: `## API 参考文档
|
|
603
|
+
|
|
604
|
+
### ${apiReference.name}
|
|
605
|
+
${apiReference.description}
|
|
606
|
+
|
|
607
|
+
**注意**: ${apiReference.note}
|
|
608
|
+
|
|
609
|
+
${Object.entries(apiReference.platformApis).map(([name, api]) => `
|
|
610
|
+
### ${name}
|
|
611
|
+
**描述**: ${api.description}
|
|
612
|
+
**用法**: ${api.usage}
|
|
613
|
+
${api.fields ? `\n**字段**:\n${api.fields.map(field => `- ${field}`).join('\n')}` : ''}
|
|
614
|
+
`).join('\n')}
|
|
615
|
+
`,
|
|
616
|
+
bestpractices: `## 最佳实践
|
|
617
|
+
|
|
618
|
+
### ${usageGuide.name}
|
|
619
|
+
|
|
620
|
+
### 工作流
|
|
621
|
+
${usageGuide.workflow.map(step => step).join('\n')}
|
|
622
|
+
|
|
623
|
+
### 最佳实践清单
|
|
624
|
+
${usageGuide.bestPractices.map(practice => `- ${practice}`).join('\n')}
|
|
625
|
+
`,
|
|
626
|
+
faq: `## 常见问题
|
|
627
|
+
|
|
628
|
+
${faq.map((item, index) => `
|
|
629
|
+
### ${index + 1}. ${item.question}
|
|
630
|
+
${item.answer}
|
|
631
|
+
`).join('\n')}
|
|
632
|
+
|
|
633
|
+
## 错误信息参考
|
|
634
|
+
|
|
635
|
+
${Object.entries(errorMessages).map(([code, error]) => `
|
|
636
|
+
### ${code}
|
|
637
|
+
**错误**: ${error.message}
|
|
638
|
+
**解决方案**: ${error.solution}
|
|
639
|
+
`).join('\n')}
|
|
640
|
+
`
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
return guides[topic] || guides.overview;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
module.exports = {
|
|
647
|
+
vuePluginTemplate,
|
|
648
|
+
configStructure,
|
|
649
|
+
componentDataStructure,
|
|
650
|
+
publishWorkflow,
|
|
651
|
+
projectConfigFiles,
|
|
652
|
+
dependencyCollection,
|
|
653
|
+
styleScopedBestPractices,
|
|
654
|
+
usageGuide,
|
|
655
|
+
apiReference,
|
|
656
|
+
faq,
|
|
657
|
+
errorMessages,
|
|
658
|
+
getEditGuide
|
|
659
|
+
};
|