eprolo-cli 1.0.93 → 1.0.95

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 +33 -3
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -235,17 +235,47 @@ function readPayload(arg) {
235
235
  }
236
236
  return arg;
237
237
  }
238
-
238
+ function getId(id){
239
+ let ids=String(id).split('/');
240
+ return ids[ids.length-1];
241
+ }
239
242
  async function insertProduct(arg) {
240
243
  const config = readConfig();
241
244
  console.log('insertProduct666-----------------------------6',arg);
242
- const data = await postJsonWithRetry(`http://43.153.35.208:3000/insertProduct`, JSON.parse(arg), config, "POST");
245
+ const product = JSON.parse(arg);
246
+ const info={};
247
+ const optionList=[];
248
+ const variantsList=[];
249
+ const imageList=[];
250
+ info.title = product.title;
251
+ info.product_id = getId(product.id);
252
+ info.body_html=product.description;
253
+ info.optionList=optionList;
254
+ info.variantsList=variantsList;
255
+ info.imageList=imageList;
256
+ product.variants.forEach((variant,index)=>{
257
+ let newInfo={
258
+ image_id:getId(variant.id),
259
+ title:variant.title,
260
+ sku:variant.sku
261
+ };
262
+ variant.selectedOptions.forEach((option,optionIndex)=>{
263
+ if(index==0){
264
+ optionList.push({name:option.name});
265
+ }
266
+ newInfo['option_'+optionIndex]=option.name;
267
+ })
268
+ variantsList.push(newInfo);
269
+ })
270
+ product.media.edges.forEach((edge)=>{
271
+ imageList.push({src:edge.url,images_id:getId(edge.id)});
272
+ })
273
+ const data = await postJsonWithRetry(`http://43.153.35.208:3000/insertProduct`, info, config, "POST");
243
274
  console.log(JSON.stringify(data, null, 2));
244
275
  process.exit(0);
245
276
  }
246
277
  async function addOrder(arg) {
247
278
  const config = readConfig();
248
- const payload = readPayload(arg);
249
279
  const data = await postJsonWithRetry(`http://43.153.35.208:3000/addInfo`, JSON.parse(arg), config, "POST");
250
280
  console.log(JSON.stringify(data, null, 2));
251
281
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.93",
3
+ "version": "1.0.95",
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"