neo-cmp-cli 1.7.15-beta.1 → 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.
- package/package.json +1 -1
- package/src/neo/neoService.js +62 -21
- package/src/template/antd-custom-cmp-template/package.json +1 -1
- package/src/template/empty-custom-cmp-template/package.json +1 -1
- package/src/template/neo-custom-cmp-template/neo.config.js +4 -10
- package/src/template/neo-custom-cmp-template/package.json +4 -2
- package/src/template/neo-custom-cmp-template/tsconfig.json +42 -64
- package/src/template/react-custom-cmp-template/package.json +1 -1
- package/src/template/react-ts-custom-cmp-template/package.json +1 -1
- package/src/template/vue2-custom-cmp-template/package.json +1 -1
- package/src/utils/cmpUtils/createCmpByZip.js +17 -6
- package/src/utils/cmpUtils/pullCmp.js +10 -9
- package/src/utils/cmpUtils/pushCmp.js +9 -8
- package/test/deprecate-versions.js +2 -2
package/package.json
CHANGED
package/src/neo/neoService.js
CHANGED
|
@@ -16,8 +16,8 @@ const NeoCrmAPI = {
|
|
|
16
16
|
tokenAPI: 'https://login.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址
|
|
17
17
|
delete: '/rest/metadata/v3.0/ui/customComponents',
|
|
18
18
|
saveAPI: '/rest/metadata/v3.0/ui/customComponents/actions/saveOrUpdateComponent', // 创建或者保存接口地址
|
|
19
|
-
queryAll: '/rest/metadata/v3.0/ui/components/filter?custom=
|
|
20
|
-
getCodeLibAPI: (cmpType) =>
|
|
19
|
+
queryAll: '/rest/metadata/v3.0/ui/components/filter?custom=true', // 不带分页
|
|
20
|
+
getCodeLibAPI: (cmpType) => `/rest/metadata/v3.0/ui/customComponents/${cmpType}/codeLib`, // 组件源码下载
|
|
21
21
|
|
|
22
22
|
uploadAPI: '/rest/metadata/v3.0/ui/customComponents/actions/upload', // 文件上传接口地址(已废弃)
|
|
23
23
|
query: '/rest/metadata/v3.0/ui/customComponents/actions/queryCustomComponents' // 带分页(暂未使用)
|
|
@@ -31,15 +31,15 @@ const cmpFields = [
|
|
|
31
31
|
'description',
|
|
32
32
|
'framework',
|
|
33
33
|
'icon',
|
|
34
|
+
'iconUrl',
|
|
34
35
|
'orderNo',
|
|
35
36
|
'version',
|
|
36
37
|
'propsSchema',
|
|
37
38
|
'defaultProps',
|
|
38
39
|
'previewProps',
|
|
39
40
|
'events',
|
|
40
|
-
'
|
|
41
|
+
'functions',
|
|
41
42
|
'asset',
|
|
42
|
-
'plugin',
|
|
43
43
|
'modelAsset',
|
|
44
44
|
'cssAsset',
|
|
45
45
|
'codeLib'
|
|
@@ -573,15 +573,20 @@ class NeoService {
|
|
|
573
573
|
}
|
|
574
574
|
|
|
575
575
|
const fileContent = fs.createReadStream(filePath);
|
|
576
|
+
const fileInfo = {
|
|
577
|
+
fileContent,
|
|
578
|
+
fileName: file,
|
|
579
|
+
fileSize: fileStat.size,
|
|
580
|
+
};
|
|
576
581
|
if (file.indexOf('Model') > -1) {
|
|
577
582
|
// 使用文件流而不是读取整个文件到内存(对大文件更友好)
|
|
578
|
-
curCmpInfo.modelAssetFile =
|
|
583
|
+
curCmpInfo.modelAssetFile = fileInfo;
|
|
579
584
|
} else if (file.endsWith('.css')) {
|
|
580
|
-
curCmpInfo.cssAssetFile =
|
|
585
|
+
curCmpInfo.cssAssetFile = fileInfo;
|
|
581
586
|
} else if (file.endsWith('.zip')) {
|
|
582
|
-
curCmpInfo.codeLibFile =
|
|
587
|
+
curCmpInfo.codeLibFile = fileInfo;
|
|
583
588
|
} else {
|
|
584
|
-
curCmpInfo.assetFile =
|
|
589
|
+
curCmpInfo.assetFile = fileInfo;
|
|
585
590
|
}
|
|
586
591
|
}
|
|
587
592
|
});
|
|
@@ -602,31 +607,56 @@ class NeoService {
|
|
|
602
607
|
throw new Error('componentData 不能为空');
|
|
603
608
|
}
|
|
604
609
|
|
|
605
|
-
const spinner = ora('
|
|
610
|
+
const spinner = ora('正在保存自定义组件信息...').start();
|
|
606
611
|
|
|
607
612
|
try {
|
|
608
613
|
const fullUpdateAPI = this.saveAPI();
|
|
609
|
-
|
|
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, {
|
|
610
635
|
headers: {
|
|
611
636
|
Authorization: `Bearer ${token}`,
|
|
612
637
|
'xsy-inner-source': 'bff',
|
|
613
|
-
|
|
614
|
-
|
|
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 // 不限制请求体长度(适用于文件上传)
|
|
615
645
|
});
|
|
616
646
|
const { code, message } = response.data || {};
|
|
617
647
|
|
|
618
648
|
if (code && code !== 200) {
|
|
619
|
-
|
|
649
|
+
errorLog(`保存自定义组件信息失败: ${response.data.message || '未知错误'}`);
|
|
650
|
+
process.exit(1);
|
|
620
651
|
}
|
|
621
652
|
|
|
622
653
|
spinner.clear();
|
|
623
654
|
spinner.stop();
|
|
624
655
|
} catch (error) {
|
|
625
|
-
errorLog('更新组件失败。', spinner);
|
|
626
656
|
if (error.message) {
|
|
627
|
-
errorLog(
|
|
657
|
+
errorLog(`保存自定义组件信息失败: ${error.message}`, spinner);
|
|
628
658
|
} else {
|
|
629
|
-
errorLog(
|
|
659
|
+
errorLog(`保存自定义组件信息失败: ${JSON.stringify(error)}`, spinner);
|
|
630
660
|
}
|
|
631
661
|
process.exit(1);
|
|
632
662
|
}
|
|
@@ -649,12 +679,9 @@ class NeoService {
|
|
|
649
679
|
|
|
650
680
|
try {
|
|
651
681
|
let queryAllAPI = this.buildFullUrl(NeoCrmAPI.queryAll);
|
|
652
|
-
queryAllAPI +=
|
|
653
|
-
const response = await axios.
|
|
682
|
+
queryAllAPI += `&fields=${cmpFields.join(',')}`;
|
|
683
|
+
const response = await axios.get(
|
|
654
684
|
queryAllAPI,
|
|
655
|
-
{
|
|
656
|
-
data: {}
|
|
657
|
-
},
|
|
658
685
|
{
|
|
659
686
|
headers: {
|
|
660
687
|
Authorization: `Bearer ${token}`,
|
|
@@ -683,6 +710,20 @@ class NeoService {
|
|
|
683
710
|
return this.cmpList || [];
|
|
684
711
|
}
|
|
685
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
|
+
|
|
686
727
|
/**
|
|
687
728
|
* 删除自定义组件
|
|
688
729
|
* @param {*} cmpType 自定义组件类型
|
|
@@ -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:
|
|
125
|
-
client_secret:
|
|
126
|
-
username:
|
|
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:
|
|
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,7 +40,7 @@
|
|
|
38
40
|
"url": "https://github.com/wibetter/neo-custom-cmp-template/issues"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"neo-register": "^1.0.
|
|
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",
|
|
@@ -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.
|
|
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"
|
|
@@ -1,71 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"experimentalDecorators": true,
|
|
4
|
-
/* Basic Options */
|
|
5
4
|
"target": "esnext",
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
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
|
-
"@": [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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": [
|
|
70
|
-
|
|
42
|
+
"include": [
|
|
43
|
+
"src",
|
|
44
|
+
"test"
|
|
45
|
+
],
|
|
46
|
+
"exclude": [
|
|
47
|
+
"node_modules"
|
|
48
|
+
]
|
|
71
49
|
}
|
|
@@ -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,
|
|
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
|
-
|
|
159
|
-
|
|
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
|
-
|
|
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 =
|
|
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,
|
|
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);
|
|
@@ -19,7 +19,7 @@ const getPropsSchema = (propsSchema = []) => {
|
|
|
19
19
|
return {
|
|
20
20
|
label: item.label,
|
|
21
21
|
description: item.description,
|
|
22
|
-
propSchema: item
|
|
22
|
+
propSchema: JSON.stringify(item)
|
|
23
23
|
};
|
|
24
24
|
});
|
|
25
25
|
};
|
|
@@ -66,32 +66,31 @@ const buildComponentData = async (assetsRoot, cmpInfo) => {
|
|
|
66
66
|
// const CatchCustomCmpModelClass = modelModule.default || modelModule;
|
|
67
67
|
} else {
|
|
68
68
|
errorLog(`未找到自定义组件模型文件,请检查以下路径是否存在:${modelFile}`);
|
|
69
|
-
|
|
69
|
+
process.exit(1);
|
|
70
70
|
}
|
|
71
71
|
if (!globalThis.window || !globalThis.window.NEOEditorCustomModels) {
|
|
72
72
|
errorLog(
|
|
73
73
|
`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${modelFile} `
|
|
74
74
|
);
|
|
75
|
-
|
|
75
|
+
process.exit(1);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const ModelClass = globalThis.window.NEOEditorCustomModels[cmpType];
|
|
79
79
|
if (!ModelClass) {
|
|
80
80
|
errorLog(`未找到自定义组件模型类(${cmpType}),模型文件地址: ${modelFile} `);
|
|
81
|
-
|
|
81
|
+
process.exit(1);
|
|
82
82
|
}
|
|
83
83
|
// 实例化模型类
|
|
84
84
|
const modelInstance = new ModelClass();
|
|
85
85
|
|
|
86
86
|
if (!modelInstance) {
|
|
87
87
|
errorLog(`未找到自定义组件模型信息(${cmpType}),模型文件地址: ${modelFile} `);
|
|
88
|
-
|
|
88
|
+
process.exit(1);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// 构建组件数据,合并模型实例的信息
|
|
92
92
|
const curCmpInfo = {
|
|
93
93
|
...cmpInfo,
|
|
94
|
-
plugin: cmpInfo.modelAsset,
|
|
95
94
|
version: currentPackageJson.version || '1.0.0',
|
|
96
95
|
// 技术栈标识: 从 package.json / framework 字段获取,没有则默认 为 react ts 技术栈
|
|
97
96
|
framework: currentPackageJson.framework ? getFramework(currentPackageJson.framework) : 0, // 0: React, 1: vue2, 2: jQuery, 3: vue3
|
|
@@ -100,10 +99,12 @@ const buildComponentData = async (assetsRoot, cmpInfo) => {
|
|
|
100
99
|
description: modelInstance.description || '',
|
|
101
100
|
componentCategory: (modelInstance.tags || ['自定义组件']).join(','),
|
|
102
101
|
targetPage: (modelInstance.targetPage || ['customPage']).join(','),
|
|
102
|
+
targetDevice: (modelInstance.targetDevice || ['all']).join(','),
|
|
103
|
+
targetApplication: (modelInstance.targetApplication || ['all']).join(','),
|
|
103
104
|
iconUrl: modelInstance.iconSrc,
|
|
104
105
|
defaultProps: JSON.stringify(modelInstance.defaultComProps || {}),
|
|
105
106
|
previewProps: JSON.stringify(modelInstance.previewComProps || {}),
|
|
106
|
-
props:
|
|
107
|
+
props: getPropsSchema(modelInstance.propsSchema || []),
|
|
107
108
|
events: modelInstance.events || [],
|
|
108
109
|
functions: modelInstance.functions || modelInstance.actions || [],
|
|
109
110
|
// 如果模型实例中有其他属性,也可以添加
|
|
@@ -114,7 +115,7 @@ const buildComponentData = async (assetsRoot, cmpInfo) => {
|
|
|
114
115
|
modelInstance.enableDuplicate !== undefined ? modelInstance.enableDuplicate : true
|
|
115
116
|
};
|
|
116
117
|
|
|
117
|
-
console.log(`自定义组件模型信息(${cmpType}):`, curCmpInfo);
|
|
118
|
+
console.log(`自定义组件模型信息(${cmpType}):`, _.omit(curCmpInfo, ['assetFile', 'modelAssetFile', 'cssAssetFile', 'codeLibFile']));
|
|
118
119
|
return curCmpInfo;
|
|
119
120
|
} catch (error) {
|
|
120
121
|
errorLog(`自定义组件模型文件解析失败 (${modelFile || '未知路径'}): ${error.message}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { execSync } = require('child_process');
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
const versionsToDeprecate = ["1.7.
|
|
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),请升级到最新版本。';
|