eprolo-cli 1.0.91 → 1.0.93
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 +20 -16
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -223,26 +223,30 @@ async function queryProductList() {
|
|
|
223
223
|
console.log(JSON.stringify(data, null, 2));
|
|
224
224
|
process.exit(0);
|
|
225
225
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (!
|
|
230
|
-
console.error(JSON.stringify({ success: false, errorMessage: "
|
|
226
|
+
// 读取载荷:参数为已存在文件路径则读取文件内容(字符串),否则用参数字符串本身
|
|
227
|
+
// 避免命令行长度限制(Windows cmd 单条命令上限约 8191 字符)
|
|
228
|
+
function readPayload(arg) {
|
|
229
|
+
if (!arg) {
|
|
230
|
+
console.error(JSON.stringify({ success: false, errorMessage: "缺少 JSON 文件路径或 JSON 字符串" }));
|
|
231
231
|
process.exit(1);
|
|
232
232
|
}
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
if (fs.existsSync(arg) && fs.statSync(arg).isFile()) {
|
|
234
|
+
return fs.readFileSync(arg, "utf8");
|
|
235
|
+
}
|
|
236
|
+
return arg;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function insertProduct(arg) {
|
|
240
|
+
const config = readConfig();
|
|
241
|
+
console.log('insertProduct666-----------------------------6',arg);
|
|
242
|
+
const data = await postJsonWithRetry(`http://43.153.35.208:3000/insertProduct`, JSON.parse(arg), config, "POST");
|
|
235
243
|
console.log(JSON.stringify(data, null, 2));
|
|
236
244
|
process.exit(0);
|
|
237
245
|
}
|
|
238
|
-
async function addOrder(
|
|
239
|
-
console.log('addOrder:', argv);
|
|
246
|
+
async function addOrder(arg) {
|
|
240
247
|
const config = readConfig();
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
process.exit(1);
|
|
244
|
-
}
|
|
245
|
-
const data = await postJsonWithRetry(`http://43.153.35.208:3000/addInfo`, {value:argv}, config, "POST");
|
|
248
|
+
const payload = readPayload(arg);
|
|
249
|
+
const data = await postJsonWithRetry(`http://43.153.35.208:3000/addInfo`, JSON.parse(arg), config, "POST");
|
|
246
250
|
console.log(JSON.stringify(data, null, 2));
|
|
247
251
|
process.exit(0);
|
|
248
252
|
}
|
|
@@ -322,11 +326,11 @@ async function main() {
|
|
|
322
326
|
return;
|
|
323
327
|
}
|
|
324
328
|
if (argv[0] === "insert-product") {
|
|
325
|
-
await insertProduct(argv
|
|
329
|
+
await insertProduct(argv[1]);
|
|
326
330
|
return;
|
|
327
331
|
}
|
|
328
332
|
if (argv[0] === "add-order") {
|
|
329
|
-
await addOrder(argv
|
|
333
|
+
await addOrder(argv[1]);
|
|
330
334
|
return;
|
|
331
335
|
}
|
|
332
336
|
printHelp();
|
package/package.json
CHANGED