neo-cmp-cli 1.7.15 → 1.7.16

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 (30) hide show
  1. package/package.json +1 -1
  2. package/src/neo/neoService.js +131 -22
  3. package/src/template/antd-custom-cmp-template/package.json +2 -2
  4. package/src/template/antd-custom-cmp-template/src/components/dataDashboard/model.ts +15 -1
  5. package/src/template/antd-custom-cmp-template/src/components/infoCard/model.ts +15 -1
  6. package/src/template/develop/neo-custom-cmp-template/src/components/contactCardList/model.ts +1 -1
  7. package/src/template/develop/neo-custom-cmp-template/src/components/contactForm/model.ts +1 -1
  8. package/src/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/model.ts +1 -1
  9. package/src/template/echarts-custom-cmp-template/package.json +1 -1
  10. package/src/template/echarts-custom-cmp-template/src/components/chartWidget/model.ts +15 -1
  11. package/src/template/echarts-custom-cmp-template/src/components/mapWidget/model.ts +15 -1
  12. package/src/template/empty-cmp/model.ts +15 -1
  13. package/src/template/empty-custom-cmp-template/package.json +2 -2
  14. package/src/template/neo-custom-cmp-template/neo.config.js +4 -10
  15. package/src/template/neo-custom-cmp-template/package.json +5 -3
  16. package/src/template/neo-custom-cmp-template/src/components/entityCardList/model.ts +15 -1
  17. package/src/template/neo-custom-cmp-template/src/components/entityDetail/model.ts +15 -1
  18. package/src/template/neo-custom-cmp-template/src/components/entityForm/model.ts +15 -1
  19. package/src/template/neo-custom-cmp-template/src/components/entityTable/model.ts +15 -1
  20. package/src/template/neo-custom-cmp-template/tsconfig.json +42 -64
  21. package/src/template/react-custom-cmp-template/package.json +2 -2
  22. package/src/template/react-custom-cmp-template/src/components/infoCard/model.js +15 -1
  23. package/src/template/react-ts-custom-cmp-template/package.json +2 -2
  24. package/src/template/react-ts-custom-cmp-template/src/components/listWidget/model.ts +15 -1
  25. package/src/template/vue2-custom-cmp-template/package.json +2 -2
  26. package/src/template/vue2-custom-cmp-template/src/components/vueInfoCard/model.js +15 -1
  27. package/src/utils/cmpUtils/createCmpByZip.js +17 -6
  28. package/src/utils/cmpUtils/pullCmp.js +10 -9
  29. package/src/utils/cmpUtils/pushCmp.js +29 -11
  30. package/test/deprecate-versions.js +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.7.15",
3
+ "version": "1.7.16",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -14,11 +14,14 @@ const NeoCrmAPI = {
14
14
  neoBaseURL: 'https://crm.xiaoshouyi.com', // 平台根地址
15
15
  loginAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // code 获取接口地址
16
16
  tokenAPI: 'https://login.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址
17
- uploadAPI: '/rest/metadata/v3.0/ui/customComponents/actions/upload', // 文件上传接口地址
18
17
  delete: '/rest/metadata/v3.0/ui/customComponents',
19
- query: '/rest/metadata/v3.0/ui/customComponents/actions/queryCustomComponents', // 带分页
20
- queryAll: '/rest/metadata/v3.0/ui/customComponents/actions/queryAllCustomComponents', // 不带分页
21
- saveAPI: '/rest/metadata/v3.0/ui/customComponents/actions/saveOrUpdateComponent' // 创建或者保存接口地址
18
+ saveAPI: '/rest/metadata/v3.0/ui/customComponents/actions/saveOrUpdateComponent', // 创建或者保存接口地址
19
+ queryAll: '/rest/metadata/v3.0/ui/components/filter?custom=true', // 不带分页
20
+ getCodeLibAPI: (cmpType) => `/rest/metadata/v3.0/ui/customComponents/${cmpType}/codeLib`, // 组件源码下载
21
+
22
+ uploadAPI: '/rest/metadata/v3.0/ui/customComponents/actions/upload', // 文件上传接口地址(已废弃)
23
+ query: '/rest/metadata/v3.0/ui/customComponents/actions/queryCustomComponents' // 带分页(暂未使用)
24
+ // queryAll_v1: '/rest/metadata/v3.0/ui/customComponents/actions/queryAllCustomComponents', // 不带分页(已废弃)
22
25
  };
23
26
 
