bootic_cli 1.1.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: 216121435cde22e62af2e80deace1604d9bbdc2c1fb4815fedb18a40b4bc24a9
4
- data.tar.gz: 2d3e00c8bf4a651d107555ca7ec5e3fcc871d82976bec3f65c39183c08f09bd0
3
+ metadata.gz: 810eddf35c01c317b19fb60930b7112ed974fd35a793241895965a39b84c83e7
4
+ data.tar.gz: 10c44b948045fc88a895299ad429912b67bbae5dfc2e59796b3a75073d7e1411
5
5
  SHA512:
6
- metadata.gz: d80d3453d1d3d0fb7bfe73cbccc4cd5cb5652e7fb0ed9081611d29f5e42e8c6d2456cb0f4ca7a3ccfbed4e739afed8e61c2c9b2bbae73849ec826525185b2f7d
7
- data.tar.gz: 7db8337b8b6225af0d39400f9967b881ab6d1a026c026ef0e18dd56361b64b4b85cbb0bf8be2c76bbb0ed26087ca73d0e0199654f83ff5ef6b1cd87d7afce330
6
+ metadata.gz: 7b9e1ac14b64fa1e8fbea3a0a5b02bb0aaa49e9fc41a2cc9694ccaf787ca53cacfb407b7321465097ad595ecc94084d9c488bb63229332c73644d23064649db9
7
+ data.tar.gz: f611a28457b4c58d35bb97fa70e0aafd20c4d6c1467a61f8e184c221f0ab4188aaa966ea56c530bbb6ea9c9b575c2d83c85bfa896005b96eee81d293d812b19f
@@ -177,18 +177,23 @@ module BooticCli
177
177
  IRB.conf[:PROMPT_MODE] = :CUSTOM
178
178
  IRB.conf[:AUTO_INDENT] = false
179
179
  irb = IRB::Irb.new(IRB::WorkSpace.new(context))
180
- IRB.conf[:MAIN_CONTEXT] = irb.context
181
180
 
182
- trap('SIGINT') do
183
- irb.signal_handle
184
- end
181
+ if irb.respond_to?(:run)
182
+ irb.run
183
+ else
184
+ IRB.conf[:MAIN_CONTEXT] = irb.context
185
+
186
+ trap('SIGINT') do
187
+ irb.signal_handle
188
+ end
185
189
 
186
- begin
187
- catch(:IRB_EXIT) do
188
- irb.eval_input
190
+ begin
191
+ catch(:IRB_EXIT) do
192
+ irb.eval_input
193
+ end
194
+ ensure
195
+ IRB.irb_at_exit
189
196
  end
190
- ensure
191
- IRB.irb_at_exit
192
197
  end
193
198
  end
194
199
  end
@@ -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.1.0'
2
+ VERSION = '1.2.1'
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: 1.1.0
4
+ version: 1.2.1
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: 2025-01-02 00:00:00.000000000 Z
12
+ date: 2026-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor