bootic_cli 0.9.2 → 0.9.4

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
  SHA256:
3
- metadata.gz: 1053a78f5dcee0b27021985457476ccc2ff4666842c887b2a2bf86cc5b4eb5cf
4
- data.tar.gz: 62d10a5ad2b1d927275a247a5898d1d16090b7e1c624790fbbed801e3b4a1094
3
+ metadata.gz: a296e4252d391af00cccfff4af93d652c2daa29e4b8d65cd42202331bfc1b70d
4
+ data.tar.gz: 2f485bdd0c668f84738a21d7872404180ebaf04f594d37b1e000bc5df1966f52
5
5
  SHA512:
6
- metadata.gz: 3b7f0b1a2357cf1f4655d09fed51b134d37c091987c99b5bca5164ab13e06dafc04f588fa7ec380d9e03c28d6db3b919993d7e858a7c8a30ad940e4ba7fa47e9
7
- data.tar.gz: 79969ffa8e65899084cadd182708347dd79280412a2a77413eea68aa2f1d803909cea29e8fa5a92e97d9af9644ed86f9c4f6e94c25d91f472300030e89accb9d
6
+ metadata.gz: 8d44a11d8d69d2bd619cd69b8f9e8cfcaf42eea3674f6281cc14c9d70f74c1660da618f4b07983a034ac2d23534e380d83f485946705c641032af12feaa4c835
7
+ data.tar.gz: 6ad0e38e1b4274e68cc52c9d987f0b126af1d786707d2962d82b719bbc158ad4bb8bfba7efe3b1e63bf59ae05cd27e35753ccadea3c09deceeeceb0e735bb546
@@ -139,7 +139,7 @@ module BooticCli
139
139
  if options['force'].nil? && has_lockfile?
140
140
  prompt.say("Looks like there's another process already watching this dir.")
141
141
  prompt.say("If this is not the case, please run this command with --force (or -f)")
142
- abort
142
+ exit
143
143
  end
144
144
 
145
145
  local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['public'])
@@ -220,7 +220,7 @@ module BooticCli
220
220
  within_theme do
221
221
  unless File.directory?(dir) and contains_theme?(dir)
222
222
  prompt.say("Path doesn't exist or doesn't contain theme: #{dir}")
223
- abort
223
+ exit
224
224
  end
225
225
 
226
226
  dirname = File.dirname(dir)
@@ -254,14 +254,14 @@ module BooticCli
254
254
  def warn_about_public
255
255
  unless prompt.yes_or_no?("You're pushing changes directly to your public theme. Are you sure?", true)
256
256
  prompt.say("Ok, sure. You can skip the above warning prompt by passing a `--public` flag.")
257
- abort
257
+ exit
258
258
  end
259
259
  end
260
260
 
261
261
  def within_theme(&block)
262
262
  unless is_within_theme?
263
263
  prompt.say "This directory doesn't look like a Bootic theme! (#{current_expanded_dir})", :magenta
264
- abort
264
+ exit
265
265
  end
266
266
 
267
267
  logged_in_action do
@@ -313,7 +313,7 @@ module BooticCli
313
313
  input = shell.ask("#{question} [#{default_char}]").strip
314
314
  rescue Interrupt
315
315
  say "\nCtrl-C received. Bailing out!", :magenta
316
- abort
316
+ exit
317
317
  end
318
318
 
319
319
  return default_answer if input == '' || input.downcase == default_char
@@ -31,6 +31,7 @@ module BooticCli
31
31
  end
32
32
 
33
33
  # file sizes may differ as they are served by CDN (that shrinks them)
34
+ # puts "Comparing APIAsset vs other digest:\n#{digest}\n#{other.digest}"
34
35
  self.digest == other.digest # && self.file_size == other.file_size
35
36
  end
36
37
 
@@ -19,12 +19,12 @@ module BooticCli
19
19
 
20
20
  def ==(other)
21
21
  if other.digest.to_s == '' # api theme asset without a digest set
22
- # puts "Other has no digest, so comparing dates: #{self.updated_on} vs #{other.updated_on}"
22
+ # puts "Other has no digest, so comparing dates: #{self.updated_on.to_i} vs #{other.updated_on.to_i}"
23
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
+ # puts "Comparing FSTheme vs other digest:\n#{digest}\n#{other.digest}"
28
28
  self.digest == other.digest # self.file_size == other.file_size
29
29
  end
30
30
  end
@@ -33,22 +33,34 @@ module BooticCli
33
33
  TEMPLATE_PATTERNS = ['sections/*.html', '*.html', '*.css', '*.js', '*.json', 'theme.yml'].freeze
