eprolo-cli 1.0.49 → 1.0.50

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.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +27 -28
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -86,42 +86,41 @@ function postJson(url, body, headers = {}) {
86
86
  // ---------------------------------------------------------------------------
87
87
 
88
88
  async function postJsonWithRetry(url, body, config) {
89
- const headers = {'liu':'123'};
90
89
  if (config.accessToken) headers["accessToken"] = `${config.accessToken}`;
91
90
 
92
91
  let result = await postJson(url, body, headers);
93
92
 
94
- if (result.statusCode === 401) {
95
- // 刷新 token
96
- const refreshRes = await postJson(REFRESH_API, {
97
- accessToken: config.accessToken,
98
- accountId: config.accountId,
99
- shopId: config.shopId
100
- });
101
-
102
- if (refreshRes.statusCode >= 200 && refreshRes.statusCode < 300 && refreshRes.data.accessToken) {
103
- // 更新凭据文件
104
- config.accessToken = refreshRes.data.accessToken;
105
- if (refreshRes.data.account) config.account = refreshRes.data.account;
106
- writeConfig(config);
107
-
108
- // 用新 token 重试
109
- headers["authorization"] = `Bearer ${config.accessToken}`;
110
- result = await postJson(url, body, headers);
111
- } else {
112
- const err = new Error("Token 刷新失败,请重新登录授权");
113
- err.response = refreshRes.data;
114
- throw err;
115
- }
116
- }
117
-
118
- if (result.statusCode < 200 || result.statusCode >= 300) {
93
+ // if (result.statusCode === 401) {
94
+ // // 刷新 token
95
+ // const refreshRes = await postJson(REFRESH_API, {
96
+ // accessToken: config.accessToken,
97
+ // accountId: config.accountId,
98
+ // shopId: config.shopId
99
+ // });
100
+
101
+ // if (refreshRes.statusCode >= 200 && refreshRes.statusCode < 300 && refreshRes.data.accessToken) {
102
+ // // 更新凭据文件
103
+ // config.accessToken = refreshRes.data.accessToken;
104
+ // if (refreshRes.data.account) config.account = refreshRes.data.account;
105
+ // writeConfig(config);
106
+
107
+ // // 用新 token 重试
108
+ // headers["authorization"] = `Bearer ${config.accessToken}`;
109
+ // result = await postJson(url, body, headers);
110
+ // } else {
111
+ // const err = new Error("Token 刷新失败,请重新登录授权");
112
+ // err.response = refreshRes.data;
113
+ // throw err;
114
+ // }
115
+ // }
116
+
117
+ if (result.code !== 0) {
119
118
  const err = new Error(`HTTP ${result.statusCode}`);
120
119
  err.response = result.data;
121
120
  throw err;
122
121
  }
123
122
 
124
- return result.data;
123
+ return result;
125
124
  }
126
125
 
127
126
  // ---------------------------------------------------------------------------
@@ -190,7 +189,7 @@ async function queryOrders() {
190
189
  process.exit(1);
191
190
  }
192
191
 
193
- const data = await postJsonWithRetry(ORDERS_API, {}, config);
192
+ const data = await postJsonWithRetry(ORDERS_API, {id:'1'}, config);
194
193
  console.log(JSON.stringify(data, null, 2));
195
194
  process.exit(0);
196
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "CLI for Dianxiaobao ICBU AI publishing, authorization profile management, task submission, and task status checks.",
5
5
  "bin": {
6
6
  "eprolo": "bin/eprolo-cli.js"