neo-cmp-cli 1.7.3 → 1.7.5-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 +355 -201
- package/package.json +7 -5
- package/src/config/auth.config.js +23 -0
- package/src/config/default.config.js +25 -0
- package/src/initData/neo.config.js +20 -11
- package/src/module/index.js +122 -80
- package/src/neo/neoLogin.js +451 -0
- package/src/neo/neoService.js +86 -8
- package/src/template/antd-custom-cmp-template/neo.config.js +19 -10
- package/src/template/antd-custom-cmp-template/package.json +1 -1
- package/src/template/echarts-custom-cmp-template/neo.config.js +20 -11
- package/src/template/echarts-custom-cmp-template/package.json +1 -1
- package/src/template/empty-custom-cmp-template/neo.config.js +19 -10
- package/src/template/empty-custom-cmp-template/package.json +1 -1
- package/src/template/neo-custom-cmp-template/neo.config.js +15 -6
- package/src/template/neo-custom-cmp-template/package.json +1 -1
- package/src/template/react-custom-cmp-template/neo.config.js +19 -10
- package/src/template/react-custom-cmp-template/package.json +1 -1
- package/src/template/react-ts-custom-cmp-template/neo.config.js +19 -10
- package/src/template/react-ts-custom-cmp-template/package.json +1 -1
- package/src/template/vue2-custom-cmp-template/neo.config.js +19 -10
- package/src/template/vue2-custom-cmp-template/package.json +1 -1
- package/src/utils/cmpUtils/createCmpByZip.js +6 -0
- 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.5-beta.1",
|
|
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,23 @@
|
|
|
1
|
+
const curConfig = require('../config/index'); // 获取当前项目根目录下的配置文件
|
|
2
|
+
|
|
3
|
+
const authConfig = curConfig.neoConfig || {};
|
|
4
|
+
|
|
5
|
+
// NeoCRM 跨 Pod 授权配置
|
|
6
|
+
module.exports = {
|
|
7
|
+
loginURL: authConfig.loginURL || 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录 URL,从创建连接器的客户端信息中获取(Login_Url)
|
|
8
|
+
tokenAPI: authConfig.tokenAPI || 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
9
|
+
// 重定向 URI,动态生成
|
|
10
|
+
getRedirectURI: (port) => {
|
|
11
|
+
return `http://localhost:${port}`;
|
|
12
|
+
},
|
|
13
|
+
// 获取 授权码 相关配置
|
|
14
|
+
response_type: 'code', // 认证类型;此参数值必须为 code
|
|
15
|
+
client_id: '04c8b45c4dbe36426a660bf70d3fe3e7', // 客户端 ID,跨 Pod 级链接器【内置】
|
|
16
|
+
scope: 'all', // 固定值:all
|
|
17
|
+
oauthType: 'standard', // 固定值:standard
|
|
18
|
+
access_type: 'offline', // 此参数值为 online 时,不产生 refresh_token ;此参数值为 offline 时,返回refresh_token
|
|
19
|
+
|
|
20
|
+
// 获取 令牌 相关配置
|
|
21
|
+
client_secret: '370817d1336a3737f95c671eea39a23b', // 客户端秘钥,跨 Pod 级链接器【内置】
|
|
22
|
+
grant_type: 'authorization_code' // 授权类型;此参数值必须为 authorization_code
|
|
23
|
+
};
|
|
@@ -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,6 +11,8 @@ 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');
|
|
15
|
+
const authConfig = require('../config/auth.config.js');
|
|
14
16
|
const curConfig = require('../config/index'); // 获取当前项目根目录下的配置文件
|
|
15
17
|
const hasNeoProject = require('../utils/projectUtils/hasNeoProject.js');
|
|
16
18
|
const consoleTag = require('../utils/neoParams').consoleTag;
|
|
@@ -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(authConfig);
|
|
178
|
+
await loginService.login();
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error(chalk.red(`\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(authConfig);
|
|
197
|
+
await loginService.logout();
|
|
198
|
+
} catch (error) {
|
|
199
|
+
console.error(chalk.red(`\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
|
+
console.error(errors.join('\n'));
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (!ans.name) {
|
|
240
|
+
console.error('自定义组件项目名称不能为空。');
|
|
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
|
+
console.error('自定义组件名称不能为空。');
|
|
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]',
|
|
@@ -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 }) => {
|