lightshortcuts 1.1.1 → 1.1.3

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 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 lscrcPath = path.join(
33
- process.cwd() || process.env.HOME || process.env.USERPROFILE,
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.1");
53
+ program.version("1.1.3");
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
- `登录成功欢迎${autoLoginRes.user?.identity_name}`,
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: "password",
280
- message: "请输入密码:",
284
+ name: "email",
285
+ message: "请输入邮箱:",
281
286
  },
282
287
  {
283
288
  type: "input",
284
- name: "email",
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: "是否使用以上配置?",
@@ -476,10 +509,11 @@ program
476
509
  },
477
510
  ])
478
511
  .then((asw) => {
479
- let { useConfig, saveConfig } = asw;
512
+ let { useConfig, saveConfig ,release_desc} = asw;
480
513
  if (useConfig) {
481
514
  let totalConfig = {
482
515
  ...initAnswers,
516
+ release_desc,
483
517
  apps_name: defaultConfig.publishInfo.apps_name,
484
518
  };
485
519
  if (saveConfig) {