eprolo-cli 1.0.89 → 1.0.91
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 +10 -5
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const os = require("os");
|
|
6
6
|
const path = require("path");
|
|
7
|
-
const https = require("
|
|
8
|
-
|
|
7
|
+
const https = require("https");
|
|
8
|
+
const http = require("http");
|
|
9
9
|
const LOGIN_API = "https://wixtest.eprolo.com/v1/auth/verifyCode.stm";
|
|
10
10
|
const BASE_URL = "https://wixtest.eprolo.com";
|
|
11
11
|
const REFRESH_API = "https://wixtest.eprolo.com/v1/auth/refresh-code";
|
|
@@ -55,7 +55,11 @@ function postJson(url, body, headers = {},method = "POST") {
|
|
|
55
55
|
return new Promise((resolve, reject) => {
|
|
56
56
|
const target = new URL(url);
|
|
57
57
|
const payload = JSON.stringify(body);
|
|
58
|
-
|
|
58
|
+
let reqMethod=https;
|
|
59
|
+
if(String(target.protocol).startsWith("http:")){
|
|
60
|
+
reqMethod=http;
|
|
61
|
+
}
|
|
62
|
+
const req = reqMethod.request({
|
|
59
63
|
hostname: target.hostname,
|
|
60
64
|
port: target.port || 443,
|
|
61
65
|
path: `${target.pathname}${target.search}`,
|
|
@@ -220,13 +224,14 @@ async function queryProductList() {
|
|
|
220
224
|
process.exit(0);
|
|
221
225
|
}
|
|
222
226
|
async function insertProduct(argv) {
|
|
223
|
-
console.log('
|
|
227
|
+
console.log('insertProduct',argv);
|
|
224
228
|
const config = readConfig();
|
|
225
229
|
if (!argv) {
|
|
226
230
|
console.error(JSON.stringify({ success: false, errorMessage: "缺少产品 JSON 字符串" }));
|
|
227
231
|
process.exit(1);
|
|
228
232
|
}
|
|
229
|
-
const data = await postJsonWithRetry(
|
|
233
|
+
const data = await postJsonWithRetry(`http://43.153.35.208:3000/insertProduct`, {value:argv}, config, "POST");
|
|
234
|
+
// const data = await postJsonWithRetry(`${BASE_URL}/insert_product.html`, JSON.parse(argv), config, "POST");
|
|
230
235
|
console.log(JSON.stringify(data, null, 2));
|
|
231
236
|
process.exit(0);
|
|
232
237
|
}
|
package/package.json
CHANGED