Project

shopifydev

0.0
No commit activity in last 3 years
No release in over 3 years
Abstracts out and port to ruby the functionality of the shopify textmate bundle for use in other editors. Provides a shopify console with the ability to switch between configured shops, using either custom app or oauth token style authentication. Provides caches of objects and convenience methods for fetching them.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Shopifydev

Abstract out and port to ruby the functionality of the shopify textmate bundle for use in other editors.

Compatibility

There is a branch of shopifydev that specifically targets Rails 3.2.13. This is due to a dependency problem with shopify_api that arose when Rails 4.0 was released. If you have problems using shopifydev with Rails 3, try using the rails3 branch.

Installation

Add this line to your application's Gemfile:

gem 'shopifydev'

And then execute:

$ bundle

Or install it yourself as:

$ gem install shopifydev

Once Shopifydev is installed, you'll need to add a .shopifydev.yaml file to your project root. This config file should contain the secrets specific to the shopify site you are working on. Here's a sample:

api_key: youneedakey
password: andapassword
url: my_store_url.myshopify.com
project_root: relative/path (this might just be '.' for a lot of you cats)
project_root_variable: SOME_ENVIRONMENT_VARIABLE

Don't include 'http://' in the url, and don't commit this file to your repo (because secrets). The project root should be the directory where the 'assets' directory lives. If you would rather use an environment variable specific to your text editor of choice, like TM_PROJECT_DIRECTORY, you can supply that as well. Shopifydev will always prefer the environment variable, though.

Usage

WARNING: Files will always be uploaded from project_root/. This is great, because it means you can keep the shopify files separate from whatever sweet app you happen to be working on. Unfortunately, at the moment, this means autocompletion of file names really only works if project_root is '.'. But Imma fix that.

With shopifydev uploading a shopify file is a snap!

$ shopifydev upload assets/some_pic.jpg

Uploading two files is also a snap!

$ shopifydev upload assets/cart.png templates/cart.liquid 

More files? It's a UNIX system! You know this!

$ shopifydev upload {snippets,templates}/*.liquid

But Mr Authors, what if I don't have any files to upload?

$ shopify download

What could be better than that? How about uploading all your files:

$ shopifydev upload --patchify patch_directory

(I wouldn't recommend running that with '.' or any directory that contains subdirectories shopify wouldn't recognize. I'll fix that someday too! (^o ^)//)

Oh, you don't want to upload all your files, and you're too lazy to glob? Use --gitify to upload all the shopify files with changes.

$ shopifydev upload --gitify

(this uses the output of git status --porcelain, and it also runs git add on all those files so that you won't upload a file twice unless it gets changed twice in the same commit)

One final tip: alias upify='shopifydev upload'

Rails Console / Pry

To use shopifydev in the console of a rails app, add the following to your .pryrc:

    require 'shopifydev'
    require 'shopifydev/console'

Switch

The switch command lets you switch between shops in the console. In a rails app, it knows how to look up shops the local rails app knows about (that have been installed) or you can configure it in ~/.shopifydev.yaml thusly:

	test_shops:
	  arbitrary-label:
	    api_key: xxx
	    password: xxx
	    myshopify_domain: weird-autogenerated-name.myshopify.com
	  weird2:
	    api_key: xxx
	    password: xxx
	    myshopify_domain: weird-autogenerated-name2.myshopify.com
	apps:
	  development:
	    app_name1: /path/to/a/rails/app
	    app_name1: /path/to/a/rails/app

	  heroku:
	    name:                         heroku-app-name

The heroku support may or may not be working currently.

Caches

When using pry or rails console in a rails app, shopifydev keeps caches of the current shop's resources. Caches are defined on ShopifyAPI. Assuming you cd ShopifyAPI:

    products
    => lazily fetched cached products
    
    products.r
    => reload products cache
    
    products(product_type: 'xxxx')
    => reload products cache with params {product_type: 'xxxx'}
    
    products.params
    => shows params the caches were fetched with
    
    products.since
    => shows when the products cache was last fetched
    
    caches
    => lists status of all the caches & when they were last
       reloaded. Will show an ! next to records that were fetched
       with params. Example:
    
    caches true
    => shows params the caches were loaded with
    
    products.delete_all
    => delete all the products in the cache & reload the cache

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request