Uses Guard to watch for changes and update Shopify when a file is changed. Very similar functionality to guard-shopify, except that it uses the shopify_theme gem to do most of the work. This has a couple of advantages:
- shopify_theme is maintained by Shopify, so will usually be up-to-date.
- The config settings are stored in the project directory (rather than in
~/.guard_shopify
, as with guatd-shopify) - If you choose to use the
theme watch
command provided by shopify_theme instead of Guard, then everything will still work properly – you don't need to maintain two sets of config files.
Make sure you have installed Guard.
Add this line to your application's Gemfile:
gem 'guard-shopifytheme'
And then execute:
$ bundle
Or install it yourself with:
$ gem install guard-shopifytheme
If you don't already have shopify_theme set up, create a config.yml
file in your project directory (see here):
---
:api_key: YOUR_API_KEY
:password: YOUR_PASSWORD
:store: YOURSHOP.myshopify.com
:theme_id: 'YOUR_THEME_ID'
:ignore_files:
- README.md
- CHANGELOG.md
Add the Guard definition to your Guardfile with:
$ guard init guard-shopifytheme
There aren't any options, so usage is pretty simple:
# Upload Changes to Shopify
guard :shopifytheme do
watch(/assets\/.*/)
watch(/config\/.*/)
watch(/layout\/.*/)
watch(/snippets\/.*/)
watch(/templates\/.*/)
end
If you don't want to install this gem, you can just add this to your Guardfile:
require 'guard/plugin'
module ::Guard
class ShopifyTheme < ::Guard::Plugin
def run_all
end
def start
end
def run_on_changes(paths)
paths.each do |path|
system "theme upload #{path}"
end
end
def run_on_removals(paths)
paths.each do |path|
system "theme remove #{path}"
end
end
end
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- Add some tests
- Improve
start()
to ask for your shopify API details and write them to config.yml
- Danny Smith (@dannysmith)
- Shopfy_Theme by Shopify (@shopify)