bootic_cli 0.4.3 → 0.4.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
  SHA1:
3
- metadata.gz: ab56fed09f0be0994048a9cbda8ebccabdea4ed0
4
- data.tar.gz: 127a9f3f5bbc73c2863b609b1c592cbe70a1f4ea
3
+ metadata.gz: e481971c908c55b0696187dacbcd90f2c0a98d0e
4
+ data.tar.gz: c815d530ed012021ba9c2eda228fcb96cd5d8b73
5
5
  SHA512:
6
- metadata.gz: fd90883584f04cf470233ba2425d2545b80d96e805f43b229cdef0321d8f3e8263d32acd25b576eb4392a334d206d08a1511846b64479a5c22b0f783d1c0a01d
7
- data.tar.gz: 46972dc89c124720c57ff4d571d738bc567e58b72d16199ee44ddd09fa0980ad235930a7641ee00f0e592fc952579d1827f40cc16fb72e049d4b436a44072bd3
6
+ metadata.gz: 3e8f04432406d094ecec4eb6457a53f576c9ed20736e929e3779c99711000b19ec623665fb3c64cab4b2fcdc5e53d98cdcef59605bc5cb24edf0028911b780f9
7
+ data.tar.gz: 3395443655a57ec2de06b2383c38b5057a334fb607ef7e59853bb1a90b1570ecfb71ae83c4a1ce35debae1c0368cf20299154ade38fff908279a58b0797922f1
@@ -1,3 +1,4 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  require 'launchy'
2
3
  require 'bootic_cli/themes/workflows'
3
4
  require 'bootic_cli/themes/theme_selector'
@@ -79,11 +80,25 @@ module BooticCli
79
80
  end
80
81
  end
81
82
 
82
- desc 'publish', 'Publish local files to remote public theme'
83
+ desc 'publish', 'Moves your development theme into your public website'
83
84
  def publish
84
85
  within_theme do
85
- local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir, false)
86
- workflows.publish(local_theme, remote_theme)
86
+ local_theme, remote_theme = theme_selector.select_theme_pair(default_subdomain, current_dir)
87
+ if remote_theme.public?
88
+ say "You don't seem to have a development theme set up, so there's nothing to publish!", :red
89
+ else
90
+ say("Publishing means all your public theme's templates and assets will be lost.")
91
+ if prompt.yes_or_no?("Would you like to make a local copy of your current public theme before publishing?", false)
92
+
93
+ backup_path = File.join(local_theme.path, "public-theme-backup-#{Time.now.to_i}")
94
+ backup_theme, public_theme = theme_selector.select_theme_pair(default_subdomain, backup_path, true)
95
+
96
+ say("Gotcha. Backing up your public theme into #{backup_theme.path}")
97
+ workflows.pull(backup_theme, public_theme)
98
+ end
99
+
100
+ workflows.publish(local_theme, remote_theme)
101
+ end
87
102
  end
88
103
  end
89
104
 
@@ -5,6 +5,10 @@ module BooticCli
5
5
  @source, @target = source, target
6
6
  end
7
7
 
8
+ def any?
9
+ templates.any? || assets.any?
10
+ end
11
+
8
12
  def templates
9
13
  @templates ||= find_missing_files(source.templates, target.templates)
10
14
  end
@@ -9,6 +9,10 @@ module BooticCli
9
9
  @force_update = force_update
10
10
  end
11
11
 
12
+ def any?
13
+ updated_in_source.any? || updated_in_target.any? || missing_in_target.any? || missing_in_source.any?
14
+ end
15
+
12
16
  def updated_in_source
13
17
  @updated_in_source ||= UpdatedTheme.new(source: source, target: target, force_update: force_update)
14
18
  end
@@ -26,7 +26,7 @@ module BooticCli
26
26
 
27
27
  if wants_dev or prompt.yes_or_no?("Would you like to create (and work on) a development version of your theme? (recommended)", true)
28
28
  prompt.say "Good thinking. Creating a development theme out of your current public one...", :green
29
- remote_theme = shop.themes.create_dev_theme
29
+ remote_theme = APITheme.new(shop.themes.create_dev_theme)
30
30
  end
31
31
  end
32
32
 
@@ -15,6 +15,10 @@ module BooticCli
15
15
  @force_update = force_update
16
16
  end
17
17
 
18
+ def any?
19
+ templates.any? || assets.any?
20
+ end
21
+
18
22
  def templates
19
23
  @templates ||= map_pair(source.templates, target.templates) do |a, b|
20
24
  diff = Diffy::Diff.new(normalize_endings(b.body), normalize_endings(a.body), context: 1)
@@ -127,7 +127,8 @@ module BooticCli
127
127
  notice "Local <--- Remote"
128
128
 
129
129
  diff.updated_in_target.templates.each do |t|
130
- puts "Updated in remote: #{t.file_name}"
130
+ puts "Updated in remote: #{t.file_name} (updated at #{t.updated_on})"
131
+ puts t.diff.to_s(:color)
131
132
  end
132
133
 
133
134
  diff.missing_in_source.templates.each do |t|
@@ -141,7 +142,8 @@ module BooticCli
141
142
  notice "Local ---> Remote"
142
143
 
143
144
  diff.updated_in_source.templates.each do |t|
144
- puts "Updated locally: #{t.file_name}"
145
+ puts "Updated locally: #{t.file_name} (updated at #{t.updated_on})"
146
+ puts t.diff.to_s(:color)
145
147
  end
146
148
 
147
149
  diff.missing_in_target.templates.each do |f|
@@ -183,24 +185,31 @@ module BooticCli
183
185
  # ctrl-c
184
186
  Signal.trap('INT') {
185
187
  listener.stop
186
- puts 'See you in another lifetime, brotha.'
188
+ puts 'See you in another lifetime, brother.'
187
189
  exit
188
190
  }
189
191
 
190
- prompt.say "Preview changes at #{remote_theme.path}", :cyan
192
+ prompt.say "Preview changes at #{remote_theme.path}. Hit Ctrl-C to stop watching for changes.", :cyan
191
193
  Kernel.sleep
192
194
  end
193
195
 
194
196
  def publish(local_theme, remote_theme)
195
- keep_old_theme = prompt.yes_or_no?("Do you want to keep your old public theme as your dev theme?", false)
196
- # first push local files to dev theme
197
- prompt.say "Pushing local changes to development theme"
198
- push(local_theme, remote_theme, delete: true)
199
- # now publish remote dev theme
200
- # let it fail if remote_theme doesn't respond to #publish
201
- prompt.notice "Publishing development theme"
202
- remote_theme.publish(!keep_old_theme) # swap remote themes
203
- prompt.notice "Published to #{remote_theme.href}", :yellow
197
+ raise "This command is meant for dev themes only" unless remote_theme.dev?
198
+
199
+ changes = ThemeDiff.new(source: local_theme, target: remote_theme)
200
+ if changes.any?
201
+ prompt.say "There are some differences between your local and the remote version of your development theme."
202
+ if prompt.yes_or_no? "Do you want to push your local changes now?", false
203
+ push(local_theme, remote_theme, delete: true)
204
+ else
205
+ prompt.say "Oh well. Please make sure both versions are synced before publishing.", :magenta
206
+ exit(1)
207
+ end
208
+ end
209
+
210
+ prompt.notice "Alrighty! Publishing your development theme..."
211
+ remote_theme.publish(true) # syncs dev to public, without flipping them
212
+ prompt.notice "Yay! Your development theme has been made public. Take a look at #{remote_theme.path}", :cyan
204
213
  end
205
214
 
206
215
  private
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-24 00:00:00.000000000 Z
11
+ date: 2018-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor