Shopify CLI 2.0 Documentation
repository·main·Indexed 21 days ago
https://github.com/shopify/shopify-cliA Ruby-based command line tool used to build and manage Shopify apps, themes, and storefronts. This version is deprecated as of May 31, 2023. The documentation covers installation, packaging for Debian, Homebrew, and RPM, migration from Theme Kit, and managing Shopify extensions via the 'extension' command.
What's inside Shopify CLI 2.0
- Shopify CLI 2.0 is a command line interface designed to help developers build on the Shopify platform. It is distributed as a Ruby gem and is compatible with macOS, Linux, and Windows systems.
Install requirements for building RPM packages
mainTo build RPM packages for the Shopify CLI, you must have the
rpmbuildprogram installed on your system.- macOS: Install via Homebrew using
brew install rpm. - Linux: Install via yum using
yum install rpm-build.
# macOS brew install rpm # Linux yum install rpm-build- macOS: Install via Homebrew using
Migrate from Theme Kit to Shopify CLI
mainShopify CLI is the officially supported tool for Theme development and CI/CD workflows, replacing Theme Kit. To migrate, use the corresponding Shopify CLI commands to achieve the same objectives as your previous Theme Kit workflows.Build a Homebrew package of the CLI
mainThe Homebrew package for the Shopify CLI acts as a proxy for the actual Ruby gem. It works by downloading the gem and installing the source code within the Homebrew environment.
Note: This is not a metapackage. Users cannot switch between the Homebrew version and the Gem version without a complete reinstallation.
rake package:homebrewBuild a .deb package of the CLI manually
mainThe Shopify CLI Debian package is a metapackage that installs the CLI gem via Ruby and manages non-ruby dependencies.
To build the package manually:
Prepare Metadata: Place the following files in
packaging/debian/shopify-cli/DEBIAN:controlpreinstprerm
Set Version: The files use the
SHOPIFY_CLI_VERSIONvariable. For manual builds, you must set this version manually in those files (the Rake task handles this automatically).Run Build Command: Execute
dpkg-debagainst the package directory.
The resulting package will be named
shopify-cli.deb.dpkg-deb -b shopify-cliRelease Shopify CLI 2.0 using the automated process
mainThe automated release process for CLI 2.0 uses a series of Rake tasks and PR-based checkpoints. Follow these steps in order:
- Export your GitHub access token:
export GITHUB_ACCESS_TOKEN=$(dev github print-auth | grep Password | awk '{print $NF}') - Prepare the release using Rake (replace
2.x.xwith your target version):rake "release:prepare[2.x.x]" - Sanity-check and merge the PR that opens in your browser.
- Trigger Shipit on your version commit to release to RubyGems.
- Package the release:
rake release:package - Sanity-check and merge the Homebrew PR that opens in your browser.
- Verify the GitHub release includes
.deband.rpmfiles. - Complete any post-release steps found in PRs labeled
includes-post-release-steps, then delete those labels.
export GITHUB_ACCESS_TOKEN=$(dev github print-auth | grep Password | awk '{print $NF}') rake "release:prepare[2.x.x]" rake release:package- Export your GitHub access token:
Install the Shopify CLI
mainTo install the Shopify CLI on your operating system, refer to the installation guide. The guide provides specific instructions for different OSs to ensure the CLI is correctly set up in your environment.Manual requirements for Homebrew formula creation
mainTo manually create a Homebrew formula, you must first build the CLI gem. This is required because the formula is built on top of the actual CLI gem.
Run the following command from the root directory to build the gem:
gem build <root>/shopify-cli.gemspecgem build <root>/shopify-cli.gemspecRun acceptance tests with Cucumber
mainAcceptance tests verify the built
shopifycommand against various fixtures. These tests are written in Cucumber and Ruby and are located in thefeatures/directory. They provide high coverage by testing complete scenarios for major features, though they are slower than unit tests.To run all acceptance tests, use
bundle exec cucumber. To run a specific test scenario, specify the feature file and line number.bundle exec cucumber bundle exec cucumber features/theme.feature:3 # A specific testBuild an RPM package of the CLI
mainThe Shopify CLI RPM package is a metapackage that installs the CLI gem via Ruby.
Using Rake (Recommended)
For new builds, it is recommended to use the provided Rake task, which automates versioning and metadata:
rake package:rpmManual Build Process
If you need to build manually, follow these steps:
- Prepare the spec file: Copy the metadata
.spec.basefile into the.specfile. - Set the version: Manually set the
SHOPIFY_CLI_VERSIONenvironment variable in the spec file (the Rake task does this automatically). - Run rpmbuild: Navigate to the RPM directory and execute the build command.
The resulting package will be located in
build/noarch.cd packaging/rpm # Note: Ensure SHOPIFY_CLI_VERSION is set in the .spec file before running rpmbuild -bb rubygem-shopify.spec- Prepare the spec file: Copy the metadata
Install dpkg for Debian package building
mainTo build
.debpackages, you need thedpkg-debprogram. On Debian-based systems, this is usually pre-installed. On macOS, you can install it using Homebrew.brew install dpkgRelease Shopify CLI 2.0 using the manual process
mainIf automation fails, follow these manual steps to release CLI 2.0:
1. Prepare the Release Branch
- Ensure you are on the latest
mainbranch:git checkout main git pull - Create a release branch named
release_X_Y_Z(e.g.,release_2_3_6):git checkout -b release_X_Y_Z - Update the version in
lib/shopify_cli/version.rb. - Update the version at the top of
Gemfile.lock(required for CI). - Add the new release entry to
CHANGELOG.md. - Commit with the message
"Packaging for release vX.Y.Z"and push:git commit -am "Packaging for release vX.Y.Z" git push -u origin release_X_Y_Z - Open a PR, get approvals, and merge into
main. Note: The PR title will serve as the Shipit release note.
2. Deploy to RubyGems
- Deploy using Shipit.
- Update your local
mainbranch:git checkout main git pull
3. Package and Update Homebrew
- After the gem is published to RubyGems, run the packaging task:
This generatesrake package.deb,.rpm, and brew formula files inpackaging/builds/X.Y.Z/. - In the
Shopify/homebrew-shopifyrepository:- Update
masterand create a new branchrelease_X_Y_Z_of_shopify-cli. - Update the brew formula in
shopify-cli.rbusing the generated formula frompackaging/builds/X.Y.Z/. - Commit and create a PR to the Homebrew repository.
- Update
4. Finalize GitHub Release
- Go to the
Shopify/shopify-clireleases page. - Create a new release using the Shipit tag (e.g.,
vX.Y.Z). - Set the title to
Version X.Y.Zand use theCHANGELOG.mdsection as the description. - Upload the
.deband.rpmfiles frompackaging/builds/X.Y.Z/. - Check "This is a pre-release" if applicable, then click "Publish release".
- Complete any post-release steps from PRs labeled
includes-post-release-stepsand delete the labels.
# Prepare branch git checkout main git pull git checkout -b release_X_Y_Z # Commit and push git commit -am "Packaging for release vX.Y.Z" git push -u origin release_X_Y_Z # Package after RubyGems deployment rake package- Ensure you are on the latest