neo-cmp-cli 1.5.5 → 1.6.0-beta.1
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 +64 -44
- package/package.json +1 -1
- package/src/cmpUtils/createCmpByTemplate.js +2 -2
- package/src/cmpUtils/createCmpByZip.js +87 -0
- package/src/cmpUtils/pullCmp.js +96 -0
- package/src/cmpUtils/pushCmp.js +77 -101
- package/src/module/index.js +54 -5
- package/src/module/main.js +7 -1
- package/src/neo/NeoUMDContent.js +1 -0
- package/src/neo/neoService.js +152 -42
- package/src/projectUtils/createCmpProjectZip.js +122 -0
- package/src/projectUtils/hasNeoProject.js +6 -5
- package/src/template/antd-custom-cmp-template/neo.config.js +7 -4
- package/src/template/antd-custom-cmp-template/package.json +2 -1
- package/src/template/echarts-custom-cmp-template/neo.config.js +7 -4
- package/src/template/echarts-custom-cmp-template/package.json +2 -1
- package/src/template/empty-custom-cmp-template/neo.config.js +7 -4
- package/src/template/empty-custom-cmp-template/package.json +2 -1
- package/src/template/neo-custom-cmp-template/neo.config.js +12 -9
- package/src/template/neo-custom-cmp-template/package.json +2 -1
- package/src/template/neo-custom-cmp-template/pushCmp.js +166 -0
- package/src/template/react-custom-cmp-template/neo.config.js +7 -4
- package/src/template/react-custom-cmp-template/package.json +2 -1
- package/src/template/react-ts-custom-cmp-template/neo.config.js +7 -4
- package/src/template/react-ts-custom-cmp-template/package.json +2 -1
- package/src/template/vue2-custom-cmp-template/neo.config.js +7 -4
- package/src/template/vue2-custom-cmp-template/package.json +2 -1
- package/src/utils/common.js +48 -0
|
@@ -98,12 +98,12 @@ module.exports = {
|
|
|
98
98
|
}
|
|
99
99
|
*/
|
|
100
100
|
},
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
// NeoCRM 平台配置
|
|
102
|
+
neoConfig: {
|
|
103
103
|
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
104
104
|
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
105
105
|
// NeoCRM 授权配置
|
|
106
|
-
|
|
106
|
+
auth: {
|
|
107
107
|
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
108
108
|
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
109
109
|
username: 'xx', // 用户在销售易系统中的用户名
|
|
@@ -112,7 +112,10 @@ module.exports = {
|
|
|
112
112
|
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
113
113
|
*/
|
|
114
114
|
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
115
|
-
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
pushCmp: {
|
|
118
|
+
// 用于构建并发布至 NeoCRM 的相关配置
|
|
116
119
|
/*
|
|
117
120
|
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
118
121
|
NODE_ENV: 'production',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "echarts-custom-cmp-template",
|
|
3
3
|
"version": "1.1.19",
|
|
4
4
|
"description": "neo自定义组件模板(react&ts技术栈)",
|
|
5
|
+
"framework": "react-ts",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"自定义组件模板",
|
|
7
8
|
"react&ts技术栈",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"@commitlint/config-conventional": "^9.1.1",
|
|
48
49
|
"@types/react": "^16.9.11",
|
|
49
50
|
"@types/react-dom": "^16.9.15",
|
|
50
|
-
"neo-cmp-cli": "^1.5.
|
|
51
|
+
"neo-cmp-cli": "^1.5.6",
|
|
51
52
|
"husky": "^4.2.5",
|
|
52
53
|
"lint-staged": "^10.2.9",
|
|
53
54
|
"prettier": "^2.0.5",
|
|
@@ -97,12 +97,12 @@ module.exports = {
|
|
|
97
97
|
}
|
|
98
98
|
*/
|
|
99
99
|
},
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// NeoCRM 平台配置
|
|
101
|
+
neoConfig: {
|
|
102
102
|
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
103
103
|
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
104
104
|
// NeoCRM 授权配置
|
|
105
|
-
|
|
105
|
+
auth: {
|
|
106
106
|
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
107
107
|
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
108
108
|
username: 'xx', // 用户在销售易系统中的用户名
|
|
@@ -111,7 +111,10 @@ module.exports = {
|
|
|
111
111
|
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
112
112
|
*/
|
|
113
113
|
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
pushCmp: {
|
|
117
|
+
// 用于构建并发布至 NeoCRM 的相关配置
|
|
115
118
|
/*
|
|
116
119
|
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
117
120
|
NODE_ENV: 'production',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "empty-custom-cmp-template",
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"description": "neo 自定义组件",
|
|
5
|
+
"framework": "react-ts",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"react&ts 技术栈",
|
|
7
8
|
"neo 自定义组件"
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"@commitlint/config-conventional": "^9.1.1",
|
|
46
47
|
"@types/react": "^16.9.11",
|
|
47
48
|
"@types/react-dom": "^16.9.15",
|
|
48
|
-
"neo-cmp-cli": "^1.5.
|
|
49
|
+
"neo-cmp-cli": "^1.5.6",
|
|
49
50
|
"husky": "^4.2.5",
|
|
50
51
|
"lint-staged": "^10.2.9",
|
|
51
52
|
"prettier": "^2.0.5"
|
|
@@ -7,10 +7,10 @@ function resolve(dir) {
|
|
|
7
7
|
return path.resolve(__dirname, dir);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
let
|
|
10
|
+
let auth = {}; // NeoCRM 授权配置
|
|
11
11
|
if (fs.existsSync('./auth.config.js')) {
|
|
12
12
|
// 加载 NeoCRM 授权配置
|
|
13
|
-
|
|
13
|
+
auth = require('./auth.config');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// 包括生产和开发的环境配置信息
|
|
@@ -105,21 +105,24 @@ module.exports = {
|
|
|
105
105
|
}
|
|
106
106
|
*/
|
|
107
107
|
},
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
// NeoCRM 平台配置
|
|
109
|
+
neoConfig: {
|
|
110
110
|
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
111
111
|
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
112
112
|
// NeoCRM 授权配置
|
|
113
|
-
|
|
114
|
-
client_id:
|
|
115
|
-
client_secret:
|
|
116
|
-
username:
|
|
113
|
+
auth: {
|
|
114
|
+
client_id: auth.client_id || 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
115
|
+
client_secret: auth.client_secret || 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
116
|
+
username: auth.username || 'xx', // 用户在销售易系统中的用户名
|
|
117
117
|
/**
|
|
118
118
|
* password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
|
|
119
119
|
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
120
120
|
*/
|
|
121
|
-
password:
|
|
121
|
+
password: auth.password || 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
122
122
|
},
|
|
123
|
+
},
|
|
124
|
+
pushCmp: {
|
|
125
|
+
// 用于构建并发布至 NeoCRM 的相关配置
|
|
123
126
|
/*
|
|
124
127
|
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
125
128
|
NODE_ENV: 'production',
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const { catchCurPackageJson } = require('../utils/pathUtils');
|
|
5
|
+
const getConfigObj = require('../utils/getConfigObj');
|
|
6
|
+
const ora = require('ora');
|
|
7
|
+
const NeoService = require('../neo/neoService');
|
|
8
|
+
const { getFramework } = require('../utils/common');
|
|
9
|
+
const createCmpProjectZip = require('../projectUtils/createCmpProjectZip');
|
|
10
|
+
|
|
11
|
+
// 获取当前项目的package文件
|
|
12
|
+
const currentPackageJsonDir = catchCurPackageJson();
|
|
13
|
+
const currentPackageJson = getConfigObj(currentPackageJsonDir);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 构建组件数据映射
|
|
17
|
+
* @param {string} assetsRoot 构建产物的目录
|
|
18
|
+
* @param {object} cmpInfo 自定义组件信息
|
|
19
|
+
* @returns {Promise<object|null>} 自定义组件数据(含自定义组件模型信息)
|
|
20
|
+
*/
|
|
21
|
+
const buildComponentData = async (assetsRoot, cmpInfo) => {
|
|
22
|
+
if (!cmpInfo || !cmpInfo.cmpType) {
|
|
23
|
+
console.error('自定义组件信息或组件名称不能为空');
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { cmpType } = cmpInfo;
|
|
28
|
+
|
|
29
|
+
if (!assetsRoot || !fs.existsSync(assetsRoot)) {
|
|
30
|
+
console.error(`未找到自定义组件目录: ${assetsRoot}`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const widgetName = _.camelCase(cmpType);
|
|
34
|
+
const modelFile = path.join(assetsRoot, `${widgetName}Model.js`);
|
|
35
|
+
|
|
36
|
+
// 为 Node.js 环境设置全局 window 对象(模型文件可能需要)
|
|
37
|
+
// 使用 globalThis 以确保在 Node.js 和浏览器环境中都能工作
|
|
38
|
+
const originalWindow = globalThis.window;
|
|
39
|
+
if (!globalThis.window) {
|
|
40
|
+
globalThis.window = {
|
|
41
|
+
console: console,
|
|
42
|
+
neoRequire: () => {},
|
|
43
|
+
postMessage: () => {}
|
|
44
|
+
// 可以添加其他常用的 window 属性
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
// 加载自定义组件模型资源文件
|
|
50
|
+
if (fs.existsSync(modelFile)) {
|
|
51
|
+
// 加载自定义组件模型资源文件
|
|
52
|
+
let modelModule = require(modelFile);
|
|
53
|
+
// 获取导出的模型类(可能是 default 导出或命名导出)
|
|
54
|
+
// const CatchCustomCmpModelClass = modelModule.default || modelModule;
|
|
55
|
+
} else {
|
|
56
|
+
console.error(`未找到自定义组件模型文件,请检查以下路径是否存在:`, modelFile);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (!window.NEOEditorCustomModels) {
|
|
60
|
+
console.error(
|
|
61
|
+
`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${modelFile} `
|
|
62
|
+
);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const ModelClass = window.NEOEditorCustomModels[cmpType];
|
|
67
|
+
if (!ModelClass) {
|
|
68
|
+
console.error(`未找到自定义组件模型类(${cmpType}),模型文件地址: ${modelFile} `);
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
// 实例化模型类
|
|
72
|
+
const modelInstance = new ModelClass();
|
|
73
|
+
|
|
74
|
+
if (!modelInstance) {
|
|
75
|
+
console.error(`未找到自定义组件模型信息(${cmpType}),模型文件地址: ${modelFile} `);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 构建组件数据,合并模型实例的信息
|
|
80
|
+
const curCmpInfo = {
|
|
81
|
+
...cmpInfo,
|
|
82
|
+
plugin: cmpInfo.modelAsset,
|
|
83
|
+
version: currentPackageJson.version || '1.0.0',
|
|
84
|
+
// 技术栈标识: 从 package.json / framework 字段获取,没有则默认 为 react ts 技术栈
|
|
85
|
+
framework: currentPackageJson.framework ? getFramework(currentPackageJson.framework) : '0', // 0: React, 1: vue2, 2: jQuery, 3: vue3
|
|
86
|
+
// 从模型实例中提取并设置组件信息
|
|
87
|
+
label: modelInstance.label || cmpType,
|
|
88
|
+
description: modelInstance.description || '',
|
|
89
|
+
componentCategory: (modelInstance.tags || []).join(','),
|
|
90
|
+
icon: modelInstance.iconSrc,
|
|
91
|
+
defaultProps: JSON.stringify(modelInstance.defaultComProps || {}),
|
|
92
|
+
previewProps: JSON.stringify(modelInstance.previewComProps || {}),
|
|
93
|
+
propsSchema: JSON.stringify(modelInstance.propsSchema || []),
|
|
94
|
+
events: modelInstance.events || [],
|
|
95
|
+
actions: modelInstance.actions || [],
|
|
96
|
+
// 如果模型实例中有其他属性,也可以添加
|
|
97
|
+
exposedToDesigner:
|
|
98
|
+
modelInstance.exposedToDesigner !== undefined ? modelInstance.exposedToDesigner : true,
|
|
99
|
+
namespace: modelInstance.namespace || 'neo-cmp-cli',
|
|
100
|
+
enableDuplicate:
|
|
101
|
+
modelInstance.enableDuplicate !== undefined ? modelInstance.enableDuplicate : true
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
console.log(`自定义组件模型信息(${cmpType}):`, curCmpInfo);
|
|
105
|
+
return curCmpInfo;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error(`自定义组件模型文件解析失败 (${modelFile || '未知路径'}):`, error.message);
|
|
108
|
+
console.error(error.stack);
|
|
109
|
+
return null;
|
|
110
|
+
} finally {
|
|
111
|
+
// 恢复原始的 window 对象(如果之前存在)
|
|
112
|
+
if (originalWindow === undefined) {
|
|
113
|
+
delete globalThis.window;
|
|
114
|
+
} else {
|
|
115
|
+
globalThis.window = originalWindow;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 发布组件到 NeoCRM
|
|
122
|
+
* @param {object} config 配置信息
|
|
123
|
+
* @param {string} assetsRoot 构建产物的目录
|
|
124
|
+
*/
|
|
125
|
+
const pushCmp = async (config, cmpType) => {
|
|
126
|
+
const { auth: credentials } = config;
|
|
127
|
+
|
|
128
|
+
if (!credentials) {
|
|
129
|
+
console.error('未找到 NeoCRM 平台授权配置(neo.config.js / neoConfig');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const spinner = ora('正在发布组件...').start();
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
// 步骤 1: 初始化 NeoService
|
|
137
|
+
spinner.text = '发布自定义组件:初始化 NeoService...';
|
|
138
|
+
const neoService = new NeoService(config);
|
|
139
|
+
|
|
140
|
+
// 步骤 2: 打包源码文件(打包单个自定义组件源码)
|
|
141
|
+
spinner.text = '发布自定义组件:打包源码文件(含单个自定义组件源码)...';
|
|
142
|
+
createCmpProjectZip(cmpType, process.cwd(), config.assetsRoot);
|
|
143
|
+
|
|
144
|
+
// 步骤 3: 上传构建后资源文件
|
|
145
|
+
spinner.text = '发布自定义组件:上传自定义组件构建产物到 OSS...';
|
|
146
|
+
const cmpInfo = await neoService.publish2oss(cmpType);
|
|
147
|
+
|
|
148
|
+
// 步骤 5: 构建组件数据
|
|
149
|
+
spinner.text = '发布自定义组件:构建组件数据...';
|
|
150
|
+
const componentInfo = await buildComponentData(config.assetsRoot, cmpInfo);
|
|
151
|
+
if (!componentInfo) {
|
|
152
|
+
throw new Error(`构建组件数据失败,未获取到自定义组件模型信息。(${cmpType})`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 步骤 6: 保存组件信息
|
|
156
|
+
spinner.text = '发布自定义组件:保存组件信息...';
|
|
157
|
+
await neoService.updateCustomComponent(componentInfo);
|
|
158
|
+
|
|
159
|
+
spinner.succeed('自定义组件发布成功!\n', componentInfo);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
spinner.fail(`自定义组件发布失败: ${error.message}`);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
module.exports = pushCmp;
|
|
@@ -96,12 +96,12 @@ module.exports = {
|
|
|
96
96
|
}
|
|
97
97
|
*/
|
|
98
98
|
},
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
// NeoCRM 平台配置
|
|
100
|
+
neoConfig: {
|
|
101
101
|
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
102
102
|
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
103
103
|
// NeoCRM 授权配置
|
|
104
|
-
|
|
104
|
+
auth: {
|
|
105
105
|
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
106
106
|
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
107
107
|
username: 'xx', // 用户在销售易系统中的用户名
|
|
@@ -110,7 +110,10 @@ module.exports = {
|
|
|
110
110
|
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
111
111
|
*/
|
|
112
112
|
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
113
|
-
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
pushCmp: {
|
|
116
|
+
// 用于构建并发布至 NeoCRM 的相关配置
|
|
114
117
|
/*
|
|
115
118
|
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
116
119
|
NODE_ENV: 'production',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "react-custom-cmp-template",
|
|
3
3
|
"version": "1.1.0",
|
|
4
4
|
"description": "neo自定义组件模板(react技术栈)",
|
|
5
|
+
"framework": "react-js",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"自定义组件模板",
|
|
7
8
|
"react技术栈",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@commitlint/cli": "^8.3.5",
|
|
46
47
|
"@commitlint/config-conventional": "^9.1.1",
|
|
47
|
-
"neo-cmp-cli": "^1.5.
|
|
48
|
+
"neo-cmp-cli": "^1.5.6",
|
|
48
49
|
"husky": "^4.2.5",
|
|
49
50
|
"lint-staged": "^10.2.9",
|
|
50
51
|
"prettier": "^2.0.5"
|
|
@@ -97,12 +97,12 @@ module.exports = {
|
|
|
97
97
|
}
|
|
98
98
|
*/
|
|
99
99
|
},
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// NeoCRM 平台配置
|
|
101
|
+
neoConfig: {
|
|
102
102
|
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
103
103
|
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
104
104
|
// NeoCRM 授权配置
|
|
105
|
-
|
|
105
|
+
auth: {
|
|
106
106
|
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
107
107
|
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
108
108
|
username: 'xx', // 用户在销售易系统中的用户名
|
|
@@ -111,7 +111,10 @@ module.exports = {
|
|
|
111
111
|
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
112
112
|
*/
|
|
113
113
|
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
pushCmp: {
|
|
117
|
+
// 用于构建并发布至 NeoCRM 的相关配置
|
|
115
118
|
/*
|
|
116
119
|
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
117
120
|
NODE_ENV: 'production',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "react-ts-custom-cmp-template",
|
|
3
3
|
"version": "1.1.1",
|
|
4
4
|
"description": "neo自定义组件模板(react&ts技术栈)",
|
|
5
|
+
"framework": "react-ts",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"自定义组件模板",
|
|
7
8
|
"react&ts技术栈",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"@commitlint/config-conventional": "^9.1.1",
|
|
47
48
|
"@types/react": "^16.9.11",
|
|
48
49
|
"@types/react-dom": "^16.9.15",
|
|
49
|
-
"neo-cmp-cli": "^1.5.
|
|
50
|
+
"neo-cmp-cli": "^1.5.6",
|
|
50
51
|
"husky": "^4.2.5",
|
|
51
52
|
"lint-staged": "^10.2.9",
|
|
52
53
|
"prettier": "^2.0.5"
|
|
@@ -105,12 +105,12 @@ module.exports = {
|
|
|
105
105
|
cssSourceMap: true
|
|
106
106
|
*/
|
|
107
107
|
},
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
// NeoCRM 平台配置
|
|
109
|
+
neoConfig: {
|
|
110
110
|
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
111
111
|
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
112
112
|
// NeoCRM 授权配置
|
|
113
|
-
|
|
113
|
+
auth: {
|
|
114
114
|
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
115
115
|
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
116
116
|
username: 'xx', // 用户在销售易系统中的用户名
|
|
@@ -119,7 +119,10 @@ module.exports = {
|
|
|
119
119
|
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
120
120
|
*/
|
|
121
121
|
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
122
|
-
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
pushCmp: {
|
|
125
|
+
// 用于构建并发布至 NeoCRM 的相关配置
|
|
123
126
|
/*
|
|
124
127
|
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
125
128
|
NODE_ENV: 'production',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "vue2-custom-cmp-template",
|
|
3
3
|
"version": "1.0.1",
|
|
4
4
|
"description": "neo自定义组件模板(vue2.0技术栈)",
|
|
5
|
+
"framework": "vue2.0",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"自定义组件模板",
|
|
7
8
|
"vue2.0技术栈",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@commitlint/cli": "^8.3.5",
|
|
46
47
|
"@commitlint/config-conventional": "^9.1.1",
|
|
47
|
-
"neo-cmp-cli": "^1.5.
|
|
48
|
+
"neo-cmp-cli": "^1.5.6",
|
|
48
49
|
"husky": "^4.2.5",
|
|
49
50
|
"lint-staged": "^10.2.9",
|
|
50
51
|
"prettier": "^2.0.5",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { consoleTag } = require('./neoParams');
|
|
2
|
+
/**
|
|
3
|
+
* 获取技术栈标识
|
|
4
|
+
* 目的:兼容用户非标准写法
|
|
5
|
+
* 0: React, 1: vue2, 2: jQuery, 3: vue3
|
|
6
|
+
*/
|
|
7
|
+
function getFramework(_framework) {
|
|
8
|
+
let defaultFramework = '0'; // 默认 React 技术栈
|
|
9
|
+
if (!_framework) {
|
|
10
|
+
return defaultFramework;
|
|
11
|
+
}
|
|
12
|
+
let curFramework = _framework.toLowerCase().trim();
|
|
13
|
+
switch (curFramework) {
|
|
14
|
+
case 'jquery':
|
|
15
|
+
case 'jq':
|
|
16
|
+
curFramework = '2';
|
|
17
|
+
break;
|
|
18
|
+
case 'vue2':
|
|
19
|
+
case 'vue 2':
|
|
20
|
+
case 'vue2.0':
|
|
21
|
+
case 'vue 2.0':
|
|
22
|
+
curFramework = '1';
|
|
23
|
+
break;
|
|
24
|
+
case 'vue':
|
|
25
|
+
case 'vue3':
|
|
26
|
+
case 'vue 3':
|
|
27
|
+
case 'vue3.0':
|
|
28
|
+
case 'vue 3.0':
|
|
29
|
+
curFramework = '3';
|
|
30
|
+
console.error(`${consoleTag} 暂不支持 vue3.0 技术栈。`);
|
|
31
|
+
break;
|
|
32
|
+
case 'react-js':
|
|
33
|
+
console.error(`${consoleTag} 暂不支持 react-js 技术栈。`);
|
|
34
|
+
curFramework = '0';
|
|
35
|
+
break;
|
|
36
|
+
case 'react':
|
|
37
|
+
case 'react-ts':
|
|
38
|
+
curFramework = '0';
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
curFramework = '0';
|
|
42
|
+
}
|
|
43
|
+
return curFramework;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
getFramework
|
|
48
|
+
};
|