Getting started with the Chec CLI

4 min read
by Guy Marriott
January 29, 2020

Since the days of jQuery, developing front-end apps with JavaScript has become steadily more complex.

When starting a new, cutting edge JavaScipt project, you need to configure Webpack, Babel, the other code compiler of the month, and decide what flavour of ECMAScript you want.

What a nightmare!

Fortunately, leading JavaScript frameworks like Vue and React have worked on a way to make starting projects easy as possible. With Vue CLI or react-create-app, the hardest part about making a modern web app is just sitting down (or standing up) and starting your project!

How great would it be to start, and build eCommerce projects right from the command line?

Enter the Chec CLI.

Starting an eCommerce project should be simple, so we created a command line tool that does all the grunt work for you.

The Chec CLI

We're JavaScript developers, so we know that getting things started can be long-winded. We're following in the footsteps of other JavaScript projects and libraries to offer up our very own CLI.

Simply install globally using NPM:

npm install -g @chec/cli
chec

chec cli

When you're new to Commerce.js and Chec, you might find it helpful to just have a play around with a site that already has products, carts, and checkouts. The CLI can get you started in minutes.

First, create an account:

    ~ chec register
    This will open the Chec registration page in your browser
    Press any key to continue or q to exit:

The registration process involves opening a web browser to register your account with Chec. You’ll need to enter basic details about you as a merchant—the storefront that will be selling your products.

Next, use the chec demo-store command to quickly spin up a new store. This command will seed some data into your Chec account, so make sure this won't affect any other integrations you might already have with the Chec API.

When you run the command, you can choose from a list of examples that we have using some of the various JavaScript libraries that are popular.

Once this command finishes downloading and setting up your store, you should be ready to go! Each store might have a slightly different development process, but the demo should be ready to view and edit locally on your machine. Have fun hacking!

The source code for these example sites is public. When you install the demo, the CLI will inform you where the source was downloaded from.

At Chec, we're always looking for awesome examples of storefronts using our API. If you have an example that you would love to share with us, get in touch.

Other uses for the Chec CLI

In addition to using our CLI to quickly create demo stores, we have two other features that we think will make working with Chec and Commerce.js a little bit easier.

Make API requests without having to worry about authentication

Once you've registered or logged into your Chec account using the CLI, requests using the CLI means you don't have to worry about remembering to pass through your API keys, just specify the request method, the endpoint, and any request payload and the CLI takes care of the rest!

    ~ chec request GET /v1/developer/user
    {
      "email": "guy@chec.io",
      "created_at": "2019-08-28 11:05:24",
      "merchants": [
        {
          "id": 16595,
          "business_name": "Acme, Inc.",
          "business_description": "Helping a coyote with his bird problem",
          "status": "active",
          "timezone": "UT8",
          "country": "US",
          "currency": {
            "symbol": "$",
            "code": "USD"
          }
        }
      ]
    }

Follow a live feed of API requests that Chec is handling

Chec tracks a couple of weeks worth of history of the failed API requests for each merchant. When you're working on an integration with Chec's API, or a customer is having an issue with your site that you can't reproduce, watching the logs for any failures can be incredibly helpful to track down bugs. You can familiarise yourself with the watching logs on the CLI by using the in-built documentation in the CLI:

    chec logs --help

What's next for the Chec CLI

We're keen to continue working on the Chec CLI, continuing to make developers lives easier when it comes to creating eCommerce websites. We're always happy to receive feedback. Please feel free to raise issues on GitHub for our CLI project if you have some suggestions or come across anything that doesn't work quite right.

In the future, we'll be working to expand our demo stores, and we expect to add more commands based on the features we release to the API.

You might also like