theme-juice 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/bin/tj +5 -13
- data/lib/theme-juice/cli.rb +172 -343
- data/lib/theme-juice/command.rb +14 -0
- data/lib/theme-juice/commands/create.rb +17 -0
- data/lib/theme-juice/commands/delete.rb +17 -0
- data/lib/theme-juice/commands/install.rb +17 -0
- data/lib/theme-juice/commands/list.rb +17 -0
- data/lib/theme-juice/commands/subcommand.rb +17 -0
- data/lib/theme-juice/environment.rb +14 -0
- data/lib/theme-juice/interaction.rb +446 -0
- data/lib/theme-juice/interactions/create_site_options.rb +288 -0
- data/lib/theme-juice/interactions/delete_site_options.rb +58 -0
- data/lib/theme-juice/interactions/teejay.rb +6 -0
- data/lib/theme-juice/service.rb +190 -0
- data/lib/theme-juice/services/config_file.rb +44 -0
- data/lib/theme-juice/services/create_site.rb +387 -0
- data/lib/theme-juice/services/delete_site.rb +114 -0
- data/lib/theme-juice/services/list_sites.rb +40 -0
- data/lib/theme-juice/version.rb +1 -1
- data/lib/theme-juice.rb +19 -6
- metadata +33 -6
- data/lib/theme-juice/executor.rb +0 -804
- data/lib/theme-juice/ui.rb +0 -227
- data/lib/theme-juice/utilities.rb +0 -56
data/lib/theme-juice/ui.rb
DELETED
@@ -1,227 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module ThemeJuice
|
4
|
-
module UI
|
5
|
-
|
6
|
-
# List of icons
|
7
|
-
SUCCESS = "\u2713"
|
8
|
-
ERROR = "\u2191"
|
9
|
-
NOTICE = "\u2192"
|
10
|
-
QUESTION = "\u003F"
|
11
|
-
GENERAL = "\u002D"
|
12
|
-
RESTART = "\u21AA"
|
13
|
-
LIST = "\u2022"
|
14
|
-
|
15
|
-
class << self
|
16
|
-
include ::Thor::Actions
|
17
|
-
include ::Thor::Shell
|
18
|
-
|
19
|
-
###
|
20
|
-
# Output formatted message to terminal
|
21
|
-
#
|
22
|
-
# @param {String} message
|
23
|
-
# @param {Hash} opts
|
24
|
-
#
|
25
|
-
# @return {Void}
|
26
|
-
###
|
27
|
-
def speak(message, opts = {})
|
28
|
-
format_message! message, opts
|
29
|
-
|
30
|
-
# Check if we're suppressing terminal output
|
31
|
-
if opts.key? :quiet
|
32
|
-
message
|
33
|
-
else
|
34
|
-
say message
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
###
|
39
|
-
# Output success message
|
40
|
-
#
|
41
|
-
# @param {String} message
|
42
|
-
#
|
43
|
-
# @return {Void}
|
44
|
-
###
|
45
|
-
def success(message)
|
46
|
-
self.speak message, {
|
47
|
-
color: [:black, :on_green, :bold],
|
48
|
-
icon: :success,
|
49
|
-
row: true
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
###
|
54
|
-
# Output notice message
|
55
|
-
#
|
56
|
-
# @param {String} message
|
57
|
-
#
|
58
|
-
# @return {Void}
|
59
|
-
###
|
60
|
-
def notice(message)
|
61
|
-
self.speak message, {
|
62
|
-
color: [:black, :on_yellow],
|
63
|
-
icon: :notice,
|
64
|
-
row: true
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
###
|
69
|
-
# Output error message and exit. Allows a block to be passed
|
70
|
-
# as well, which will be executed before exiting
|
71
|
-
#
|
72
|
-
# @param {String} message
|
73
|
-
#
|
74
|
-
# @return {Void}
|
75
|
-
###
|
76
|
-
def error(message)
|
77
|
-
self.speak message, {
|
78
|
-
color: [:white, :on_red],
|
79
|
-
icon: :error,
|
80
|
-
row: true
|
81
|
-
}
|
82
|
-
|
83
|
-
yield if block_given?
|
84
|
-
|
85
|
-
exit 1
|
86
|
-
end
|
87
|
-
|
88
|
-
###
|
89
|
-
# Output a list of messages
|
90
|
-
#
|
91
|
-
# @param {String} header
|
92
|
-
# @param {Symbol} color
|
93
|
-
# @param {Array} list
|
94
|
-
#
|
95
|
-
# @return {Void}
|
96
|
-
###
|
97
|
-
def list(header, color, list)
|
98
|
-
self.speak header, {
|
99
|
-
color: [:black, :"on_#{color}"],
|
100
|
-
icon: :notice,
|
101
|
-
row: true
|
102
|
-
}
|
103
|
-
|
104
|
-
list.each do |item|
|
105
|
-
self.speak item, {
|
106
|
-
color: :"#{color}",
|
107
|
-
icon: :general
|
108
|
-
}
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
###
|
113
|
-
# Ask a question
|
114
|
-
#
|
115
|
-
# @param {String} question
|
116
|
-
# @param {Hash} opts
|
117
|
-
#
|
118
|
-
# @return {Void}
|
119
|
-
###
|
120
|
-
def prompt(question, *opts)
|
121
|
-
format_message! question, {
|
122
|
-
color: :blue,
|
123
|
-
icon: :question
|
124
|
-
}
|
125
|
-
|
126
|
-
opts.each do |opt|
|
127
|
-
if opt.respond_to? :key?
|
128
|
-
|
129
|
-
# if opt.key? :default
|
130
|
-
# opt[:default] = set_color(opt[:default], :black, :bold)
|
131
|
-
# end
|
132
|
-
|
133
|
-
if opt.key? :indent
|
134
|
-
set!(question) { |str| (" " * opt[:indent]) << str }
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
break
|
139
|
-
end
|
140
|
-
|
141
|
-
ask "#{question} :", *opts
|
142
|
-
end
|
143
|
-
|
144
|
-
###
|
145
|
-
# Ask a yes or no question
|
146
|
-
#
|
147
|
-
# @param {String} question
|
148
|
-
# @param {Hash} opts
|
149
|
-
#
|
150
|
-
# @return {Bool}
|
151
|
-
###
|
152
|
-
def agree?(question, opts = {})
|
153
|
-
|
154
|
-
unless opts.key? :color
|
155
|
-
opts[:color] = :blue
|
156
|
-
end
|
157
|
-
|
158
|
-
format_message! question, {
|
159
|
-
color: opts[:color],
|
160
|
-
icon: :question
|
161
|
-
}
|
162
|
-
|
163
|
-
if opts.key? :simple
|
164
|
-
yes? " :", if opts.key? :color then opts[:color] end
|
165
|
-
else
|
166
|
-
yes? "#{question} (y/N) :"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
private
|
171
|
-
|
172
|
-
###
|
173
|
-
# Destructively format message
|
174
|
-
#
|
175
|
-
# @param {String} message
|
176
|
-
# @param {Hash} opts
|
177
|
-
#
|
178
|
-
# @return {String}
|
179
|
-
###
|
180
|
-
def format_message!(message, opts = {})
|
181
|
-
|
182
|
-
unless ::ThemeJuice::Utilities.no_unicode
|
183
|
-
if opts.key? :icon
|
184
|
-
if opts.key? :empty
|
185
|
-
set!(message) { |msg| " #{self.const_get(opts[:icon].to_s.upcase)}" }
|
186
|
-
else
|
187
|
-
set!(message) { |msg| " #{self.const_get(opts[:icon].to_s.upcase)} " << msg }
|
188
|
-
end
|
189
|
-
else
|
190
|
-
set!(message) { |msg| " " << msg }
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
if opts.key? :indent
|
195
|
-
set!(message) { |str| (" " * opts[:indent]) << str }
|
196
|
-
end
|
197
|
-
|
198
|
-
if opts.key? :row
|
199
|
-
set!(message) { |msg| msg.ljust(terminal_width) }
|
200
|
-
elsif opts.key? :width
|
201
|
-
set!(message) { |msg| msg.ljust(opts[:width]) }
|
202
|
-
end
|
203
|
-
|
204
|
-
unless ::ThemeJuice::Utilities.no_colors
|
205
|
-
if opts.key? :color
|
206
|
-
set!(message) { |msg| set_color(msg, *opts[:color]) }
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
if opts.key? :newline
|
211
|
-
set!(message) { |msg| "\n" << msg }
|
212
|
-
end
|
213
|
-
|
214
|
-
message
|
215
|
-
end
|
216
|
-
|
217
|
-
###
|
218
|
-
# Run destructive block against message
|
219
|
-
#
|
220
|
-
# @return {String}
|
221
|
-
###
|
222
|
-
def set!(string)
|
223
|
-
str = yield(string); string.clear; string << str
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module ThemeJuice
|
4
|
-
module Utilities
|
5
|
-
class << self
|
6
|
-
attr_accessor :vvv_path
|
7
|
-
attr_accessor :no_unicode
|
8
|
-
attr_accessor :no_colors
|
9
|
-
|
10
|
-
include ::Thor::Actions
|
11
|
-
include ::Thor::Shell
|
12
|
-
|
13
|
-
###
|
14
|
-
# Check if program is installed
|
15
|
-
#
|
16
|
-
# @note Doesn't work on Win
|
17
|
-
#
|
18
|
-
# @param {String} program
|
19
|
-
#
|
20
|
-
# @return {Bool}
|
21
|
-
###
|
22
|
-
def installed?(program)
|
23
|
-
system "which #{program} > /dev/null 2>&1"
|
24
|
-
end
|
25
|
-
|
26
|
-
###
|
27
|
-
# Check if current version is outdated
|
28
|
-
#
|
29
|
-
# @return {Bool}
|
30
|
-
###
|
31
|
-
def check_if_current_version_is_outdated
|
32
|
-
local_version = ::ThemeJuice::VERSION
|
33
|
-
|
34
|
-
fetcher = ::Gem::SpecFetcher.fetcher
|
35
|
-
dependency = ::Gem::Dependency.new "theme-juice", ">= #{local_version}"
|
36
|
-
|
37
|
-
remotes, = fetcher.search_for_dependency dependency
|
38
|
-
remote_version = remotes.map { |n, _| n.version }.sort.last
|
39
|
-
|
40
|
-
if ::Gem::Version.new(local_version) < ::Gem::Version.new(remote_version)
|
41
|
-
::ThemeJuice::UI.speak "Your version of Theme Juice (#{local_version}) is outdated. There is a newer version (#{remote_version}) available. Please update now.", {
|
42
|
-
color: [:black, :on_yellow],
|
43
|
-
icon: :notice,
|
44
|
-
row: true
|
45
|
-
}
|
46
|
-
else
|
47
|
-
::ThemeJuice::UI.speak "Your version of Theme Juice (#{local_version}) up to date.", {
|
48
|
-
color: [:black, :on_green],
|
49
|
-
icon: :notice,
|
50
|
-
row: true
|
51
|
-
}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|