Shopifly is a command-line utility that helps to enforce branch-theme parity.
At this time it is compatible only with config.yml
based Shopify Themekit
setups.
Shopifly requires the theme
command to be in your command line. See
installation instructions.
Add this line to your application's Gemfile:
gem 'shopifly'
And then execute:
$ bundle
Or install it globally using:
$ gem install shopifly
Shopifly requires two local files: config.stores.yml
and .current_store
.
These files should both be added to your .gitignore
.
The config.stores.yml
file tells it how to access the different stores you
own.
Sample Config:
# config.stores.yml
shared_config:
deploy_command: "theme deploy"
directory: ../shopify/
ignore_files:
- config/settings_data.json
stores:
default: "dev"
dev:
password: xxx
store: my-shop-dev.myshopify.com
qa:
password: xxx
store: my-shop-staging.myshopify.com
live
password: xxx
store: my-shop.myshopify.com
The .current_store
file tells Shopifly which store you currently would like to
work with.
The .current_store
file should just be a one-line file with the name of the
store from the config.stores.yml
file that you'd currently like to work with.
You can easily upload the same theme to multiple stores by manipulating this
variable
For example, a possible value for the config.stores.yml
file above would be:
dev
Shopifly configures the local config.yml
to point to a theme that corresponds
to the current branch name.
It uses a "find or create" algorithm, generating this theme if it does not exist.
Shopifly configures the build
, development
and production
keys of your
config.yml
to all point to this remote theme.
Note It is always important to quit any running file watch processes (i.e.
theme watch
) before switching branches.
$ git checkout -b new-branch
$ fly sync
"Theme doesn't exist, creating..."
"Setting config to point to new-branch, my-shop-dev.myshopify.com"
"Uploading theme!"
$ git checkout master
$ fly sync
"Theme already exists: master, mack-weldon.myshopify.com"
"Setting config to point to master, my-shop-dev.myshopify.com"
$ git checkout existing-branch
$ fly sync --with-settings
"Downloading settings"
...
"Uploading settings"
The fly sync
command performs the following:
Assuming we're on a branch called my-branch-theme
, and .current_store
==
dev
- Checks if there exists a theme on the
dev
store namedmy-branch-theme
. - If so, skips to step 5. If not:
- Create a Shopify theme on the
dev
store namedmy-branch-theme
. - Uploads the contents of your current branch to the theme using the
shared_config.deploy_command
fromconfig.stores.yml
. - If the theme did not previously exist or if the
--with-settings
flag is used, identifies the currently published theme on your.current_store
and copies thesettings_data.json
from the published theme to themy-branch-theme
theme. - Sets your
config.yml
build
,development
andproduction
keys to point to this new theme.
In this repo:
rake build
In another repo:
gem install --local ~/dev/lunchtime/shopifly/pkg/shopifly-X.X.X.gem
To install this gem onto your local machine and ruby version (found in
.ruby-version
), run bundle exec rake install
.
To release a new version, update the version number in version.rb
, and then
run bundle exec rake release
, which will create a git tag for the version,
push git commits and tags, and push the .gem
file to
rubygems.org.
All rights reserved, Lunchtime Labs LLC, 2020