34
34
  ASSET_PATTERNS = [File.join(ASSETS_DIR, '*')].freeze
35
35
 
36
+ ASSET_PATH_REGEX = /^assets\/[^\/]+$/.freeze
37
+ TEMPLATE_PATH_REGEX = /^[^\/]+\.(html|css|scss|js|json|yml)$/.freeze
38
+ SECTION_PATH_REGEX = /^sections\/[^\/]+.html$/.freeze
39
+
36
40
  def self.resolve_path(path, dir)
37
41
  File.expand_path(path).sub(File.expand_path(dir) + '/', '')
38
42
  end
39
43
 
40
- # helper to resolve the right type (Template or Asset) from a local path
44
+ # helper to resolve the right type (Template or Asset) from a local path
41
45
  # this is not part of the generic Theme interface
42
- def self.resolve_type(path)
43
- path =~ /assets\// ? :asset : :template
46
+ def self.resolve_type(path, dir)
47
+ relative_path = resolve_path(path, dir)
48
+
49
+ if relative_path[ASSET_PATH_REGEX]
50
+ :asset
51
+ elsif relative_path[TEMPLATE_PATH_REGEX] || relative_path[SECTION_PATH_REGEX]
52
+ :template
53
+ end
44
54
  end
45
55
 
46
56
  def self.resolve_file(path, workdir)
47
- file = File.new(path)
48
- type = resolve_type(path)
57
+ unless type = resolve_type(path, workdir)
58
+ return # neither an asset or template
59
+ end
49
60
 
50
61
  # initialize a new asset or template as it might be a new file
51
- item = if path =~ /assets\//
62
+ file = File.new(path)
63
+ item = if type == :asset
52
64
  file_name = File.basename(path)
53
65
  ThemeAsset.new(file_name, file, file.mtime.utc)
54
66
  else
@@ -326,6 +326,11 @@ module BooticCli
326
326
  return if File.basename(path)[0] == '.' # filter out .lock and .state
327
327
 
328
328
  item, type = FSTheme.resolve_file(path, dir)
329
+ unless item
330
+ # puts "Not a template or asset: #{path}"
331
+ return
332
+ end
333
+
329
334
  success = handle_file_errors(type, item) do
330
335
  case type
331
336
  when :template
@@ -338,7 +343,11 @@ module BooticCli
338
343
  end
339
344
 
340
345
  def delete_file(theme, path, dir)
341
- type = FSTheme.resolve_type(path)
346
+ unless type = FSTheme.resolve_type(path, dir)
347
+ # puts "Not a template or asset: #{path}"
348
+ return
349
+ end
350
+
342
351
  success = case type
343
352
  when :template
344
353
  file_name = FSTheme.resolve_path(path, dir)
@@ -346,8 +355,6 @@ module BooticCli
346
355
  when :asset
347
356
  file_name = File.basename(path)
348
357
  theme.remove_asset(file_name)
349
- else
350
- raise "Invalid type: #{type}"
351
358
  end
352
359
  puts "Deleted remote #{type}: #{highlight(file_name)}" if success
353
360
  end
@@ -361,7 +368,7 @@ module BooticCli
361
368
 
362
369
  if fields.include?('$.updated_on') || fields.include?('updated_on')
363
370
  prompt.say("#{file.file_name} timestamp #{e.errors.first.messages.first}", :red)
364
- abort
371
+ exit
365
372
  end
366
373
 
367
374
  error_msg = if fields.include?('file_content_type') or fields.include?('content_type')
@@ -389,15 +396,15 @@ module BooticCli
389
396
 
390
397
  rescue APITheme::UnknownResponse => e # 502s, 503s, etc
391
398
  prompt.say("Got an unknown response from server: #{e.message}. Please try again in a minute.", :red)
392
- abort
399
+ exit
393
400
 
394
- rescue Net::OpenTimeout, Net::ReadTimeout => e
401
+ rescue SocketError, Net::OpenTimeout, Net::ReadTimeout => e
395
402
  prompt.say("I'm having trouble connecting to the server. Please try again in a minute.", :red)
396
- abort
403
+ exit
397
404
 
398
405
  rescue BooticClient::ServerError => e
399
406
  prompt.say("Couldn't save #{file.file_name}. Please try again in a few minutes.", :red)
400
- abort
407
+ exit
401
408
  end
402
409
  end
403
410
  end
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.4'
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.9.2
4
+ version: 0.9.4
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: 2023-04-12 00:00:00.000000000 Z
12
+ date: 2023-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor