cloudcc-cli 2.2.1 → 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.
Files changed (43) hide show
  1. package/README.md +21 -0
  2. package/bin/cc.js +1 -0
  3. package/bin/mcp.js +18 -0
  4. package/package.json +14 -6
  5. package/src/classes/create.js +1 -0
  6. package/src/classes/get.js +1 -0
  7. package/src/classes/publish.js +4 -0
  8. package/src/classes/pull.js +5 -1
  9. package/src/mcp/index.js +227 -0
  10. package/src/mcp/readme.md +132 -0
  11. package/src/mcp/tools/ccdk/fetcher.js +18 -0
  12. package/src/mcp/tools/ccdk/handler.js +98 -0
  13. package/src/mcp/tools/ccdk/prompt.js +453 -0
  14. package/src/mcp/tools/classes/handler.js +358 -0
  15. package/src/mcp/tools/classes/prompt.js +1261 -0
  16. package/src/mcp/tools/dev-env/fetcher.js +500 -0
  17. package/src/mcp/tools/dev-env/handler.js +92 -0
  18. package/src/mcp/tools/dev-env/prompt.js +256 -0
  19. package/src/mcp/tools/key-guide/fetcher.js +278 -0
  20. package/src/mcp/tools/key-guide/handler.js +43 -0
  21. package/src/mcp/tools/key-guide/prompt.js +71 -0
  22. package/src/mcp/tools/plugin/handler.js +92 -0
  23. package/src/mcp/tools/plugin/prompt.js +659 -0
  24. package/src/plugin/create.js +1 -2
  25. package/src/plugin/create1.js +1 -2
  26. package/src/plugin/publish.js +3 -0
  27. package/src/plugin/publish1.js +6 -2
  28. package/src/script/publish.js +3 -0
  29. package/src/script/pull.js +3 -0
  30. package/src/timer/publish.js +3 -0
  31. package/src/timer/pull.js +3 -0
  32. package/src/triggers/publish.js +3 -0
  33. package/src/triggers/pull.js +3 -0
  34. package/template/Appvue +452 -12
  35. package/template/cloudcc-cli.configjs +7 -1
  36. package/template/index.js +0 -4
  37. package/template/vueconfigjs +10 -10
  38. package/utils/checkVersion.js +2 -0
  39. package/utils/utils.js +32 -9
  40. package/template/demojava +0 -15
  41. package/template/indexvue +0 -29
  42. package/template/javaconfigjson +0 -3
  43. package/template/package-lockjson +0 -13952
@@ -284,6 +284,9 @@ class Builder {
284
284
  }
285
285
 
286
286
  async upload(obj, header) {
287
+ const now = new Date();
288
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
289
+ console.log(chalk.green(timeStr));
287
290
  console.log(chalk.green('Posting, please wait...'));
288
291
  let jsContent = "";
289
292
  try {
@@ -318,6 +321,7 @@ class Builder {
318
321
  console.log("res", res);
319
322
  console.error(chalk.red(`Fail: ${res.returnInfo}`));
320
323
  console.log();
324
+ throw new Error('Publish Class Failed: ' + res.returnInfo);
321
325
  }
322
326
  return res;
323
327
  }
@@ -329,9 +333,9 @@ class Builder {
329
333
  }
330
334
  }
331
335
 
