cloudcc-cli 2.2.2 → 2.2.3
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 +12 -0
- package/bin/cc.js +1 -0
- package/bin/mcp.js +18 -0
- package/package.json +14 -6
- package/src/classes/create.js +1 -0
- package/src/classes/get.js +1 -0
- package/src/classes/publish.js +1 -0
- package/src/classes/pull.js +2 -1
- package/src/mcp/index.js +227 -0
- package/src/mcp/readme.md +132 -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/classes/handler.js +358 -0
- package/src/mcp/tools/classes/prompt.js +1261 -0
- package/src/mcp/tools/dev-env/fetcher.js +500 -0
- package/src/mcp/tools/dev-env/handler.js +92 -0
- package/src/mcp/tools/dev-env/prompt.js +256 -0
- package/src/mcp/tools/key-guide/fetcher.js +278 -0
- package/src/mcp/tools/key-guide/handler.js +43 -0
- package/src/mcp/tools/key-guide/prompt.js +71 -0
- package/src/mcp/tools/plugin/handler.js +92 -0
- package/src/mcp/tools/plugin/prompt.js +659 -0
- package/src/plugin/create.js +1 -2
- package/src/plugin/create1.js +1 -2
- package/src/plugin/publish1.js +3 -2
- package/template/Appvue +452 -12
- package/utils/utils.js +32 -9
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin 工具处理器
|
|
3
|
+
* 提供 Vue 插件的创建、发布功能
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const createPluginModule = require('../../../plugin/create1');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 创建插件
|
|
12
|
+
*/
|
|
13
|
+
async function createPlugin({ pluginName, projectPath = process.cwd() }) {
|
|
14
|
+
try {
|
|
15
|
+
// 临时改变工作目录以兼容原有模块
|
|
16
|
+
const originalCwd = process.cwd();
|
|
17
|
+
process.chdir(projectPath);
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
await createPluginModule(pluginName);
|
|
21
|
+
const pluginPath = path.join(projectPath, `plugins/${pluginName}`);
|
|
22
|
+
return {
|
|
23
|
+
content: [{
|
|
24
|
+
type: 'text',
|
|
25
|
+
text: `✓ 插件创建成功!\n\n插件路径: ${pluginPath}\n生成的文件:\n - ${pluginName}.vue (主组件文件)\n - components/HelloWorld.vue (示例子组件)\n - config.json (配置文件)\n\n下一步:\n1. 编辑 ${pluginName}.vue 实现你的组件逻辑\n2. 在 componentInfo 中配置组件信息\n3. 确保所有 <style> 标签都有 scoped 属性\n4. 使用 publish_plugin 发布到服务器`
|
|
26
|
+
}]
|
|
27
|
+
};
|
|
28
|
+
} finally {
|
|
29
|
+
process.chdir(originalCwd);
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
content: [{
|
|
34
|
+
type: 'text',
|
|
35
|
+
text: `✗ 创建失败: ${error.message}\n\n可能的原因:\n- 插件名称已存在\n- 权限不足\n- 磁盘空间不足`
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 发布插件到服务器
|
|
43
|
+
*/
|
|
44
|
+
async function publishPlugin({ pluginName, projectPath = process.cwd() }) {
|
|
45
|
+
try {
|
|
46
|
+
const pluginPath = path.join(projectPath, `plugins/${pluginName}`);
|
|
47
|
+
const vueFilePath = path.join(pluginPath, `${pluginName}.vue`);
|
|
48
|
+
const configPath = path.join(pluginPath, 'config.json');
|
|
49
|
+
|
|
50
|
+
// 检查插件是否存在
|
|
51
|
+
if (!fs.existsSync(vueFilePath)) {
|
|
52
|
+
return {
|
|
53
|
+
content: [{
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: `✗ 插件不存在: plugins/${pluginName}/${pluginName}.vue\n\n请先使用 create_plugin 创建插件`
|
|
56
|
+
}]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 检查配置文件
|
|
61
|
+
if (!fs.existsSync(configPath)) {
|
|
62
|
+
return {
|
|
63
|
+
content: [{
|
|
64
|
+
type: 'text',
|
|
65
|
+
text: `✗ 配置文件不存在: plugins/${pluginName}/config.json\n\n请确保插件目录完整`
|
|
66
|
+
}]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 返回需要运行的命令
|
|
71
|
+
const command = `npx cc publish plugin ${pluginName}`;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
content: [{
|
|
75
|
+
type: 'text',
|
|
76
|
+
text: `✓ 插件检查通过!\n\n插件: ${pluginName}\n路径: ${pluginPath}\n\n请运行以下命令发布插件:\n\n${command}\n\n发布过程:\n1. 编译 Vue 组件\n2. 收集依赖文件\n3. 上传到服务器\n4. 在 CloudCC 开发者控制台验证`
|
|
77
|
+
}]
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return {
|
|
81
|
+
content: [{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: `✗ 检查失败: ${error.message}`
|
|
84
|
+
}]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
createPlugin,
|
|
91
|
+
publishPlugin
|
|
92
|
+
};
|