bootic_cli 0.2.0.pre3 → 0.2.0.pre4

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
  SHA1:
3
- metadata.gz: 7e431e8096c1631c299bef2480ee7b8790df2a84
4
- data.tar.gz: 0e0feeb799a8c2bd9a8158511b6efaaedab31cd3
3
+ metadata.gz: 01b310353094a4af7a0b179b02660c020fb98480
4
+ data.tar.gz: 2583f1d57a24e858ef0ba028f8c4696cf7496ade
5
5
  SHA512:
6
- metadata.gz: 34e96a633bb6bae2d620c0cb4d12dffdcf0fc6343c0cff50a996400021a56d0cb3ca42970b85f3c8ee32d4b5bca51fcc54020c19a0a171761fd960f527612d11
7
- data.tar.gz: ce7c0a78c0a5152dfd82f8568f69e534069a3c97b966bdd93cfeef64fd287f8dc170cfa3a8b520e4dbebcc2b3de9af4c1bd8f7f6842579dc8bef8d3185e4cde0
6
+ metadata.gz: ff09b1ba8c214698dc2a1d4ff033b2de5d72c9163aee1c0aea2c2a1f6b361dd1d17c8df18da43af385281c52bd4a1fb22310534ebce6d75fc3f061495b8716ba
7
+ data.tar.gz: ed01f33cbfc925e52309306b6ec57a61944171f1a554d8f7792f7536a25044fe4f3611a0cb28cc43004d949beddd4df5f1ca4bf210dc787e6adc2093327f5944
data/bootic_cli.gemspec CHANGED
@@ -19,16 +19,16 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'thor'
22
+ spec.add_dependency 'thor', '~> 0'
23
23
  spec.add_dependency 'bootic_client', "~> 0.0.19"
24
24
  spec.add_dependency 'diffy', "~> 3.2"
25
25
  spec.add_dependency 'listen', "~> 3.1"
26
- spec.add_dependency 'launchy'
26
+ spec.add_dependency 'launchy', "~> 2.4"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 1.9"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "rspec"
31
- spec.add_development_dependency "byebug"
30
+ spec.add_development_dependency "rspec", "~> 3.2"
31
+ spec.add_development_dependency "byebug", "~> 9"
32
32
 
33
33
  spec.post_install_message = <<-END
34
34
  Bootic client installed.
@@ -5,9 +5,19 @@ require 'bootic_cli/themes/theme_selector'
5
5
  module BooticCli
6
6
  module Commands
7
7
  class Themes < BooticCli::Command
8
- desc 'pull [shop] [dir]', 'Pull latest theme changes in [shop] into directory [dir] (current by default)'
8
+ desc 'clone [shop] [dir]', 'Clone remote [shop] theme into directory [dir] (shop subdomain by default)'
9
9
  option :destroy, banner: '<true|false>', type: :boolean, default: true
10
10
  option :public, banner: '<true|false>', type: :boolean, default: false, aliases: '-p'
11
+ def clone(subdomain = nil, dir = nil)
12
+ logged_in_action do
13
+ local_theme, remote_theme = theme_selector.setup_theme_pair(subdomain, dir, options['public'])
14
+ workflows.pull(local_theme, remote_theme, destroy: options['destroy'])
15
+ end
16
+ end
17
+
18
+ desc 'pull', 'Pull remote changes into current theme directory'
19
+ option :public, banner: '<true|false>', type: :boolean, default: false, aliases: '-p'
20
+ option :destroy, banner: '<true|false>', type: :boolean, default: true
11
21
  def pull(subdomain = nil, dir = '.')
12
22
  logged_in_action do
13
23
  local_theme, remote_theme = theme_selector.select_theme_pair(subdomain, dir, options['public'])
@@ -65,7 +75,15 @@ module BooticCli
65
75
  def open(subdomain = nil, dir = '.')
66
76
  logged_in_action do
