The Shopify App CLI: A Tool to Help You Build Faster

The Shopify App CLI: A Tool to Help You Build Faster
CLI-tool

This year at Shopify Unite, we announced the beta release of the Shopify App CLI, a command line tool designed to help partners build apps by scaffolding app code and automating some of the app development process. We're happy to announce that the Shopify App CLI is now officially available to Shopify Developers.

The Shopify App CLI tool is designed to help you be more productive on our platform by making app development faster, and removing as much boilerplate code as possible. In this article, we’ll go through everything you need to know about this tool, including how to work with it, and how it will grow.

Did you miss this announcement at Shopify Unite? Watch Vanessa Lee, Director of Product at Shopify, introduce the Shopify App CLI from the mainstage in the video below. 

What the Shopify App CLI does

The Shopify App CLI tool facilitates the app development process by removing a lot of obstacles of starting a new project. When you type shopify create project <name> into the terminal, it will automatically create a new project for you. You’ll have the choice of creating a project with a node.js backend and React front end, or in Ruby on Rails.

There are four major ways the Shopify App CLI tool will help you speed up your development process.

1. Creating a project

When you create a project, it will ask you to select an organization, development store, and which type of app you’d like to make. Then it will register your app in the Partner Dashboard for you:

CLI tool: creating project 1

The CLI will then run a tunnel for you with shopify serve, so that your app is accessible to the internet, a requirement for authenticating with Shopify. This will tunnel your project via ngrok as well as run your server for local development:

CLI tool: creating project 2

You might also like: GraphQL vs REST: How One Shopify Partner Increased Performance and Reliability.

2. Adding information

The CLI also facilitates the process of adding products, customers, or draft orders to test your app on. Run shopify populate to populate these:

CLI tool: Adding Information

3. Charging for your app

Charging for your app is done by using the Billing API. The CLI will help set up this API. You can do this by running shopify generate:

CLI tool: Charging for your app

You might also like: How to Use Relative Pagination In Your Application.

4. Deploying your project

Deploying your project can also be done via the CLI. This is where shopify deploy comes in handy:

CLI tool: deploying your project

In addition to these features, the Shopify App CLI also has commands to populate your development store, serve your app, and run an ngrok tunnel. Follow the link below to install the CLI on your machine and explore these features yourself. 

Install the CLI

How we built the Shopify App CLI

In the past, we’ve built command line tools with Node, Go, and Ruby. We wanted to build the Shopify App CLI in a language that is simply installed, fast, and easy to contribute to.

Node has some fantastic libraries for writing command line tools, like yargs and ink, but managing paths and installation for a Node-based tool can be difficult. We don’t want to rely on dependencies like these to execute.

Go is a great choice for building a cross-platform command line tool because it can be easily compiled to binaries for major operating systems, but we were concerned about how approachable it is and how easy it would be for you to contribute to it.

Ruby is a much more approachable language than Go, and has a more extensive standard library than Node, allowing us to achieve more without having any dependencies, keeping the tool lightning fast. Ruby is also pre-installed or very easily installed on Mac OS and major Linux distributions, and we’re very familiar with it at Shopify. We have written command line tools in Ruby internally and have extracted this knowledge into cli-kit, a framework for building command line tools, and cli-ui, a collection of command line UI patterns. 

The cli-ui kit provides a robust user experience through reusable UI components without having to think about terminal escape sequences, terminal widths, or other esoteric details involved in building a command line tool.

It can give the user prompts to select options:

CLI tool: user prompts

Frames to differentiate processes:

CLI tool: differentiate processes

And color formatting:

CLI tool: color formatting

These open source tools are used internally to power our own command line tools, and we think they’ll help you build apps more efficiently, too. 

Build apps for Shopify merchants

Whether you want to build apps for the Shopify App Store, offer private app development services, or are looking for ways to grow your user base, the Shopify Partner Program will set you up for success. Join for free and access educational resources, developer preview environments, and recurring revenue share opportunities.

Sign up

A flexible tool for you

In building the Shopify App CLI, we wanted to ensure that we created something that’s adaptable for as many developers as possible. We looked at the landscape of developer-focused tools, and came up with a number of commandments for the tool to follow.

  1. Don’t make assumptions. Internally, our tools make a lot of assumptions about the user’s development environment. At Shopify, everyone uses Macs. Outside of Shopify though, developers have preferences for different operating systems and about how they install languages. The Shopify App CLI recommends how to install languages, but doesn’t enforce any one particular way.

  2. Don't require escalated privileges. Generally, open source tools avoid using escalated privileges. If they do, it’s usually left to the user to execute as a part of a specific action(sudo make install, for example). Giving the App CLI global permissions could create potential security concerns on a developer’s system.

  3. Don’t delete stuff. Any operation executed by the tool should be non-destructive. We leave it up to you to remove projects and files created by the tool if you want to.

These rules are intended to create a flexible tool, so you can use the Shopify App CLI in whatever way best suits your preferences.

Install the CLI

The future of the Shopify App CLI

The Shopify App CLI is designed to make Shopify app development faster, highlight the packages and libraries available to you, and give you a delightful user experience. By making it easier, quicker, and more intuitive to build apps, it will make your development process smoother, so you can focus on creating great products for your users.

The CLI is open source, so you can contribute directly to the codebase. We’re always looking for more apps to scaffold, for new partner-developed features, and for feedback. As a true collaboration between Shopify and you, our developer community, we hope the Shopify App CLI will continue to grow to meet your needs.

Have you tried the Shopify App CLI? Share your experience in the comments below!

About the Author

Katie and Tyler are developers on the Platform Dev Tools and Education team at Shopify. They work on tools and documentation to help our partners build better apps. They live in Toronto and both have dogs.

Grow your business with the Shopify Partner Program

Learn more