@lazycatcloud/lzc-cli 1.2.65 → 1.3.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/changelog.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 1.3.2
2
+
3
+ 1. 增加用户友好的上传 LPK 错误提示
4
+
5
+ # 1.3.1
6
+
7
+ 1. 升级 lzc-cli 1.3.1 版本
8
+
1
9
  # 1.2.65
2
10
 
3
11
  1. 适配新版本开发者平台接口
@@ -31,11 +31,17 @@ async function login(username, password) {
31
31
  })
32
32
  .then(async (res) => {
33
33
  let bodyText = await res.text()
34
- let body = JSON.parse(bodyText)
35
- if (body.success) {
36
- return Promise.resolve(body.data)
34
+ try {
35
+ let body = JSON.parse(bodyText)
36
+ if (body.success) {
37
+ return Promise.resolve(body.data)
38
+ }
39
+ throw body
40
+ } catch (error) {
41
+ error.responseStatus = res.status
42
+ error.responseBody = bodyText
43
+ return Promise.reject(error)
37
44
  }
38
- return Promise.reject(body.message)
39
45
  })
40
46
  .then((data) => {
41
47
  env.set({ token: data.token }, true)
@@ -94,7 +100,11 @@ async function interactiveLogin() {
94
100
  await login(info.username, info.password)
95
101
  } catch (e) {
96
102
  logger.debug("login error: ", e)
97
- logger.error("帐号或者密码错误,请重新输入!")
103
+ if (e?.errorCode == 0 || e?.message == "密码错误") {
104
+ logger.error("帐号或者密码错误,请重新输入!")
105
+ } else {
106
+ logger.error(`登录失败,${e?.message ?? e}`)
107
+ }
98
108
  return interactiveLogin()
99
109
  }
100
110
  }
@@ -224,12 +224,6 @@ export class Publish {
224
224
 
225
225
  await autoLogin()
226
226
 
227
- if (!changelog) {
228
- const answer = await askChangeLog(locale)
229
- changelog = answer.changelog
230
- }
231
- changelog = changelog.trim() // clean space ^:)
232
-
233
227
  logger.info("正在提交审核...")
234
228
  const form = new FormData()
235
229
  form.append("file", fs.createReadStream(pkgPath))
@@ -248,6 +242,17 @@ export class Publish {
248
242
  }
249
243
  const lpkInfo = await JSON.parse(text)
250
244
  logger.debug("upload lpk response", lpkInfo)
245
+ if (res.status >= 400) {
246
+ logger.error(`LPK 文件上传失败,err: ${lpkInfo?.message ?? lpkInfo}`)
247
+ return
248
+ }
249
+
250
+ // 填写更新日志
251
+ if (!changelog) {
252
+ const answer = await askChangeLog(locale)
253
+ changelog = answer.changelog
254
+ }
255
+ changelog = changelog.trim() // clean space ^:)
251
256
 
252
257
  const sendURL = this.baseUrl + `/app/${lpkInfo.package}/review/create`
253
258
  logger.debug("publish url is", sendURL)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-cli",
3
- "version": "1.2.65",
3
+ "version": "1.3.2",
4
4
  "description": "lazycat cloud developer kit",
5
5
  "scripts": {
6
6
  "prepublishOnly": "node check-changelog.js"