bootic_cli 0.9.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bootic_cli.gemspec +1 -1
- data/lib/bootic_cli/commands/themes.rb +19 -6
- data/lib/bootic_cli/themes/api_theme.rb +2 -28
- data/lib/bootic_cli/themes/fs_theme.rb +8 -4
- data/lib/bootic_cli/themes/workflows.rb +1 -1
- data/lib/bootic_cli/utils.rb +33 -0
- data/lib/bootic_cli/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216121435cde22e62af2e80deace1604d9bbdc2c1fb4815fedb18a40b4bc24a9
|
4
|
+
data.tar.gz: 2d3e00c8bf4a651d107555ca7ec5e3fcc871d82976bec3f65c39183c08f09bd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d80d3453d1d3d0fb7bfe73cbccc4cd5cb5652e7fb0ed9081611d29f5e42e8c6d2456cb0f4ca7a3ccfbed4e739afed8e61c2c9b2bbae73849ec826525185b2f7d
|
7
|
+
data.tar.gz: 7db8337b8b6225af0d39400f9967b881ab6d1a026c026ef0e18dd56361b64b4b85cbb0bf8be2c76bbb0ed26087ca73d0e0199654f83ff5ef6b1cd87d7afce330
|
data/bootic_cli.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'thor', '~>
|
22
|
+
spec.add_dependency 'thor', '~> 1.x'
|
23
23
|
spec.add_dependency 'bootic_client', "~> 0.0.31"
|
24
24
|
spec.add_dependency 'diffy', "~> 3.2"
|
25
25
|
spec.add_dependency 'listen', "~> 3.1"
|
@@ -184,12 +184,8 @@ module BooticCli
|
|
184
184
|
|
185
185
|
# prompt.say("Publishing means all your public theme's templates and assets will be replaced and lost.")
|
186
186
|
if prompt.yes_or_no?("Would you like to make a local copy of your current public theme before publishing?", diff.any?) # default to true if changes exist
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
prompt.say("Gotcha. Backing up your public theme into #{prompt.highlight(backup_theme.path)}")
|
191
|
-
workflows.pull(backup_theme, public_theme)
|
192
|
-
prompt.say "Done! Existing public theme was saved to #{prompt.highlight(File.basename(backup_theme.path))}", :cyan
|
187
|
+
path = File.join(local_theme.path, "backups", "public-theme-backup-#{Time.now.to_i}")
|
188
|
+
create_backup_from(public_theme, local_theme, path)
|
193
189
|
end
|
194
190
|
|
195
191
|
workflows.publish(local_theme, remote_theme)
|
@@ -197,6 +193,16 @@ module BooticCli
|
|
197
193
|
end
|
198
194
|
end
|
199
195
|
|
196
|
+
desc 'backup', 'Create a backup copy of the current remote theme'
|
197
|
+
option :dev, banner: '<true|false>', type: :boolean, aliases: '-d', desc: 'Clones development theme instead of the public one (default)'
|
198
|
+
def backup(path = nil)
|
199
|
+
within_theme do
|
200
|
+
local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, options['dev'].nil?)
|
201
|
+
path ||= File.join(local_theme.path, "backups", "#{remote_theme.public? ? 'public' : 'dev'}-theme-backup-#{Time.now.to_i}")
|
202
|
+
create_backup_from(remote_theme, local_theme, path)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
200
206
|
# desc 'open', 'Open theme preview URL in a browser'
|
201
207
|
# option :public, banner: '<true|false>', type: :boolean, aliases: '-p', desc: 'Opens public theme URL'
|
202
208
|
# def open
|
@@ -303,6 +309,13 @@ module BooticCli
|
|
303
309
|
@theme_selector ||= BooticCli::Themes::ThemeSelector.new(root, prompt: prompt)
|
304
310
|
end
|
305
311
|
|
312
|
+
def create_backup_from(theme, local_theme, backup_path)
|
313
|
+
backup_theme = theme_selector.select_local_theme(backup_path, local_theme.subdomain)
|
314
|
+
prompt.say("Gotcha. Backing up your #{theme.public? ? 'public' : 'dev'} theme into #{prompt.highlight(backup_theme.path)}")
|
315
|
+
workflows.pull(backup_theme, theme)
|
316
|
+
prompt.say "Done! Existing #{theme.public? ? 'public' : 'dev'} theme was saved to #{prompt.highlight(File.basename(backup_theme.path))}", :cyan
|
317
|
+
end
|
318
|
+
|
306
319
|
class Prompt
|
307
320
|
def initialize(shell = Thor::Shell::Color.new)
|
308
321
|
@shell = shell
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'time'
|
2
|
-
require '
|
2
|
+
require 'bootic_cli/utils'
|
3
3
|
|
4
4
|
module BooticCli
|
5
5
|
module Themes
|
@@ -15,13 +15,8 @@ module BooticCli
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class APIAsset < ItemWithTime
|
18
|
-
REQUEST_OPTS = {
|
19
|
-
open_timeout: 5,
|
20
|
-
read_timeout: 5
|
21
|
-
}
|
22
|
-
|
23
18
|
def file
|
24
|
-
@file ||=
|
19
|
+
@file ||= BooticCli::Utils.fetch_http_file(rels[:file].href)
|
25
20
|
end
|
26
21
|
|
27
22
|
def ==(other)
|
@@ -34,27 +29,6 @@ module BooticCli
|
|
34
29
|
# puts "Comparing APIAsset vs other digest:\n#{digest}\n#{other.digest}"
|
35
30
|
self.digest == other.digest # && self.file_size == other.file_size
|
36
31
|
end
|
37
|
-
|
38
|
-
def fetch_data(attempt = 1, skip_verify = false)
|
39
|
-
uri = URI.parse(rels[:file].href)
|
40
|
-
opts = REQUEST_OPTS.merge({
|
41
|
-
verify_mode: skip_verify ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER,
|
42
|
-
use_ssl: uri.port == 443
|
43
|
-
})
|
44
|
-
|
45
|
-
Net::HTTP.start(uri.host, uri.port, opts) do |http|
|
46
|
-
resp = http.get(uri.path)
|
47
|
-
raise "Invalid response: #{resp.code}" unless resp.code.to_i == 200
|
48
|
-
resp.body
|
49
|
-
end
|
50
|
-
rescue Net::OpenTimeout, Net::ReadTimeout => e
|
51
|
-
raise if attempt > 3 # max attempts
|
52
|
-
# puts "#{e.class} for #{File.basename(uri.path)}! Retrying request..."
|
53
|
-
fetch_data(attempt + 1)
|
54
|
-
rescue OpenSSL::SSL::SSLError => e
|
55
|
-
# retry but skipping verification
|
56
|
-
fetch_data(attempt + 1, true)
|
57
|
-
end
|
58
32
|
end
|
59
33
|
|
60
34
|
class APITheme
|
@@ -30,12 +30,16 @@ module BooticCli
|
|
30
30
|
end
|
31
31
|
|
32
32
|
ASSETS_DIR = 'assets'.freeze
|
33
|
-
TEMPLATE_PATTERNS = [
|
33
|
+
TEMPLATE_PATTERNS = [
|
34
|
+
'*.html', '*.css', '*.js', '*.json', '*.yml',
|
35
|
+
'sections/*.html', 'partials/*.html', 'data/*.json', 'data/*.yml'
|
36
|
+
].freeze
|
34
37
|
ASSET_PATTERNS = [File.join(ASSETS_DIR, '*')].freeze
|
35
38
|
|
36
39
|
ASSET_PATH_REGEX = /^assets\/[^\/]+$/.freeze
|
37
40
|
TEMPLATE_PATH_REGEX = /^[^\/]+\.(html|css|scss|js|json|yml)$/.freeze
|
38
|
-
SECTION_PATH_REGEX = /^sections\/[^\/]
|
41
|
+
SECTION_PATH_REGEX = /^(sections|partials)\/[^\/]+\.html$/.freeze
|
42
|
+
DATA_PATH_REGEX = /^data\/[^\/]+\.(json|yml)$/.freeze
|
39
43
|
|
40
44
|
def self.resolve_path(path, dir)
|
41
45
|
File.expand_path(path).sub(File.expand_path(dir) + '/', '')
|
@@ -48,7 +52,7 @@ module BooticCli
|
|
48
52
|
|
49
53
|
if relative_path[ASSET_PATH_REGEX]
|
50
54
|
:asset
|
51
|
-
elsif relative_path[TEMPLATE_PATH_REGEX] || relative_path[SECTION_PATH_REGEX]
|
55
|
+
elsif relative_path[TEMPLATE_PATH_REGEX] || relative_path[SECTION_PATH_REGEX] || relative_path[DATA_PATH_REGEX]
|
52
56
|
:template
|
53
57
|
end
|
54
58
|
end
|
@@ -104,7 +108,7 @@ module BooticCli
|
|
104
108
|
|
105
109
|
def templates
|
106
110
|
@templates ||= (
|
107
|
-
paths_for(TEMPLATE_PATTERNS).
|
111
|
+
paths_for(TEMPLATE_PATTERNS).map do |path|
|
108
112
|
name = self.class.resolve_path(path, dir)
|
109
113
|
file = File.new(path)
|
110
114
|
Template.new(name, file.read, file.mtime.utc)
|
@@ -400,7 +400,7 @@ module BooticCli
|
|
400
400
|
prompt.say("Got an unknown response from server: #{e.message}. Please try again in a minute.", :red)
|
401
401
|
exit
|
402
402
|
|
403
|
-
rescue SocketError, Net::OpenTimeout, Net::ReadTimeout => e
|
403
|
+
rescue Faraday::TimeoutError, SocketError, Net::OpenTimeout, Net::ReadTimeout => e
|
404
404
|
prompt.say("I'm having trouble connecting to the server. Please try again in a minute.", :red)
|
405
405
|
exit
|
406
406
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module BooticCli
|
4
|
+
module Utils
|
5
|
+
REQUEST_OPTS = {
|
6
|
+
open_timeout: 5,
|
7
|
+
read_timeout: 5
|
8
|
+
}.freeze
|
9
|
+
|
10
|
+
MAX_FETCH_ATTEMPTS = 3
|
11
|
+
|
12
|
+
def self.fetch_http_file(href, attempt: 1, skip_verify: false)
|
13
|
+
uri = URI.parse(href)
|
14
|
+
opts = REQUEST_OPTS.merge({
|
15
|
+
verify_mode: skip_verify ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER,
|
16
|
+
use_ssl: uri.port == 443
|
17
|
+
})
|
18
|
+
|
19
|
+
Net::HTTP.start(uri.host, uri.port, opts) do |http|
|
20
|
+
resp = http.get(uri.path)
|
21
|
+
raise "Invalid response: #{resp.code}" unless resp.code.to_i == 200
|
22
|
+
StringIO.new(resp.body)
|
23
|
+
end
|
24
|
+
rescue Net::OpenTimeout, Net::ReadTimeout => e
|
25
|
+
raise if attempt > MAX_FETCH_ATTEMPTS # max attempts
|
26
|
+
# puts "#{e.class} for #{File.basename(uri.path)}! Retrying request..."
|
27
|
+
fetch_http_file(href, attempt: attempt + 1)
|
28
|
+
rescue OpenSSL::SSL::SSLError => e
|
29
|
+
# retry but skipping verification
|
30
|
+
fetch_http_file(href, attempt: attempt + 1, skip_verify: true)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bootic_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootic_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismael Celis
|
8
8
|
- Tomás Pollak
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.x
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 1.x
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bootic_client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/bootic_cli/themes/theme_selector.rb
|
161
161
|
- lib/bootic_cli/themes/updated_theme.rb
|
162
162
|
- lib/bootic_cli/themes/workflows.rb
|
163
|
+
- lib/bootic_cli/utils.rb
|
163
164
|
- lib/bootic_cli/version.rb
|
164
165
|
- lib/bootic_cli/worker_pool.rb
|
165
166
|
- libexec/inspector
|
@@ -187,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
188
|
version: '0'
|
188
189
|
requirements: []
|
189
190
|
rubygems_version: 3.4.6
|
190
|
-
signing_key:
|
191
|
+
signing_key:
|
191
192
|
specification_version: 4
|
192
193
|
summary: Bootic command-line client.
|
193
194
|
test_files: []
|