neo-cmp-cli 1.7.5 → 1.7.6
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 +351 -197
- package/package.json +7 -5
- package/src/config/auth.config.js +25 -0
- package/src/config/default.config.js +25 -0
- package/src/initData/neo.config.js +20 -11
- package/src/module/index.js +135 -93
- package/src/module/main.js +6 -5
- package/src/module/neoInitByCopy.js +4 -3
- package/src/neo/neoLogin.js +545 -0
- package/src/neo/neoService.js +98 -13
- package/src/template/antd-custom-cmp-template/neo.config.js +19 -10
- package/src/template/echarts-custom-cmp-template/neo.config.js +20 -11
- package/src/template/empty-custom-cmp-template/neo.config.js +19 -10
- package/src/template/neo-custom-cmp-template/neo.config.js +15 -6
- package/src/template/react-custom-cmp-template/neo.config.js +19 -10
- package/src/template/react-ts-custom-cmp-template/neo.config.js +19 -10
- package/src/template/vue2-custom-cmp-template/README.md +79 -5
- package/src/template/vue2-custom-cmp-template/neo.config.js +19 -10
- package/test/deprecate-versions.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo-cmp-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.6",
|
|
4
4
|
"description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neo-cli",
|
|
@@ -43,18 +43,20 @@
|
|
|
43
43
|
"adm-zip": "^0.5.10",
|
|
44
44
|
"akfun": "^5.1.12",
|
|
45
45
|
"axios": "^0.27.2",
|
|
46
|
+
"babel-plugin-import": "^1.13.8",
|
|
46
47
|
"chalk": "^4.0.0",
|
|
47
48
|
"deepmerge": "^4.2.2",
|
|
49
|
+
"external-remotes-plugin": "^1.0.0",
|
|
48
50
|
"figlet": "^1.2.0",
|
|
49
51
|
"form-data": "^4.0.0",
|
|
50
52
|
"fs-extra": "^10.1.0",
|
|
51
53
|
"inquirer": "^7.3.3",
|
|
54
|
+
"lodash": "^4.17.21",
|
|
55
|
+
"open": "^8.4.2",
|
|
52
56
|
"ora": "^4.0.4",
|
|
57
|
+
"portfinder": "^1.0.38",
|
|
53
58
|
"webpack-sources": "^3.2.3",
|
|
54
|
-
"yargs": "^12.0.2"
|
|
55
|
-
"lodash": "^4.17.21",
|
|
56
|
-
"external-remotes-plugin": "^1.0.0",
|
|
57
|
-
"babel-plugin-import": "^1.13.8"
|
|
59
|
+
"yargs": "^12.0.2"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
62
|
"@commitlint/cli": "^8.3.5",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const curConfig = require('../config/index'); // 获取当前项目根目录下的配置文件
|
|
2
|
+
|
|
3
|
+
const neoConfig = curConfig.neoConfig || {};
|
|
4
|
+
const authConfig = neoConfig.auth || {};
|
|
5
|
+
|
|
6
|
+
// NeoCRM 跨 Pod 授权配置
|
|
7
|
+
module.exports = {
|
|
8
|
+
loginURL: neoConfig.loginURL || 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录 URL,从创建连接器的客户端信息中获取(Login_Url)
|
|
9
|
+
tokenAPI: neoConfig.tokenAPI || 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
10
|
+
redirectUri: neoConfig.redirectUri || 'http://localhost:1028', // 固定端口号,用于接收授权码
|
|
11
|
+
// 重定向 URI,动态生成
|
|
12
|
+
getRedirectURI: (port) => {
|
|
13
|
+
return `http://localhost:${port}`;
|
|
14
|
+
},
|
|
15
|
+
// 获取 授权码 相关配置
|
|
16
|
+
response_type: 'code', // 认证类型;此参数值必须为 code
|
|
17
|
+
client_id: authConfig.client_id || '04c8b45c4dbe36426a660bf70d3fe3e7', // 客户端 ID,跨 Pod 级链接器【内置】
|
|
18
|
+
scope: 'all', // 固定值:all
|
|
19
|
+
oauthType: 'standard', // 固定值:standard
|
|
20
|
+
access_type: 'offline', // 此参数值为 online 时,不产生 refresh_token ;此参数值为 offline 时,返回refresh_token
|
|
21
|
+
|
|
22
|
+
// 获取 令牌 相关配置
|
|
23
|
+
client_secret: authConfig.client_secret || '370817d1336a3737f95c671eea39a23b', // 客户端秘钥,跨 Pod 级链接器【内置】
|
|
24
|
+
grant_type: 'authorization_code' // 授权类型;此参数值必须为 authorization_code
|
|
25
|
+
};
|
|
@@ -133,6 +133,31 @@ const defaultNEOConfig = {
|
|
|
133
133
|
},
|
|
134
134
|
assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
|
|
135
135
|
},
|
|
136
|
+
// 授权码授权模式下的 NeoCRM 平台配置
|
|
137
|
+
neoConfig: {
|
|
138
|
+
authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
|
|
139
|
+
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
140
|
+
// 当 authType 为 oauth2 时,loginURL 配置项必填
|
|
141
|
+
loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
|
|
142
|
+
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token' // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
143
|
+
},
|
|
144
|
+
/*
|
|
145
|
+
// 密码授权模式下的 NeoCRM 平台配置
|
|
146
|
+
neoConfig: {
|
|
147
|
+
authType: 'password', // 授权类型,可选值:oauth2(默认)、password
|
|
148
|
+
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
149
|
+
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
150
|
+
// 当 authType 为 password 时,auth 配置项必填
|
|
151
|
+
auth: {
|
|
152
|
+
client_id: auth.client_id || 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
153
|
+
client_secret: auth.client_secret || 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
154
|
+
username: auth.username || 'xx', // 用户在销售易系统中的用户名
|
|
155
|
+
// password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
|
|
156
|
+
// 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
157
|
+
password: auth.password || 'xx xx', // 用户账户密码 + 8 位安全令牌
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
*/
|
|
136
161
|
pushCmp: {
|
|
137
162
|
output: {
|
|
138
163
|
filename: '[name].js',
|
|
@@ -97,22 +97,31 @@ module.exports = {
|
|
|
97
97
|
}
|
|
98
98
|
*/
|
|
99
99
|
},
|
|
100
|
-
// NeoCRM 平台配置
|
|
100
|
+
// 授权码授权模式下的 NeoCRM 平台配置
|
|
101
101
|
neoConfig: {
|
|
102
|
+
authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
|
|
103
|
+
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
104
|
+
// 当 authType 为 oauth2 时,loginURL 配置项必填
|
|
105
|
+
loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
|
|
106
|
+
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token' // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
107
|
+
},
|
|
108
|
+
/*
|
|
109
|
+
// 密码授权模式下的 NeoCRM 平台配置
|
|
110
|
+
neoConfig: {
|
|
111
|
+
authType: 'password', // 授权类型,可选值:oauth2(默认)、password
|
|
102
112
|
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
103
113
|
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
104
|
-
//
|
|
114
|
+
// 当 authType 为 password 时,auth 配置项必填
|
|
105
115
|
auth: {
|
|
106
|
-
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
107
|
-
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
108
|
-
username: 'xx', // 用户在销售易系统中的用户名
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
114
|
-
}
|
|
116
|
+
client_id: auth.client_id || 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
117
|
+
client_secret: auth.client_secret || 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
118
|
+
username: auth.username || 'xx', // 用户在销售易系统中的用户名
|
|
119
|
+
// password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
|
|
120
|
+
// 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
121
|
+
password: auth.password || 'xx xx', // 用户账户密码 + 8 位安全令牌
|
|
122
|
+
},
|
|
115
123
|
},
|
|
124
|
+
*/
|
|
116
125
|
pushCmp: {
|
|
117
126
|
// 用于构建并发布至 NeoCRM 的相关配置
|
|
118
127
|
/*
|
package/src/module/index.js
CHANGED
|
@@ -11,9 +11,11 @@ const { validateProjectName } = require('../utils/projectNameValidator.js');
|
|
|
11
11
|
const mainAction = require('./main.js'); // 入口文件
|
|
12
12
|
const getCmpTypeByDir = require('../utils/cmpUtils/getCmpTypeByDir.js');
|
|
13
13
|
const NeoService = require('../neo/neoService.js');
|
|
14
|
+
const NeoLoginService = require('../neo/neoLogin.js');
|
|
14
15
|
const curConfig = require('../config/index'); // 获取当前项目根目录下的配置文件
|
|
15
16
|
const hasNeoProject = require('../utils/projectUtils/hasNeoProject.js');
|
|
16
17
|
const consoleTag = require('../utils/neoParams').consoleTag;
|
|
18
|
+
const { errorLog, successLog } = require('../utils/common');
|
|
17
19
|
// neo 的 package 文件
|
|
18
20
|
const neoPackage = require('../../package.json');
|
|
19
21
|
|
|
@@ -57,7 +59,7 @@ yargs
|
|
|
57
59
|
(argv) => {
|
|
58
60
|
if (argv.type && argv.name) {
|
|
59
61
|
if (hasNeoProject()) {
|
|
60
|
-
|
|
62
|
+
errorLog(
|
|
61
63
|
`${consoleTag}创建自定义组件失败,当前目录(${process.cwd()})已经是一个自定义组件项目,请勿重复创建。`
|
|
62
64
|
);
|
|
63
65
|
process.exit(1);
|
|
@@ -135,7 +137,7 @@ yargs
|
|
|
135
137
|
// 验证项目名称是否合法
|
|
136
138
|
const { isValid, errors } = validateProjectName(ans.name);
|
|
137
139
|
if (!isValid) {
|
|
138
|
-
|
|
140
|
+
errorLog(errors.join('\n'));
|
|
139
141
|
process.exit(1);
|
|
140
142
|
}
|
|
141
143
|
|
|
@@ -161,87 +163,125 @@ yargs
|
|
|
161
163
|
neoConfigInit('neo.config.js');
|
|
162
164
|
}
|
|
163
165
|
)
|
|
166
|
+
.command(
|
|
167
|
+
'login',
|
|
168
|
+
'登录 NeoCRM 平台(OAuth2 授权)',
|
|
169
|
+
(yargs) => {
|
|
170
|
+
yargs
|
|
171
|
+
.reset()
|
|
172
|
+
.usage(titleTip('Usage') + ': $0 login')
|
|
173
|
+
.alias('h', 'help');
|
|
174
|
+
},
|
|
175
|
+
async () => {
|
|
176
|
+
try {
|
|
177
|
+
const loginService = new NeoLoginService(curConfig.neoConfig);
|
|
178
|
+
await loginService.login();
|
|
179
|
+
} catch (error) {
|
|
180
|
+
errorLog(`\n登录失败: ${error.message}`);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
.command(
|
|
186
|
+
'logout',
|
|
187
|
+
'登出 NeoCRM 平台',
|
|
188
|
+
(yargs) => {
|
|
189
|
+
yargs
|
|
190
|
+
.reset()
|
|
191
|
+
.usage(titleTip('Usage') + ': $0 logout')
|
|
192
|
+
.alias('h', 'help');
|
|
193
|
+
},
|
|
194
|
+
async () => {
|
|
195
|
+
try {
|
|
196
|
+
const loginService = new NeoLoginService(curConfig.neoConfig);
|
|
197
|
+
await loginService.logout();
|
|
198
|
+
} catch (error) {
|
|
199
|
+
errorLog(`\n登出失败: ${error.message}`);
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
)
|
|
164
204
|
.command('create', '创建项目或者组件', (yargs) => {
|
|
165
205
|
return yargs
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
.command(
|
|
207
|
+
'project [options]',
|
|
208
|
+
'创建自定义组件项目(含工程代码)',
|
|
209
|
+
(yargs) => {
|
|
210
|
+
yargs
|
|
211
|
+
.reset()
|
|
212
|
+
.usage(titleTip('Usage') + ': $0 project [options]')
|
|
213
|
+
.option('name', {
|
|
214
|
+
alias: 'n',
|
|
215
|
+
describe: '自定义组件项目名称'
|
|
216
|
+
})
|
|
217
|
+
.alias('h', 'help');
|
|
218
|
+
},
|
|
219
|
+
(argv) => {
|
|
220
|
+
if (argv.name) {
|
|
221
|
+
mainAction.createCmpProjectByTemplate(argv.name);
|
|
222
|
+
} else {
|
|
223
|
+
const questions = [
|
|
224
|
+
{
|
|
225
|
+
name: 'name',
|
|
226
|
+
type: 'input',
|
|
227
|
+
message: '请设置自定义组件项目名称:'
|
|
228
|
+
}
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
inquirer.prompt(questions).then((ans) => {
|
|
232
|
+
// 验证项目名称是否合法
|
|
233
|
+
const { isValid, errors } = validateProjectName(ans.name);
|
|
234
|
+
if (!isValid) {
|
|
235
|
+
errorLog(errors.join('\n'));
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (!ans.name) {
|
|
240
|
+
errorLog('自定义组件项目名称不能为空。');
|
|
241
|
+
process.exit(1);
|
|
242
|
+
} else {
|
|
243
|
+
mainAction.createCmpProjectByTemplate(ans.name);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
206
247
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
}
|
|
248
|
+
)
|
|
249
|
+
.command(
|
|
250
|
+
'cmp [options]',
|
|
251
|
+
'创建自定义组件',
|
|
252
|
+
(yargs) => {
|
|
253
|
+
yargs
|
|
254
|
+
.reset()
|
|
255
|
+
.usage(titleTip('Usage') + ': $0 cmp [options]')
|
|
256
|
+
.option('name', {
|
|
257
|
+
alias: 'n',
|
|
258
|
+
describe: '自定义组件名称'
|
|
259
|
+
})
|
|
260
|
+
.alias('h', 'help');
|
|
261
|
+
},
|
|
262
|
+
(argv) => {
|
|
263
|
+
if (argv.name) {
|
|
264
|
+
mainAction.createCmpByTemplate(argv.name);
|
|
265
|
+
} else {
|
|
266
|
+
const questions = [
|
|
267
|
+
{
|
|
268
|
+
name: 'name',
|
|
269
|
+
type: 'input',
|
|
270
|
+
message: '请设置自定义组件名称:'
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
inquirer.prompt(questions).then((ans) => {
|
|
275
|
+
if (!ans.name) {
|
|
276
|
+
errorLog('自定义组件名称不能为空。');
|
|
277
|
+
process.exit(1);
|
|
278
|
+
} else {
|
|
279
|
+
mainAction.createCmpByTemplate(ans.name);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
242
283
|
}
|
|
243
|
-
|
|
244
|
-
)
|
|
284
|
+
);
|
|
245
285
|
})
|
|
246
286
|
.command(
|
|
247
287
|
'pull cmp [options]',
|
|
@@ -265,7 +305,7 @@ yargs
|
|
|
265
305
|
const spinner = ora('正在拉取线上自定义组件列表...').start();
|
|
266
306
|
const cmpList = await neoService.getCustomCmpList();
|
|
267
307
|
if (cmpList.length === 0) {
|
|
268
|
-
|
|
308
|
+
errorLog('当前租户暂无任何自定义组件。');
|
|
269
309
|
process.exit(1);
|
|
270
310
|
}
|
|
271
311
|
spinner.stop('线上自定义组件列表拉取成功。');
|
|
@@ -283,7 +323,7 @@ yargs
|
|
|
283
323
|
];
|
|
284
324
|
inquirer.prompt(questions).then((ans) => {
|
|
285
325
|
if (!ans.cmpType) {
|
|
286
|
-
|
|
326
|
+
errorLog('自定义组件名称不能为空。');
|
|
287
327
|
process.exit(1);
|
|
288
328
|
} else {
|
|
289
329
|
mainAction.pullCmp(ans.cmpType, neoService);
|
|
@@ -314,7 +354,7 @@ yargs
|
|
|
314
354
|
const spinner = ora('正在获取线上自定义组件列表...').start();
|
|
315
355
|
const cmpList = await neoService.getCustomCmpList();
|
|
316
356
|
if (cmpList.length === 0) {
|
|
317
|
-
|
|
357
|
+
errorLog('当前租户暂无任何自定义组件。');
|
|
318
358
|
process.exit(1);
|
|
319
359
|
}
|
|
320
360
|
spinner.stop('线上自定义组件列表获取成功。');
|
|
@@ -332,7 +372,7 @@ yargs
|
|
|
332
372
|
];
|
|
333
373
|
inquirer.prompt(questions).then((ans) => {
|
|
334
374
|
if (!ans.cmpType) {
|
|
335
|
-
|
|
375
|
+
errorLog('自定义组件名称不能为空。');
|
|
336
376
|
process.exit(1);
|
|
337
377
|
} else {
|
|
338
378
|
mainAction.deleteCmp(ans.cmpType, neoService);
|
|
@@ -360,7 +400,7 @@ yargs
|
|
|
360
400
|
} else {
|
|
361
401
|
const cmpTypes = getCmpTypeByDir();
|
|
362
402
|
if (cmpTypes.length === 0) {
|
|
363
|
-
|
|
403
|
+
errorLog('当前自定义组件目录中未找到自定义组件。(./src/components 目录下)');
|
|
364
404
|
process.exit(1);
|
|
365
405
|
}
|
|
366
406
|
const cmpTypeChoices = cmpTypes.map((cmpType) => ({
|
|
@@ -377,7 +417,7 @@ yargs
|
|
|
377
417
|
];
|
|
378
418
|
inquirer.prompt(questions).then((ans) => {
|
|
379
419
|
if (!ans.cmpType) {
|
|
380
|
-
|
|
420
|
+
errorLog('未选择要预览的自定义组件。');
|
|
381
421
|
process.exit(1);
|
|
382
422
|
}
|
|
383
423
|
mainAction.previewCmp(ans.cmpType);
|
|
@@ -456,7 +496,7 @@ yargs
|
|
|
456
496
|
} else {
|
|
457
497
|
const cmpTypes = getCmpTypeByDir();
|
|
458
498
|
if (cmpTypes.length === 0) {
|
|
459
|
-
|
|
499
|
+
errorLog('当前自定义组件目录中未找到自定义组件。(./src/components 目录下)');
|
|
460
500
|
process.exit(1);
|
|
461
501
|
}
|
|
462
502
|
const cmpTypeChoices = cmpTypes.map((cmpType) => ({
|
|
@@ -473,7 +513,7 @@ yargs
|
|
|
473
513
|
];
|
|
474
514
|
inquirer.prompt(questions).then((ans) => {
|
|
475
515
|
if (!ans.cmpType) {
|
|
476
|
-
|
|
516
|
+
errorLog('未选择要发布的自定义组件。');
|
|
477
517
|
process.exit(1);
|
|
478
518
|
}
|
|
479
519
|
mainAction.publish2oss(ans.cmpType);
|
|
@@ -500,7 +540,7 @@ yargs
|
|
|
500
540
|
} else {
|
|
501
541
|
const cmpTypes = getCmpTypeByDir();
|
|
502
542
|
if (cmpTypes.length === 0) {
|
|
503
|
-
|
|
543
|
+
errorLog('当前自定义组件目录中未找到自定义组件。(./src/components 目录下)');
|
|
504
544
|
process.exit(1);
|
|
505
545
|
}
|
|
506
546
|
const cmpTypeChoices = cmpTypes.map((cmpType) => ({
|
|
@@ -517,7 +557,7 @@ yargs
|
|
|
517
557
|
];
|
|
518
558
|
inquirer.prompt(questions).then((ans) => {
|
|
519
559
|
if (!ans.cmpType) {
|
|
520
|
-
|
|
560
|
+
errorLog('未选择要发布的自定义组件。');
|
|
521
561
|
process.exit(1);
|
|
522
562
|
}
|
|
523
563
|
mainAction.pushCmp(ans.cmpType);
|
|
@@ -588,7 +628,7 @@ yargs
|
|
|
588
628
|
.alias('v', 'version')
|
|
589
629
|
.strict()
|
|
590
630
|
.fail((msg, err, yargs) => {
|
|
591
|
-
|
|
631
|
+
errorLog(`\n运行命令时发生错误: ${msg}。\n`);
|
|
592
632
|
console.log(titleTip('当前可用命令列表:'));
|
|
593
633
|
console.log('');
|
|
594
634
|
// 定义所有可用命令及其描述
|
|
@@ -597,8 +637,6 @@ yargs
|
|
|
597
637
|
// { cmd: 'config init', desc: '创建 neo.config.js 配置文件' },
|
|
598
638
|
{ cmd: 'create project [options]', desc: '创建自定义组件项目(含工程代码)' },
|
|
599
639
|
{ cmd: 'create cmp [options]', desc: '创建自定义组件' },
|
|
600
|
-
{ cmd: 'pull cmp [options]', desc: '拉取线上自定义组件' },
|
|
601
|
-
{ cmd: 'delete cmp [options]', desc: '删除线上自定义组件' },
|
|
602
640
|
{ cmd: 'preview [options]', desc: '预览指定自定义组件(仅预览组件本身内容)' },
|
|
603
641
|
// { cmd: 'dev', desc: '开启本地调试模式' },
|
|
604
642
|
{ cmd: 'linkDebug', desc: '开启外链调试模式(在线上页面设计器端调试)' },
|
|
@@ -606,8 +644,12 @@ yargs
|
|
|
606
644
|
// { cmd: 'build2lib', desc: '构建 UMD 模块' },
|
|
607
645
|
// { cmd: 'build2esm', desc: '构建 ESM 模块' },
|
|
608
646
|
// { cmd: 'publish2oss [options]', desc: '发布到oss' },
|
|
609
|
-
{ cmd: 'push cmp [options]', desc: '构建并发布自定义组件到 NeoCRM 平台' },
|
|
610
647
|
// { cmd: 'inspect', desc: '输出当前配置文件' },
|
|
648
|
+
{ cmd: 'login', desc: '登录 NeoCRM 平台(OAuth2 授权)' },
|
|
649
|
+
{ cmd: 'logout', desc: '登出 NeoCRM 平台' },
|
|
650
|
+
{ cmd: 'pull cmp [options]', desc: '拉取线上自定义组件' },
|
|
651
|
+
{ cmd: 'delete cmp [options]', desc: '删除线上自定义组件' },
|
|
652
|
+
{ cmd: 'push cmp [options]', desc: '构建并发布自定义组件到 NeoCRM 平台' },
|
|
611
653
|
{ cmd: 'open [options]', desc: '使用 Cursor 或 VSCode 打开项目' }
|
|
612
654
|
];
|
|
613
655
|
commands.forEach(({ cmd, desc }) => {
|
package/src/module/main.js
CHANGED
|
@@ -19,6 +19,7 @@ const createCmpProjectByTemplate = require('../utils/projectUtils/createCmpProje
|
|
|
19
19
|
const pullCmp = require('../utils/cmpUtils/pullCmp');
|
|
20
20
|
const deleteCmp = require('../utils/cmpUtils/deleteCmp');
|
|
21
21
|
const openProject = require('../utils/projectUtils/openProject');
|
|
22
|
+
const { errorLog, successLog } = require('../utils/common');
|
|
22
23
|
|
|
23
24
|
const getValue = (originValue, defaultValue) => {
|
|
24
25
|
return originValue !== undefined ? originValue : defaultValue;
|
|
@@ -109,7 +110,7 @@ function setupEntries(config, options) {
|
|
|
109
110
|
console.info('已自动生成 entry 入口配置:', entries);
|
|
110
111
|
}
|
|
111
112
|
} catch (error) {
|
|
112
|
-
|
|
113
|
+
errorLog(error.message);
|
|
113
114
|
process.exit(1);
|
|
114
115
|
}
|
|
115
116
|
|
|
@@ -155,7 +156,7 @@ module.exports = {
|
|
|
155
156
|
createCmpByTemplate,
|
|
156
157
|
dev: () => {
|
|
157
158
|
if (!curConfig.dev) {
|
|
158
|
-
|
|
159
|
+
errorLog('未找到 dev 相关配置。');
|
|
159
160
|
process.exit(1);
|
|
160
161
|
}
|
|
161
162
|
akfun.dev(curConfig, consoleTag);
|
|
@@ -163,11 +164,11 @@ module.exports = {
|
|
|
163
164
|
previewCmp: (cmpName) => {
|
|
164
165
|
// 预览组件本身内容
|
|
165
166
|
if (!cmpName) {
|
|
166
|
-
|
|
167
|
+
errorLog('请输入要预览的组件名称。');
|
|
167
168
|
process.exit(1);
|
|
168
169
|
}
|
|
169
170
|
if (!curConfig.preview) {
|
|
170
|
-
|
|
171
|
+
errorLog('未找到 preview 相关配置。');
|
|
171
172
|
process.exit(1);
|
|
172
173
|
}
|
|
173
174
|
curConfig.dev = Object.assign(curConfig.dev, curConfig.preview); // 将 preview 设置给 dev
|
|
@@ -178,7 +179,7 @@ module.exports = {
|
|
|
178
179
|
linkDebug: () => {
|
|
179
180
|
// 外链调试模式
|
|
180
181
|
if (!curConfig.linkDebug) {
|
|
181
|
-
|
|
182
|
+
errorLog('未找到 debug 相关配置。');
|
|
182
183
|
process.exit(1);
|
|
183
184
|
}
|
|
184
185
|
// 将 linkDebug 设置给 dev
|
|
@@ -4,6 +4,7 @@ const { consoleTag } = require('../utils/neoParams'); // 输出标记
|
|
|
4
4
|
const { replaceInPackage } = require('../utils/replaceInPackage');
|
|
5
5
|
const { resetPackageVersion } = require('../utils/resetPackageVersion');
|
|
6
6
|
const autoEntryRootDir = require('../utils/autoEntryRootDir');
|
|
7
|
+
const { errorLog } = require('../utils/common');
|
|
7
8
|
|
|
8
9
|
const templateList = {
|
|
9
10
|
react: {
|
|
@@ -14,7 +15,7 @@ const templateList = {
|
|
|
14
15
|
projectName: 'react-ts-custom-cmp-template',
|
|
15
16
|
dir: path.resolve(__dirname, '../template/react-ts-custom-cmp-template')
|
|
16
17
|
},
|
|
17
|
-
|
|
18
|
+
antd: {
|
|
18
19
|
projectName: 'antd-custom-cmp-template',
|
|
19
20
|
dir: path.resolve(__dirname, '../template/antd-custom-cmp-template')
|
|
20
21
|
},
|
|
@@ -22,7 +23,7 @@ const templateList = {
|
|
|
22
23
|
projectName: 'echarts-custom-cmp-template',
|
|
23
24
|
dir: path.resolve(__dirname, '../template/echarts-custom-cmp-template')
|
|
24
25
|
},
|
|
25
|
-
|
|
26
|
+
neo: {
|
|
26
27
|
projectName: 'neo-custom-cmp-template',
|
|
27
28
|
dir: path.resolve(__dirname, '../template/neo-custom-cmp-template')
|
|
28
29
|
},
|
|
@@ -54,7 +55,7 @@ const neoInitByCopy = function (type, projectName) {
|
|
|
54
55
|
// 自动切换到项目根目录
|
|
55
56
|
autoEntryRootDir(finalProjectPath);
|
|
56
57
|
})
|
|
57
|
-
.catch((err) =>
|
|
58
|
+
.catch((err) => errorLog(`${consoleTag}自定义组件模板下载失败:`, err));
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
module.exports = neoInitByCopy;
|