332
- function publish(argvs) {
336
+ async function publish(argvs) {
333
337
  let p = new Builder()
334
- p.publish(argvs)
338
+ await p.publish(argvs)
335
339
  }
336
340
 
337
341
  module.exports = publish;
@@ -39,6 +39,9 @@ async function publish(argvs) {
39
39
 
40
40
  if (scriptContent) {
41
41
  let devConsoleConfig = await getPackageJson()
42
+ const now = new Date();
43
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
44
+ console.log(chalk.green(timeStr));
42
45
  console.log(chalk.green('Posting, please wait...'));
43
46
  configContent.scriptContent = scriptContent.trim()
44
47
  let res = await post((devConsoleConfig.baseUrl || BaseUrl) + "/devconsole/script/saveClientScript", configContent, devConsoleConfig)
@@ -16,6 +16,9 @@ async function pull(argvs) {
16
16
  const srcPath = path.join(process.cwd(), `script/${namePath}/`);
17
17
 
18
18
  let devConsoleConfig = await getPackageJson()
19
+ const now = new Date();
20
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
21
+ console.log(chalk.green(timeStr));
19
22
  console.log(chalk.green('Pulling, please wait...'));
20
23
  let configContent = JSON.parse(fs.readFileSync(srcPath + "config.json", 'utf8'));
21
24
  if (!configContent.id) {
@@ -11,6 +11,9 @@ async function publish(name) {
11
11
  let res = await checkUpdate();
12
12
  if (!res) {
13
13
  console.log();
14
+ const now = new Date();
15
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
16
+ console.log(chalk.green(timeStr));
14
17
  console.log(chalk.green('Posting, please wait...'));
15
18
  console.log();
16
19
  const timerPath = path.join(process.cwd(), `schedule/${name}/`);
package/src/timer/pull.js CHANGED
@@ -12,6 +12,9 @@ async function pull(name) {
12
12
  let res = await checkUpdate();
13
13
  if (!res) {
14
14
  console.log();
15
+ const now = new Date();
16
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
17
+ console.log(chalk.green(timeStr));
15
18
  console.log(chalk.green('Pulling, please wait...'));
16
19
  console.log();
17
20
  const timerPath = path.join(process.cwd(), `schedule/${name}/`);
@@ -12,6 +12,9 @@ async function publish(argvs) {
12
12
  let res = await checkUpdate();
13
13
  if (!res) {
14
14
  console.log();
15
+ const now = new Date();
16
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
17
+ console.log(chalk.green(timeStr));
15
18
  console.log(chalk.green('Posting, please wait...'));
16
19
  console.log();
17
20
  const triggersPath = path.join(process.cwd(), `triggers/${namePath}/`);
@@ -11,6 +11,9 @@ async function pull(argvs) {
11
11
  let res = await checkUpdate();
12
12
  if (!res) {
13
13
  console.log();
14
+ const now = new Date();
15
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
16
+ console.log(chalk.green(timeStr));
14
17
  console.log(chalk.green('Pulling, please wait...'));
15
18
  console.log();
16
19
  const triggersPath = path.join(process.cwd(), `triggers/${namePath}/`);
package/template/Appvue CHANGED
@@ -1,25 +1,465 @@
1
1
  <template>
2
- <div class="cc-container">
3
- <div>hello World</div>
2
+ <div class="welcome-container">
3
+ <!-- 渐变背景线条 -->
4
+ <div class="bg-lines">
5
+ <div class="line line-1"></div>
6
+ <div class="line line-2"></div>
7
+ <div class="line line-3"></div>
8
+ </div>
9
+
10
+ <!-- 主要内容 -->
11
+ <div class="welcome-content">
12
+ <div class="header">
13
+ <div class="logo-mark"></div>
14
+ <span class="tag">Welcome</span>
15
+ </div>
16
+
17
+ <div class="title-section">
18
+ <h1 class="main-title">{{ mainTitle }}</h1>
19
+ <div class="title-underline"></div>
20
+ </div>
21
+
22
+ <p class="description">{{ description }}</p>
23
+
24
+ <div class="stats">
25
+ <div class="stat-item" v-for="(stat, index) in stats" :key="index">
26
+ <div class="stat-number">{{ stat.number }}</div>
27
+ <div class="stat-label">{{ stat.label }}</div>
28
+ </div>
29
+ </div>
30
+
31
+ <button class="cta-button" @click="handleClick">
32
+ <span class="button-text">探索更多</span>
33
+ <span class="button-arrow">→</span>
34
+ </button>
35
+ </div>
36
+
37
+ <!-- 装饰线 -->
38
+ <div class="decorative-line"></div>
4
39
  </div>
5
40
  </template>
6
41
 
7
42
  <script>
8
- export default {
9
- name: "App",
10
- };
43
+ export default {
44
+ name: "App",
45
+ data() {
46
+ return {
47
+ mainTitle: "CloudCC开发者,您好",
48
+ description: "开发文档:https://dev-help.cloudcc.cn/",
49
+ stats: [
50
+ { number: "∞", label: "可能性" },
51
+ { number: "⚡", label: "高效开发" },
52
+ { number: "🚀", label: "快速上手" },
53
+ ],
54
+ };
55
+ },
56
+ methods: {
57
+ handleClick() {
58
+ console.log("探索开始");
59
+ },
60
+ },
61
+ };
11
62
  </script>
12
63
 
13
64
  <style lang="scss" scoped>
14
- html body {
15
- padding: 0;
16
- margin: 0;
17
- height: 100vh;
65
+ * {
66
+ margin: 0;
67
+ padding: 0;
68
+ box-sizing: border-box;
69
+ }
70
+
71
+ .welcome-container {
72
+ position: relative;
73
+ width: 100%;
74
+ height: 100vh;
75
+ display: flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ overflow: hidden;
79
+ background: #fafafa;
80
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
81
+ "Ubuntu", "Cantarell", sans-serif;
82
+ }
83
+
84
+ // 背景线条
85
+ .bg-lines {
86
+ position: absolute;
87
+ top: 0;
88
+ left: 0;
89
+ width: 100%;
90
+ height: 100%;
91
+ z-index: 0;
92
+ opacity: 0.3;
93
+ }
94
+
95
+ .line {
96
+ position: absolute;
97
+ background: linear-gradient(90deg, transparent, #000, transparent);
98
+ opacity: 0.05;
99
+
100
+ &-1 {
101
+ width: 200%;
102
+ height: 1px;
103
+ top: 20%;
104
+ left: -50%;
105
+ animation: moveLine 8s linear infinite;
106
+ }
107
+
108
+ &-2 {
109
+ width: 200%;
110
+ height: 1px;
111
+ top: 50%;
112
+ right: -50%;
113
+ animation: moveLine 10s linear infinite reverse;
114
+ }
115
+
116
+ &-3 {
117
+ width: 200%;
118
+ height: 1px;
119
+ bottom: 20%;
120
+ left: -50%;
121
+ animation: moveLine 12s linear infinite;
122
+ }
123
+ }
124
+
125
+ @keyframes moveLine {
126
+ 0% {
127
+ transform: translateX(0);
128
+ }
129
+ 100% {
130
+ transform: translateX(50%);
131
+ }
132
+ }
133
+
134
+ // 主要内容
135
+ .welcome-content {
136
+ position: relative;
137
+ z-index: 10;
138
+ max-width: 600px;
139
+ margin: 0 auto;
140
+ padding: 0 40px;
141
+ text-align: center;
142
+ animation: fadeInContent 0.8s ease-out;
143
+ }
144
+
145
+ @keyframes fadeInContent {
146
+ 0% {
147
+ opacity: 0;
148
+ transform: translateY(20px);
149
+ }
150
+ 100% {
151
+ opacity: 1;
152
+ transform: translateY(0);
153
+ }
154
+ }
155
+
156
+ // 头部
157
+ .header {
158
+ display: flex;
159
+ align-items: center;
160
+ justify-content: center;
161
+ gap: 12px;
162
+ margin-bottom: 40px;
163
+ }
164
+
165
+ .logo-mark {
166
+ width: 24px;
167
+ height: 24px;
168
+ border: 2px solid #000;
169
+ border-radius: 4px;
170
+ position: relative;
171
+ animation: logoRotate 2s ease-in-out infinite;
172
+
173
+ &::after {
174
+ content: "";
175
+ position: absolute;
176
+ width: 8px;
177
+ height: 8px;
178
+ background: #000;
179
+ border-radius: 50%;
180
+ top: 50%;
181
+ left: 50%;
182
+ transform: translate(-50%, -50%);
183
+ }
184
+ }
185
+
186
+ @keyframes logoRotate {
187
+ 0%,
188
+ 100% {
189
+ transform: rotate(0deg);
190
+ }
191
+ 50% {
192
+ transform: rotate(90deg);
193
+ }
194
+ }
195
+
196
+ .tag {
197
+ font-size: 12px;
198
+ font-weight: 600;
199
+ letter-spacing: 1.2px;
200
+ color: #666;
201
+ text-transform: uppercase;
202
+ padding: 4px 12px;
203
+ border: 1px solid #ddd;
204
+ border-radius: 20px;
205
+ background: rgba(255, 255, 255, 0.8);
206
+ }
207
+
208
+ // 标题部分
209
+ .title-section {
210
+ margin-bottom: 30px;
211
+ position: relative;
212
+ }
213
+
214
+ .main-title {
215
+ font-size: 48px;
216
+ font-weight: 700;
217
+ line-height: 1.3;
218
+ color: #000;
219
+ margin-bottom: 16px;
220
+ letter-spacing: -0.5px;
221
+ }
222
+
223
+ .title-underline {
224
+ width: 60px;
225
+ height: 3px;
226
+ background: linear-gradient(90deg, #000, transparent);
227
+ margin: 0 auto;
228
+ border-radius: 2px;
229
+ animation: expandWidth 0.8s ease-out 0.3s backwards;
230
+ }
231
+
232
+ @keyframes expandWidth {
233
+ 0% {
234
+ width: 0;
235
+ }
236
+ 100% {
237
+ width: 60px;
238
+ }
239
+ }
240
+
241
+ // 描述文本
242
+ .description {
243
+ font-size: 16px;
244
+ color: #666;
245
+ line-height: 1.6;
246
+ margin-bottom: 50px;
247
+ font-weight: 400;
248
+ letter-spacing: 0.3px;
249
+ }
250
+
251
+ // 统计数据
252
+ .stats {
253
+ display: flex;
254
+ justify-content: center;
255
+ gap: 60px;
256
+ margin-bottom: 50px;
257
+ }
258
+
259
+ .stat-item {
260
+ text-align: center;
261
+ opacity: 0;
262
+ animation: slideInStats 0.6s ease-out forwards;
263
+
264
+ &:nth-child(1) {
265
+ animation-delay: 0.2s;
266
+ }
267
+
268
+ &:nth-child(2) {
269
+ animation-delay: 0.3s;
270
+ }
271
+
272
+ &:nth-child(3) {
273
+ animation-delay: 0.4s;
274
+ }
275
+ }
276
+
277
+ @keyframes slideInStats {
278
+ 0% {
279
+ opacity: 0;
280
+ transform: translateY(10px);
281
+ }
282
+ 100% {
283
+ opacity: 1;
284
+ transform: translateY(0);
285
+ }
286
+ }
287
+
288
+ .stat-number {
289
+ font-size: 28px;
290
+ font-weight: 700;
291
+ color: #000;
292
+ margin-bottom: 4px;
293
+ }
294
+
295
+ .stat-label {
296
+ font-size: 12px;
297
+ color: #999;
298
+ font-weight: 500;
299
+ letter-spacing: 0.5px;
300
+ }
301
+
302
+ // 按钮
303
+ .cta-button {
304
+ padding: 14px 32px;
305
+ font-size: 16px;
306
+ font-weight: 600;
307
+ color: #fff;
308
+ background: #000;
309
+ border: 2px solid #000;
310
+ border-radius: 4px;
311
+ cursor: pointer;
312
+ transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
313
+ display: inline-flex;
314
+ align-items: center;
315
+ gap: 8px;
316
+ position: relative;
317
+ overflow: hidden;
318
+ animation: fadeInUp 0.8s ease-out 0.5s backwards;
319
+
320
+ &::before {
321
+ content: "";
322
+ position: absolute;
323
+ top: 0;
324
+ left: -100%;
325
+ width: 100%;
326
+ height: 100%;
327
+ background: #333;
328
+ z-index: -1;
329
+ transition: left 0.3s ease;
330
+ }
331
+
332
+ &:hover {
333
+ background: #333;
334
+ border-color: #333;
335
+ transform: translateX(4px);
336
+
337
+ .button-arrow {
338
+ animation: arrowMove 0.3s ease;
339
+ }
340
+ }
341
+
342
+ &:active {
343
+ transform: translateX(2px);
344
+ }
345
+ }
346
+
347
+ .button-text {
348
+ position: relative;
349
+ }
350
+
351
+ .button-arrow {
352
+ display: inline-block;
353
+ transition: transform 0.3s ease;
354
+ }
355
+
356
+ @keyframes arrowMove {
357
+ 0%,
358
+ 100% {
359
+ transform: translateX(0);
360
+ }
361
+ 50% {
362
+ transform: translateX(4px);
363
+ }
364
+ }
365
+
366
+ @keyframes fadeInUp {
367
+ 0% {
368
+ opacity: 0;
369
+ transform: translateY(10px);
370
+ }
371
+ 100% {
372
+ opacity: 1;
373
+ transform: translateY(0);
374
+ }
375
+ }
376
+
377
+ // 装饰线
378
+ .decorative-line {
379
+ position: absolute;
380
+ bottom: 40px;
381
+ left: 50%;
382
+ width: 40px;
383
+ height: 2px;
384
+ background: #000;
385
+ transform: translateX(-50%);
386
+ opacity: 0.2;
387
+ animation: pulse 2s ease-in-out infinite;
388
+ }
389
+
390
+ @keyframes pulse {
391
+ 0%,
392
+ 100% {
393
+ opacity: 0.2;
394
+ width: 40px;
395
+ }
396
+ 50% {
397
+ opacity: 0.5;
398
+ width: 50px;
399
+ }
400
+ }
401
+
402
+ // 响应式
403
+ @media (max-width: 768px) {
404
+ .welcome-content {
405
+ padding: 0 30px;
406
+ }
407
+
408
+ .main-title {
409
+ font-size: 36px;
410
+ }
411
+
412
+ .description {
413
+ font-size: 14px;
414
+ margin-bottom: 40px;
415
+ }
416
+
417
+ .stats {
418
+ gap: 40px;
419
+ margin-bottom: 40px;
420
+ }
421
+
422
+ .stat-number {
423
+ font-size: 24px;
424
+ }
425
+
426
+ .cta-button {
427
+ padding: 12px 28px;
428
+ font-size: 14px;
429
+ }
430
+
431
+ .header {
432
+ margin-bottom: 30px;
433
+ }
434
+
435
+ .title-section {
436
+ margin-bottom: 25px;
437
+ }
438
+ }
439
+
440
+ @media (max-width: 480px) {
441
+ .main-title {
442
+ font-size: 28px;
443
+ }
444
+
445
+ .description {
446
+ font-size: 13px;
447
+ }
448
+
449
+ .stats {
450
+ gap: 30px;
451
+ }
452
+
453
+ .stat-number {
454
+ font-size: 20px;
455
+ }
456
+
457
+ .cta-button {
18
458
  width: 100%;
19
459
  }
20
460
 
21
- .cc-container {
22
- text-align: center;
23
- padding: 8px;
461
+ .bg-lines {
462
+ display: none;
24
463
  }
464
+ }
25
465
  </style>
@@ -1 +1,7 @@
1
- module.exports = { "use": "dev", "dev": { "safetyMark": "xxx", "CloudCCDev": "xxx" } }
1
+ module.exports = {
2
+ "use": "dev",
3
+ "dev": {
4
+ "safetyMark": "xxx",
5
+ "CloudCCDev": "xxx"
6
+ }
7
+ }
package/template/index.js CHANGED
@@ -59,10 +59,6 @@ module.exports = function (creator, options, callback) {
59
59
  name, description
60
60
  })
61
61
 
62
- creator.copyTpl('package-lockjson', path.join(projectPath, "package-lock.json"), {
63
- name, description
64
- })
65
-
66
62
  creator.copyTpl('vueconfigjs', path.join(projectPath, "vue.config.js"))
67
63
 
68
64
  creator.copyTpl('babelconfigjs', path.join(projectPath, "babel.config.js"))
@@ -1,14 +1,14 @@
1
1
  const external = process.env.NODE_ENV == 'development' ? {} : {
2
- "vue": 'Vue',
3
- "vue-router": 'VueRouter',
4
- 'vue-echarts': 'VueECharts',
5
- 'element-ui': 'ELEMENT',
6
- "axios": 'axios',
7
- "d3": 'd3',
8
- 'echarts': 'echarts',
9
- "jschardet": 'jschardet',
10
- "crypto-js": 'CryptoJS',
11
- "vue-i18n": 'VueI18n',
2
+ "vue": 'Vue',
3
+ "vue-router": 'VueRouter',
4
+ 'vue-echarts': 'VueECharts',
5
+ 'element-ui': 'ELEMENT',
6
+ "axios": 'axios',
7
+ "d3": 'd3',
8
+ 'echarts': 'echarts',
9
+ "jschardet": 'jschardet',
10
+ "crypto-js": 'CryptoJS',
11
+ "vue-i18n": 'VueI18n',
12
12
  }
13
13
  module.exports = {
14
14
  publicPath: '/',
@@ -29,6 +29,8 @@ function checkNpmVersion() {
29
29
  console.log(' ' + chalk.green('★') + ' Current Version : ' + chalk.bold.green('v' + config.version));
30
30
  console.log(' ' + chalk.blue('★') + ' Latest Version : ' + chalk.bold.blue('v' + onlineVersion));
31
31
  console.log(' ' + chalk.yellow('★') + ' Published At : ' + chalk.gray(formattedTime));
32
+ console.log(' ' + chalk.magenta('★') + ' Developer Docs : ' + chalk.cyan('https://dev-help.cloudcc.cn/'));
33
+ console.log(' ' + chalk.magenta('★') + ' Changelog : ' + chalk.cyan('https://www.npmjs.com/package/cloudcc-cli'));
32
34
  console.log(' ' + chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
33
35
 
34
36
  if (onlineVersionNum - currentVersion > 0) {
package/utils/utils.js CHANGED
@@ -21,7 +21,12 @@ const formateData = (data, header = { appVersion: "1.0.0" }) => {
21
21
  * @param {object} config 配置参数
22
22
  */
23
23
  async function getBaseUrl(config) {
24
- if (config.baseUrl) {
24
+ // 如果已经有apiSvc和setupSvc则直接返回
25
+ if (config.apiSvc && config.setupSvc) {
26
+ return config;
27
+ }
28
+ // 优先使用baseUrl,其次使用orgId获取
29
+ else if (config.baseUrl) {
25
30
  config.apiSvc = config.baseUrl + (config.apiSvcPrefix || "/apisvc")
26
31
  config.setupSvc = config.baseUrl + (config.setupSvcPrefix || "/setup")
27
32
  } else if (config.orgId) {
@@ -192,17 +197,35 @@ function parseVueDataFunction(vueContent) {
192
197
  // }
193
198
 
194
199
  try {
195
- // 提取 <script> 标签中的内容
196
- const scriptMatch = vueContent.match(/<script[^>]*>([\s\S]*?)<\/script>/);
197
- if (!scriptMatch) {
200
+ // 提取 <script> 标签中的内容,排除带 src 属性的外部脚本
201
+ // 匹配所有 script 标签
202
+ const scriptRegex = /<script([^>]*)>([\s\S]*?)<\/script>/g;
203
+ let scriptContent = null;
204
+ let match;
205
+
206
+ while ((match = scriptRegex.exec(vueContent)) !== null) {
207
+ const attributes = match[1];
208
+ const content = match[2];
209
+
210
+ // 跳过带 src 属性的外部脚本标签
211
+ if (attributes && attributes.includes('src=')) {
212
+ continue;
213
+ }
214
+
215
+ // 查找包含 export default 的 script 标签
216
+ if (content && content.includes('export default')) {
217
+ scriptContent = content;
218
+ break;
219
+ }
220
+ }
221
+
222
+ if (!scriptContent) {
198
223
  console.log()
199
- console.log(chalk.red("Error: Cannot find <script> tag in the vue file."));
224
+ console.log(chalk.red("Error: Cannot find <script> tag with component code in the vue file."));
200
225
  console.log()
201
226
  return null;
202
227
  }
203
228
 
204
- const scriptContent = scriptMatch[1];
205
-
206
229
  // 使用 Babel 解析 JavaScript 代码
207
230
  const ast = babelParser.parse(scriptContent, {
208
231
  sourceType: 'module',
@@ -215,7 +238,7 @@ function parseVueDataFunction(vueContent) {
215
238
  babelTraverse(ast, {
216
239
  ObjectMethod(path) {
217
240
  // 查找名为 data 的方法
218
- if (path.node.key.name === 'data' && path.node.params.length === 0) {
241
+ if (path.node.key && path.node.key.name === 'data' && path.node.params.length === 0) {
219
242
  // 查找 return 语句
220
243
  path.traverse({
221
244
  ReturnStatement(returnPath) {
@@ -231,7 +254,7 @@ function parseVueDataFunction(vueContent) {
231
254
  },
232
255
  // 也处理 data: function() {} 的形式
233
256
  ObjectProperty(path) {
234
- if (path.node.key.name === 'data' &&
257
+ if (path.node.key && path.node.key.name === 'data' &&
235
258
  (path.node.value.type === 'FunctionExpression' || path.node.value.type === 'ArrowFunctionExpression')) {
236
259
  // 查找 return 语句
237
260
  path.traverse({