eprolo-cli 1.0.76 → 1.0.80
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 +42 -1
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -7,9 +7,11 @@ const path = require("path");
|
|
|
7
7
|
const https = require("https");
|
|
8
8
|
|
|
9
9
|
const LOGIN_API = "https://wixtest.eprolo.com/v1/auth/verifyCode.stm";
|
|
10
|
+
const BASE_URL = "https://wixtest.eprolo.com";
|
|
10
11
|
const REFRESH_API = "https://wixtest.eprolo.com/v1/auth/refresh-code";
|
|
11
12
|
const ORDERS_API = "https://wixtest.eprolo.com/order_list.html";
|
|
12
13
|
const PRODUCT_TYPE_API = "https://wixtest.eprolo.com/getproduct.html";
|
|
14
|
+
const PRODUCT_LIST_API = "https://wixtest.eprolo.com/product_list.html";
|
|
13
15
|
const CONFIG_DIR = path.join(os.homedir(), ".eprolo-toolkit");
|
|
14
16
|
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
15
17
|
|
|
@@ -222,6 +224,34 @@ async function queryProductId(productId) {
|
|
|
222
224
|
console.log(JSON.stringify(data, null, 2));
|
|
223
225
|
process.exit(0);
|
|
224
226
|
}
|
|
227
|
+
async function queryProductList() {
|
|
228
|
+
const config = readConfig();
|
|
229
|
+
const data = await postJsonWithRetry(PRODUCT_LIST_API, {}, config, "GET");
|
|
230
|
+
console.log(JSON.stringify(data, null, 2));
|
|
231
|
+
process.exit(0);
|
|
232
|
+
}
|
|
233
|
+
async function insertProduct(argv) {
|
|
234
|
+
console.log('insertProduct', JSON.stringify(argv, null, 2));
|
|
235
|
+
const config = readConfig();
|
|
236
|
+
if (!argv) {
|
|
237
|
+
console.error(JSON.stringify({ success: false, errorMessage: "缺少产品 JSON 字符串" }));
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
const data = await postJsonWithRetry(`${BASE_URL}/insert_product.html`, JSON.parse(argv), config, "POST");
|
|
241
|
+
console.log(JSON.stringify(data, null, 2));
|
|
242
|
+
process.exit(0);
|
|
243
|
+
}
|
|
244
|
+
async function addOrder(argv) {
|
|
245
|
+
console.log('addOrder', JSON.stringify(argv, null, 2));
|
|
246
|
+
const config = readConfig();
|
|
247
|
+
if (!argv) {
|
|
248
|
+
console.error(JSON.stringify({ success: false, errorMessage: "缺少订单 JSON 字符串" }));
|
|
249
|
+
process.exit(1);
|
|
250
|
+
}
|
|
251
|
+
const data = await postJsonWithRetry(`${BASE_URL}/add_order.html`, JSON.parse(argv), config, "POST");
|
|
252
|
+
console.log(JSON.stringify(data, null, 2));
|
|
253
|
+
process.exit(0);
|
|
254
|
+
}
|
|
225
255
|
// ---------------------------------------------------------------------------
|
|
226
256
|
// help
|
|
227
257
|
// ---------------------------------------------------------------------------
|
|
@@ -292,7 +322,18 @@ async function main() {
|
|
|
292
322
|
await queryProductId(argv[1]);
|
|
293
323
|
return;
|
|
294
324
|
}
|
|
295
|
-
|
|
325
|
+
if (argv[0] === "product-list") {
|
|
326
|
+
await queryProductList();
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (argv[0] === "insert-product") {
|
|
330
|
+
await insertProduct(argv.slice(1));
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (argv[0] === "add-order") {
|
|
334
|
+
await addOrder(argv.slice(1));
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
296
337
|
printHelp();
|
|
297
338
|
}
|
|
298
339
|
|
package/package.json
CHANGED