eprolo-cli 1.0.96 → 1.0.98
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/eprolo-cli.js +8 -13
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -106,18 +106,16 @@ async function postJsonWithRetry(url, body, config, method = "POST") {
|
|
|
106
106
|
let result = await postJson(url, body, headers, method);
|
|
107
107
|
if (result.data.code == '-1') {
|
|
108
108
|
// 刷新 token
|
|
109
|
-
const refreshRes = await postJson(
|
|
110
|
-
refreshToken: config.refreshToken
|
|
111
|
-
});
|
|
109
|
+
const refreshRes = await postJson(LOGIN_API, {penApiKey: config.refreshToken});
|
|
112
110
|
|
|
113
|
-
if (refreshRes.data.code == 0
|
|
111
|
+
if (refreshRes.data.code == 0) {
|
|
114
112
|
// 更新凭据文件
|
|
115
|
-
body.timestamp = data.data.timestamp;
|
|
116
|
-
body.sign = data.data.accessToken;
|
|
117
|
-
writeConfig(data.data);
|
|
113
|
+
body.timestamp = refreshRes.data.data.timestamp;
|
|
114
|
+
body.sign = refreshRes.data.data.accessToken;
|
|
115
|
+
writeConfig(refreshRes.data.data);
|
|
118
116
|
|
|
119
117
|
// 用新 token 重试
|
|
120
|
-
headers["apiKey"] = `${
|
|
118
|
+
headers["apiKey"] = `${refreshRes.data.data.apiKey}`;
|
|
121
119
|
result = await postJson(url, body, headers,method);
|
|
122
120
|
}
|
|
123
121
|
else {
|
|
@@ -153,9 +151,6 @@ async function login(argv) {
|
|
|
153
151
|
}));
|
|
154
152
|
process.exit(1);
|
|
155
153
|
}
|
|
156
|
-
// res.data.data.openApiKey = userCode;
|
|
157
|
-
// const { account, accessToken, accountId, shopId } = res.data;
|
|
158
|
-
// const config = { account, accessToken, defaultShop, accountId, shopId, version: 1 };
|
|
159
154
|
writeConfig(res.data.data);
|
|
160
155
|
|
|
161
156
|
console.log("login ok");
|
|
@@ -263,14 +258,14 @@ async function insertProduct(arg) {
|
|
|
263
258
|
if(index==0){
|
|
264
259
|
optionList.push({name:option.name});
|
|
265
260
|
}
|
|
266
|
-
newInfo['
|
|
261
|
+
newInfo['option'+optionIndex]=option.name;
|
|
267
262
|
})
|
|
268
263
|
variantsList.push(newInfo);
|
|
269
264
|
})
|
|
270
265
|
product.media.edges.forEach((edge)=>{
|
|
271
266
|
imageList.push({src:edge.url,images_id:getId(edge.id)});
|
|
272
267
|
})
|
|
273
|
-
const data = await postJsonWithRetry(
|
|
268
|
+
const data = await postJsonWithRetry(BASE_URL+'/insert_product.html', info, config, "POST");
|
|
274
269
|
console.log(JSON.stringify(data, null, 2));
|
|
275
270
|
process.exit(0);
|
|
276
271
|
}
|
package/package.json
CHANGED