In November 2019, we announced the beta release of the Shopify App CLI, a command line tool designed to help developers build apps by scaffolding app code and automating some of the app development process. The Shopify App CLI tool is designed to help you be more productive on our platform by making app development faster.
Since its beta release, we’ve been working hard on the CLI tool to improve its robustness and make it easier to install on a variety of platforms, now including Windows 10, natively. In this article, we’ll go through some of its features of version 1.1 (the latest at the time of writing), so you can leverage it in your development process when building new apps.
Did you miss the announcement of the CLI tool at Shopify Unite 2019? Watch Vanessa Lee, Director of Product at Shopify, introduce it in the video below.
What the Shopify App CLI tool does
As a brief refresher: command-line interface (CLI) tools are scripts, programs, and libraries that have been created with a specific purpose in mind. You use CLI commands to work with a CLI app.
The Shopify App CLI tool facilitates the app development process by removing a lot of the obstacles you might face when starting a new app. When you type
shopify create into the terminal, it will prompt you for what type of app you’d like to create. You’ll have the choice of creating an app with a
node.js backend and React front end, or in Ruby on Rails.
"The Shopify App CLI tool facilitates the app development process by removing a lot of the obstacles you might face when starting a new app."
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 an app, it will ask you to select an organization, development store, and which type of app you’d like to make. Then, it will create your app in the Partner Dashboard for you:
The CLI will then run a tunnel for you with
shopify serve, so that your app is accessible to the internet via
https, a requirement for authenticating with Shopify. This will tunnel your app via ngrok as well as run your server for local development:
You might also like: Developing Your First Shopify App: 4 Mistakes to Avoid.
2. Adding testing 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:
You might also like: How to Use Relative Pagination In Your Application.
3. Deploying your app
Deploying your app to external platforms such as Heroku can also be done via the CLI. This is where
shopify deploy comes in handy:
Follow the link below to install the CLI on your machine and explore these features yourself. There are now more installation options available, and native Windows support.
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:.
- 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.
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.
- 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.
"In building the Shopify App CLI, we wanted to ensure that we created something that’s adaptable for as many developers as possible."
You can view the full list of our principles in the CLI tool wiki. These rules are intended to create a flexible tool, so you can use the Shopify App CLI in whatever way best suits your preferences.
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 where installation is fast and easy, as well as being easy to contribute to. Here is the decision making process we went through:
- 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. Hence, we chose Ruby.
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:
Frames to differentiate processes:
And color formatting options:
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.
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 tool is open source, so you can contribute directly to the codebase. We’re always looking for more apps to scaffold, new partner-developed features, and 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.
Build apps for Shopify merchants
Whether you want to build apps for the Shopify App Store, offer custom 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