cloudcc-cli 2.2.7 → 2.2.9

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 (46) hide show
  1. package/.cloudcc-cache.json +35 -4
  2. package/.cursor/skills/cloudcc-cli-dev/BACKEND_CLASS.md +97 -0
  3. package/.cursor/skills/cloudcc-cli-dev/BACKEND_SCHEDULE.md +78 -0
  4. package/.cursor/skills/cloudcc-cli-dev/BACKEND_TRIGGER.md +137 -0
  5. package/.cursor/skills/cloudcc-cli-dev/CLI_CHEATSHEET.md +215 -0
  6. package/{skill → .cursor/skills/cloudcc-cli-dev}/SKILL.md +13 -2
  7. package/.cursor/skills/cloudcc-cli-dev/VUE_CUSTOM_COMPONENT.md +151 -0
  8. package/README.md +25 -2
  9. package/bin/index.js +2 -0
  10. package/build/component-cc-test-001.common.js +831 -0
  11. package/build/component-cc-test-001.common.js.map +1 -0
  12. package/build/component-cc-test-001.css +1 -0
  13. package/build/component-cc-test-001.umd.js +874 -0
  14. package/build/component-cc-test-001.umd.js.map +1 -0
  15. package/build/component-cc-test-001.umd.min.js +8 -0
  16. package/build/component-cc-test-001.umd.min.js.map +1 -0
  17. package/build/demo.html +1 -0
  18. package/docs/CloudCC/350/207/252/345/256/232/344/271/211/347/273/204/344/273/266/344/275/277/347/224/250/350/257/264/346/230/216.md +130 -0
  19. package/docs/cloudcc/345/256/232/346/227/266/344/275/234/344/270/232.md +472 -0
  20. package/docs/cloudcc/345/256/232/346/227/266/347/261/273.md +302 -0
  21. package/docs//350/207/252/345/256/232/344/271/211/347/261/273.md +258 -0
  22. package/docs//350/247/246/345/217/221/345/231/250/347/261/273.md +404 -0
  23. package/package.json +1 -1
  24. package/plugins/cc-test-001/cc-test-001.vue +32 -0
  25. package/plugins/cc-test-001/components/HelloWorld.vue +11 -0
  26. package/plugins/cc-test-001/config.json +6 -0
  27. package/src/classes/index.js +1 -6
  28. package/src/plugin/delete.js +91 -0
  29. package/src/plugin/doc.js +76 -0
  30. package/src/plugin/get.js +0 -1
  31. package/src/plugin/index.js +1 -0
  32. package/src/plugin/publish1.js +34 -20
  33. package/src/plugin/pull.js +69 -31
  34. package/src/triggers/doc.js +258 -222
  35. package/src/triggers/pullList.js +3 -0
  36. package/target/ccopenapi-0.0.4-classes.jar +0 -0
  37. package/target/ccopenapi-0.0.4.jar +0 -0
  38. package/target/maven-archiver/pom.properties +3 -0
  39. package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +20 -0
  40. package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +19 -0
  41. package/skill/BACKEND_CODE.md +0 -114
  42. package/skill/CLI_CHEATSHEET.md +0 -90
  43. package/skill/VUE_CUSTOM_COMPONENT.md +0 -50
  44. /package/{skill → .cursor/skills/cloudcc-cli-dev}/INSTALL_AND_BOOTSTRAP.md +0 -0
  45. /package/{skill → .cursor/skills/cloudcc-cli-dev}/OBJECTS_AND_FIELDS.md +0 -0
  46. /package/{skill → .cursor/skills/cloudcc-cli-dev}/REQUIREMENTS_BREAKDOWN.md +0 -0
@@ -19,6 +19,7 @@ class Builder {
19
19
 
20
20
  }
21
21
  }
22
+ this.pluginConfigPath = ""
22
23
  this.plugin = process.argv.splice(2)[0]
23
24
  }
24
25
  async publish(argvs) {
@@ -27,7 +28,8 @@ class Builder {
27
28
  if (!res) {
28
29
  this.options.devConsoleConfig = await getPackageJson();
29
30
  this.options.devConsoleConfig.CloudCCDev = "";
30
- this.options.pluginConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), `plugins/${name}/config.json`), 'utf8'));
31
+ this.pluginConfigPath = path.join(process.cwd(), `plugins/${name}/config.json`);
32
+ this.options.pluginConfig = JSON.parse(fs.readFileSync(this.pluginConfigPath, 'utf8'));
31
33
  let config = this.options.devConsoleConfig