24
27
  const cmpFields = [
@@ -28,15 +31,15 @@ const cmpFields = [
28
31
  'description',
29
32
  'framework',
30
33
  'icon',
34
+ 'iconUrl',
31
35
  'orderNo',
32
36
  'version',
33
37
  'propsSchema',
34
38
  'defaultProps',
35
39
  'previewProps',
36
40
  'events',
37
- 'actions',
41
+ 'functions',
38
42
  'asset',
39
- 'plugin',
40
43
  'modelAsset',
41
44
  'cssAsset',
42
45
  'codeLib'
@@ -294,7 +297,8 @@ class NeoService {
294
297
  }
295
298
 
296
299
  /**
297
- * 上传文件到 Neo 平台
300
+ * 上传文件到 Neo 平台(已废弃)
301
+ * 备注:已废弃,改为 保存时直接上传组件资源文件
298
302
  * @param {string} filePath 文件路径
299
303
  * @param {object} options 可选配置
300
304
  * @param {string} options.fieldName 表单字段名,默认为 'customComponentCode'
@@ -323,7 +327,7 @@ class NeoService {
323
327
  }
324
328
 
325
329
  // 检查文件大小
326
- const maxSize = options.maxSize || 50 * 1024 * 1024; // 默认 50MB
330
+ const maxSize = options.maxSize || 5 * 1024 * 1024; // 默认 5MB
327
331
  if (fileStat.size > maxSize) {
328
332
  const sizeMB = (fileStat.size / 1024 / 1024).toFixed(2);
329
333
  const maxSizeMB = (maxSize / 1024 / 1024).toFixed(2);
@@ -454,7 +458,8 @@ class NeoService {
454
458
  }
455
459
 
456
460
  /**
457
- * 将构建产物上传到 NeoCRM 平台端
461
+ * 将构建产物上传到 NeoCRM 平台端(已废弃)
462
+ * 备注:已废弃,改为 保存时直接上传组件资源文件
458
463
  *
459
464
  * @param {object} cmpType 自定义组件名称
460
465
  * @param {array} fileExtensions 需要上传的文件类型,默认 ['.js', '.css', '.zip']
@@ -521,6 +526,74 @@ class NeoService {
521
526
  return curCmpInfo;
522
527
  }
523
528
 
529
+ /**
530
+ * 处理组件构建产物
531
+ *
532
+ * @param {object} cmpType 自定义组件名称
533
+ * @param {array} fileExtensions 需要处理的文件类型,默认 ['.js', '.css', '.zip']
534
+ */
535
+ async getCmpAssets(cmpType, fileExtensions = ['.js', '.css', '.zip']) {
536
+ if (!cmpType) {
537
+ errorLog(`自定义组件名称不能为空: ${cmpType}`);
538
+ return;
539
+ }
540
+ if (!fs.existsSync(this.assetsRoot)) {
541
+ errorLog(`未找到自定义组件资源目录: ${this.assetsRoot}`);
542
+ return;
543
+ }
544
+
545
+ // 当前组件信息
546
+ const curCmpInfo = {
547
+ cmpType
548
+ };
549
+
550
+ const files = fs.readdirSync(this.assetsRoot); // 读取构建目录下的所有文件
551
+
552
+ // 处理构建产物目录下所有指定类型的文件
553
+ files.forEach((file) => {
554
+ const filePath = path.join(this.assetsRoot, file);
555
+ // 获取文件状态
556
+ const fileStat = fs.statSync(filePath);
557
+ // 检查文件扩展名
558
+ // const fileExt = path.extname(file);
559
+ const fileInfo = path.parse(filePath);
560
+ if (fileStat.isFile() && fileExtensions.includes(fileInfo.ext)) {
561
+ let widgetName = _.camelCase(cmpType);
562
+
563
+ if (file.indexOf(widgetName) < 0) {
564
+ return;
565
+ }
566
+
567
+ // 检查文件大小
568
+ const maxSize = 5 * 1024 * 1024; // 默认 5MB
569
+ if (fileStat.size > maxSize) {
570
+ const sizeMB = (fileStat.size / 1024 / 1024).toFixed(2);
571
+ const maxSizeMB = (maxSize / 1024 / 1024).toFixed(2);
572
+ throw new Error(`${file} 文件大小超过限制: ${sizeMB}MB > ${maxSizeMB}MB`);
573
+ }
574
+
575
+ const fileContent = fs.createReadStream(filePath);
576
+ const fileInfo = {
577
+ fileContent,
578
+ fileName: file,
579
+ fileSize: fileStat.size,
580
+ };
581
+ if (file.indexOf('Model') > -1) {
582
+ // 使用文件流而不是读取整个文件到内存(对大文件更友好)
583
+ curCmpInfo.modelAssetFile = fileInfo;
584
+ } else if (file.endsWith('.css')) {
585
+ curCmpInfo.cssAssetFile = fileInfo;
586
+ } else if (file.endsWith('.zip')) {
587
+ curCmpInfo.codeLibFile = fileInfo;
588
+ } else {
589
+ curCmpInfo.assetFile = fileInfo;
590
+ }
591
+ }
592
+ });
593
+
594
+ return curCmpInfo;
595
+ }
596
+
524
597
  /**
525
598
  * 更新自定义组件
526
599
  * @param {object} componentData 组件数据
@@ -534,31 +607,56 @@ class NeoService {
534
607
  throw new Error('componentData 不能为空');
535
608
  }
536
609
 
537
- const spinner = ora('正在更新自定义组件...').start();
610
+ const spinner = ora('正在保存自定义组件信息...').start();
538
611
 
539
612
  try {
540
613
  const fullUpdateAPI = this.saveAPI();
541
- const response = await axios.post(fullUpdateAPI, componentData, {
614
+
615
+ // 创建 FormData
616
+ const formData = new FormData();
617
+ // 处理 componentData 中的 fileInfo 文件
618
+ if (componentData.assetFile) {
619
+ formData.append('assetFile', componentData.assetFile.fileContent, componentData.assetFile.fileName);
620
+ }
621
+ if (componentData.modelAssetFile) {
622
+ formData.append('modelAssetFile', componentData.modelAssetFile.fileContent, componentData.modelAssetFile.fileName);
623
+ }
624
+ if (componentData.cssAssetFile) {
625
+ formData.append('cssAssetFile', componentData.cssAssetFile.fileContent, componentData.cssAssetFile.fileName);
626
+ }
627
+ if (componentData.codeLibFile) {
628
+ formData.append('codeLibFile', componentData.codeLibFile.fileContent, componentData.codeLibFile.fileName);
629
+ }
630
+
631
+ // 将 componentData 中组件基本信息
632
+ formData.append('component', JSON.stringify(_.omit(componentData, ['assetFile', 'modelAssetFile', 'cssAssetFile', 'codeLibFile'])));
633
+
634
+ const response = await axios.post(fullUpdateAPI, formData, {
542
635
  headers: {
543
636
  Authorization: `Bearer ${token}`,
544
637
  'xsy-inner-source': 'bff',
545
- 'Content-Type': 'application/json'
546
- }
638
+ // 无需手动设置 Content-Type,formData.getHeaders() 会自动设置正确的 multipart/form-data 和 boundary
639
+ ...formData.getHeaders()
640
+ },
641
+ timeout: 120000, // 默认 60 秒
642
+ // 确保 axios 正确处理大文件和流
643
+ maxContentLength: Infinity, // 不限制响应内容长度
644
+ maxBodyLength: Infinity // 不限制请求体长度(适用于文件上传)
547
645
  });
548
646
  const { code, message } = response.data || {};
549
647
 
550
648
  if (code && code !== 200) {
551
- throw new Error(`更新组件失败: ${response.data.message || '未知错误'}`);
649
+ errorLog(`保存自定义组件信息失败: ${response.data.message || '未知错误'}`);
650
+ process.exit(1);
552
651
  }
553
652
 
554
653
  spinner.clear();
555
654
  spinner.stop();
556
655
  } catch (error) {
557
- errorLog('更新组件失败。', spinner);
558
656
  if (error.message) {
559
- errorLog(`更新组件失败: ${error.message}`);
657
+ errorLog(`保存自定义组件信息失败: ${error.message}`, spinner);
560
658
  } else {
561
- errorLog(`响应数据: ${JSON.stringify(error)}`);
659
+ errorLog(`保存自定义组件信息失败: ${JSON.stringify(error)}`, spinner);
562
660
  }
563
661
  process.exit(1);
564
662
  }
@@ -581,12 +679,9 @@ class NeoService {
581
679
 
582
680
  try {
583
681
  let queryAllAPI = this.buildFullUrl(NeoCrmAPI.queryAll);
584
- queryAllAPI += `?fields=${cmpFields.join(',')}`;
585
- const response = await axios.post(
682
+ queryAllAPI += `&fields=${cmpFields.join(',')}`;
683
+ const response = await axios.get(
586
684
  queryAllAPI,
587
- {
588
- data: {}
589
- },
590
685
  {
591
686
  headers: {
592
687
  Authorization: `Bearer ${token}`,
@@ -615,6 +710,20 @@ class NeoService {
615
710
  return this.cmpList || [];
616
711
  }
617
712
 
713
+ /**
714
+ * 获取自定义组件源码文件地址
715
+ * @param {string} cmpType 自定义组件名称
716
+ * @returns {string} 源码文件地址
717
+ */
718
+ getCodeLibByCmpType(cmpType) {
719
+ if (!cmpType) {
720
+ return null;
721
+ };
722
+ return this.buildFullUrl(NeoCrmAPI.getCodeLibAPI(cmpType));
723
+ }
724
+
725
+
726
+
618
727
  /**
619
728
  * 删除自定义组件
620
729
  * @param {*} cmpType 自定义组件类型
@@ -38,7 +38,7 @@
38
38
  "url": "https://github.com/wibetter/antd-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.0.6",
41
+ "neo-register": "^1.0.7",
42
42
  "antd": "4.9.4",
43
43
  "react": "^16.9.0",
44
44
  "react-dom": "^16.9.0"
@@ -48,7 +48,7 @@
48
48
  "@commitlint/config-conventional": "^9.1.1",
49
49
  "@types/react": "^16.9.11",
50
50
  "@types/react-dom": "^16.9.15",
51
- "neo-cmp-cli": "^1.7.5",
51
+ "neo-cmp-cli": "^1.7.16",
52
52
  "husky": "^4.2.5",
53
53
  "lint-staged": "^10.2.9",
54
54
  "prettier": "^2.0.5"
@@ -15,7 +15,21 @@ export class DataDashboardModel {
15
15
  description: string = '酷炫的数据展示仪表板,支持动态数据更新和动画效果';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['仪表板'];
18
+ // tags: string[] = ['仪表板'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  iconSrc: string = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
@@ -15,7 +15,21 @@ export class InfoCardModel {
15
15
  description: string = '信息展示卡片';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  iconSrc: string = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
@@ -15,7 +15,7 @@ export class ContactCardListModel {
15
15
  description: string = '展示联系人信息的卡片列表组件,支持姓名和手机号展示';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
19
 
20
20
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
21
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/card-list.svg';
@@ -16,7 +16,7 @@ export class ContactFormModel {
16
16
  '基于 Ant Design 的联系人表单组件,支持姓名、所有人、业务类型、所属部门、手机号等字段';
17
17
 
18
18
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
19
- tags: string[] = ['自定义组件'];
19
+ // tags: string[] = ['自定义组件'];
20
20
 
21
21
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
22
22
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/contact-form.svg';
@@ -15,7 +15,7 @@ export class NeoEntityGridModel {
15
15
  description: string = 'Neo 实体表格组件';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
19
 
20
20
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
21
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/table.svg';
@@ -38,7 +38,7 @@
38
38
  "url": "https://github.com/wibetter/echarts-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.0.6",
41
+ "neo-register": "^1.0.7",
42
42
  "react": "^16.9.0",
43
43
  "react-dom": "^16.9.0",
44
44
  "echarts": "^5.5.1"
@@ -16,7 +16,21 @@ export class ChartWidgetModel {
16
16
  '支持多种图表类型切换的专业图表组件,支持丰富的配置选项';
17
17
 
18
18
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
19
- tags: string[] = ['自定义组件'];
19
+ // tags: string[] = ['自定义组件'];
20
+
21
+ /**
22
+ * 用于设置组件支持的页面类型
23
+ *
24
+ * 当前 NeoCRM 平台存在的页面类型:
25
+ * all: 1 全页面
26
+ * indexPage: 2 首页
27
+ * entityListPage: 3 实体列表页
28
+ * entityFormPage: 4 实体表单页
29
+ * entityDetailPage: 5 实体详情页
30
+ * customPage: 6 自定义页面
31
+ * bizPage: 7 业务页面
32
+ */
33
+ // targetPage: string[] = ['customPage'];
20
34
 
21
35
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
22
36
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/chart.svg';
@@ -15,7 +15,21 @@ export class MapWidgetModel {
15
15
  description: string = '地图展示组件,支持传入经纬度或地址名称';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/map.svg';
@@ -15,7 +15,21 @@ export class CmpModel {
15
15
  description: string = 'xx组件详细描述';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  iconSrc: string = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
@@ -37,7 +37,7 @@
37
37
  "url": "https://github.com/wibetter/empty-custom-cmp-template/issues"
38
38
  },
39
39
  "dependencies": {
40
- "neo-register": "^1.0.6",
40
+ "neo-register": "^1.0.7",
41
41
  "react": "^16.9.0",
42
42
  "react-dom": "^16.9.0"
43
43
  },
@@ -46,7 +46,7 @@
46
46
  "@commitlint/config-conventional": "^9.1.1",
47
47
  "@types/react": "^16.9.11",
48
48
  "@types/react-dom": "^16.9.15",
49
- "neo-cmp-cli": "^1.7.5",
49
+ "neo-cmp-cli": "^1.7.16",
50
50
  "husky": "^4.2.5",
51
51
  "lint-staged": "^10.2.9",
52
52
  "prettier": "^2.0.5"
@@ -7,12 +7,6 @@ function resolve(dir) {
7
7
  return path.resolve(__dirname, dir);
8
8
  }
9
9
 
10
- let auth = {}; // NeoCRM 授权配置
11
- if (fs.existsSync('./auth.config.js')) {
12
- // 加载 NeoCRM 授权配置
13
- auth = require('./auth.config');
14
- }
15
-
16
10
  // 包括生产和开发的环境配置信息
17
11
  module.exports = {
18
12
  settings: {
@@ -121,12 +115,12 @@ module.exports = {
121
115
  tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
122
116
  // 当 authType 为 password 时,auth 配置项必填
123
117
  auth: {
124
- client_id: auth.client_id || 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
125
- client_secret: auth.client_secret || 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
126
- username: auth.username || 'xx', // 用户在销售易系统中的用户名
118
+ client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
119
+ client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
120
+ username: 'xx', // 用户在销售易系统中的用户名
127
121
  // password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
128
122
  // 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
129
- password: auth.password || 'xx xx', // 用户账户密码 + 8 位安全令牌
123
+ password: 'xx xx', // 用户账户密码 + 8 位安全令牌
130
124
  },
131
125
  },
132
126
  */
@@ -14,6 +14,8 @@
14
14
  "preview": "neo preview",
15
15
  "linkDebug": "neo linkDebug",
16
16
  "pushCmp": "neo push cmp",
17
+ "pullCmp": "neo pull cmp",
18
+ "deleteCmp": "neo delete cmp",
17
19
  "format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
18
20
  },
19
21
  "files": [
@@ -38,13 +40,13 @@
38
40
  "url": "https://github.com/wibetter/neo-custom-cmp-template/issues"
39
41
  },
40
42
  "dependencies": {
41
- "neo-register": "^1.0.6",
43
+ "neo-register": "^1.0.8",
42
44
  "react": "^16.9.0",
43
45
  "react-dom": "^16.9.0",
44
46
  "axios": "^0.27.2",
45
47
  "antd": "^4.9.4",
46
48
  "lodash": "^4.17.21",
47
- "neo-open-api": "^1.0.11"
49
+ "neo-open-api": "^1.1.0"
48
50
  },
49
51
  "devDependencies": {
50
52
  "@commitlint/cli": "^8.3.5",
@@ -52,7 +54,7 @@
52
54
  "@types/react": "^16.9.11",
53
55
  "@types/react-dom": "^16.9.15",
54
56
  "@types/axios": "^0.14.0",
55
- "neo-cmp-cli": "^1.7.5",
57
+ "neo-cmp-cli": "^1.7.16",
56
58
  "husky": "^4.2.5",
57
59
  "lint-staged": "^10.2.9",
58
60
  "prettier": "^2.0.5"
@@ -15,7 +15,21 @@ export class EntityCardListModel {
15
15
  description: string = '展示实体数据信息的卡片列表组件,支持姓名和手机号展示';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/data-list.svg';
@@ -17,7 +17,21 @@ export class EntityDetailModel {
17
17
  description: string = '展示实体数据详情信息,支持多列布局和字段类型识别';
18
18
 
19
19
  /** 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签) */
20
- tags: string[] = ['自定义组件'];
20
+ // tags: string[] = ['自定义组件'];
21
+
22
+ /**
23
+ * 用于设置组件支持的页面类型
24
+ *
25
+ * 当前 NeoCRM 平台存在的页面类型:
26
+ * all: 1 全页面
27
+ * indexPage: 2 首页
28
+ * entityListPage: 3 实体列表页
29
+ * entityFormPage: 4 实体表单页
30
+ * entityDetailPage: 5 实体详情页
31
+ * customPage: 6 自定义页面
32
+ * bizPage: 7 业务页面
33
+ */
34
+ // targetPage: string[] = ['customPage'];
21
35
 
22
36
  /** 组件图标,用于设置在编辑器左侧组件面板中展示的图标 */
23
37
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/detail.svg';
@@ -19,7 +19,21 @@ export class EntityFormModel {
19
19
  description: string = '基于 XObject 的对象表单组件,用于新增数据';
20
20
 
21
21
  /** 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签) */
22
- tags: string[] = ['自定义组件'];
22
+ // tags: string[] = ['自定义组件'];
23
+
24
+ /**
25
+ * 用于设置组件支持的页面类型
26
+ *
27
+ * 当前 NeoCRM 平台存在的页面类型:
28
+ * all: 1 全页面
29
+ * indexPage: 2 首页
30
+ * entityListPage: 3 实体列表页
31
+ * entityFormPage: 4 实体表单页
32
+ * entityDetailPage: 5 实体详情页
33
+ * customPage: 6 自定义页面
34
+ * bizPage: 7 业务页面
35
+ */
36
+ // targetPage: string[] = ['customPage'];
23
37
 
24
38
  /** 组件图标,用于设置在编辑器左侧组件面板中展示的图标 */
25
39
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/custom-form.svg';
@@ -19,11 +19,25 @@ export class EntityTableModel {
19
19
  description: string = '基于 XObject 的数据表格组件,支持增删改查操作';
20
20
 
21
21
  /** 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签) */
22
- tags: string[] = ['自定义组件'];
22
+ // tags: string[] = ['自定义组件'];
23
23
 
24
24
  /** 组件图标,用于设置在编辑器左侧组件面板中展示的图标 */
25
25
  iconSrc: string = 'https://custom-widgets.bj.bcebos.com/table.svg';
26
26
 
27
+ /**
28
+ * 用于设置组件支持的页面类型
29
+ *
30
+ * 当前 NeoCRM 平台存在的页面类型:
31
+ * all: 1 全页面
32
+ * indexPage: 2 首页
33
+ * entityListPage: 3 实体列表页
34
+ * entityFormPage: 4 实体表单页
35
+ * entityDetailPage: 5 实体详情页
36
+ * customPage: 6 自定义页面
37
+ * bizPage: 7 业务页面
38
+ */
39
+ // targetPage: string[] = ['customPage'];
40
+
27
41
  /** 初次插入页面的默认属性数据 */
28
42
  defaultComProps = {
29
43
  title: '实体数据表格',
@@ -1,71 +1,49 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "experimentalDecorators": true,
4
- /* Basic Options */
5
4
  "target": "esnext",
6
- /* 指定编译之后的版本: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
7
- "module": "esnext" /* 指定要使用的模板标准: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
8
- // "lib": [], /* Specify library files to be included in the compilation. */
9
- "allowJs": false /* 指定是否允许编译JS文件,默认false,即不编译JS文件. */,
10
- // "checkJs": true, /* 指定是否检查和报告JS文件中的错误,默认false */
11
- "jsx": "react" /* 指定jsx代码用于的开发环境:'preserve','react-native', or 'react'. */,
12
- "declaration": false /* 指定是否在编译的时候生成相的d.ts声明文件 */,
13
- // "declarationMap": true, /* 指定编译时是否生成.map文件 */
14
- // "sourceMap": true, /* 指定编译时是否生成.map文件 */
15
- // "outFile": "./", /* 指定输出文件合并为一个文件 */
16
- // "outDir": "dist", /* 指定输出文件夹,值为一个文件夹路径字符串,输出的文件都将放置在这个文件夹*/
17
- // "rootDir": "src", /* 指定编译文件的根目录,编译器会在根目录查找入口文件 */
18
- // "composite": true, /* 是否编译构建引用项目 */
19
- // "removeComments": true, /* 指定是否将编译后的文件注释删掉,设为true的话即删除注释,默认为false */
20
- "noEmit": false /* 不生成编译文件 */,
21
- "importHelpers": true /* 指定是否引入tslib里的复制工具函数,默认为false */,
22
- // "downlevelIteration": true, /* 当target为"ES5"或"ES3"时,为"for-of" "spread"和"destructuring"中的迭代器提供完全支持 */
23
- "isolatedModules": false /* 指定是否将每个文件作为单独的模块,默认为true */,
24
-
25
- /* Strict Type-Checking Options */
26
- "strict": false /* 指定是否启动所有类型检查 */,
27
- "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
28
- "strictNullChecks": true /* Enable strict null checks. */,
29
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
30
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
31
- "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
32
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
33
-
34
- /* Additional Checks */
35
- "noUnusedLocals": false /* Report errors on unused locals. */,
36
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
37
- "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
38
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
39
-
40
- /* Module Resolution Options */
41
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
42
- "baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
5
+ "module": "esnext",
6
+ "allowJs": false,
7
+ "jsx": "react",
8
+ "declaration": false,
9
+ "noEmit": false,
10
+ "importHelpers": true,
11
+ "isolatedModules": false,
12
+ "strict": false,
13
+ "noImplicitAny": true,
14
+ "strictNullChecks": true,
15
+ "noImplicitThis": true,
16
+ "noUnusedLocals": false,
17
+ "noImplicitReturns": true,
18
+ "moduleResolution": "node",
19
+ "baseUrl": "./",
43
20
  "paths": {
44
- "@": ["./src"],
45
- "@assets/*": ["src/assets/*"],
46
- "@components/*": ["src/components/*"],
47
- "$utils/*": ["src/utils/*"]
48
- } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
49
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
50
- /* 指定声明文件或文件夹的路径列表,如果指定了此项,则只有在这里列出的声明文件才会被加载 */
51
- "typeRoots": ["./@types", "./node_modules/@types"],
52
- // "types": [], /* 指定需要包含的模块,只有在这里列出的模块的声明文件才会被加载 */
53
- "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
54
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
55
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
56
-
57
- /* Source Map Options */
58
- // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
59
- // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
60
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
61
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
62
-
63
- /* Experimental Options */
64
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
65
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
66
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
67
- // "suppressImplicitAnyIndexErrors": true /* Suppress --noImplicitAny errors for indexing objects lacking index signatures. See issue #1232 for more details. */
21
+ "@": [
22
+ "./src"
23
+ ],
24
+ "@assets/*": [
25
+ "src/assets/*"
26
+ ],
27
+ "@components/*": [
28
+ "src/components/*"
29
+ ],
30
+ "$utils/*": [
31
+ "src/utils/*"
32
+ ]
33
+ },
34
+ "typeRoots": [
35
+ "./@types",
36
+ "./node_modules/@types"
37
+ ],
38
+ "allowSyntheticDefaultImports": true,
39
+ "esModuleInterop": true,
40
+ "forceConsistentCasingInFileNames": true
68
41
  },
69
- "include": ["src", "test"],
70
- "exclude": ["node_modules"]
42
+ "include": [
43
+ "src",
44
+ "test"
45
+ ],
46
+ "exclude": [
47
+ "node_modules"
48
+ ]
71
49
  }
@@ -38,14 +38,14 @@
38
38
  "url": "https://github.com/wibetter/react-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.0.6",
41
+ "neo-register": "^1.0.7",
42
42
  "react": "^16.9.0",
43
43
  "react-dom": "^16.9.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@commitlint/cli": "^8.3.5",
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
- "neo-cmp-cli": "^1.7.5",
48
+ "neo-cmp-cli": "^1.7.16",
49
49
  "husky": "^4.2.5",
50
50
  "lint-staged": "^10.2.9",
51
51
  "prettier": "^2.0.5"
@@ -15,7 +15,21 @@ export class InfoCardModel {
15
15
  description = '信息展示卡片';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  // iconSrc = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
@@ -38,7 +38,7 @@
38
38
  "url": "https://github.com/wibetter/react-ts-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.0.6",
41
+ "neo-register": "^1.0.7",
42
42
  "react": "^16.9.0",
43
43
  "react-dom": "^16.9.0"
44
44
  },
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.7.5",
50
+ "neo-cmp-cli": "^1.7.16",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5"
@@ -15,7 +15,21 @@ export class ListWidgetModel {
15
15
  description: string = '支持配置的列表展示组件,内置模拟数据';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags: string[] = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  iconSrc: string = 'https://neo-widgets.bj.bcebos.com/favicon.png';
@@ -38,14 +38,14 @@
38
38
  "url": "https://github.com/wibetter/vue2-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.0.6",
41
+ "neo-register": "^1.0.7",
42
42
  "vue": "^2.6.14",
43
43
  "element-ui": "^2.15.12"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@commitlint/cli": "^8.3.5",
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
- "neo-cmp-cli": "^1.7.5",
48
+ "neo-cmp-cli": "^1.7.16",
49
49
  "husky": "^4.2.5",
50
50
  "lint-staged": "^10.2.9",
51
51
  "prettier": "^2.0.5",
@@ -15,7 +15,21 @@ export class InfoCardModel {
15
15
  description = '信息展示卡片';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
- tags = ['自定义组件'];
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * indexPage: 2 首页
26
+ * entityListPage: 3 实体列表页
27
+ * entityFormPage: 4 实体表单页
28
+ * entityDetailPage: 5 实体详情页
29
+ * customPage: 6 自定义页面
30
+ * bizPage: 7 业务页面
31
+ */
32
+ // targetPage: string[] = ['customPage'];
19
33
 
20
34
  // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
35
  iconSrc = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
@@ -120,7 +120,8 @@ function formatConfigObject(obj, indent = 0, fileDir = '') {
120
120
  * 3、对于 组件源码中的 tsconfig.json 文件内容 和 当前项目 tsconfig  进行 非覆盖式 merge 处理;
121
121
  * 4、对于 组件源码中的 package.json 文件内容 和 当前项目 package.json  进行 非覆盖式 merge 处理,并识别新增 依赖,提示用户 重新安装依赖
122
122
  */
123
- module.exports = async function (cmpZipUrl, cmpName, componentBaseDir = './src/components') {
123
+ module.exports = async function (cmpZipUrl, option = {}) {
124
+ const { token, cmpName, componentBaseDir = './src/components' } = option || {};
124
125
  const finalCmpName = cmpName;
125
126
 
126
127
  if (!hasNeoProject()) {
@@ -154,16 +155,26 @@ module.exports = async function (cmpZipUrl, cmpName, componentBaseDir = './src/c
154
155
  // 下载 zip 文件
155
156
  let response;
156
157
  try {
157
- response = await axios({
158
- url: cmpZipUrl,
159
- method: 'GET',
158
+ response = await axios.get(cmpZipUrl, {
159
+ headers: {
160
+ Authorization: `Bearer ${token}`,
161
+ 'xsy-inner-source': 'bff',
162
+ },
160
163
  responseType: 'arraybuffer',
161
164
  timeout: 60000, // 60秒超时
162
165
  maxContentLength: Infinity,
163
- maxBodyLength: Infinity
166
+ maxBodyLength: Infinity,
167
+ maxRedirects: 5, // 支持重定向
168
+ validateStatus: function (status) {
169
+ // 接受 2xx 和 3xx 状态码(重定向)
170
+ return status >= 200 && status < 400;
171
+ }
164
172
  });
165
173
  } catch (axiosError) {
166
- errorLog(`下载文件失败: ${axiosError.message}`, spinner);
174
+ const errorMessage = axiosError.response
175
+ ? `下载文件失败: HTTP ${axiosError.response.status} - ${axiosError.message}`
176
+ : `下载文件失败: ${axiosError.message}`;
177
+ errorLog(errorMessage, spinner);
167
178
  throw axiosError;
168
179
  }
169
180
 
@@ -72,22 +72,23 @@ const pullCmp = async (cmpType, authConfig, _neoService) => {
72
72
  }
73
73
 
74
74
  // 判断拉取的组件和当前项目是否为同一技术栈
75
- if (cmpInfo.framework !== framework) {
75
+ if (cmpInfo.framework && cmpInfo.framework !== framework) {
76
76
  errorLog(`拉取失败,${cmpType}自定义组件与当前项目技术栈不一致。`, spinner);
77
77
  process.exit(1);
78
78
  }
79
79
 
80
- // 获取当前源码
81
- if (!cmpInfo.codeLib) {
82
- errorLog(`拉取失败,${cmpType}自定义组件未记录对应的源码文件。`, spinner);
83
- process.exit(1);
84
- }
85
-
86
80
  // 下载源码文件并解析到 src/components 目录下
87
- const codeLib = cmpInfo.codeLib; // 源码文件地址(zip包地址)
81
+ const codeLib = neoService.getCodeLibByCmpType(cmpType); // 源码文件地址(zip包地址)
82
+
83
+ // 确保 token 有效
84
+ const token = await neoService.ensureValidToken();
88
85
 
89
86
  // 将zip 包里面的自定义组件源码解析到 src/components 目录下
90
- const cmpResult = await createCmpByZip(codeLib, cmpType, './src/components');
87
+ const cmpResult = await createCmpByZip(codeLib, {
88
+ token,
89
+ cmpName: cmpType,
90
+ componentBaseDir: './src/components'
91
+ });
91
92
  if (!cmpResult) {
92
93
  errorLog(`拉取失败,${cmpType}自定义组件源码解析失败,请检查源码文件是否正确。`, spinner);
93
94
  process.exit(1);
@@ -12,6 +12,18 @@ const createCmpProjectZip = require('../projectUtils/createCmpProjectZip');
12
12
  const currentPackageJsonDir = catchCurPackageJson();
13
13
  const currentPackageJson = getConfigObj(currentPackageJsonDir);
14
14
 
15
+
16
+ // 获取属性 propsSchema 数据结构
17
+ const getPropsSchema = (propsSchema = []) => {
18
+ return propsSchema.map((item) => {
19
+ return {
20
+ label: item.label,
21
+ description: item.description,
22
+ propSchema: JSON.stringify(item)
23
+ };
24
+ });
25
+ };
26
+
15
27
  /**
16
28
  * 构建组件数据映射
17
29
  * @param {string} assetsRoot 构建产物的目录
@@ -54,45 +66,47 @@ const buildComponentData = async (assetsRoot, cmpInfo) => {
54
66
  // const CatchCustomCmpModelClass = modelModule.default || modelModule;
55
67
  } else {
56
68
  errorLog(`未找到自定义组件模型文件,请检查以下路径是否存在:${modelFile}`);
57
- return null;
69
+ process.exit(1);
58
70
  }
59
71
  if (!globalThis.window || !globalThis.window.NEOEditorCustomModels) {
60
72
  errorLog(
61
73
  `模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${modelFile} `
62
74
  );
63
- return null;
75
+ process.exit(1);
64
76
  }
65
77
 
66
78
  const ModelClass = globalThis.window.NEOEditorCustomModels[cmpType];
67
79
  if (!ModelClass) {
68
80
  errorLog(`未找到自定义组件模型类(${cmpType}),模型文件地址: ${modelFile} `);
69
- return null;
81
+ process.exit(1);
70
82
  }
71
83
  // 实例化模型类
72
84
  const modelInstance = new ModelClass();
73
85
 
74
86
  if (!modelInstance) {
75
87
  errorLog(`未找到自定义组件模型信息(${cmpType}),模型文件地址: ${modelFile} `);
76
- return null;
88
+ process.exit(1);
77
89
  }
78
90
 
79
91
  // 构建组件数据,合并模型实例的信息
80
92
  const curCmpInfo = {
81
93
  ...cmpInfo,
82
- plugin: cmpInfo.modelAsset,
83
94
  version: currentPackageJson.version || '1.0.0',
84
95
  // 技术栈标识: 从 package.json / framework 字段获取,没有则默认 为 react ts 技术栈
85
96
  framework: currentPackageJson.framework ? getFramework(currentPackageJson.framework) : 0, // 0: React, 1: vue2, 2: jQuery, 3: vue3
86
97
  // 从模型实例中提取并设置组件信息
87
98
  label: modelInstance.label || cmpType,
88
99
  description: modelInstance.description || '',
89
- componentCategory: (modelInstance.tags || []).join(','),
90
- icon: modelInstance.iconSrc,
100
+ componentCategory: (modelInstance.tags || ['自定义组件']).join(','),
101
+ targetPage: (modelInstance.targetPage || ['customPage']).join(','),
102
+ targetDevice: (modelInstance.targetDevice || ['all']).join(','),
103
+ targetApplication: (modelInstance.targetApplication || ['all']).join(','),
104
+ iconUrl: modelInstance.iconSrc,
91
105
  defaultProps: JSON.stringify(modelInstance.defaultComProps || {}),
92
106
  previewProps: JSON.stringify(modelInstance.previewComProps || {}),
93
- propsSchema: JSON.stringify(modelInstance.propsSchema || []),
107
+ props: getPropsSchema(modelInstance.propsSchema || []),
94
108
  events: modelInstance.events || [],
95
- actions: modelInstance.actions || [],
109
+ functions: modelInstance.functions || modelInstance.actions || [],
96
110
  // 如果模型实例中有其他属性,也可以添加
97
111
  exposedToDesigner:
98
112
  modelInstance.exposedToDesigner !== undefined ? modelInstance.exposedToDesigner : true,
@@ -101,7 +115,7 @@ const buildComponentData = async (assetsRoot, cmpInfo) => {
101
115
  modelInstance.enableDuplicate !== undefined ? modelInstance.enableDuplicate : true
102
116
  };
103
117
 
104
- console.log(`自定义组件模型信息(${cmpType}):`, curCmpInfo);
118
+ console.log(`自定义组件模型信息(${cmpType}):`, _.omit(curCmpInfo, ['assetFile', 'modelAssetFile', 'cssAssetFile', 'codeLibFile']));
105
119
  return curCmpInfo;
106
120
  } catch (error) {
107
121
  errorLog(`自定义组件模型文件解析失败 (${modelFile || '未知路径'}): ${error.message}`);
@@ -151,7 +165,8 @@ const pushCmp = async (config, cmpType) => {
151
165
  errorLog(`[1/4] 源码文件打包失败。`, spinner);
152
166
  }
153
167
 
154
- // 步骤 3: 上传构建后资源文件
168
+ /*
169
+ // 步骤 3: 上传构建后资源文件(改放在保存时直接上传组件资源文件)
155
170
  spinner.start(`[2/4] 上传自定义组件构建产物到 OSS...`);
156
171
  let cmpInfo;
157
172
  try {
@@ -164,6 +179,9 @@ const pushCmp = async (config, cmpType) => {
164
179
  } catch (error) {
165
180
  errorLog(`[2/4] 构建产物上传失败。`, spinner);
166
181
  }
182
+ */
183
+ spinner.start(`[2/4] 获取自定义组件构建产物...`);
184
+ const cmpInfo = await neoService.getCmpAssets(cmpType);
167
185
 
168
186
  // 步骤 4: 构建组件数据
169
187
  spinner.start(`[3/4] 构建组件数据...`);
@@ -1,7 +1,7 @@
1
1
  const { execSync } = require('child_process');
2
2
 
3
- // 所有需要废弃的版本(1.6.2 之前的所有版本)
4
- const versionsToDeprecate = ["1.7.10", "1.7.11", "1.7.12", "1.7.13"];
3
+ // 所有需要废弃的版本
4
+ const versionsToDeprecate = ["1.7.15-beta.1", "1.7.15", "1.7.12", "1.7.13"];
5
5
 
6
6
  const packageName = 'neo-cmp-cli';
7
7
  const deprecateMessage = '此版本为开发中版本(存在 bug),请升级到最新版本。';