neo-cmp-cli 1.9.5 → 1.9.7
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 +34 -34
- package/dist/neo/pushCmp.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/empty-custom-cmp-template/package.json +1 -1
- package/template/neo-custom-cmp-template/package.json +1 -1
- package/template/neo-custom-cmp-template/src/components/entityCardList/model.ts +11 -1
- package/template/neo-custom-cmp-template/src/components/entityForm_c/index.tsx +0 -8
- package/template/neo-custom-cmp-template/src/components/entityForm_c/model.ts +1 -6
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/test/deprecate-versions.js +1 -1
package/README.md
CHANGED
|
@@ -519,6 +519,38 @@ neo delete cmp -n xxCmp
|
|
|
519
519
|
- ⚠️ **影响范围**:删除组件后,所有使用该组件的页面和表单将受到影响,请确保没有正在使用的场景
|
|
520
520
|
- 💡 **建议先备份**:删除前建议先使用 `neo pull cmp` 拉取组件源码到本地进行备份
|
|
521
521
|
|
|
522
|
+
### 10. 自定义组件之间实现模块共享
|
|
523
|
+
|
|
524
|
+
**步骤 1**:在自定义组件A(customCmpA)/ 配置文件中定义要共享出来的模块A(xxModuleA)
|
|
525
|
+
|
|
526
|
+
```javascript
|
|
527
|
+
// customCmpA 组件的 neo.config.js
|
|
528
|
+
module.exports = {
|
|
529
|
+
neoCommonModule: {
|
|
530
|
+
// exports: ['xxModule'], // 数组写法,用于导出当前自定义组件中的第三方依赖模块
|
|
531
|
+
exports: { 'xxModuleA': path.resolve('./src/components/xxModuleA') }, // 对象写法,可用于导出自定义组件中的某个内容模块(需要使用绝对路径导出)
|
|
532
|
+
},
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
**步骤 2**:在自定义组件B(customCmpB)/ 配置文件中声明需要使用自定义组件 A 分享出来的模块(xxModuleA)
|
|
537
|
+
|
|
538
|
+
```javascript
|
|
539
|
+
// customCmpB 组件的 neo.config.js
|
|
540
|
+
module.exports = {
|
|
541
|
+
neoCommonModule: {
|
|
542
|
+
remoteDeps: ['customCmpA'], // 远程依赖(自定义组件),表示当前自定义组件 B 会用到哪些自定义组件
|
|
543
|
+
externals: ['xxModuleA'], // 自定义组件中需要剔除的外部模块(远程自定义组件中分享出来的模块),仅支持数组写法,需要和 remoteDeps 配合使用
|
|
544
|
+
},
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
**步骤 3**:在自定义组件B 中使用自定义组件 A 分享出来的模块(xxModuleA)
|
|
549
|
+
|
|
550
|
+
```javascript
|
|
551
|
+
import xxModuleA from 'xxModuleA'; // 导入自定义组件 A 共享出来的模块
|
|
552
|
+
```
|
|
553
|
+
|
|
522
554
|
## ⚙️ 配置说明
|
|
523
555
|
|
|
524
556
|
neo-cmp-cli 默认提供完整配置;如需自定义,使用 `neo config init` 生成 `neo.config.js` 并按需修改。
|
|
@@ -544,7 +576,7 @@ module.exports = {
|
|
|
544
576
|
|
|
545
577
|
> **提示**:当未配置 `entry` 时,cli 默认从 `src/components` 目录下扫描并识别自定义组件,并自动生成对应的 entry 构建入口配置。
|
|
546
578
|
|
|
547
|
-
优先级:`linkDebug/build2lib/
|
|
579
|
+
优先级:`linkDebug/build2lib/pushCmp.entry` > `webpack.entry`
|
|
548
580
|
|
|
549
581
|
如需自定义构建入口配置,请按如下结构调整项目工程配置文件(`neo.config.js`):
|
|
550
582
|
|
|
@@ -555,7 +587,7 @@ module.exports = {
|
|
|
555
587
|
},
|
|
556
588
|
linkDebug: { entry: {} },
|
|
557
589
|
build2lib: { entry: {} },
|
|
558
|
-
|
|
590
|
+
pushCmp: { entry: {} },
|
|
559
591
|
}
|
|
560
592
|
```
|
|
561
593
|
|
|
@@ -695,38 +727,6 @@ module.exports = {
|
|
|
695
727
|
}
|
|
696
728
|
```
|
|
697
729
|
|
|
698
|
-
#### 11. 自定义组件之间实现模块共享
|
|
699
|
-
|
|
700
|
-
**步骤 1**:在自定义组件A(customCmpA)/ 配置文件中定义要共享出来的模块A(xxModuleA)
|
|
701
|
-
|
|
702
|
-
```javascript
|
|
703
|
-
// customCmpA 组件的 neo.config.js
|
|
704
|
-
module.exports = {
|
|
705
|
-
neoCommonModule: {
|
|
706
|
-
// exports: ['xxModule'], // 数组写法,用于导出当前自定义组件中的第三方依赖模块
|
|
707
|
-
exports: { 'xxModuleA': path.resolve('./src/components/xxModuleA') }, // 对象写法,可用于导出自定义组件中的某个内容模块(需要使用绝对路径导出)
|
|
708
|
-
},
|
|
709
|
-
}
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
**步骤 2**:在自定义组件B(customCmpB)/ 配置文件中声明需要使用自定义组件 A 分享出来的模块(xxModuleA)
|
|
713
|
-
|
|
714
|
-
```javascript
|
|
715
|
-
// customCmpB 组件的 neo.config.js
|
|
716
|
-
module.exports = {
|
|
717
|
-
neoCommonModule: {
|
|
718
|
-
remoteDeps: ['customCmpA'], // 远程依赖(自定义组件),表示当前自定义组件 B 会用到哪些自定义组件
|
|
719
|
-
externals: ['xxModuleA'], // 自定义组件中需要剔除的外部模块(远程自定义组件中分享出来的模块),仅支持数组写法,需要和 remoteDeps 配合使用
|
|
720
|
-
},
|
|
721
|
-
}
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
**步骤 3**:在自定义组件B 中使用自定义组件 A 分享出来的模块(xxModuleA)
|
|
725
|
-
|
|
726
|
-
```javascript
|
|
727
|
-
import xxModuleA from 'xxModuleA'; // 导入自定义组件 A 共享出来的模块
|
|
728
|
-
```
|
|
729
|
-
|
|
730
730
|
---
|
|
731
731
|
|
|
732
732
|
如需更多细节与高级用法,请参考模板项目与源码注释。
|
package/dist/neo/pushCmp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),s=require("lodash"),o=require("akfun"),r=require("ora"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),s=require("lodash"),o=require("akfun"),r=require("ora"),a=require("./neoService.js"),i=require("../utils/common.js"),n=require("../utils/pathUtils.js"),c=require("../utils/projectUtils/createCmpProjectZip.js");var l,p;exports.__require=function(){if(p)return l;p=1;const u=e,g=t,m=s,{getConfigObj:d}=o,w=r,y=a.__require(),{getFramework:f,errorLog:h,successLog:v}=i.__require(),{catchCurPackageJson:b}=n.__require(),T=c.__require(),C=d(b()),$=(e=[])=>e.map(e=>({label:e.label,description:e.description,propSchema:JSON.stringify(e)})),P=(e=[],t)=>e&&0!==e.length?e.map(e=>({...e,componentType:t,eventCategory:e.eventCategory||2,pageType:e.pageType||1,targetDevice:e.targetDevice||1,eventParams:e.eventParams||[]})):[],q=(e=[],t)=>e&&0!==e.length?e.map(e=>({...e,componentType:t,funcScope:e.funcScope||"all",pageType:e.pageType||1,targetDevice:e.targetDevice||1,custom:void 0===e.custom||e.custom,funcInParams:e.funcInParams||[],funcOutParams:e.funcOutParams||[]})):[];return l=async(e,t)=>{const s=w("正在发布组件...").start();try{let o,r=new y(e);await r.ensureValidToken(),s.start("[1/4] 打包源码文件(含单个自定义组件源码)...");try{o=T(t,process.cwd(),e.assetsRoot),o?v(`[1/4] 源码文件打包完成: ${g.basename(o)}。`,s):h("[1/4] 源码文件打包失败,未返回 zip 文件路径。",s)}catch(e){h("[1/4] 源码文件打包失败。",s)}s.start("[2/4] 获取自定义组件构建产物...");const a=await r.getCmpAssets(t);let i;s.start("[3/4] 构建组件数据...");try{i=await(async(e,t)=>{if(!t||!t.cmpType)return h("自定义组件信息或组件名称不能为空"),null;const{cmpType:s}=t;if(!e||!u.existsSync(e))return h(`未找到自定义组件目录: ${e}`),null;const o=m.camelCase(s),r=g.join(e,`${o}Model.js`),a=globalThis.window;globalThis.window||(globalThis.window={console:console,neoRequire:()=>{},postMessage:()=>{}});try{u.existsSync(r)?require(r):(h(`未找到自定义组件模型文件,请检查以下路径是否存在:${r}`),process.exit(1)),globalThis.window&&globalThis.window.NEOEditorCustomModels||(h(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${r} `),process.exit(1));const e=globalThis.window.NEOEditorCustomModels[s];e||(h(`未找到自定义组件模型类(${s}),模型文件地址: ${r} `),process.exit(1));const o=new e;o||(h(`未找到自定义组件模型信息(${s}),模型文件地址: ${r} `),process.exit(1));const a={...t,version:C.version||"1.0.0",framework:C.framework?f(C.framework):0,label:o.label||s,description:o.description||"",componentCategory:(o.tags||["自定义组件"]).join(","),targetPage:o.targetPage||["customPage"],targetObject:o.targetObject||["all"],targetApplication:o.targetApplication||["all"],targetDevice:o.targetDevice||"all",iconUrl:o.iconUrl||o.iconUrl,defaultProps:JSON.stringify(o.defaultComProps||{}),previewProps:JSON.stringify(o.previewComProps||{}),props:$(o.propsSchema||[]),events:P(o.events||[],s),functions:q(o.functions||o.actions||[],s),exposedToDesigner:void 0===o.exposedToDesigner||o.exposedToDesigner,namespace:o.namespace||"neo-cmp-cli",enableDuplicate:void 0===o.enableDuplicate||o.enableDuplicate};return console.log(`自定义组件模型信息(${s}):`,m.omit(a,["assetFile","modelAssetFile","cssAssetFile","codeLibFile"])),a}catch(e){return h(`自定义组件模型文件解析失败 (${r||"未知路径"}): ${e.message}`),h(e.stack),null}finally{void 0===a?delete globalThis.window:globalThis.window=a}})(e.assetsRoot,a),i?v("[3/4] 组件数据构建完成。",s):h(`[3/4] 未获取到自定义组件模型信息(${t})。`,s)}catch(e){h(`[3/4] 组件数据构建失败: ${e.message}`,s)}s.start("[4/4] 保存组件信息到 NeoCRM 平台...");try{await r.updateCustomComponent(i),v("[4/4] 组件信息保存成功",s)}catch(e){h("[4/4] 组件信息保存失败",s)}const{tenant_id:n,instance_uri:c}=r.tokenCache||{};console.log(`\n✅ 自定义组件发布成功!\n(当前租户 ID: ${n||"未返回"},所在租户的 API 域名: ${c||"未返回"}。)`)}catch(e){try{s&&s.isSpinning&&h(`❌ 自定义组件发布失败: ${e.message}`,s)}catch{h(`\n❌ 自定义组件发布失败: ${e.message}`)}throw e}},l};
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.9.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.9.7";const o={version:e};exports.default=o,exports.version=e;
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export class EntityCardListModel {
|
|
|
29
29
|
* customPage: 6 自定义页面
|
|
30
30
|
* bizPage: 7 业务页面
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
targetPage: string[] = ['all'];
|
|
33
33
|
|
|
34
34
|
// 组件图标,用于设置在编辑器左侧组件面板中展示的图标
|
|
35
35
|
iconUrl: string = 'https://custom-widgets.bj.bcebos.com/data-list.svg';
|
|
@@ -44,6 +44,16 @@ export class EntityCardListModel {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
// 当前组件支持的函数列表(其他组件可触发当前组件的函数)
|
|
48
|
+
functions = [
|
|
49
|
+
{
|
|
50
|
+
apiKey: 'loadObjectData',
|
|
51
|
+
label: '重新获取数据列表',
|
|
52
|
+
helpTextKey: '获取实体业务数据列表',
|
|
53
|
+
funcInParams: [],
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
47
57
|
/**
|
|
48
58
|
* 组件面板配置,用于生成编辑器右侧属性配置面板内容
|
|
49
59
|
*/
|
|
@@ -238,11 +238,6 @@ export default class EntityForm extends React.PureComponent<
|
|
|
238
238
|
console.log('触发了表单提交事件:', this.props);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
@aop
|
|
242
|
-
onBeforeSubmit(formValues: any) {
|
|
243
|
-
console.log('触发了表单提交前事件:', formValues);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
241
|
/**
|
|
247
242
|
* 处理表单提交
|
|
248
243
|
* 执行新增操作
|
|
@@ -252,9 +247,6 @@ export default class EntityForm extends React.PureComponent<
|
|
|
252
247
|
const { xObjectApiKey } = this.props.xObjectDataApi || {};
|
|
253
248
|
const { fieldList } = this.state;
|
|
254
249
|
|
|
255
|
-
// 触发表单提交事件
|
|
256
|
-
this.onBeforeSubmit(values);
|
|
257
|
-
|
|
258
250
|
if (!xObjectApiKey) {
|
|
259
251
|
message.error('请先选择要操作的对象');
|
|
260
252
|
return;
|
|
@@ -61,12 +61,7 @@ export class EntityFormModel {
|
|
|
61
61
|
// description: '这是一个表单提交事件', // 暂未使用
|
|
62
62
|
label: '提交表单后', // 事件
|
|
63
63
|
helpText: '表单提交后触发该事件' // 信息icon hover 时的提示文本
|
|
64
|
-
}
|
|
65
|
-
{
|
|
66
|
-
apiKey: 'onBeforeSubmit',
|
|
67
|
-
label: '提交表单前',
|
|
68
|
-
helpText: '表单提交前触发该事件'
|
|
69
|
-
},
|
|
64
|
+
}
|
|
70
65
|
];
|
|
71
66
|
|
|
72
67
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { execSync } = require('child_process');
|
|
2
2
|
|
|
3
3
|
// 所有需要废弃的版本
|
|
4
|
-
const versionsToDeprecate = ["1.
|
|
4
|
+
const versionsToDeprecate = ["1.9.0", "1.9.1", "1.9.2", "1.9.3"];
|
|
5
5
|
|
|
6
6
|
const packageName = 'neo-cmp-cli';
|
|
7
7
|
const deprecateMessage = '此版本为开发中版本(存在 bug),请升级到最新版本。';
|