bootic_cli 1.2.0 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e79d9578ddb578beef27140d4339a48aa2ed8f3f483a9090d1a2ed7e8e263581
4
- data.tar.gz: b14a3dfbc8850d37721a8be37234fa83919240a8b36ff527c8a1d9040a0464a7
3
+ metadata.gz: 810eddf35c01c317b19fb60930b7112ed974fd35a793241895965a39b84c83e7
4
+ data.tar.gz: 10c44b948045fc88a895299ad429912b67bbae5dfc2e59796b3a75073d7e1411
5
5
  SHA512:
6
- metadata.gz: 62c666c6924988e9a1b85180a8e3dd6ab55a7c023cae703362a4869cc4dc7d4f8d2b0ac1a9be5dcdeb7fdcbec3c772d0a82eedc87cc6db3d85567e6570eb685b
7
- data.tar.gz: dc592ce57c5348ed215862d98790c38de8f8b049a5b028ec5a97f224a596d7bf75952bbf3a7b84aa392c54f9463f604d51ec7b9d83bbb1467ac4e466d7e081d8
6
+ metadata.gz: 7b9e1ac14b64fa1e8fbea3a0a5b02bb0aaa49e9fc41a2cc9694ccaf787ca53cacfb407b7321465097ad595ecc94084d9c488bb63229332c73644d23064649db9
7
+ data.tar.gz: f611a28457b4c58d35bb97fa70e0aafd20c4d6c1467a61f8e184c221f0ab4188aaa966ea56c530bbb6ea9c9b575c2d83c85bfa896005b96eee81d293d812b19f
@@ -25,8 +25,18 @@ module BooticCli
25
25
  prompt.say "Directory already exists! (#{local_theme.path})", :red
26
26
  else
27
27
  prompt.say "Cloning theme files into #{local_theme.path}"
28
- workflows.pull(local_theme, remote_theme)
28
+
29
+ # write the pairing info first, so that if the pull below fails partway
30
+ # through, the directory is still resumable with `bootic themes pull`
29
31
  local_theme.write_subdomain
32
+
33
+ begin
34
+ workflows.pull(local_theme, remote_theme)
35
+ rescue BooticCli::Themes::Workflows::RetryableError => e
36
+ prompt.say e.message, :red
37
+ prompt.say "Once your connection is back, run `bootic themes pull` from within #{local_theme.path} to finish cloning.", :magenta
38
+ exit 1
39
+ end
30
40
  end
31
41
  end
32
42
  end
@@ -273,7 +283,13 @@ module BooticCli
273
283
  end
274
284
 
275
285
  logged_in_action do
276
- yield
286
+ begin
287
+ yield
288
+ rescue BooticCli::Themes::Workflows::RetryableError => e
289
+ prompt.say e.message, :red
290
+ prompt.say "Once your connection is back, run `bootic themes pull` from within this directory to resume.", :magenta
291
+ exit 1
292
+ end
277
293
  end
278
294
  end
279
295
 
@@ -59,15 +59,15 @@ module BooticCli
59
59
  end
60
60
 
61
61
  def find_remote_shop(subdomain = nil)
62
- if !subdomain
63
- return root.shops.first
64
- end
65
-
66
- if root.has?(:all_shops)
62
+ found = if subdomain.nil?
63
+ root.shops.first
64
+ elsif root.has?(:all_shops)
67
65
  root.all_shops(subdomains: subdomain).find { |s| s.subdomain == subdomain }
68
66
  else
69
67
  root.shops.find { |s| s.subdomain == subdomain }
70
68
  end
69
+
70
+ found or raise "No active shop named #{subdomain}"
71
71
  end
72
72
 
73
73
  private
@@ -26,6 +26,14 @@ module BooticCli
26
26
 
27
27
  class Workflows
28
28
  CONCURRENCY = 10
29
+ MAX_ATTEMPTS = 3 # 1 initial try + 2 retries
30
+
31
+ # raised when a transient error (network or server-side) persists after retrying
32
+ class RetryableError < StandardError; end
33
+ # client couldn't reach the server at all (timeouts, DNS/socket errors)
34
+ class ConnectionError < RetryableError; end
35
+ # server responded, but with an error (502s, 503s, etc)
36
+ class ServerUnavailableError < RetryableError; end
29
37
 
30
38
  def initialize(prompt: NullPrompt)
31
39
  @prompt = prompt
@@ -362,7 +370,9 @@ module BooticCli
362
370
  end
363
371
 
364
372
  def handle_file_errors(type, file, &block)
373
+ attempts = 0
365
374
  begin
375
+ attempts += 1
366
376
  yield
367
377
  true
368
378
  rescue APITheme::EntityErrors => e
@@ -396,17 +406,21 @@ module BooticCli
396
406
  prompt.say("Invalid request: #{e.message}. Skipping...", :red)
397
407
  false # just continue, don't abort
398
408
 
399
- rescue APITheme::UnknownResponse => e # 502s, 503s, etc
400
- prompt.say("Got an unknown response from server: #{e.message}. Please try again in a minute.", :red)
401
- exit
402
-
403
409
  rescue Faraday::TimeoutError, SocketError, Net::OpenTimeout, Net::ReadTimeout => e
404
- prompt.say("I'm having trouble connecting to the server. Please try again in a minute.", :red)
405
- exit
410
+ if attempts < MAX_ATTEMPTS
411
+ prompt.say("Trouble connecting to the server while saving #{file.file_name} (#{e.message}). Retrying (attempt #{attempts + 1}/#{MAX_ATTEMPTS})...", :yellow)
412
+ retry
413
+ end
406
414
 
407
- rescue BooticClient::ServerError => e
408
- prompt.say("Couldn't save #{file.file_name}. Please try again in a few minutes.", :red)
409
- exit
415
+ raise ConnectionError, "Couldn't reach the server to save #{file.file_name} after #{attempts} attempts (#{e.message})."
416
+
417
+ rescue APITheme::UnknownResponse, BooticClient::ServerError => e # 502s, 503s, etc
418
+ if attempts < MAX_ATTEMPTS
419
+ prompt.say("Server error while saving #{file.file_name} (#{e.message}). Retrying (attempt #{attempts + 1}/#{MAX_ATTEMPTS})...", :yellow)
420
+ retry
421
+ end
422
+
423
+ raise ServerUnavailableError, "Server kept failing to save #{file.file_name} after #{attempts} attempts (#{e.message})."
410
424
  end
411
425
  end
412
426
  end
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  - Tomás Pollak
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2025-01-22 00:00:00.000000000 Z
12
+ date: 2026-07-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: thor
@@ -186,7 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  - !ruby/object:Gem::Version
187
188
  version: '0'
188
189
  requirements: []
189
- rubygems_version: 3.6.2
190
+ rubygems_version: 3.4.6
191
+ signing_key:
190
192
  specification_version: 4
191
193
  summary: Bootic command-line client.
192
194
  test_files: []