bootic_cli 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bootic_cli/commands/themes.rb +1 -1
- data/lib/bootic_cli/themes/fs_theme.rb +12 -1
- data/lib/bootic_cli/themes/theme_diff.rb +5 -4
- data/lib/bootic_cli/themes/updated_theme.rb +11 -4
- data/lib/bootic_cli/themes/workflows.rb +2 -2
- data/lib/bootic_cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2678e5ad8fef33d47eda0b55c2b014d3da644e42
|
4
|
+
data.tar.gz: 3eb8e3690d8d379911dd4528927c8e61c5b27515
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 173b6a35f6a715b6e75b2a5c7a4379a198b8d7b045257b8afa66143bf4fa5e87e31f53721fb9fc0e51b7f37263ae429cd92a4f9511ed0b05353286734790e9d4
|
7
|
+
data.tar.gz: ac13c53e4b8a6ede30ea4d21bca91defac55146c8245579c36f7eb11fd6ec355c1aa99c13ad76145006469b6b430f3ab92f4fded5cf07238a948ad1600f23ffb
|
@@ -86,9 +86,16 @@ module BooticCli
|
|
86
86
|
setup
|
87
87
|
path = File.join(dir, file_name)
|
88
88
|
|
89
|
+
# remove DOS line endings for new templates
|
90
|
+
# or for existing ones that don't have any.
|
91
|
+
if !File.exist?(path) or !has_dos_line_endings?(path)
|
92
|
+
body = body.gsub(/\r\n?/, "\n")
|
93
|
+
end
|
94
|
+
|
89
95
|
File.open(path, 'w') do |io|
|
90
|
-
io.write
|
96
|
+
io.write(body)
|
91
97
|
end
|
98
|
+
|
92
99
|
@templates = nil
|
93
100
|
end
|
94
101
|
|
@@ -121,6 +128,10 @@ module BooticCli
|
|
121
128
|
|
122
129
|
attr_reader :dir
|
123
130
|
|
131
|
+
def has_dos_line_endings?(path)
|
132
|
+
!!IO.read(path)["\r\n"]
|
133
|
+
end
|
134
|
+
|
124
135
|
def paths_for(patterns)
|
125
136
|
patterns.reduce([]) {|m, pattern| m + Dir[File.join(dir, pattern)]}
|
126
137
|
end
|
@@ -4,16 +4,17 @@ require 'bootic_cli/themes/missing_items_theme'
|
|
4
4
|
module BooticCli
|
5
5
|
module Themes
|
6
6
|
class ThemeDiff
|
7
|
-
def initialize(source:, target:)
|
7
|
+
def initialize(source:, target:, force_update:)
|
8
8
|
@source, @target = source, target
|
9
|
+
@force_update = force_update
|
9
10
|
end
|
10
11
|
|
11
12
|
def updated_in_source
|
12
|
-
@updated_in_source ||= UpdatedTheme.new(source: source, target: target)
|
13
|
+
@updated_in_source ||= UpdatedTheme.new(source: source, target: target, force_update: force_update)
|
13
14
|
end
|
14
15
|
|
15
16
|
def updated_in_target
|
16
|
-
@updated_in_target ||= UpdatedTheme.new(source: target, target: source)
|
17
|
+
@updated_in_target ||= UpdatedTheme.new(source: target, target: source, force_update: force_update)
|
17
18
|
end
|
18
19
|
|
19
20
|
def missing_in_target
|
@@ -25,7 +26,7 @@ module BooticCli
|
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
28
|
-
attr_reader :source, :target
|
29
|
+
attr_reader :source, :target, :force_update
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
@@ -8,14 +8,17 @@ module BooticCli
|
|
8
8
|
class UpdatedTheme
|
9
9
|
TemplateWithDiff = Struct.new('TemplateWithDiff', :file_name, :body, :updated_on, :diff)
|
10
10
|
|
11
|
-
def initialize(source:, target:)
|
11
|
+
def initialize(source:, target:, force_update: false)
|
12
12
|
@source, @target = source, target
|
13
|
+
# when doing a pull or push, we don't care if the other end has a more recent version
|
14
|
+
# we only do that when syncing changes, in which case force_update should be false
|
15
|
+
@force_update = force_update
|
13
16
|
end
|
14
17
|
|
15
18
|
def templates
|
16
19
|
@templates ||= map_pair(source.templates, target.templates) do |a, b|
|
17
20
|
diff = Diffy::Diff.new(normalize_endings(b.body), normalize_endings(a.body), context: 1)
|
18
|
-
if
|
21
|
+
if !diff.to_s.empty? && should_update?(a, b)
|
19
22
|
c = TemplateWithDiff.new(a.file_name, a.body, a.updated_on, diff)
|
20
23
|
[true, c]
|
21
24
|
else
|
@@ -26,12 +29,16 @@ module BooticCli
|
|
26
29
|
|
27
30
|
def assets
|
28
31
|
@assets ||= map_pair(source.assets, target.assets) do |a, b|
|
29
|
-
[
|
32
|
+
[should_update?(a, b), a]
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
private
|
34
|
-
attr_reader :source, :target
|
37
|
+
attr_reader :source, :target, :force_update
|
38
|
+
|
39
|
+
def should_update?(a, b)
|
40
|
+
force_update || more_recent?(a, b)
|
41
|
+
end
|
35
42
|
|
36
43
|
def more_recent?(a, b)
|
37
44
|
a.updated_on > b.updated_on
|
@@ -32,7 +32,7 @@ module BooticCli
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def pull(local_theme, remote_theme, delete: true)
|
35
|
-
diff = ThemeDiff.new(source: local_theme, target: remote_theme)
|
35
|
+
diff = ThemeDiff.new(source: local_theme, target: remote_theme, force_update: true)
|
36
36
|
check_dupes!(local_theme.assets)
|
37
37
|
|
38
38
|
download_opts = {
|
@@ -61,7 +61,7 @@ module BooticCli
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def push(local_theme, remote_theme, delete: true)
|
64
|
-
diff = ThemeDiff.new(source: local_theme, target: remote_theme)
|
64
|
+
diff = ThemeDiff.new(source: local_theme, target: remote_theme, force_update: true)
|
65
65
|
check_dupes!(local_theme.assets)
|
66
66
|
|
67
67
|
notice 'Pushing local changes to remote...'
|
data/lib/bootic_cli/version.rb
CHANGED