67
77
  _, remote_theme = theme_selector.select_theme_pair(subdomain, dir, options['public'])
68
- Launchy.open remote_theme.href
78
+ Launchy.open remote_theme.path
79
+ end
80
+ end
81
+
82
+ desc 'pair [shop]', 'Pair this directory to remote [shop]'
83
+ def pair(subdomain, dir = '.')
84
+ logged_in_action do
85
+ local_theme = theme_selector.pair(subdomain, dir)
86
+ say "Directory #{local_theme.path} paired with shop #{subdomain}", :yellow
69
87
  end
70
88
  end
71
89
 
@@ -32,7 +32,7 @@ module BooticCli
32
32
  end
33
33
  end
34
34
 
35
- def href
35
+ def path
36
36
  theme.rels[:theme_preview].href
37
37
  end
38
38
 
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'yaml/store'
2
3
 
3
4
  module BooticCli
4
5
  module Themes
@@ -30,10 +31,21 @@ module BooticCli
30
31
  [item, type]
31
32
  end
32
33
 
33
- def initialize(dir)
34
- FileUtils.mkdir_p dir
35
- FileUtils.mkdir_p File.join(dir, ASSETS_DIR)
34
+ attr_reader :subdomain
35
+
36
+ def initialize(dir, subdomain: nil)
36
37
  @dir = dir
38
+ @setup = false
39
+ @subdomain = subdomain ? write_subdomain(subdomain) : read_subdomain
40
+ end
41
+
42
+ def reset!
43
+ return false unless @setup
44
+ FileUtils.rm_rf dir
45
+ end
46
+
47
+ def path
48
+ File.expand_path(dir)
37
49
  end
38
50
 
39
51
  # Implement generic Theme interface
@@ -63,6 +75,7 @@ module BooticCli
63
75
  end
64
76
 
65
77
  def add_template(file_name, body)
78
+ setup
66
79
  path = File.join(dir, file_name)
67
80
 
68
81
  File.open(path, 'w') do |io|
@@ -79,6 +92,7 @@ module BooticCli
79
92
  end
80
93
 
81
94
  def add_asset(file_name, file)
95
+ setup
82
96
  path = File.join(dir, ASSETS_DIR, file_name)
83
97
  File.open(path, 'wb') do |io|
84
98
  io.write file.read
@@ -102,6 +116,32 @@ module BooticCli
102
116
  def paths_for(patterns)
103
117
  patterns.reduce([]) {|m, pattern| m + Dir[File.join(dir, pattern)]}
104
118
  end
119
+
120
+ def setup
121
+ return self if @setup
122
+ FileUtils.mkdir_p dir
123
+ FileUtils.mkdir_p File.join(dir, ASSETS_DIR)
124
+ @setup = true
125
+ self
126
+ end
127
+
128
+ def store
129
+ @store ||= (
130
+ setup
131
+ YAML::Store.new(File.join(path, '.state'))
132
+ )
133
+ end
134
+
135
+ def write_subdomain(sub)
136
+ store.transaction do
137
+ store['subdomain'] = sub
138
+ end
139
+ sub
140
+ end
141
+
142
+ def read_subdomain
143
+ store.transaction{ store['subdomain'] }
144
+ end
105
145
  end
106
146
  end
107
147
  end
@@ -1,4 +1,3 @@
1
- require 'yaml/store'
2
1
  require 'bootic_cli/themes/api_theme'
3
2
  require 'bootic_cli/themes/fs_theme'
4
3
 
@@ -10,38 +9,49 @@ module BooticCli
10
9
  @prompt = prompt
11
10
  end
12
11
 
12
+ def setup_theme_pair(subdomain, dir = nil, production = false)
13
+ shop = find_remote_shop(subdomain)
14
+ raise "no shop with subdomain #{subdomain}" unless shop
15
+
16
+ path = dir || shop.subdomain
17
+ local_theme = select_local_theme(path, shop.subdomain)
18
+ remote_theme = select_remote_theme(shop, production)
19
+
20
+ prompt.say "Cloning theme files into #{local_theme.path}"
21
+ prompt.say "Preview remote theme at #{remote_theme.path}", :yellow
22
+ [local_theme, remote_theme]
23
+ end
24
+
13
25
  def select_theme_pair(subdomain, dir, production = false)
