lightshortcuts 1.1.1 → 1.1.2
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/bin/lsc.js +55 -22
- package/lib/LSC.js +2 -2
- package/lib/core/api.js +3 -3
- package/lib/defaults.js +3 -0
- package/lsc.config.json +9 -12
- package/package.json +1 -1
package/bin/lsc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { writeFile } = require("fs");
|
|
3
|
+
const { writeFile, existsSync } = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const { Command } = require("commander");
|
|
6
6
|
const inquirer = require("inquirer");
|
|
@@ -29,10 +29,14 @@ const info = (message, ...args) => {
|
|
|
29
29
|
// 主目录下登录配置文件
|
|
30
30
|
let confPath = path.join(process.cwd(), "./lsc.config.json");
|
|
31
31
|
// 读取发布配置文件
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const currentDirConfig = path.join(process.cwd(), ".lscrc.json");
|
|
33
|
+
const homeDirConfig = path.join(
|
|
34
|
+
process.env.HOME || process.env.USERPROFILE,
|
|
34
35
|
".lscrc.json",
|
|
35
36
|
);
|
|
37
|
+
const lscrcPath = existsSync(currentDirConfig)
|
|
38
|
+
? currentDirConfig
|
|
39
|
+
: homeDirConfig;
|
|
36
40
|
|
|
37
41
|
const defaultConfig = require("../lib/defaults");
|
|
38
42
|
const {
|
|
@@ -46,7 +50,7 @@ const {
|
|
|
46
50
|
sendWechatWebhook,
|
|
47
51
|
} = require("../lib/core/api");
|
|
48
52
|
|
|
49
|
-
program.version("1.1.
|
|
53
|
+
program.version("1.1.2");
|
|
50
54
|
|
|
51
55
|
// 登录并保存token
|
|
52
56
|
let lightBaseURL = "";
|
|
@@ -97,6 +101,7 @@ let loginQuestions = [
|
|
|
97
101
|
const { user_token } = await submitLogin({
|
|
98
102
|
account: answers.account,
|
|
99
103
|
password: ps,
|
|
104
|
+
maxRetries: 1,
|
|
100
105
|
});
|
|
101
106
|
if (user_token) {
|
|
102
107
|
answers.token = user_token;
|
|
@@ -167,7 +172,7 @@ const loginAction = async function (env) {
|
|
|
167
172
|
// log("登录响应:", res);
|
|
168
173
|
if (autoLoginRes.user_token) {
|
|
169
174
|
log(
|
|
170
|
-
|
|
175
|
+
`登录成功!欢迎${autoLoginRes.user?.identity_name}`,
|
|
171
176
|
autoLoginRes.user_token,
|
|
172
177
|
);
|
|
173
178
|
//更新当前发布配置里面的token
|
|
@@ -266,8 +271,8 @@ program
|
|
|
266
271
|
program
|
|
267
272
|
.command("md5")
|
|
268
273
|
.description("获取MD5密码")
|
|
269
|
-
.option("-p, --password <type>", "输入密码")
|
|
270
274
|
.option("-e, --email <type>", "输入邮箱")
|
|
275
|
+
.option("-p, --password <type>", "输入密码")
|
|
271
276
|
.action(async (opts) => {
|
|
272
277
|
let { password, email } = opts;
|
|
273
278
|
//如何没有密码或者邮箱,通过交互式输入
|
|
@@ -276,13 +281,13 @@ program
|
|
|
276
281
|
.prompt([
|
|
277
282
|
{
|
|
278
283
|
type: "input",
|
|
279
|
-
name: "
|
|
280
|
-
message: "
|
|
284
|
+
name: "email",
|
|
285
|
+
message: "请输入邮箱:",
|
|
281
286
|
},
|
|
282
287
|
{
|
|
283
288
|
type: "input",
|
|
284
|
-
name: "
|
|
285
|
-
message: "
|
|
289
|
+
name: "password",
|
|
290
|
+
message: "请输入密码:",
|
|
286
291
|
},
|
|
287
292
|
])
|
|
288
293
|
.then((answers) => {
|
|
@@ -365,6 +370,13 @@ program
|
|
|
365
370
|
type: "input",
|
|
366
371
|
message: "请输入离线包id:",
|
|
367
372
|
name: "pkgid",
|
|
373
|
+
validate: (input) => {
|
|
374
|
+
if (!input || (typeof input === 'string' && input.trim() === '')) {
|
|
375
|
+
return "请输入离线包id";
|
|
376
|
+
}
|
|
377
|
+
return true;
|
|
378
|
+
},
|
|
379
|
+
filter: (input) => typeof input === 'string' ? input.trim() : input,
|
|
368
380
|
},
|
|
369
381
|
{
|
|
370
382
|
type: "input",
|
|
@@ -437,28 +449,49 @@ program
|
|
|
437
449
|
{ key: 2, value: 2, name: "结束" },
|
|
438
450
|
],
|
|
439
451
|
},
|
|
452
|
+
{
|
|
453
|
+
type: "confirm",
|
|
454
|
+
message: "是否要发布H5web应用?",
|
|
455
|
+
name: "publishH5webF",
|
|
456
|
+
default: false,
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
type: "input",
|
|
460
|
+
message: "请填写H5web应用ID,多个ID用逗号隔开:",
|
|
461
|
+
name: "publish_h5web_arr",
|
|
462
|
+
when: (answers) => answers.publishH5webF,
|
|
463
|
+
validate: (input) => {
|
|
464
|
+
if (!input || (typeof input === "string" && input.trim() === "")) {
|
|
465
|
+
return "请填写H5web应用ID";
|
|
466
|
+
}
|
|
467
|
+
return true;
|
|
468
|
+
},
|
|
469
|
+
filter: (input) => {
|
|
470
|
+
if (typeof input !== "string") return [];
|
|
471
|
+
return input
|
|
472
|
+
.trim()
|
|
473
|
+
.split(",")
|
|
474
|
+
.map((id) => id.trim())
|
|
475
|
+
.filter(Boolean);
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
type: "confirm",
|
|
480
|
+
message: "是否开启企业微信推送?",
|
|
481
|
+
name: "need_wechat_push",
|
|
482
|
+
default: false,
|
|
483
|
+
},
|
|
440
484
|
{
|
|
441
485
|
type: "input",
|
|
442
486
|
message: "发布日志:",
|
|
443
487
|
name: "release_desc",
|
|
444
488
|
default: "功能更新",
|
|
445
489
|
when: (answers) => {
|
|
490
|
+
delete answers.publishH5webF;
|
|
446
491
|
initAnswers = Object.assign({}, answers);
|
|
447
|
-
// log("initAnswers",initAnswers);
|
|
448
492
|
return true;
|
|
449
493
|
},
|
|
450
494
|
},
|
|
451
|
-
// {
|
|
452
|
-
// type: "input",
|
|
453
|
-
// message: "请输入API前缀地址:",
|
|
454
|
-
// name: "lightBaseURL",
|
|
455
|
-
// default: "https://xxx.xxx.xxx/lightadmin/pas-api",
|
|
456
|
-
// when: (answers) => {
|
|
457
|
-
// initAnswers = Object.assign({}, answers);
|
|
458
|
-
// // log("initAnswers",initAnswers);
|
|
459
|
-
// return true;
|
|
460
|
-
// },
|
|
461
|
-
// },
|
|
462
495
|
{
|
|
463
496
|
type: "confirm",
|
|
464
497
|
message: "是否使用以上配置?",
|
package/lib/LSC.js
CHANGED
|
@@ -158,7 +158,7 @@ async function publish(h5pkgid, app_id, app_name = "") {
|
|
|
158
158
|
async function Main(h5pkgid, ids) {
|
|
159
159
|
let tokenIsReady = await checkSession();
|
|
160
160
|
if (tokenIsReady) {
|
|
161
|
-
info("
|
|
161
|
+
info("会话有效,启动离线包发布流程!");
|
|
162
162
|
const appList = await queryApp();
|
|
163
163
|
// log("查询APP列表", appList);
|
|
164
164
|
//检验APP列表是否包含ids中的所有应用
|
|
@@ -230,7 +230,7 @@ const publishH5web = async (pkg_id_arr, app_name = "") => {
|
|
|
230
230
|
async function MainH5web(publish_h5web_arr) {
|
|
231
231
|
let tokenIsReady = await checkSession();
|
|
232
232
|
if (tokenIsReady) {
|
|
233
|
-
info("
|
|
233
|
+
info("会话有效,启动H5web发布流程!");
|
|
234
234
|
let chkH5webid = await queryCompList();
|
|
235
235
|
let chkPkg = checkH5webAppIds(chkH5webid, publish_h5web_arr); //过滤id,只处理存在H5web离线包发布
|
|
236
236
|
if (chkPkg && chkPkg.length > 0) {
|
package/lib/core/api.js
CHANGED
|
@@ -143,7 +143,7 @@ const getCaptcha = async function () {
|
|
|
143
143
|
// 返回结果
|
|
144
144
|
return { captchaId, captchaText };
|
|
145
145
|
} catch (error) {
|
|
146
|
-
log(
|
|
146
|
+
log(`\n获取验证码失败: ${error}`);
|
|
147
147
|
throw error;
|
|
148
148
|
}
|
|
149
149
|
},
|
|
@@ -193,7 +193,7 @@ const ocrCaptcha = async function (base64) {
|
|
|
193
193
|
);
|
|
194
194
|
};
|
|
195
195
|
//表单登录接受传入登录账号密码,返回token
|
|
196
|
-
const submitLogin = async function (loginData = { account: "", password: "" }) {
|
|
196
|
+
const submitLogin = async function (loginData = { account: "", password: "",maxRetries: 3 }) {
|
|
197
197
|
return retryWrapper(
|
|
198
198
|
async () => {
|
|
199
199
|
// 校验登录账号密码是否为空
|
|
@@ -243,7 +243,7 @@ const submitLogin = async function (loginData = { account: "", password: "" }) {
|
|
|
243
243
|
}
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
|
-
maxRetries:
|
|
246
|
+
maxRetries: 3,
|
|
247
247
|
delay: 3000,
|
|
248
248
|
retryMessage: "登录",
|
|
249
249
|
},
|
package/lib/defaults.js
CHANGED
|
@@ -15,6 +15,9 @@ var defaults = {
|
|
|
15
15
|
pkg_dir: "./dist/", //离线包所在路径
|
|
16
16
|
release_desc: "功能更新", //发布日志
|
|
17
17
|
task_status: "0", //对上一版本的处理:0:发布,1:暂停,2:下架
|
|
18
|
+
need_wechat_push: false, //是否需要企业微信推送
|
|
19
|
+
webhookUrl: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXXX", //企业微信推送Webhook地址
|
|
20
|
+
publish_h5web_arr: [], //发布到指定H5web应用,默认不发布
|
|
18
21
|
},
|
|
19
22
|
lightBaseURL: "http://new-light-dev.ghzq",
|
|
20
23
|
};
|
package/lsc.config.json
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"pkgid": "
|
|
3
|
-
"need_wechat_push": false,
|
|
2
|
+
"pkgid": "news",
|
|
4
3
|
"set_pkg_version": "1.0.1",
|
|
5
4
|
"ios_version_scope": "7.0.7",
|
|
6
5
|
"android_version_scope": "7.0.7.0",
|
|
7
6
|
"harmony_version_scope": "1.0.1",
|
|
8
7
|
"publish_app_arr": [
|
|
9
|
-
"3542"
|
|
8
|
+
"3542",
|
|
9
|
+
"3543"
|
|
10
10
|
],
|
|
11
11
|
"pkg_dir": "./dist/",
|
|
12
|
-
"pkg_zip_name": "
|
|
12
|
+
"pkg_zip_name": "news",
|
|
13
13
|
"task_status": 2,
|
|
14
|
+
"publishH5web": true,
|
|
15
|
+
"publish_h5web_arr": [
|
|
16
|
+
"323",
|
|
17
|
+
"533m"
|
|
18
|
+
],
|
|
14
19
|
"apps_name": {
|
|
15
20
|
"3542": "开发版",
|
|
16
21
|
"3543": "仿真版"
|
|
17
|
-
},
|
|
18
|
-
"publish_h5web_arr": [
|
|
19
|
-
"8112734868610136",
|
|
20
|
-
"8112734868610049"
|
|
21
|
-
],
|
|
22
|
-
"h5web_name": {
|
|
23
|
-
"8112734868610136": "账户分析PC公版",
|
|
24
|
-
"8112734868610049": "账户分析超级终端版"
|
|
25
22
|
}
|
|
26
23
|
}
|