32
34
  if ("private" != this.options.devConsoleConfig.version) {
33
35
  config = { "accessToken": this.options.devConsoleConfig.pluginToken || await this.getToken(config) };
@@ -42,14 +44,14 @@ class Builder {
42
44
  let obj = this.getVueValue(item);
43
45
  if (obj) {
44
46
  this.initPluginFile(item, obj, "plginTemp" + i);
45
- this.build(obj, config, "plginTemp" + i)
47
+ await this.build(obj, config, "plginTemp" + i)
46
48
  }
47
49
  }
48
50
  } else {
49
51
  let obj = this.getVueValue(answers.buildFileName);
50
52
  if (obj) {
51
53
  this.initPluginFile(answers.buildFileName, obj, "plginTemp");
52
- this.build(obj, config, "plginTemp")
54
+ await this.build(obj, config, "plginTemp")
53
55
  }
54
56
  }
55
57
  }
@@ -188,13 +190,12 @@ class Builder {
188
190
  }
189
191
  vueData = JSON.stringify(data);
190
192
 
191
- // 收集所有依赖文件
192
- const baseDir = path.join(process.cwd(), 'plugins');
193
- const entryFile = path.join(baseDir, buildFileName);
194
- const allDependencies = collectDependenciesWithTree(entryFile, baseDir);
193
+ // 收集所有依赖文件(相对路径以项目根为基准,便于线上还原为 plugins/...、utils/...)
194
+ const rootDir = process.cwd();
195
+ const entryFile = path.join(rootDir, 'plugins', buildFileName);
196
+ const allDependencies = collectDependenciesWithTree(entryFile, rootDir);
195
197
 
196
198
  // 收集根目录下的配置文件
197
- const rootDir = process.cwd();
198
199
  const configFiles = ['package.json', 'cloudcc-cli.config.js'];
199
200
 
200
201
  for (const configFile of configFiles) {
@@ -277,18 +278,26 @@ class Builder {
277
278
 
278
279
  build(obj, config, plginTemp) {
279
280
  console.error(chalk.green('Compiling, Please Wait...'));
280
- exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugins/${plginTemp}.js`, async (error, stdout, stderr) => {
281
- if (error) {
282
- console.error('Compilation Failed:', error);
283
- console.error(chalk.red('Compilation Failed:' + stdout));
284
- return;
285
- } else {
286
- console.error(chalk.green('Compilation Successful!'));
287
- console.error();
288
- await this.upload(obj, config)
289
- fs.unlinkSync(`plugins/${plginTemp}.js`);
290
- }
291
- })
281
+ return new Promise((resolve, reject) => {
282
+ exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugins/${plginTemp}.js`, async (error, stdout) => {
283
+ if (error) {
284
+ console.error('Compilation Failed:', error);
285
+ console.error(chalk.red('Compilation Failed:' + stdout));
286
+ reject(error);
287
+ return;
288
+ }
289
+
290
+ try {
291
+ console.error(chalk.green('Compilation Successful!'));
292
+ console.error();
293
+ await this.upload(obj, config)
294
+ fs.unlinkSync(`plugins/${plginTemp}.js`);
295
+ resolve();
296
+ } catch (uploadError) {
297
+ reject(uploadError);
298
+ }
299
+ })
300
+ });
292
301
  }
293
302
 