14
26
  local_theme = select_local_theme(dir)
15
- st = YAML::Store.new(File.join(File.expand_path(dir), '.state'))
16
- shop = resolve_and_store_shop(subdomain, dir)
17
- remote_theme = resolve_remote_theme(shop, production)
18
- prompt.say "Preview remote theme at #{remote_theme.rels[:theme_preview].href}", :yellow
19
- [local_theme, APITheme.new(remote_theme)]
27
+ shop = find_remote_shop(local_theme.subdomain)
28
+ raise "no shop with subdomain #{local_theme.subdomain}" unless shop
29
+ remote_theme = select_remote_theme(shop, production)
30
+
31
+ prompt.say "Preview remote theme at #{remote_theme.path}", :yellow
32
+ [local_theme, remote_theme]
20
33
  end
21
34
 
22
- def select_local_theme(dir)
23
- FSTheme.new(File.expand_path(dir))
35
+ def pair(subdomain, dir)
36
+ shop = find_remote_shop(subdomain)
37
+ raise "no shop with subdomain #{subdomain}" unless shop
38
+ select_local_theme(dir, subdomain)
24
39
  end
25
40
 
26
- def resolve_and_store_shop(subdomain, dir)
27
- st = YAML::Store.new(File.join(File.expand_path(dir), '.state'))
28
- st.transaction do
29
- sub = st['subdomain']
30
- if sub
31
- shop = find_remote_shop(sub)
32
- raise "No shop could be resolved with subdomain: #{subdomain} and dir: #{dir}" unless shop
33
- shop
34
- else # no subdomain stored yet. Resolve and store.
35
- shop = resolve_shop_from_subdomain_or_dir(subdomain, dir)
36
- st['subdomain'] = shop.subdomain
37
- shop
38
- end
39
- end
41
+ def select_local_theme(dir, subdomain = nil)
42
+ FSTheme.new(File.expand_path(dir), subdomain: subdomain)
40
43
  end
41
44
 
42
- private
45
+ def select_remote_theme(shop, production = false)
46
+ theme = resolve_remote_theme(shop, production)
47
+ APITheme.new(theme)
48
+ end
49
+
50
+ def find_remote_shop(subdomain = nil)
51
+ if !subdomain
52
+ return root.shops.first
53
+ end
43
54
 
44
- def find_remote_shop(subdomain)
45
55
  if root.has?(:all_shops)
46
56
  root.all_shops(subdomains: subdomain).first
47
57
  else
@@ -49,15 +59,7 @@ module BooticCli
49
59
  end
50
60
  end
51
61
 
52
- def resolve_shop_from_subdomain_or_dir(subdomain, dir)
53
- shop = if subdomain
54
- find_remote_shop(subdomain)
55
- elsif dir
56
- subdomain = File.basename(dir)
57
- find_remote_shop(subdomain)
58
- end
59
- shop || root.shops.first
60
- end
62
+ private
61
63
 
62
64
  def resolve_remote_theme(shop, production = false)
63
65
  if production
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = "0.2.0.pre3"
2
+ VERSION = "0.2.0.pre4"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre3
4
+ version: 0.2.0.pre4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-20 00:00:00.000000000 Z
11
+ date: 2018-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: launchy
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '2.4'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '2.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -112,30 +112,30 @@ dependencies:
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '3.2'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '3.2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: byebug
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: '9'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: '9'
139
139
  description: Bootic command line.
140
140
  email:
141
141
  - ismaelct@gmail.com
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: 1.3.1
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.6.8
202
+ rubygems_version: 2.6.13
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Bootic command line.