bootic_cli 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce65ebb8fcfa965e89d36c586b1e8727b107293a
4
- data.tar.gz: 65a6397f16c67cd0384cd32562b811b629329515
3
+ metadata.gz: d2765e7635f1721bf89ff0c5f35e089229a917bf
4
+ data.tar.gz: 585e9460e97ee451c0ff8167a74177843231a7bb
5
5
  SHA512:
6
- metadata.gz: 3cb885f8025ac8a13a10073b4ed53924a324a5058fa293b0195f64df17b863ea7a7584edad90928ffc81dfbd03d71b84d1621cbad57945360ff3e97ed27457fc
7
- data.tar.gz: e00d252e1e00dad78e4588d1f7040e2a0954db1914007ac5b550620ddc71bc3096847ba98604dffdd471645078b052fff3510f882839b95ab2cc6e4c0310e8d8
6
+ metadata.gz: 126f5bd5af00aefdbca55b4a7a474042b80ddb36e83719b5fde9ee68d6a7c2c551053d6c76b6d47445b29181d005d42252b31e2d95cfba1c364f4498a5105bfd
7
+ data.tar.gz: 5a9f2eb890175edb519bac77d7b472055f13b9de15a13c1e7040ead4a7db96a4d05b7f59153105c4fe2ea7d1dd5b0ab2e74a75b689f6531b4d003d8e9ab4d072
@@ -30,20 +30,25 @@ module BooticCli
30
30
  end
31
31
 
32
32
  ASSETS_DIR = 'assets'.freeze
33
- TEMPLATE_PATTERNS = ['*.liquid', '*.html', '*.css', '*.js', 'theme.yml'].freeze
33
+ TEMPLATE_PATTERNS = ['sections/*.html', '*.html', '*.css', '*.js', 'theme.yml', 'settings.json'].freeze
34
34
  ASSET_PATTERNS = [File.join(ASSETS_DIR, '*')].freeze
35
35
 
36
+ def self.resolve_path(path, dir)
37
+ File.expand_path(path).sub(File.expand_path(dir) + '/', '')
38
+ end
39
+
36
40
  # helper to resolve the right type (Template or Asset) from a local path
37
41
  # this is not part of the generic Theme interface
38
42
  def self.resolve_type(path)
39
43
  path =~ /assets\// ? :asset : :template
40
44
  end
41
45
 
42
- def self.resolve_file(path)
46
+ def self.resolve_file(path, workdir)
43
47
  file = File.new(path)
44
48
  type = resolve_type(path)
45
- file_name = File.basename(path)
49
+ file_name = resolve_path(path, workdir)
46
50
 
51
+ # initialize a new asset or template as it might be a new file
47
52
  item = if path =~ /assets\//
48
53
  ThemeAsset.new(file_name, file, file.mtime.utc)
49
54
  else
@@ -87,7 +92,7 @@ module BooticCli
87
92
  def templates
88
93
  @templates ||= (
89
94
  paths_for(TEMPLATE_PATTERNS).sort.map do |path|
90
- name = File.basename(path)
95
+ name = self.class.resolve_path(path, dir)
91
96
  file = File.new(path)
92
97
  Template.new(name, file.read, file.mtime.utc)
93
98
  end
@@ -114,6 +119,9 @@ module BooticCli
114
119
  body = body.gsub(/\r\n?/, "\n")
115
120
  end
116
121
 
122
+ dir = File.dirname(path)
123
+ FileUtils.mkdir_p(dir) unless File.exist?(dir)
124
+
117
125
  File.open(path, 'w') do |io|
118
126
  io.write(body)
119
127
  end
@@ -155,7 +163,9 @@ module BooticCli
155
163
  end
156
164
 
157
165
  def paths_for(patterns)
158
- patterns.reduce([]) {|m, pattern| m + Dir[File.join(dir, pattern)]}
166
+ patterns.reduce([]) do |m, pattern|
167
+ m + Dir[File.join(dir, pattern)]
168
+ end
159
169
  end
160
170
 
161
171
  def setup
@@ -189,21 +189,22 @@ module BooticCli
189
189
 
190
190
  def watch(dir, remote_theme, watcher: Listen)
191
191
  listener = watcher.to(dir) do |modified, added, removed|
192
+
192
193
  if modified.any?
193
194
  modified.each do |path|
194
- upsert_file(remote_theme, path)
195
+ upsert_file(remote_theme, path, dir)
195
196
  end
196
197
  end
197
198
 
198
199
  if added.any?
199
200
  added.each do |path|
200
- upsert_file(remote_theme, path)
201
+ upsert_file(remote_theme, path, dir)
201
202
  end
202
203
  end
203
204
 
204
205
  if removed.any?
205
206
  removed.each do |path|
206
- delete_file(remote_theme, path)
207
+ delete_file(remote_theme, path, dir)
207
208
  end
208
209
  end
209
210
 
@@ -321,9 +322,10 @@ module BooticCli
321
322
  pool.start
322
323
  end
323
324
 
324
- def upsert_file(theme, path)
325
+ def upsert_file(theme, path, dir)
325
326
  return if File.basename(path)[0] == '.' # filter out .lock and .state
326
- item, type = FSTheme.resolve_file(path)
327
+
328
+ item, type = FSTheme.resolve_file(path, dir)
327
329
  success = handle_file_errors(type, item) do
328
330
  case type
329
331
  when :template
@@ -335,9 +337,9 @@ module BooticCli
335
337
  puts "Uploaded #{type}: #{highlight(item.file_name)}" if success
336
338
  end
337
339
 
338
- def delete_file(theme, path)
340
+ def delete_file(theme, path, dir)
339
341
  type = FSTheme.resolve_type(path)
340
- file_name = File.basename(path)
342
+ file_name = FSTheme.resolve_path(path, dir)
341
343
  success = case type
342
344
  when :template
343
345
  theme.remove_template(file_name)
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = '0.7.3'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-02 00:00:00.000000000 Z
12
+ date: 2020-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor