lightshortcuts 1.0.1 → 1.0.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/README.md CHANGED
@@ -6,16 +6,32 @@
6
6
 
7
7
  1. 安装
8
8
 
9
- ```bash
9
+ 使用npm或yarn进行全局安装,Linux系统需要管理员权限:
10
+
11
+ ```
10
12
  npm install -g lightshortcuts
11
13
  ```
12
14
 
15
+ 升级包:
16
+
17
+ ```shell
18
+ npm update -g lightshortcuts
19
+ ```
20
+
13
21
  2. 初始化发布配置
14
22
 
23
+ 方式一:使用模板一键初始化:
24
+
15
25
  ```bash
16
26
  lsc init
17
27
  ```
18
28
 
29
+ 方式二:交互模式进行创建:
30
+
31
+ ```bash
32
+ lsc config
33
+ ```
34
+
19
35
  之后将在当前路径下创建发布配置文件lsc.config.json,请打开文件,根据需要做相应修改:
20
36
 
21
37
  ```json
package/bin/lsc.js CHANGED
@@ -12,12 +12,13 @@ const loadModSync = require("../lib/helpers/loadModSync");
12
12
  // 读取发布配置文件
13
13
  const defaultConfig = require("../lib/defaults");
14
14
  const { checkSession } = require("../lib/core/API");
15
- const { config } = require("process");
16
15
  let confPath = path.join(process.cwd(), "./lsc.config.json");
17
16
 
18
- program.version("0.0.1");
17
+ program.version("0.0.2");
19
18
 
