theme-juice 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/cli.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module ThemeJuice
|
4
|
-
class CLI <
|
4
|
+
class CLI < Thor
|
5
5
|
|
6
|
+
#
|
7
|
+
# Command aliases
|
8
|
+
#
|
6
9
|
map %w[--version -v] => :version
|
7
10
|
map %w[new, add, build, make] => :create
|
8
|
-
map %w[
|
11
|
+
map %w[prep] => :setup
|
9
12
|
map %w[remove, trash, teardown] => :delete
|
10
13
|
map %w[sites, show] => :list
|
11
14
|
map %w[assets, dev] => :watch
|
@@ -13,461 +16,287 @@ module ThemeJuice
|
|
13
16
|
map %w[deploy, remote] => :server
|
14
17
|
map %w[vagrant, vvv] => :vm
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
#
|
20
|
+
# Class options
|
21
|
+
#
|
22
|
+
class_option :vvv_path, :type => :string, :aliases => "-fp", :default => nil, :desc => "Force path to VVV installation"
|
23
|
+
class_option :yolo, :type => :boolean, :aliases => "-y", :desc => "Say yes to anything and everything"
|
24
|
+
class_option :boring, :type => :boolean, :aliases => "-b", :desc => "Disable all the coolness"
|
25
|
+
class_option :no_unicode, :type => :boolean, :aliases => "-nu", :desc => "Disable all unicode characters"
|
26
|
+
class_option :no_colors, :type => :boolean, :aliases => "-nc", :desc => "Disable all colored output"
|
27
|
+
class_option :no_animations, :type => :boolean, :aliases => "-na", :desc => "Disable all animations"
|
19
28
|
|
20
|
-
|
29
|
+
desc "--version, -v", "Print current version"
|
30
|
+
#
|
21
31
|
# Print current version
|
22
32
|
#
|
23
33
|
# @return {String}
|
24
|
-
|
25
|
-
desc "--version, -v", "Print current version"
|
34
|
+
#
|
26
35
|
def version
|
27
|
-
|
36
|
+
self.set_environment
|
28
37
|
|
29
|
-
|
30
|
-
color: :green,
|
31
|
-
icon: :notice
|
32
|
-
}
|
38
|
+
@interaction.speak ::ThemeJuice::VERSION, { color: :green }
|
33
39
|
end
|
34
40
|
|
35
|
-
|
41
|
+
desc "create", "Create new site and setup VVV environment"
|
42
|
+
method_option :bare, :type => :boolean, :aliases => "-b", :desc => "Create a VVV site without a starter theme"
|
43
|
+
method_option :site, :type => :string, :aliases => "-s", :default => false, :desc => "Name of the development site"
|
44
|
+
method_option :location, :type => :string, :aliases => "-l", :default => false, :desc => "Location of the local site"
|
45
|
+
method_option :theme, :type => :string, :aliases => "-t", :default => false, :desc => "Starter theme to install"
|
46
|
+
method_option :url, :type => :string, :aliases => "-u", :default => false, :desc => "Development URL of the site"
|
47
|
+
method_option :repository, :type => :string, :aliases => "-r", :desc => "Initialize a new Git remote repository"
|
48
|
+
method_option :skip_repo, :type => :boolean, :desc => "Skip repository prompts and use defaults"
|
49
|
+
method_option :skip_db, :type => :boolean, :desc => "Skip database prompts and use defaults"
|
50
|
+
method_option :use_defaults, :type => :boolean, :desc => "Skip all prompts and use default settings"
|
51
|
+
#
|
36
52
|
# Install and setup VVV environment with new site
|
37
53
|
#
|
38
54
|
# @param {String} site (nil)
|
39
55
|
# Name of the site to create
|
40
|
-
# @param {Bool} bare (false)
|
41
|
-
# Create a bare VVV site without starter
|
42
56
|
#
|
43
57
|
# @return {Void}
|
44
|
-
|
45
|
-
desc "create [SITE]", "Create new SITE and setup the VVV development environment"
|
46
|
-
method_option :bare, type: :boolean, aliases: "-b", desc: "Create a VVV site without a starter theme"
|
47
|
-
method_option :site, type: :string, aliases: "-s", default: false, desc: "Name of the development site"
|
48
|
-
method_option :location, type: :string, aliases: "-l", default: false, desc: "Location of the local site"
|
49
|
-
method_option :theme, type: :string, aliases: "-t", default: false, desc: "Starter theme to install"
|
50
|
-
method_option :url, type: :string, aliases: "-u", default: false, desc: "Development URL of the site"
|
51
|
-
method_option :repository, type: :string, aliases: "-r", desc: "Initialize a new Git remote repository"
|
52
|
-
method_option :skip_repo, type: :boolean, desc: "Skip repository prompts and use defaults"
|
53
|
-
method_option :skip_db, type: :boolean, desc: "Skip database prompts and use defaults"
|
54
|
-
method_option :use_defaults, type: :boolean, desc: "Skip all prompts and use default settings"
|
58
|
+
#
|
55
59
|
def create(site = nil)
|
56
|
-
self.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
site
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
# Check if user passed all required options through flags
|
73
|
-
if options.length >= 6 || options[:use_defaults]
|
74
|
-
::ThemeJuice::UI.success "Well... looks like you just have everything all figured out, huh?"
|
75
|
-
elsif site.nil?
|
76
|
-
::ThemeJuice::UI.speak "Just a few questions before we begin...", {
|
77
|
-
color: [:black, :on_green],
|
78
|
-
icon: :notice,
|
79
|
-
row: true
|
80
|
-
}
|
81
|
-
else
|
82
|
-
::ThemeJuice::UI.success "Your site name shall be '#{site}'! Just a few more questions before we begin..."
|
83
|
-
end
|
84
|
-
|
85
|
-
# Ask for the Site name if not passed directly
|
86
|
-
site ||= ::ThemeJuice::UI.prompt "What's the site name? (letters, numbers and dashes only)"
|
87
|
-
self.validate_site_name(site)
|
88
|
-
|
89
|
-
# Bare install?
|
90
|
-
bare_setup ||= options[:bare]
|
91
|
-
|
92
|
-
# Make sure Site name was given, else throw err
|
93
|
-
unless site.empty?
|
94
|
-
clean_site_name = site.gsub(/[^\w]/, "_")[0..10]
|
95
|
-
|
96
|
-
# Location of site installation
|
97
|
-
if options[:location]
|
98
|
-
site_location = options[:location]
|
99
|
-
else
|
100
|
-
if options[:use_defaults]
|
101
|
-
site_location = "#{Dir.pwd}/"
|
102
|
-
else
|
103
|
-
site_location = ::ThemeJuice::UI.prompt "Where do you want to setup the site?", default: "#{Dir.pwd}/", path: true
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# Starter theme to clone
|
108
|
-
if bare_setup
|
109
|
-
starter_theme = "none"
|
110
|
-
else
|
111
|
-
|
112
|
-
if options[:theme]
|
113
|
-
starter_theme = options[:theme]
|
114
|
-
else
|
115
|
-
require "highline/import"
|
116
|
-
|
117
|
-
# Hash of baked-in starter themes
|
118
|
-
themes = {
|
119
|
-
"theme-juice/theme-juice-starter" => "https://github.com/ezekg/theme-juice-starter.git"
|
120
|
-
}
|
121
|
-
|
122
|
-
if options[:use_defaults]
|
123
|
-
starter_theme = themes["theme-juice/theme-juice-starter"]
|
124
|
-
else
|
125
|
-
::ThemeJuice::UI.speak "Which starter theme would you like to use? (partial name is acceptable)", {
|
126
|
-
color: :blue,
|
127
|
-
icon: :question
|
128
|
-
}
|
129
|
-
|
130
|
-
choose do |menu|
|
131
|
-
menu.index = ::ThemeJuice::UI::speak "", {
|
132
|
-
icon: :question,
|
133
|
-
indent: 2,
|
134
|
-
empty: true,
|
135
|
-
quiet: true
|
136
|
-
}
|
137
|
-
|
138
|
-
menu.prompt = ::ThemeJuice::UI::speak "Choose one :", {
|
139
|
-
color: :blue,
|
140
|
-
icon: :question,
|
141
|
-
width: 16,
|
142
|
-
quiet: true
|
143
|
-
}
|
144
|
-
|
145
|
-
themes.each do |theme, repo|
|
146
|
-
menu.choice theme do
|
147
|
-
|
148
|
-
if theme == "theme-juice/theme-juice-starter"
|
149
|
-
::ThemeJuice::UI.success "Awesome choice!"
|
150
|
-
end
|
151
|
-
|
152
|
-
starter_theme = repo
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
menu.choice "other" do
|
157
|
-
starter_theme = ::ThemeJuice::UI.prompt "What is the repository URL for the starter theme you would like to clone?", indent: 2
|
158
|
-
end
|
159
|
-
|
160
|
-
menu.choice "none" do |opt|
|
161
|
-
::ThemeJuice::UI.notice "Next time you need to create a site without a starter theme, you can just run the 'setup' command instead."
|
162
|
-
starter_theme, bare_setup = opt, true
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
# Development url
|
170
|
-
if options[:url]
|
171
|
-
dev_url = options[:url]
|
172
|
-
else
|
173
|
-
if options[:use_defaults]
|
174
|
-
dev_url = "#{site}.dev"
|
175
|
-
else
|
176
|
-
dev_url = ::ThemeJuice::UI.prompt "What do you want the development url to be? (this should end in '.dev')", default: "#{site}.dev"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
unless dev_url.match /(.dev)$/
|
181
|
-
::ThemeJuice::UI.error "Your development url doesn't end with '.dev'. This is used within Vagrant, so that's not gonna work. Aborting mission."
|
182
|
-
end
|
183
|
-
|
184
|
-
# Initialize a git repository on setup
|
185
|
-
if options[:repository]
|
186
|
-
repository = options[:repository]
|
187
|
-
else
|
188
|
-
if options[:use_defaults] || options[:skip_repo]
|
189
|
-
repository = false
|
190
|
-
else
|
191
|
-
if ::ThemeJuice::UI.agree? "Would you like to initialize a new Git repository?"
|
192
|
-
repository = ::ThemeJuice::UI.prompt "What is the repository's URL?", indent: 2
|
193
|
-
else
|
194
|
-
repository = false
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
# Database host
|
200
|
-
if options[:use_defaults] || options[:skip_db]
|
201
|
-
db_host = "vvv"
|
202
|
-
else
|
203
|
-
db_host = ::ThemeJuice::UI.prompt "Database host", default: "vvv"
|
204
|
-
end
|
205
|
-
|
206
|
-
# Database name
|
207
|
-
if options[:use_defaults] || options[:skip_db]
|
208
|
-
db_name = "#{clean_site_name}_db"
|
209
|
-
else
|
210
|
-
db_name = ::ThemeJuice::UI.prompt "Database name", default: "#{clean_site_name}_db"
|
211
|
-
end
|
212
|
-
|
213
|
-
# Database username
|
214
|
-
if options[:use_defaults] || options[:skip_db]
|
215
|
-
db_user = "#{clean_site_name}_user"
|
216
|
-
else
|
217
|
-
db_user = ::ThemeJuice::UI.prompt "Database username", default: "#{clean_site_name}_user"
|
218
|
-
end
|
219
|
-
|
220
|
-
# Database password
|
221
|
-
if options[:use_defaults] || options[:skip_db]
|
222
|
-
db_pass = SecureRandom.base64
|
223
|
-
else
|
224
|
-
db_pass = ::ThemeJuice::UI.prompt "Database password", default: SecureRandom.base64
|
225
|
-
end
|
60
|
+
self.set_environment
|
61
|
+
@interaction.hello
|
62
|
+
|
63
|
+
opts = {
|
64
|
+
:site_bare => options[:bare],
|
65
|
+
:site_name => site || options[:site],
|
66
|
+
:site_location => options[:location],
|
67
|
+
:site_starter_theme => options[:theme],
|
68
|
+
:site_dev_location => nil,
|
69
|
+
:site_dev_url => options[:url],
|
70
|
+
:site_repository => options[:repository],
|
71
|
+
:skip_repo => options[:skip_repo],
|
72
|
+
:skip_db => options[:skip_db],
|
73
|
+
:use_defaults => options[:use_defaults]
|
74
|
+
}
|
226
75
|
|
227
|
-
|
228
|
-
opts = {
|
229
|
-
site_name: site,
|
230
|
-
site_location: File.expand_path(site_location),
|
231
|
-
starter_theme: starter_theme,
|
232
|
-
bare_setup: bare_setup,
|
233
|
-
dev_location: File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/www/tj-#{site}"),
|
234
|
-
dev_url: dev_url,
|
235
|
-
repository: repository,
|
236
|
-
db_host: db_host,
|
237
|
-
db_name: db_name,
|
238
|
-
db_user: db_user,
|
239
|
-
db_pass: db_pass,
|
240
|
-
}
|
241
|
-
|
242
|
-
# Verify that all the options are correct
|
243
|
-
::ThemeJuice::UI.list "Your settings :", :yellow, [
|
244
|
-
"Site name: #{opts[:site_name]}",
|
245
|
-
"Site location: #{opts[:site_location]}",
|
246
|
-
"Starter theme: #{opts[:starter_theme]}",
|
247
|
-
"Development location: #{opts[:dev_location]}",
|
248
|
-
"Development url: http://#{opts[:dev_url]}",
|
249
|
-
"Initialized repository: #{opts[:repository]}",
|
250
|
-
"Database host: #{opts[:db_host]}",
|
251
|
-
"Database name: #{opts[:db_name]}",
|
252
|
-
"Database username: #{opts[:db_user]}",
|
253
|
-
"Database password: #{opts[:db_pass]}"
|
254
|
-
]
|
255
|
-
|
256
|
-
if ::ThemeJuice::UI.agree? "Do the options above look correct?"
|
257
|
-
::ThemeJuice::Executor::create opts
|
258
|
-
else
|
259
|
-
::ThemeJuice::UI.error "Dang typos... aborting mission."
|
260
|
-
end
|
261
|
-
else
|
262
|
-
::ThemeJuice::UI.error "Site name is required. Aborting mission."
|
263
|
-
end
|
76
|
+
::ThemeJuice::Command::Create.new(opts)
|
264
77
|
end
|
265
78
|
|
266
|
-
|
79
|
+
desc "setup [SITE]", "Setup an existing SITE in development environment"
|
80
|
+
#
|
267
81
|
# Setup an existing WordPress install in VVV
|
268
82
|
#
|
269
83
|
# @param {String} site (nil)
|
270
|
-
# Name of the
|
84
|
+
# Name of the site to setup
|
271
85
|
#
|
272
86
|
# @return {Void}
|
273
|
-
|
274
|
-
|
87
|
+
#
|
88
|
+
method_option :site, :type => :string, :aliases => "-s", :default => false, :desc => "Name of the development site"
|
89
|
+
method_option :location, :type => :string, :aliases => "-l", :default => false, :desc => "Location of the local site"
|
90
|
+
method_option :url, :type => :string, :aliases => "-u", :default => false, :desc => "Development URL of the site"
|
91
|
+
method_option :repository, :type => :string, :aliases => "-r", :desc => "Initialize a new Git remote repository"
|
92
|
+
method_option :skip_repo, :type => :boolean, :desc => "Skip repository prompts and use defaults"
|
93
|
+
method_option :skip_db, :type => :boolean, :desc => "Skip database prompts and use defaults"
|
94
|
+
method_option :use_defaults, :type => :boolean, :desc => "Skip all prompts and use default settings"
|
275
95
|
def setup(site = nil)
|
276
|
-
|
96
|
+
self.set_environment
|
97
|
+
@interaction.hello
|
98
|
+
|
99
|
+
opts = {
|
100
|
+
:site_bare => true,
|
101
|
+
:site_name => site || options[:site],
|
102
|
+
:site_location => options[:location],
|
103
|
+
:site_starter_theme => false,
|
104
|
+
:site_dev_location => nil,
|
105
|
+
:site_dev_url => options[:url],
|
106
|
+
:site_repository => options[:repository],
|
107
|
+
:skip_repo => options[:skip_repo],
|
108
|
+
:skip_db => options[:skip_db],
|
109
|
+
:use_defaults => options[:use_defaults]
|
110
|
+
}
|
111
|
+
|
112
|
+
::ThemeJuice::Command::Create.new(opts)
|
277
113
|
end
|
278
114
|
|
279
|
-
|
115
|
+
desc "delete SITE", "Remove SITE from the VVV development environment (does not remove local site)"
|
116
|
+
method_option :site, :type => :string, :aliases => "-s", :default => false, :desc => "Name of the development site"
|
117
|
+
method_option :restart, :type => :boolean, :aliases => "-r", :desc => "Restart development environment after SITE deletion"
|
118
|
+
#
|
280
119
|
# Remove all traces of site from Vagrant
|
281
120
|
#
|
282
|
-
# @param {String} site
|
283
|
-
#
|
121
|
+
# @param {String} site (nil)
|
122
|
+
# Site to delete. This will not delete your local files, only
|
123
|
+
# files within the VVV environment.
|
284
124
|
#
|
285
125
|
# @return {Void}
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
::ThemeJuice::UI.speak "Are you sure you want to delete '#{site}'? (y/N)", {
|
295
|
-
color: [:white, :on_red],
|
296
|
-
icon: :notice,
|
297
|
-
row: true
|
126
|
+
#
|
127
|
+
def delete(site = nil)
|
128
|
+
self.set_environment
|
129
|
+
|
130
|
+
opts = {
|
131
|
+
:site_name => site || options[:site],
|
132
|
+
:site_dev_location => nil,
|
133
|
+
:restart => options[:restart]
|
298
134
|
}
|
299
135
|
|
300
|
-
|
301
|
-
::ThemeJuice::Executor::delete site, options[:restart]
|
302
|
-
end
|
136
|
+
::ThemeJuice::Command::Delete.new(opts)
|
303
137
|
end
|
304
138
|
|
305
|
-
|
139
|
+
desc "list", "List all sites within the VVV development environment"
|
140
|
+
#
|
306
141
|
# List all development sites
|
307
142
|
#
|
308
143
|
# @return {Void}
|
309
|
-
|
310
|
-
desc "list", "List all sites within the VVV development environment"
|
144
|
+
#
|
311
145
|
def list
|
312
|
-
self.
|
313
|
-
self.use_unicode_chars?
|
314
|
-
self.force_vvv_path?
|
146
|
+
self.set_environment
|
315
147
|
|
316
|
-
::ThemeJuice::
|
148
|
+
::ThemeJuice::Command::List.new
|
317
149
|
end
|
318
150
|
|
319
|
-
|
151
|
+
desc "install", "Run installation for the starter theme"
|
152
|
+
method_option :config, :type => :string, :aliases => "-c", :default => nil, :desc => "Force path to config file"
|
153
|
+
#
|
320
154
|
# Install and setup starter theme
|
321
155
|
#
|
322
156
|
# @return {Void}
|
323
|
-
|
324
|
-
desc "install", "Run installation for the starter theme"
|
325
|
-
method_option :config, type: :string, aliases: "-c", default: nil, desc: "Force path to config file"
|
157
|
+
#
|
326
158
|
def install
|
327
|
-
self.
|
328
|
-
self.use_unicode_chars?
|
329
|
-
self.force_vvv_path?
|
159
|
+
self.set_environment
|
330
160
|
|
331
|
-
::ThemeJuice::
|
161
|
+
::ThemeJuice::Command::Install.new
|
332
162
|
end
|
333
163
|
|
334
|
-
|
164
|
+
#
|
335
165
|
# Assets
|
336
166
|
#
|
337
167
|
# @param {*} commands
|
338
168
|
# Commands to run
|
339
169
|
#
|
340
170
|
# @return {Void}
|
341
|
-
|
171
|
+
#
|
342
172
|
desc "watch [COMMANDS]", "Watch and compile assets"
|
343
173
|
def watch(*commands)
|
344
|
-
self.
|
345
|
-
|
346
|
-
|
174
|
+
self.set_environment
|
175
|
+
|
176
|
+
opts = {
|
177
|
+
:subcommand => "watch",
|
178
|
+
:commands => commands.join(" ")
|
179
|
+
}
|
347
180
|
|
348
|
-
::ThemeJuice::
|
181
|
+
::ThemeJuice::Command::Subcommand.new(opts)
|
349
182
|
end
|
350
183
|
|
351
|
-
|
184
|
+
#
|
352
185
|
# Vendor dependencies
|
353
186
|
#
|
354
187
|
# @param {*} commands
|
355
188
|
# Commands to run
|
356
189
|
#
|
357
190
|
# @return {Void}
|
358
|
-
|
191
|
+
#
|
359
192
|
desc "vendor [COMMANDS]", "Manage vendor dependencies"
|
360
193
|
def vendor(*commands)
|
361
|
-
self.
|
362
|
-
|
363
|
-
|
194
|
+
self.set_environment
|
195
|
+
|
196
|
+
opts = {
|
197
|
+
:subcommand => "vendor",
|
198
|
+
:commands => commands.join(" ")
|
199
|
+
}
|
364
200
|
|
365
|
-
::ThemeJuice::
|
201
|
+
::ThemeJuice::Command::Subcommand.new(opts)
|
366
202
|
end
|
367
203
|
|
368
|
-
|
204
|
+
#
|
369
205
|
# Server/Deployment
|
370
206
|
#
|
371
207
|
# @param {*} commands
|
372
208
|
# Commands to run
|
373
209
|
#
|
374
210
|
# @return {Void}
|
375
|
-
|
211
|
+
#
|
376
212
|
desc "server [COMMANDS]", "Manage deployment and migration"
|
377
213
|
def server(*commands)
|
378
|
-
self.
|
379
|
-
|
380
|
-
|
214
|
+
self.set_environment
|
215
|
+
|
216
|
+
opts = {
|
217
|
+
:subcommand => "server",
|
218
|
+
:commands => commands.join(" ")
|
219
|
+
}
|
381
220
|
|
382
|
-
::ThemeJuice::
|
221
|
+
::ThemeJuice::Command::Subcommand.new(opts)
|
383
222
|
end
|
384
223
|
|
385
|
-
|
224
|
+
#
|
386
225
|
# Vagrant
|
387
226
|
#
|
388
227
|
# @param {*} commands
|
389
228
|
# Commands to run
|
390
229
|
#
|
391
230
|
# @return {Void}
|
392
|
-
|
231
|
+
#
|
393
232
|
desc "vm [COMMANDS]", "Manage virtual development environment with Vagrant"
|
394
233
|
def vm(*commands)
|
395
|
-
self.
|
396
|
-
self.use_unicode_chars?
|
397
|
-
self.force_vvv_path?
|
234
|
+
self.set_environment
|
398
235
|
|
399
|
-
system "cd #{
|
236
|
+
system "cd #{@environment.vvv_path} && vagrant #{commands.join(" ")}"
|
400
237
|
end
|
401
238
|
|
402
|
-
|
239
|
+
#
|
403
240
|
# Non-Thor commands
|
404
|
-
|
241
|
+
#
|
405
242
|
no_commands do
|
406
243
|
|
407
|
-
|
408
|
-
#
|
244
|
+
#
|
245
|
+
# Set up the environment
|
409
246
|
#
|
410
247
|
# @return {Void}
|
411
|
-
|
412
|
-
def
|
413
|
-
::ThemeJuice::
|
248
|
+
#
|
249
|
+
def set_environment
|
250
|
+
@environment = ::ThemeJuice::Environment
|
251
|
+
@interaction = ::ThemeJuice::Interaction
|
252
|
+
|
253
|
+
@environment.no_colors = if self.boring? then true else options[:no_colors] end
|
254
|
+
@environment.no_unicode = if self.boring? then true else options[:no_unicode] end
|
255
|
+
@environment.no_animations = if self.boring? then true else options[:no_animations] end
|
256
|
+
|
257
|
+
self.force_vvv_path?
|
258
|
+
self.yolo?
|
414
259
|
end
|
415
260
|
|
416
|
-
###
|
417
|
-
# Disable unicode characters if flag is passed
|
418
261
|
#
|
419
|
-
#
|
420
|
-
|
421
|
-
|
422
|
-
|
262
|
+
# Enable boring-mode
|
263
|
+
#
|
264
|
+
# @return {Bool}
|
265
|
+
#
|
266
|
+
def boring?
|
267
|
+
@environment.boring = options[:boring]
|
423
268
|
end
|
424
269
|
|
425
|
-
|
270
|
+
#
|
271
|
+
# Enable yolo-mode
|
272
|
+
#
|
273
|
+
# @return {Bool}
|
274
|
+
#
|
275
|
+
def yolo?
|
276
|
+
@environment.yolo = options[:yolo]
|
277
|
+
end
|
278
|
+
|
279
|
+
#
|
426
280
|
# Set VVV path
|
427
281
|
#
|
428
282
|
# @return {Void}
|
429
|
-
|
283
|
+
#
|
430
284
|
def force_vvv_path?
|
431
285
|
if options[:vvv_path].nil?
|
432
|
-
|
286
|
+
@environment.vvv_path = File.expand_path("~/vagrant")
|
433
287
|
else
|
434
|
-
|
435
|
-
|
288
|
+
@environment.vvv_path = options[:vvv_path]
|
289
|
+
@interaction.notice "You're using a custom VVV path : (#{@environment.vvv_path})"
|
436
290
|
|
437
|
-
unless
|
438
|
-
|
291
|
+
unless @interaction.agree? "Is the path correct?"
|
292
|
+
@interaction.error "Good call. Let's create things, not break things. Aborting mission."
|
439
293
|
end
|
440
294
|
end
|
441
295
|
|
442
|
-
unless Dir.exist?
|
443
|
-
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
###
|
448
|
-
# Make sure site name is valid
|
449
|
-
#
|
450
|
-
# @param {String} site
|
451
|
-
#
|
452
|
-
# @return {Void}
|
453
|
-
###
|
454
|
-
def validate_site_name(site)
|
455
|
-
site.match /[^0-9A-Za-z.\-]/ do |char|
|
456
|
-
::ThemeJuice::UI.error "Site name contains an invalid character '#{char}'. This name is used for creating directories, so that's not gonna work. Aborting mission."
|
296
|
+
unless Dir.exist? @environment.vvv_path
|
297
|
+
@interaction.error "Cannot load VVV path (#{@environment.vvv_path}). Aborting mission before something bad happens."
|
457
298
|
end
|
458
299
|
end
|
459
|
-
|
460
|
-
###
|
461
|
-
# Output welcome message
|
462
|
-
#
|
463
|
-
# @return {Void}
|
464
|
-
###
|
465
|
-
def welcome_message
|
466
|
-
::ThemeJuice::UI.speak "Welcome to Theme Juice!", {
|
467
|
-
color: [:black, :on_green, :bold],
|
468
|
-
row: true
|
469
|
-
}
|
470
|
-
end
|
471
300
|
end
|
472
301
|
end
|
473
302
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module ThemeJuice
|
4
|
+
class Command
|
5
|
+
include ::Thor::Actions
|
6
|
+
include ::Thor::Shell
|
7
|
+
|
8
|
+
def initialize(opts = {})
|
9
|
+
@environment = ::ThemeJuice::Environment
|
10
|
+
@interaction = ::ThemeJuice::Interaction
|
11
|
+
@opts = opts
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|