eprolo-cli 1.0.91 → 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.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +20 -16
  2. 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
- async function insertProduct(argv) {
227
- console.log('insertProduct',argv);
228
- const config = readConfig();
229
- if (!argv) {
230
- console.error(JSON.stringify({ success: false, errorMessage: "缺少产品 JSON 字符串" }));
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
- 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");
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(argv) {
239
- console.log('addOrder:', argv);
246
+ async function addOrder(arg) {
240
247
  const config = readConfig();
241
- if (!argv) {
242
- console.error(JSON.stringify({ success: false, errorMessage: "缺少订单 JSON 字符串" }));
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`, { value: payload }, 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.slice(1));
329
+ await insertProduct(argv[1]);
326
330
  return;
327
331
  }
328
332
  if (argv[0] === "add-order") {
329
- await addOrder(argv.slice(1));
333
+ await addOrder(argv[1]);
330
334
  return;
331
335
  }
332
336
  printHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.91",
3
+ "version": "1.0.92",
4
4
  "description": "CLI for Dianxiaobao ICBU AI publishing, authorization profile management, task submission, and task status checks.",
5
5
  "bin": {
6
6
  "eprolo": "bin/eprolo-cli.js"