20
19
  program.command("config").action(function () {
20
+ let initConfig = {},
21
+ initAnswers = {};
21
22
  inquirer
22
23
  .prompt([
23
24
  {
@@ -28,29 +29,40 @@ program.command("config").action(function () {
28
29
  {
29
30
  type: "input",
30
31
  message: "请输入离线包id:",
31
- name: "h5pkgid",
32
+ name: "pkgid",
32
33
  },
33
34
  {
34
35
  type: "input",
35
- message: "请输入离线包名称:",
36
- name: "name",
36
+ message: "请指定离线包发布版本号:",
37
+ name: "set_pkg_version",
38
+ default: "1.0.1",
37
39
  },
38
40
  {
39
41
  type: "input",
40
- message: "请指定发布版本号:",
41
- name: "version",
42
- default: "1.0.1",
42
+ message: "APP版本iOS版本范围:",
43
+ name: "ios_version_scope",
44
+ default: "7.0.6",
45
+ },
46
+ {
47
+ type: "input",
48
+ message: "APP版本Android版本范围:",
49
+ name: "android_version_scope",
50
+ default: "7.0.6.0",
43
51
  },
44
52
  {
45
53
  type: "checkbox",
46
54
  message: "请选择发布的APP:",
47
- name: "apps",
55
+ name: "publish_app_arr",
48
56
  choices: [
49
57
  {
58
+ key: "3577",
59
+ value: "3592",
50
60
  name: "开发版_iOS",
51
61
  checked: true,
52
62
  },
53
63
  {
64
+ key: "3577",
65
+ value: "3577",
54
66
  name: "开发版_安卓",
55
67
  checked: true,
56
68
  },
@@ -64,7 +76,7 @@ program.command("config").action(function () {
64
76
  },
65
77
  {
66
78
  type: "input",
67
- message: "离线包压缩包存放位置:",
79
+ message: "离线包压缩包存放相对位置:",
68
80
  name: "pkg_dir",
69
81
  default: "./dist/",
70
82
  },
@@ -78,13 +90,49 @@ program.command("config").action(function () {
78
90
  type: "rawlist",
79
91
  message: "是否处理上一版本离线包?",
80
92
  name: "task_status",
81
- default: "保留",
82
- choices: ["保留", "暂停", "下架"],
93
+ choices: [
94
+ { key: 0, value: 0, name: "保留", checked: true },
95
+ { key: 1, value: 1, name: "暂停" },
96
+ { key: 2, value: 3, name: "结束" },
97
+ ],
98
+ },
99
+ {
100
+ type: "confirm",
101
+ message: "是否使用以上配置?",
102
+ name: "useConfig",
103
+ default: true,
104
+ when: function (answers) {
105
+ initAnswers = answers;
106
+ console.log(answers);
107
+ return true;
108
+ },
109
+ },
110
+ {
111
+ type: "confirm",
112
+ message: "是否保存配置?",
113
+ name: "saveConfig",
114
+ default: true,
115
+ when: function (answers) {
116
+ return answers.useConfig;
117
+ },
83
118
  },
84
119
  ])
85
- .then((answer) => {
120
+ .then((asw) => {
86
121
  // 用户输入的结果最终会在这里输出
87
- console.log(answer);
122
+ let { useConfig, saveConfig } = asw;
123
+ if (useConfig) {
124
+ let totalConfig = {
125
+ publishInfo: {...initAnswers,apps_name:defaultConfig.publishInfo.apps_name},
126
+ lightBaseURL: defaultConfig.lightBaseURL,
127
+ };
128
+ if (saveConfig) {
129
+ // 保存配置
130
+ writeConfig(totalConfig);
131
+ }
132
+ // console.log(totalConfig);
133
+ } else {
134
+ console.log("已结束!");
135
+ }
88
136
  });
89
137
  });
90
138
 
@@ -104,28 +152,14 @@ program.command("init").action(function () {
104
152
  ])
105
153
  .then((answer) => {
106
154
  if (answer.initConfig) {
107
- writeConfig();
155
+ writeConfig(defaultConfig);
108
156
  } else {
109
157
  console.log("配置无变化");
110
158
  }
111
159
  });
112
160
  } else {
113
- writeConfig();
161
+ writeConfig(defaultConfig);
114
162
  }
115
- function writeConfig () {
116
- // 写入文件内容(如果文件不存在会创建一个文件)
117
- writeFile(
118
- "./lsc.config.json",
119
- JSON.stringify(defaultConfig),
120
- { flag: "w" },
121
- function (err) {
122
- if (err) {
123
- throw err;
124
- }
125
- console.log("创建配置模板成功,请打开文件进行相应修改");
126
- }
127
- );
128
- };
129
163
  });
130
164
  });
131
165
 
@@ -174,4 +208,19 @@ program
174
208
  }
175
209
  });
176
210
 
211
+ async function writeConfig(configArgs) {
212
+ // 写入文件内容(如果文件不存在会创建一个文件)
213
+ writeFile(
214
+ "./lsc.config.json",
215
+ JSON.stringify(configArgs),
216
+ { flag: "w" },
217
+ function (err) {
218
+ if (err) {
219
+ throw err;
220
+ }
221
+ console.log("创建配置模板成功,请打开文件进行相应修改");
222
+ }
223
+ );
224
+ }
225
+
177
226
  program.parse(process.argv);
package/lsc.config.json CHANGED
@@ -1,20 +1,14 @@
1
1
  {
2
- "publishInfo": {
3
- "token": "XXXXX", //登录token
4
- "pkgid": "XXXXX", //离线包ID
5
- "set_pkg_version": "1.0.1", //指定发布版本
6
- "publish_app_arr": [3577, 3592], //发布到指定APP,默认开发版
7
- "apps_name": {
8
- "3592": "开发版_iOS",
9
- "3577": "开发版_安卓",
10
- "3559": "测试"
11
- },
12
- "android_version_scope": "7.0.6.0", //Android端离线包兼容版本
13
- "ios_version_scope": "7.0.6", //iOS端离线包兼容版本
14
- "pkg_zip_name": "dist.zip",
15
- "pkg_dir": "./dist/", //离线包所在路径
16
- "release_desc": "功能更新", //发布日志
17
- "task_status": "0" //对上一版本的处理:0:发布,1:暂停,2:下架
18
- },
19
- "lightBaseURL": "https://xxx.xxx.xxx/lightadmin/pas-api"
20
- }
2
+ "publishInfo": {
3
+ "token": "XXXXX",
4
+ "pkgid": "XXXXX",
5
+ "set_pkg_version": "1.2.9",
6
+ "publish_app_arr": [3592, 3577],
7
+ "android_version_scope": "7.0.7.0",
8
+ "ios_version_scope": "7.0.7",
9
+ "pkg_zip_name": "XXXXX.zip",
10
+ "pkg_dir": "./dist/",
11
+ "task_status": "2"
12
+ },
13
+ "lightBaseURL": "https://xxx.xxx.xxx/lightadmin/pas-api"
14
+ }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "inquirer": "^8.2.0",
10
10
  "qs": "^6.10.3"
11
11
  },
12
- "version": "1.0.1",
12
+ "version": "1.0.2",
13
13
  "description": "Light离线包自动发布工具",
14
14
  "main": "index.js",
15
15
  "devDependencies": {},