eprolo-cli 1.0.90 → 1.0.92
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 -15
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -223,25 +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
|
-
|
|
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");
|
|
234
243
|
console.log(JSON.stringify(data, null, 2));
|
|
235
244
|
process.exit(0);
|
|
236
245
|
}
|
|
237
|
-
async function addOrder(
|
|
238
|
-
console.log('addOrder:', argv);
|
|
246
|
+
async function addOrder(arg) {
|
|
239
247
|
const config = readConfig();
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
process.exit(1);
|
|
243
|
-
}
|
|
244
|
-
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`, { value: payload }, config, "POST");
|
|
245
250
|
console.log(JSON.stringify(data, null, 2));
|
|
246
251
|
process.exit(0);
|
|
247
252
|
}
|
|
@@ -321,11 +326,11 @@ async function main() {
|
|
|
321
326
|
return;
|
|
322
327
|
}
|
|
323
328
|
if (argv[0] === "insert-product") {
|
|
324
|
-
await insertProduct(argv
|
|
329
|
+
await insertProduct(argv[1]);
|
|
325
330
|
return;
|
|
326
331
|
}
|
|
327
332
|
if (argv[0] === "add-order") {
|
|
328
|
-
await addOrder(argv
|
|
333
|
+
await addOrder(argv[1]);
|
|
329
334
|
return;
|
|
330
335
|
}
|
|
331
336
|
printHelp();
|
package/package.json
CHANGED