shopify_theme 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/shopify_theme.rb +34 -3
- data/lib/shopify_theme/cli.rb +22 -1
- data/lib/shopify_theme/version.rb +1 -1
- data/shopify_theme.gemspec +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/cli_spec.rb +12 -2
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6157b9bdb277a5335fb30d287296a7d190678f6d
|
4
|
+
data.tar.gz: 4d67641a71dbf5f44a3b96296fa749761fcedefa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88bae8b6b99275741f476858dedcadab0bb2216a791c1f7715dee1e1ad4dfb4992a07bee500ababbaecc21004a5abc89a1cdf7a0690f1dd634c33176d8eb6bce
|
7
|
+
data.tar.gz: 357a5dd0f6875e1ba8d77f756022bdbcb6865158dca36a513a8991cee735bd84fc59ae7e1ccedfbe1f4b68274d665cee3e046dbe05570eb46adbd9f09a057590
|
data/README.md
CHANGED
@@ -43,6 +43,9 @@ Example of config.yml. Notice store has no http or https declaration. You can
|
|
43
43
|
use `:whitelist_files:` to specify files for upload. The `assets/`, `config/`,
|
44
44
|
`layout/`, `snippets/` and `templates/` directories are included by default.
|
45
45
|
|
46
|
+
You can also use `:ignore_files:` to exclude files from getting uploaded, for
|
47
|
+
example your `config/settings.html` or other configuration driven items
|
48
|
+
|
46
49
|
```yaml
|
47
50
|
---
|
48
51
|
:api_key: 7a8da86d3dd730b67a357dedabaac5d6
|
@@ -52,6 +55,8 @@ use `:whitelist_files:` to specify files for upload. The `assets/`, `config/`,
|
|
52
55
|
:whitelist_files:
|
53
56
|
- directoryToUpload/
|
54
57
|
- importantFile.txt
|
58
|
+
:ignore_files:
|
59
|
+
- config/settings.html
|
55
60
|
```
|
56
61
|
|
57
62
|
Download all the theme files
|
@@ -90,6 +95,16 @@ Open the store in the default browser
|
|
90
95
|
theme open
|
91
96
|
```
|
92
97
|
|
98
|
+
Bootstrap a new theme with [Timber](http://www.shopify.com/timber)
|
99
|
+
|
100
|
+
```
|
101
|
+
# use latest stable
|
102
|
+
theme bootstrap api_key password shop_name theme_name
|
103
|
+
|
104
|
+
# use latest build
|
105
|
+
theme bootstrap api_key password shop_name theme_name master
|
106
|
+
```
|
107
|
+
|
93
108
|
# Common Problems
|
94
109
|
|
95
110
|
## How do I edit a theme that isn't my shops main theme?
|
data/lib/shopify_theme.rb
CHANGED
@@ -7,6 +7,8 @@ module ShopifyTheme
|
|
7
7
|
NOOPParser = Proc.new {|data, format| {} }
|
8
8
|
TIMER_RESET = 10
|
9
9
|
PERMIT_LOWER_LIMIT = 3
|
10
|
+
TIMBER_ZIP = "https://github.com/Shopify/Timber/archive/%s.zip"
|
11
|
+
LAST_KNOWN_STABLE = "v1.1.0"
|
10
12
|
|
11
13
|
def self.test?
|
12
14
|
ENV['test']
|
@@ -79,10 +81,24 @@ module ShopifyTheme
|
|
79
81
|
response
|
80
82
|
end
|
81
83
|
|
84
|
+
def self.upload_timber(name, master)
|
85
|
+
source = TIMBER_ZIP % (master ? 'master' : LAST_KNOWN_STABLE)
|
86
|
+
puts master ? "Using latest build from shopify" : "Using last known stable build -- #{LAST_KNOWN_STABLE}"
|
87
|
+
response = shopify.post("/admin/themes.json", :body => {:theme => {:name => name, :src => source, :role => 'unpublished'}})
|
88
|
+
manage_timer(response)
|
89
|
+
body = JSON.parse(response.body)
|
90
|
+
if theme = body['theme']
|
91
|
+
watch_until_processing_complete(theme)
|
92
|
+
else
|
93
|
+
puts "Could not download theme!"
|
94
|
+
puts body
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
82
99
|
def self.config
|
83
100
|
@config ||= if File.exist? 'config.yml'
|
84
101
|
config = YAML.load(File.read('config.yml'))
|
85
|
-
puts ":ignore_files: is deprecated for a white list, use :whitelist_files: instead" if config[:ignore_files] && !test?
|
86
102
|
config
|
87
103
|
else
|
88
104
|
puts "config.yml does not exist!" unless test?
|
@@ -90,16 +106,20 @@ module ShopifyTheme
|
|
90
106
|
end
|
91
107
|
end
|
92
108
|
|
109
|
+
def self.config=(config)
|
110
|
+
@config = config
|
111
|
+
end
|
112
|
+
|
93
113
|
def self.path
|
94
114
|
@path ||= config[:theme_id] ? "/admin/themes/#{config[:theme_id]}/assets.json" : "/admin/assets.json"
|
95
115
|
end
|
96
116
|
|
97
117
|
def self.ignore_files
|
98
|
-
|
118
|
+
(config[:ignore_files] || []).compact.map { |r| Regexp.new(r) }
|
99
119
|
end
|
100
120
|
|
101
121
|
def self.whitelist_files
|
102
|
-
|
122
|
+
(config[:whitelist_files] || []).compact
|
103
123
|
end
|
104
124
|
|
105
125
|
def self.is_binary_data?(string)
|
@@ -120,4 +140,15 @@ module ShopifyTheme
|
|
120
140
|
base_uri "https://#{config[:store]}"
|
121
141
|
ShopifyTheme
|
122
142
|
end
|
143
|
+
|
144
|
+
def self.watch_until_processing_complete(theme)
|
145
|
+
count = 0
|
146
|
+
while true do
|
147
|
+
Kernel.sleep(count)
|
148
|
+
response = shopify.get("/admin/themes/#{theme['id']}.json")
|
149
|
+
theme = JSON.parse(response.body)['theme']
|
150
|
+
return theme if theme['previewable']
|
151
|
+
count += 5
|
152
|
+
end
|
153
|
+
end
|
123
154
|
end
|
data/lib/shopify_theme/cli.rb
CHANGED
@@ -36,6 +36,27 @@ module ShopifyTheme
|
|
36
36
|
create_file('config.yml', config.to_yaml)
|
37
37
|
end
|
38
38
|
|
39
|
+
desc "bootstrap API_KEY PASSWORD STORE THEME_NAME", "bootstrap with Timber to shop and configure local directory. Include master if you'd like to use the latest build for the theme"
|
40
|
+
method_option :master, :type => :boolean, :default => false
|
41
|
+
def bootstrap(api_key=nil, password=nil, store=nil, theme_name=nil, master=nil)
|
42
|
+
ShopifyTheme.config = {:api_key => api_key, :password => password, :store => store}
|
43
|
+
|
44
|
+
theme_name ||= 'Timber'
|
45
|
+
say("Registering #{theme_name} theme on #{store}", :green)
|
46
|
+
theme = ShopifyTheme.upload_timber(theme_name, master || false)
|
47
|
+
|
48
|
+
say("Creating directory named #{theme_name}", :green)
|
49
|
+
empty_directory(theme_name)
|
50
|
+
|
51
|
+
say("Saving configuration to #{theme_name}", :green)
|
52
|
+
ShopifyTheme.config.merge!(theme_id: theme['id'])
|
53
|
+
create_file("#{theme_name}/config.yml", ShopifyTheme.config.to_yaml)
|
54
|
+
|
55
|
+
say("Downloading #{theme_name} assets from Shopify")
|
56
|
+
Dir.chdir(theme_name)
|
57
|
+
download()
|
58
|
+
end
|
59
|
+
|
39
60
|
desc "download FILE", "download the shops current theme assets"
|
40
61
|
method_option :quiet, :type => :boolean, :default => false
|
41
62
|
method_option :exclude
|
@@ -151,7 +172,7 @@ module ShopifyTheme
|
|
151
172
|
def local_assets_list
|
152
173
|
local_files.reject do |p|
|
153
174
|
@permitted_files ||= (DEFAULT_WHITELIST | ShopifyTheme.whitelist_files).map{|pattern| Regexp.new(pattern)}
|
154
|
-
@permitted_files.none? { |regex| regex =~ p }
|
175
|
+
@permitted_files.none? { |regex| regex =~ p } || ShopifyTheme.ignore_files.any? { |regex| regex =~ p }
|
155
176
|
end
|
156
177
|
end
|
157
178
|
|
data/shopify_theme.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.add_development_dependency 'rake'
|
24
24
|
s.add_development_dependency 'minitest', '>= 5.0.0'
|
25
|
+
s.add_development_dependency 'pry'
|
26
|
+
s.add_development_dependency 'pry-debugger'
|
25
27
|
|
26
28
|
s.files = `git ls-files`.split("\n")
|
27
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/cli_spec.rb
CHANGED
@@ -26,12 +26,22 @@ module ShopifyTheme
|
|
26
26
|
|
27
27
|
before do
|
28
28
|
@cli = CliDouble.new
|
29
|
+
ShopifyTheme.config = {}
|
29
30
|
end
|
30
31
|
|
31
32
|
it "should remove assets that are not a part of the white list" do
|
32
33
|
@cli.local_files = ['assets/image.png', 'config.yml', 'layout/theme.liquid']
|
33
|
-
|
34
|
-
assert_equal
|
34
|
+
local_assets_list = @cli.send(:local_assets_list)
|
35
|
+
assert_equal 2, local_assets_list.length
|
36
|
+
assert_equal false, local_assets_list.include?('config.yml')
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should remove assets that are part of the ignore list" do
|
40
|
+
ShopifyTheme.config = {ignore_files: ['config/settings.html']}
|
41
|
+
@cli.local_files = ['assets/image.png', 'layout/theme.liquid', 'config/settings.html']
|
42
|
+
local_assets_list = @cli.send(:local_assets_list)
|
43
|
+
assert_equal 2, local_assets_list.length
|
44
|
+
assert_equal false, local_assets_list.include?('config/settings.html')
|
35
45
|
end
|
36
46
|
|
37
47
|
it "should generate the shop path URL to the query parameter preview_theme_id if the id is present" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Duff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 5.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-debugger
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: Command line tool to help with developing Shopify themes. Provides simple
|
112
140
|
commands to download, upload and delete files from a theme. Also includes the watch
|
113
141
|
command to watch a directory and upload files as they change.
|