Giter VIP home page Giter VIP logo

seeder's Introduction

Chec Seeder

Version License

A small utility to help with seeding data in your Chec dashboard

Download

npm install @chec/seeder

Configuring

You can define following properties as environment variables:

  • CHEC_SECRET_KEY - (required) - Your Chec secret API key.
  • CHEC_API_URL - (optional) - API URL, defaults to api.chec.io.

Usage

As a NPM script

Add a seed command to your package.json

{
    "scripts": {
        "seed": "chec-seed path/to/json/files"
    }
}

Global usage

This script can be installed globally:

npm install -g @chec/seeder

Then you can use this helper outside of a project to seed data easily, like so:

chec-seeder path/to/json/files

Within code

You can also use this package within your Node.js projects:

const seed = require('@chec/seeder');

seed('path/to/json/files');

seeder's People

Contributors

dependabot[bot] avatar dvnkshl avatar john-raymon avatar meetmartin avatar paitoanderson avatar robbieaverill avatar scopeynz avatar tomburgs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

seeder's Issues

Exit early if errors are encountered

Currently an error will show in console (like 401 Unauthorized) but it will continue with seeding. This can be a problem when assets are seeding - as it refers to past seeded items. You can just get an error "undefined index" in this case which looks pretty average.

We should just cancel with failed seeding if there's an error.

Variants not rendering when defined in the product.json seed file

This issue is a continuation of chec/commercejs-nextjs-demo-store#169.

When I try to seed two products that are associated with an existing category id as follows:

[
  {
    "product": {
      "name": "Eyebrow Wax",
      "description": "",
      "price": "15.00"
    },
    "categories": [
      {
        "id": "cat_G6kVw73gdw2eDx",
        "slug": "treatments-facial-wax-tint",
        "name": "Facial Treatments (Wax & Tint)"
      }
    ]
  },
  {
    "product": {
      "name": "Arms Wax",
      "description": "Waxing treatment of an arm region include after wax treatment and hot towelling"
    },
    "categories": [
      {
        "id": "cat_G6kVw73gdw2eDx",
        "slug": "treatments-facial-wax-tint",
        "name": "Facial Treatments (Wax & Tint)"
      }
    ],
    "variant": [
      {
        "name": "Size",
        "options": [
          {
            "description": "200ml",
            "price": "0.00"
          },
          {
            "description": "500ml",
            "price": "34.00"
          }
        ]
      }
  }
]

When I run yarn seed it successfully seeds the 1st product named "Eyebrow Wax" (because it doesn't use the "variant" property), but it fails to seed the 2nd product named "Arms Wax" and generates error Could not push an object to the products endpoint (Response code 422 (Unprocessable Entity)):

If the "variant" property is removed, then it gets seeded correctly and associated with correctly with the category id, so the error is due to that "varant" property.

And that error code is mentioned here https://commercejs.com/docs/api/#responses-amp-errors as being 422 - Validation | Validation error. Data submitted was missing something, or in the wrong format.

However, the format I've used for the "variant" property is exactly the same as is used in the template code here:
https://github.com/chec/commercejs-nextjs-demo-store/blob/master/seeds/products.json#L9

Support for seeding products with digital delivery

In order to seed products with digital delivery we'll need to be able to associate assets to a product's digital delivery record. We do this already for product assets, but this would need similar handling.

Make progress more verbose

I'm seeding 6 products and 6 images. I don't get any status updates during that time, it'd be nice if it could do something like "Seeding product 0...", "Seeding product 1..." etc (index is from JSON) so you know where it's up to

Support for seeding products with shipping rates

To seed a product with shipping rates, you must know the zone ID and base rate ID. We'll need to seed these before we can seed the products, or get them from the merchant somehow during the process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.