neo-cmp-cli 1.8.25 → 1.9.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.8.25";const o={version:e};exports.default=o,exports.version=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.9.0";const o={version:e};exports.default=o,exports.version=e;
@@ -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("../pathUtils.js"),i=require("ora"),a=require("../../neo/neoService.js"),n=require("../common.js"),c=require("../projectUtils/createCmpProjectZip.js");var l,p;exports.__require=function(){if(p)return l;p=1;const u=e,g=t,d=s,{getConfigObj:m}=o,{catchCurPackageJson:w}=r.__require(),h=i,b=a.__require(),{getFramework:f,errorLog:y,successLog:C}=n.__require(),$=c.__require(),q=m(w()),T=(e=[])=>e.map(e=>({label:e.label,description:e.description,propSchema:JSON.stringify(e)}));return l=async(e,t)=>{const s=h("正在发布组件...").start();try{let o,r=new b(e);await r.ensureValidToken(),s.start("[1/4] 打包源码文件(含单个自定义组件源码)...");try{o=$(t,process.cwd(),e.assetsRoot),o?C(`[1/4] 源码文件打包完成: ${g.basename(o)}。`,s):y("[1/4] 源码文件打包失败,未返回 zip 文件路径。",s)}catch(e){y("[1/4] 源码文件打包失败。",s)}s.start("[2/4] 获取自定义组件构建产物...");const i=await r.getCmpAssets(t);let a;s.start("[3/4] 构建组件数据...");try{a=await(async(e,t)=>{if(!t||!t.cmpType)return y("自定义组件信息或组件名称不能为空"),null;const{cmpType:s}=t;if(!e||!u.existsSync(e))return y(`未找到自定义组件目录: ${e}`),null;const o=d.camelCase(s),r=g.join(e,`${o}Model.js`),i=globalThis.window;globalThis.window||(globalThis.window={console:console,neoRequire:()=>{},postMessage:()=>{}});try{u.existsSync(r)?require(r):(y(`未找到自定义组件模型文件,请检查以下路径是否存在:${r}`),process.exit(1)),globalThis.window&&globalThis.window.NEOEditorCustomModels||(y(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${r} `),process.exit(1));const e=globalThis.window.NEOEditorCustomModels[s];e||(y(`未找到自定义组件模型类(${s}),模型文件地址: ${r} `),process.exit(1));const o=new e;o||(y(`未找到自定义组件模型信息(${s}),模型文件地址: ${r} `),process.exit(1));const i={...t,version:q.version||"1.0.0",framework:q.framework?f(q.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:T(o.propsSchema||[]),events:o.events||[],functions:o.functions||o.actions||[],exposedToDesigner:void 0===o.exposedToDesigner||o.exposedToDesigner,namespace:o.namespace||"neo-cmp-cli",enableDuplicate:void 0===o.enableDuplicate||o.enableDuplicate};return console.log(`自定义组件模型信息(${s}):`,d.omit(i,["assetFile","modelAssetFile","cssAssetFile","codeLibFile"])),i}catch(e){return y(`自定义组件模型文件解析失败 (${r||"未知路径"}): ${e.message}`),y(e.stack),null}finally{void 0===i?delete globalThis.window:globalThis.window=i}})(e.assetsRoot,i),a?C("[3/4] 组件数据构建完成。",s):y(`[3/4] 未获取到自定义组件模型信息(${t})。`,s)}catch(e){y(`[3/4] 组件数据构建失败: ${e.message}`,s)}s.start("[4/4] 保存组件信息到 NeoCRM 平台...");try{await r.updateCustomComponent(a),C("[4/4] 组件信息保存成功",s)}catch(e){y("[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&&y(`❌ 自定义组件发布失败: ${e.message}`,s)}catch{y(`\n❌ 自定义组件发布失败: ${e.message}`)}throw e}},l};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),o=require("lodash"),s=require("akfun"),r=require("../pathUtils.js"),a=require("ora"),i=require("../../neo/neoService.js"),n=require("../common.js"),c=require("../projectUtils/createCmpProjectZip.js");var l,p;exports.__require=function(){if(p)return l;p=1;const g=e,u=t,m=o,{getConfigObj:d}=s,{catchCurPackageJson:w}=r.__require(),h=a,y=i.__require(),{getFramework:b,errorLog:v,successLog:C}=n.__require(),f=c.__require(),T=d(w()),$=(e=[])=>e.map(e=>({label:e.label,description:e.description,propSchema:JSON.stringify(e)})),q=(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||[]})):[];return l=async(e,t)=>{const o=h("正在发布组件...").start();try{let s,r=new y(e);await r.ensureValidToken(),o.start("[1/4] 打包源码文件(含单个自定义组件源码)...");try{s=f(t,process.cwd(),e.assetsRoot),s?C(`[1/4] 源码文件打包完成: ${u.basename(s)}。`,o):v("[1/4] 源码文件打包失败,未返回 zip 文件路径。",o)}catch(e){v("[1/4] 源码文件打包失败。",o)}o.start("[2/4] 获取自定义组件构建产物...");const a=await r.getCmpAssets(t);let i;o.start("[3/4] 构建组件数据...");try{i=await(async(e,t)=>{if(!t||!t.cmpType)return v("自定义组件信息或组件名称不能为空"),null;const{cmpType:o}=t;if(!e||!g.existsSync(e))return v(`未找到自定义组件目录: ${e}`),null;const s=m.camelCase(o),r=u.join(e,`${s}Model.js`),a=globalThis.window;globalThis.window||(globalThis.window={console:console,neoRequire:()=>{},postMessage:()=>{}});try{g.existsSync(r)?require(r):(v(`未找到自定义组件模型文件,请检查以下路径是否存在:${r}`),process.exit(1)),globalThis.window&&globalThis.window.NEOEditorCustomModels||(v(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${r} `),process.exit(1));const e=globalThis.window.NEOEditorCustomModels[o];e||(v(`未找到自定义组件模型类(${o}),模型文件地址: ${r} `),process.exit(1));const s=new e;s||(v(`未找到自定义组件模型信息(${o}),模型文件地址: ${r} `),process.exit(1));const a={...t,version:T.version||"1.0.0",framework:T.framework?b(T.framework):0,label:s.label||o,description:s.description||"",componentCategory:(s.tags||["自定义组件"]).join(","),targetPage:s.targetPage||["customPage"],targetObject:s.targetObject||["all"],targetApplication:s.targetApplication||["all"],targetDevice:s.targetDevice||"all",iconUrl:s.iconUrl||s.iconUrl,defaultProps:JSON.stringify(s.defaultComProps||{}),previewProps:JSON.stringify(s.previewComProps||{}),props:$(s.propsSchema||[]),events:q(s.events||[],o),functions:s.functions||s.actions||[],exposedToDesigner:void 0===s.exposedToDesigner||s.exposedToDesigner,namespace:s.namespace||"neo-cmp-cli",enableDuplicate:void 0===s.enableDuplicate||s.enableDuplicate};return console.log(`自定义组件模型信息(${o}):`,m.omit(a,["assetFile","modelAssetFile","cssAssetFile","codeLibFile"])),a}catch(e){return v(`自定义组件模型文件解析失败 (${r||"未知路径"}): ${e.message}`),v(e.stack),null}finally{void 0===a?delete globalThis.window:globalThis.window=a}})(e.assetsRoot,a),i?C("[3/4] 组件数据构建完成。",o):v(`[3/4] 未获取到自定义组件模型信息(${t})。`,o)}catch(e){v(`[3/4] 组件数据构建失败: ${e.message}`,o)}o.start("[4/4] 保存组件信息到 NeoCRM 平台...");try{await r.updateCustomComponent(i),C("[4/4] 组件信息保存成功",o)}catch(e){v("[4/4] 组件信息保存失败",o)}const{tenant_id:n,instance_uri:c}=r.tokenCache||{};console.log(`\n✅ 自定义组件发布成功!\n(当前租户 ID: ${n},所在租户的 API 域名: ${c}。)`)}catch(e){try{o&&o.isSpinning&&v(`❌ 自定义组件发布失败: ${e.message}`,o)}catch{v(`\n❌ 自定义组件发布失败: ${e.message}`)}throw e}},l};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.8.25",
3
+ "version": "1.9.0",
4
4
  "description": "Neo 自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -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.8.25",
