Exploring the Shifter CLI

Hello, World, and fellow patrons of the internet. I want to revisit one of our new tools, the Shifter CLI, and share some of my favorite features with you.

The Shifter Command Line Interface (CLI) is a handy, developer-friendly tool for helping create a Shifter website. You can create a new site, set up a custom domain, or use it to publish new content. It’s also a quick way for any developer to check the status of their site, domain names, and run builds.

It’s available on GitHub as an open-source project, as many of our projects are. We take a lot of inspiration from our partner platforms and creations, so we feel it’s important to share this with our Shifter developer community and you.

Installing Globally

To use the Shifter CLI, you’ll need a Shifter account, Node, and NPM. You don’t need to install the latest version of Node, but you should have at least version 14 or greater.

To install the Shifter CLI globally, use the following command in your terminal or command line prompt:

npm install -g @shifter/cli

This will give you access to the `shifter` command in any of your projects. 

Authentication

To authenticate using the CLI, you can pass the username and credentials into the command.

shifter sites:list --username USERNAME --password PASSWORD

A feature such as shifter login, common in other CLIs, isn’t available yet. Still, we’ll be working on adding that in an upcoming release. It’s on my personal wish list of features!

I believe what we’ll ultimately do is add support for a shifter.json file in your project or the local machine. This is the defacto way providers add credentials such as the AWS CLI and Netlify CLI. We’ll likely follow this approach.

For now, it’s early days for the Shifter CLI. You can include your Shifter username and password in your command prompts to authenticate.

A note to users with multi-factor authentication enabled; the Shifter CLI does not support MFA yet, but a solution is available. You can still make granular access controls to sites and accounts by creating a separate user for programmatic access. For example, inviting your_email_address+cli@foo.bar would allow you to create an alias account based on your existing email address.

Using NPX

You can also get started using NPX. It’s a neat feature included in NPM to run a command from a local or remote npm package. NPX allows you to get started right away with the Shifter CLI.

I like it because it allows me to test CLIs of packages on a very temporary and trial basis. If I enjoy the tool or CLI, I may include it in my projects package.json or install it globally on my local machine.

Let’s give it a try:

npx @shifter/cli

I’ve also found that NPX is helpful while writing scripts in your package.json. By adding an environment variable or flag, you can create custom commands for added developer experience or include this as a part of your CI/CD tools.

Here’s an example of what you can do with NPM scripts and passing a few custom variables.

Package.json:

…

“scripts”: {

“build”: “npx @shifter/cli artifacts:build –username $USERNAME –password $PASSWORD –site-id $SITE_ID”,

  }

…

Command prompt:

SITE_ID=foo USERNAME=bar PASSWORD=baz npm run build

Commands

Let’s explore some of the available commands when using the Shifter CLI. These commands allow you to interact with a specific feature of the Shifter platform. The current version of the Shifter CLI includes support for artifacts, sites, and domains.

Artifacts

Let’s take a look at commands related to artifacts. Using the CLI, you can create new builds, list artifacts, and get the status of each.

The artifact build command will begin generating a new static site. This command has potential as a part of CI/CD tools or a simple way to publish new content.

The artifacts list command is a read-only view of the artifacts you’ve created. This would help roll back or forward changes to your Shifter site.

The artifacts status command will give us insight into the status of our artifact. The artifact’s state can be ready to deploy or in a build process. This command will help you find out.

Sites

You can also create a new site right from the CLI. I’m really excited about this feature because it could offer developers during their local development work.

The site’s command includes a few sub-commands as well. You can use these commands to create sites, delete sites, get information about your sites, and even start your site’s WordPress container environment.

The Shifter CLI is an alternative way to interact with our API. Many tasks can be automated or programmed using our API. The same can be applied using the Shifter CLI, and for some users, the CLI is a great way to get started.

Domains

And finally, the domains command. This command is packed with sub-command features related to setting up and managing your domain names. Attaching a domain name is a challenge for us to solve. We talk to many customers, and this is an area we want to work on more and collaborate with you on.

My hope is the Shifter CLI can bring some insight into managing your Shifter site. If this tool can make the domain process more accessible, all users will benefit.

Proposed Features

While we have a great set of core commands that would allow our users to do most functions, we want to improve our CLI’s usability even further. Here’s a look at a few ideas we’re thinking about.

How can we incorporate Shifter Local into the Shifter CLI?

I’ve been thinking a lot about incorporating Shifter Local into the Shifter CLI. Shifter Local is our Docker container environment to run your site locally on your machine for testing, creating, and development.

Here’s what the local command could look like.

It could include features such as creating a WordPress site right from the Shifter CLI without installing WordPress. We can invoke the docker container directly and create a new Shifter site on demand.

Let us know your feedback!

Thank you for taking an interest in the Shifter CLI. I enjoy exploring the developer tools in the Shifter ecosystem and hearing how you’re using them in your work and projects.

I look forward to your feedback on using and testing the Shifter CLI. I’m really excited about the proposed features and exploring new ways to learn together.

Thanks a bunch!

Take the Next Step

Get started on your website today with Shifter. Try out our free plan and take the first step towards building the perfect website for you and your visitors.