294
303
  async upload(obj, header) {
@@ -323,6 +332,11 @@ class Builder {
323
332
  let res = await post(`${this.options.devConsoleConfig.baseUrl || BaseUrl}${devSvcDispatch}/custom/pc/1.0/post/insertCustomComp`,
324
333
  body, header);
325
334
  if (res.returnCode == 200) {
335
+ const returnedId = res?.data?.id || res?.data;
336
+ if (!this.options.pluginConfig.id && returnedId && this.pluginConfigPath) {
337
+ this.options.pluginConfig.id = returnedId;
338
+ fs.writeFileSync(this.pluginConfigPath, JSON.stringify(this.options.pluginConfig, null, 2), 'utf8');
339
+ }
326
340
  console.error(chalk.green(`Success!`));
327
341
  console.error();
328
342
  } else {
@@ -5,6 +5,66 @@ const { getPackageJson } = require("../../utils/config");
5
5
  const { post } = require("../../utils/http");
6
6
  const BaseUrl = "https://developer.apis.cloudcc.cn";
7
7
 
8
+ /**
9
+ * 反复去掉路径开头的插件目录名,避免 plugins/foo/foo/foo.vue 这类重复嵌套
10
+ */
11
+ function stripLeadingPluginSegments(rest, pluginNames) {
12
+ const names = [...new Set(pluginNames.filter(Boolean))];
13
+ let guard = 0;
14
+ while (guard++ < 64) {
15
+ let stripped = false;
16
+ for (const n of names) {
17
+ const p = n + '/';
18
+ if (rest.startsWith(p)) {
19
+ rest = rest.slice(p.length);
20
+ stripped = true;
21
+ break;
22
+ }
23
+ }
24
+ if (!stripped) break;
25
+ }
26
+ return rest;
27
+ }
28
+
29
+ /**
30
+ * 根据服务端键解析本地绝对路径(与 publish 侧「项目根相对路径」一致)
31
+ */
32
+ function resolvePullFileFullPath(filePath, projectPath, pluginPath, normalizedPluginName, pluginName) {
33
+ const normalized = filePath.replace(/\\/g, '/').replace(/^\.\//, '');
34
+ const pluginNames = [normalizedPluginName, pluginName].filter(Boolean);
35
+
36
+ // 旧版发布:依赖键相对 plugins 目录为 ../utils/...
37
+ if (normalized.startsWith('../')) {
38
+ const trimmed = normalized.replace(/^\.\.\/+/, '');
39
+ return path.join(projectPath, trimmed);
40
+ }
41
+
42
+ // 键本身就在项目根下(无 plugins/ 前缀),如 utils/http.js
43
+ if (!normalized.startsWith('plugins/')) {
44
+ if (normalized.startsWith('utils/') || normalized.startsWith('src/') || normalized.startsWith('lib/')) {
45
+ return path.join(projectPath, normalized);
46
+ }
47
+ }
48
+
49
+ let rest = normalized;
50
+ if (rest.startsWith('plugins/')) {
51
+ rest = rest.slice('plugins/'.length);
52
+ }
53
+
54
+ rest = stripLeadingPluginSegments(rest, pluginNames);
55
+
56
+ // 仅文件名 http.js 落在插件根时,按工程惯例放到 utils/http.js(对应 import ../../utils/http)
57
+ if (rest === 'http.js') {
58
+ return path.join(projectPath, 'utils', 'http.js');
59
+ }
60
+
61
+ if (!rest || rest === '.') {
62
+ return pluginPath;
63
+ }
64
+
65
+ return path.join(pluginPath, rest);
66
+ }
67
+
8
68
  /**
9
69
  * 从服务器拉取自定义组件到本地
10
70
  * 支持通过组件名或ID拉取:
@@ -100,45 +160,23 @@ async function pullById(pluginId, projectPath) {
100
160
 
101
161
  // 遍历所有文件并保存
102
162
  Object.entries(contentMap).forEach(([filePath, content]) => {
103
- // 统一路径分隔符(服务端可能返回 Windows 风格的反斜杠)
104
- filePath = filePath.replace(/\\/g, '/');
163
+ const normalizedPath = filePath.replace(/\\/g, '/');
105
164
 
106
165
  // 获取文件名(不包含路径)
107
- const fileName = path.basename(filePath);
166
+ const fileName = path.basename(normalizedPath);
108
167
 
109
168
  // 跳过排除的文件
110
169
  if (excludedFiles.includes(fileName)) {
111
170
  return;
112
171
  }
113
172
 
114
- // 处理文件路径:去掉组件名称前缀
115
- // 例如:cc-ttt/cc-ttt.vue -> cc-ttt.vue
116
- // cc-ttt/components/HelloWorld.vue -> components/HelloWorld.vue
117
- // cc-demo/cc-demo.vue -> cc-demo.vue (当组件名是 component-cc-demo-cc 时)
118
- let relativePath = filePath;
119
-
120
- // 提取文件路径的第一个目录名
121
- const firstDir = filePath.split('/')[0];
122
-
123
- // 尝试匹配并移除前缀
124
- // 优先级:1. normalizedPluginName 2. pluginName 3. 第一个目录名(如果路径包含多个部分)
125
- let prefixToRemove = '';
126
- if (filePath.startsWith(`${normalizedPluginName}/`)) {
127
- prefixToRemove = `${normalizedPluginName}/`;
128
- } else if (filePath.startsWith(`${pluginName}/`)) {
129
- prefixToRemove = `${pluginName}/`;
130
- } else if (firstDir && filePath.includes('/')) {
131
- // 如果路径包含斜杠,说明有目录结构,移除第一个目录
132
- // 例如:cc-demo/cc-demo.vue -> cc-demo.vue
133
- prefixToRemove = `${firstDir}/`;
134
- }
135
-
136
- if (prefixToRemove) {
137
- relativePath = filePath.substring(prefixToRemove.length);
138
- }
139
-
140
- // 构建完整路径并写入文件
141
- const fullPath = path.join(pluginPath, relativePath);
173
+ const fullPath = resolvePullFileFullPath(
174
+ normalizedPath,
175
+ projectPath,
176
+ pluginPath,
177
+ normalizedPluginName,
178
+ pluginName
179
+ );
142
180
  const dir = path.dirname(fullPath);
143
181
 
144
182
  // 确保目录存在(recursive: true 会自动处理已存在的情况)