bootic_cli 0.7.1 → 0.7.2
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/lib/bootic_cli/themes/api_theme.rb +23 -3
- data/lib/bootic_cli/themes/fs_theme.rb +3 -2
- data/lib/bootic_cli/themes/workflows.rb +13 -7
- data/lib/bootic_cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66ebab01b114029b6d6cff68f2957df471694fbe
|
4
|
+
data.tar.gz: f593e3f37ed9dd3cd7ec48730afd8509f4e6f480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13d97b88ee377d64743699dd420349601cecc0c7b3a94380c9771dc553094044ea33764164e85eb5e44a4e6983ba510f897047ea266e03fd0f55ab001293b0f4
|
7
|
+
data.tar.gz: 28b87bf9559eca1c3271ad74d37e2ea7f3c385d509d5ef34a677100d5edc345e5bb8ad424f6b390b6dceeb1da333b34044b49bf53cc397a5bd3727041202473c
|
@@ -10,7 +10,7 @@ module BooticCli
|
|
10
10
|
|
11
11
|
def ==(other)
|
12
12
|
# puts "Comparing with time #{self.updated_on} vs #{other.updated_on}"
|
13
|
-
self.updated_on == other.updated_on
|
13
|
+
self.updated_on.to_i == other.updated_on.to_i
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -116,10 +116,18 @@ module BooticCli
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def add_template(file_name, body)
|
119
|
-
|
119
|
+
params = {
|
120
120
|
file_name: file_name,
|
121
121
|
body: body
|
122
|
-
|
122
|
+
}
|
123
|
+
|
124
|
+
if ts = get_updated_on(file_name)
|
125
|
+
params.merge!(last_updated_on: ts.to_i)
|
126
|
+
end
|
127
|
+
|
128
|
+
check_errors!(theme.create_template(params)).tap do |entity|
|
129
|
+
template_updated(file_name, entity)
|
130
|
+
end
|
123
131
|
end
|
124
132
|
|
125
133
|
def remove_template(file_name)
|
@@ -152,6 +160,18 @@ module BooticCli
|
|
152
160
|
private
|
153
161
|
attr_reader :theme
|
154
162
|
|
163
|
+
def get_updated_on(file_name)
|
164
|
+
if tpl = templates.find { |t| t.file_name == file_name }
|
165
|
+
tpl.updated_on
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def template_updated(file_name, new_template)
|
170
|
+
if index = templates.index { |t| t.file_name == file_name }
|
171
|
+
templates[index] = ItemWithTime.new(new_template)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
155
175
|
def check_errors!(entity)
|
156
176
|
if entity.has?(:errors)
|
157
177
|
raise EntityErrors.new(entity.errors)
|
@@ -8,7 +8,7 @@ module BooticCli
|
|
8
8
|
|
9
9
|
Template = Struct.new(:file_name, :body, :updated_on) do
|
10
10
|
def ==(other)
|
11
|
-
self.updated_on == other.updated_on
|
11
|
+
self.updated_on.to_i == other.updated_on.to_i
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -20,10 +20,11 @@ module BooticCli
|
|
20
20
|
def ==(other)
|
21
21
|
if other.digest.to_s == '' # api theme asset without a digest set
|
22
22
|
# puts "Other has no digest, so comparing dates: #{self.updated_on} vs #{other.updated_on}"
|
23
|
-
return self.updated_on == other.updated_on
|
23
|
+
return self.updated_on.to_i == other.updated_on.to_i
|
24
24
|
end
|
25
25
|
|
26
26
|
# file sizes may differ as they are served by CDN (that shrinks them)
|
27
|
+
# puts "Comparing digests:\n#{digest}\n#{other.digest}"
|
27
28
|
self.digest == other.digest # self.file_size == other.file_size
|
28
29
|
end
|
29
30
|
end
|
@@ -324,7 +324,7 @@ module BooticCli
|
|
324
324
|
def upsert_file(theme, path)
|
325
325
|
return if File.basename(path)[0] == '.' # filter out .lock and .state
|
326
326
|
item, type = FSTheme.resolve_file(path)
|
327
|
-
handle_file_errors(type, item) do
|
327
|
+
success = handle_file_errors(type, item) do
|
328
328
|
case type
|
329
329
|
when :template
|
330
330
|
theme.add_template(item.file_name, item.body)
|
@@ -332,7 +332,7 @@ module BooticCli
|
|
332
332
|
theme.add_asset(item.file_name, item.file)
|
333
333
|
end
|
334
334
|
end
|
335
|
-
puts "Uploaded #{type}: #{highlight(item.file_name)}"
|
335
|
+
puts "Uploaded #{type}: #{highlight(item.file_name)}" if success
|
336
336
|
end
|
337
337
|
|
338
338
|
def delete_file(theme, path)
|
@@ -352,15 +352,21 @@ module BooticCli
|
|
352
352
|
def handle_file_errors(type, file, &block)
|
353
353
|
begin
|
354
354
|
yield
|
355
|
+
true
|
355
356
|
rescue APITheme::EntityErrors => e
|
356
357
|
fields = e.errors.map(&:field)
|
357
358
|
|
358
|
-
|
359
|
+
if fields.include?('$.updated_on') || fields.include?('updated_on')
|
360
|
+
prompt.say("#{file.file_name} timestamp #{e.errors.first.messages.first}", :red)
|
361
|
+
abort
|
362
|
+
end
|
363
|
+
|
364
|
+
error_msg = if fields.include?('file_content_type') or fields.include?('content_type')
|
359
365
|
"is an unsupported file type for #{type}s."
|
360
|
-
elsif fields.include?(
|
366
|
+
elsif fields.include?('file_file_size') # big asset
|
361
367
|
size_str = file.file_size.to_i > 0 ? "(#{file.file_size} KB) " : ''
|
362
368
|
"#{size_str}is heavier than the maximum allowed for assets (1 MB)"
|
363
|
-
elsif fields.include?(
|
369
|
+
elsif fields.include?('body') # big template
|
364
370
|
str = file.file_name[/\.(html|liquid)$/] ? "Try splitting it into smaller chunks" : "Try saving it as an asset instead"
|
365
371
|
str += ", since templates can hold up to 64 KB of data."
|
366
372
|
else
|
@@ -368,11 +374,11 @@ module BooticCli
|
|
368
374
|
end
|
369
375
|
|
370
376
|
prompt.say("#{file.file_name} #{error_msg}. Skipping...", :red)
|
371
|
-
# abort
|
377
|
+
false # abort
|
372
378
|
|
373
379
|
rescue JSON::GeneratorError => e
|
374
380
|
prompt.say("#{file.file_name} looks like a binary file, not a template. Skipping...", :red)
|
375
|
-
# abort
|
381
|
+
false # just continue, don't abort
|
376
382
|
|
377
383
|
rescue Net::OpenTimeout, Net::ReadTimeout => e
|
378
384
|
prompt.say("I'm having trouble connecting to the server. Please try again in a minute.", :red)
|
data/lib/bootic_cli/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.2
|
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-03-
|
12
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|