51
+ "neo-cmp-cli": "^1.9.0",
52
52
  "husky": "^4.2.5",
53
53
  "lint-staged": "^10.2.9",
54
54
  "prettier": "^2.0.5"
@@ -0,0 +1,257 @@
1
+ /**
2
+ * 组件事件动作函数
3
+ * - apiKey: 事件动作名称
4
+ * - label: 事件动作标签
5
+ * - description: 描述
6
+ * - funcInParams: 事件动作入参
7
+ * - funcOutParams: 事件动作出参
8
+ * - labelKey: 事件动作标签(对应国际化键)
9
+ * - helpText: 帮助文本
10
+ * - helpTextKey: 帮助文本键(对应国际化键)
11
+ */
12
+ const functions = [
13
+ {
14
+ componentId: null,
15
+ helpText: '',
16
+ apiKey: 'logout',
17
+ custom: false,
18
+ funcInParams: null,
19
+ description: '',
20
+ label: '登出',
21
+ cmpKeyIdentifier: '',
22
+ funcOutParams: null,
23
+ helpTextKey: '',
24
+ body: null,
25
+ pageType: 1,
26
+ id: 13095000000001,
27
+ funcScope: 1,
28
+ labelKey: 'XdMDNeoFunction.logout'
29
+ },
30
+ {
31
+ componentId: null,
32
+ helpText: '',
33
+ apiKey: 'createRecord',
34
+ custom: false,
35
+ funcInParams:
36
+ '[{"apiKey":"xObjectName","label":"实体apiKey","type":"String","required":true},{"apiKey":"busiType","label":"业务类型apiKey","type":"String","required":true}]',
37
+ description: '',
38
+ label: '新建数据',
39
+ cmpKeyIdentifier: '',
40
+ funcOutParams: '[]',
41
+ helpTextKey: '',
42
+ body: null,
43
+ pageType: 1,
44
+ id: 13095000000002,
45
+ funcScope: 1,
46
+ labelKey: 'XdMDNeoFunction.createRecord'
47
+ },
48
+ {
49
+ componentId: null,
50
+ helpText: '',
51
+ apiKey: 'editRecord',
52
+ custom: false,
53
+ funcInParams:
54
+ '[{"apiKey":"xObjectName","label":"实体apiKey","type":"String","required":true},{"apiKey":"busiType","label":"业务类型apiKey","type":"String","required":true},{"apiKey":"recordId","label":"数据Id","type":"String","required":true}]',
55
+ description: '',
56
+ label: '编辑数据',
57
+ cmpKeyIdentifier: '',
58
+ funcOutParams: '[]',
59
+ helpTextKey: '',
60
+ body: null,
61
+ pageType: 1,
62
+ id: 13095000000003,
63
+ funcScope: 1,
64
+ labelKey: 'XdMDNeoFunction.editRecord'
65
+ },
66
+ {
67
+ componentId: null,
68
+ helpText: '',
69
+ apiKey: 'cloneRecord',
70
+ custom: false,
71
+ funcInParams:
72
+ '[{"apiKey":"xObjectName","label":"实体apiKey","type":"String","required":true},{"apiKey":"busiType","label":"业务类型apiKey","type":"String","required":true},{"apiKey":"recordId","label":"原始数据Id","type":"String","required":true}]',
73
+ description: '',
74
+ label: '复制数据',
75
+ cmpKeyIdentifier: '',
76
+ funcOutParams: '[]',
77
+ helpTextKey: '',
78
+ body: null,
79
+ pageType: 1,
80
+ id: 13095000000004,
81
+ funcScope: 1,
82
+ labelKey: 'XdMDNeoFunction.cloneRecord'
83
+ },
84
+ {
85
+ componentId: null,
86
+ helpText: '',
87
+ apiKey: 'showToast',
88
+ custom: false,
89
+ funcInParams:
90
+ '[{"apiKey":"type","options":[{"label":"成功","value":"success"},{"label":"警告","value":"warning"},{"label":"失败","value":"error"}],"label":"提示类型","type":"String","required":false},{"apiKey":"msg","label":"提示内容","type":"String","required":true},{"apiKey":"showTime","label":"停留时长(s)","type":"Number","required":false}]',
91
+ description: '',
92
+ label: '弹出提示信息',
93
+ cmpKeyIdentifier: '',
94
+ funcOutParams: '[]',
95
+ helpTextKey: '',
96
+ body: null,
97
+ pageType: 1,
98
+ id: 13095000000005,
99
+ funcScope: 1,
100
+ labelKey: 'XdMDNeoFunction.showToast'
101
+ },
102
+ {
103
+ componentId: null,
104
+ helpText: '',
105
+ apiKey: 'showLoading',
106
+ custom: false,
107
+ funcInParams: '[]',
108
+ description: '',
109
+ label: '弹出loading框',
110
+ cmpKeyIdentifier: '',
111
+ funcOutParams: '[]',
112
+ helpTextKey: '',
113
+ body: null,
114
+ pageType: 1,
115
+ id: 13095000000009,
116
+ funcScope: 1,
117
+ labelKey: 'XdMDNeoFunction.showLoading'
118
+ },
119
+ {
120
+ componentId: null,
121
+ helpText: '',
122
+ apiKey: 'hideLoading',
123
+ custom: false,
124
+ funcInParams: '[]',
125
+ description: '',
126
+ label: '关闭loading框',
127
+ cmpKeyIdentifier: '',
128
+ funcOutParams: '[]',
129
+ helpTextKey: '',
130
+ body: null,
131
+ pageType: 1,
132
+ id: 13095000000010,
133
+ funcScope: 1,
134
+ labelKey: 'XdMDNeoFunction.hideLoading'
135
+ },
136
+ {
137
+ componentId: null,
138
+ helpText: '',
139
+ apiKey: 'navigatePageTo',
140
+ custom: false,
141
+ funcInParams:
142
+ '[{"apiKey":"url","label":"打开的地址","type":"String","required":true},{"apiKey":"target","options":[{"label":"当前页跳转","value":0},{"label":"新页签打开","value":1}],"label":"打开页面的方式","type":"Number","required":false}]',
143
+ description: '',
144
+ label: '打开指定页面',
145
+ cmpKeyIdentifier: '',
146
+ funcOutParams: '[]',
147
+ helpTextKey: '',
148
+ body: null,
149
+ pageType: 1,
150
+ id: 13095000000011,
151
+ funcScope: 1,
152
+ labelKey: 'XdMDNeoFunction.navigatePageTo'
153
+ },
154
+ {
155
+ componentId: null,
156
+ helpText: '',
157
+ apiKey: 'log',
158
+ custom: false,
159
+ funcInParams: '[{"apiKey":"msg","label":"提示的消息内容","type":"String","required":true}]',
160
+ description: '',
161
+ label: '打印log信息',
162
+ cmpKeyIdentifier: '',
163
+ funcOutParams: '[]',
164
+ helpTextKey: '',
165
+ body: null,
166
+ pageType: 1,
167
+ id: 13095000000012,
168
+ funcScope: 1,
169
+ labelKey: 'XdMDNeoFunction.log'
170
+ },
171
+ {
172
+ componentId: null,
173
+ helpText: '',
174
+ apiKey: 'warn',
175
+ custom: false,
176
+ funcInParams: '[{"apiKey":"msg","label":"提示的消息内容","type":"String","required":true}]',
177
+ description: '',
178
+ label: '打印warn信息',
179
+ cmpKeyIdentifier: '',
180
+ funcOutParams: '[]',
181
+ helpTextKey: '',
182
+ body: null,
183
+ pageType: 1,
184
+ id: 13095000000013,
185
+ funcScope: 1,
186
+ labelKey: 'XdMDNeoFunction.warn'
187
+ },
188
+ {
189
+ componentId: null,
190
+ helpText: '',
191
+ apiKey: 'info',
192
+ custom: false,
193
+ funcInParams: '[{"apiKey":"msg","label":"提示的消息内容","type":"String","required":true}]',
194
+ description: '',
195
+ label: '打印info信息',
196
+ cmpKeyIdentifier: '',
197
+ funcOutParams: '[]',
198
+ helpTextKey: '',
199
+ body: null,
200
+ pageType: 1,
201
+ id: 13095000000014,
202
+ funcScope: 1,
203
+ labelKey: 'XdMDNeoFunction.info'
204
+ },
205
+ {
206
+ componentId: null,
207
+ helpText: '',
208
+ apiKey: 'error',
209
+ custom: false,
210
+ funcInParams: '[{"apiKey":"msg","label":"提示的消息内容","type":"String","required":true}]',
211
+ description: '',
212
+ label: '打印error信息',
213
+ cmpKeyIdentifier: '',
214
+ funcOutParams: '[]',
215
+ helpTextKey: '',
216
+ body: null,
217
+ pageType: 1,
218
+ id: 13095000000015,
219
+ funcScope: 1,
220
+ labelKey: 'XdMDNeoFunction.error'
221
+ },
222
+ {
223
+ componentId: null,
224
+ helpText: '',
225
+ apiKey: 'popupIframe',
226
+ custom: false,
227
+ funcInParams:
228
+ '[{"apiKey":"url","label":"页面地址","type":"String","required":true},{"apiKey":"title","label":"窗口标题","type":"String","required":true},{"apiKey":"height","label":"窗口高度","type":"String","required":false},{"apiKey":"width","label":"窗口宽度","type":"String","required":false}]',
229
+ description: '',
230
+ label: '弹出窗口',
231
+ cmpKeyIdentifier: '',
232
+ funcOutParams: '[]',
233
+ helpTextKey: '',
234
+ body: null,
235
+ pageType: 1,
236
+ id: 13095000000016,
237
+ funcScope: 1,
238
+ labelKey: 'XdMDNeoFunction.popupIframe'
239
+ },
240
+ {
241
+ componentId: null,
242
+ helpText: '',
243
+ apiKey: 'returnValue',
244
+ custom: false,
245
+ funcInParams: '[{"apiKey":"value","label":"需要返回的内容","type":"Boolean","required":true}]',
246
+ description: '',
247
+ label: '返回值',
248
+ cmpKeyIdentifier: '',
249
+ funcOutParams: '[]',
250
+ helpTextKey: '',
251
+ body: null,
252
+ pageType: 1,
253
+ id: 13095000000017,
254
+ funcScope: 1,
255
+ labelKey: 'XdMDNeoFunction.returnValue'
256
+ }
257
+ ]