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
@@ -0,0 +1,387 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module ThemeJuice
|
4
|
+
class Service::CreateSite < ::ThemeJuice::Service
|
5
|
+
|
6
|
+
#
|
7
|
+
# @param {Hash} opts
|
8
|
+
#
|
9
|
+
def initialize(opts = {})
|
10
|
+
opts = ::ThemeJuice::Interaction::CreateSiteOptions.new.setup_site_options(opts)
|
11
|
+
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Set up local development environment and site
|
17
|
+
#
|
18
|
+
# @return {Void}
|
19
|
+
#
|
20
|
+
def create
|
21
|
+
@interaction.notice "Running setup for '#{@opts[:site_name]}'"
|
22
|
+
|
23
|
+
setup_project_dir unless project_dir_is_setup?
|
24
|
+
setup_wordpress unless wordpress_is_setup?
|
25
|
+
setup_vvv unless vvv_is_setup?
|
26
|
+
setup_wildcard_subdomains unless wildcard_subdomains_is_setup?
|
27
|
+
setup_hosts unless hosts_is_setup?
|
28
|
+
setup_database unless database_is_setup?
|
29
|
+
setup_nginx unless nginx_is_setup?
|
30
|
+
setup_dev_site unless dev_site_is_setup?
|
31
|
+
setup_env unless env_is_setup?
|
32
|
+
setup_synced_folder unless synced_folder_is_setup?
|
33
|
+
setup_wpcli unless wpcli_is_setup?
|
34
|
+
setup_repo if using_repo?
|
35
|
+
|
36
|
+
if setup_was_successful?
|
37
|
+
@interaction.success "Setup complete!"
|
38
|
+
@interaction.speak "In order to finish creating your site, you need to provision Vagrant. Do it now? (y/N)", {
|
39
|
+
:color => [:black, :on_blue],
|
40
|
+
:icon => :restart,
|
41
|
+
:row => true
|
42
|
+
}
|
43
|
+
|
44
|
+
if @interaction.agree? "", { simple: true }
|
45
|
+
|
46
|
+
if restart_vagrant
|
47
|
+
@interaction.success "Success!"
|
48
|
+
|
49
|
+
# Output setup info
|
50
|
+
@interaction.list "Your settings :", :blue, [
|
51
|
+
"Site name: #{@opts[:site_name]}",
|
52
|
+
"Site location: #{@opts[:site_location]}",
|
53
|
+
"Starter theme: #{@opts[:site_starter_theme]}",
|
54
|
+
"Development location: #{@opts[:site_dev_location]}",
|
55
|
+
"Development url: http://#{@opts[:site_dev_url]}",
|
56
|
+
"Initialized repository: #{@opts[:site_repository]}",
|
57
|
+
"Database host: #{@opts[:site_db_host]}",
|
58
|
+
"Database name: #{@opts[:site_db_name]}",
|
59
|
+
"Database username: #{@opts[:site_db_user]}",
|
60
|
+
"Database password: #{@opts[:site_db_pass]}"
|
61
|
+
]
|
62
|
+
|
63
|
+
unless OS.windows?
|
64
|
+
@interaction.notice "Do you want to open up your new site 'http://#{@opts[:site_dev_url]}' now? (y/N)"
|
65
|
+
|
66
|
+
run ["open http://#{@opts[:site_dev_url]}"] if @interaction.agree? "", {
|
67
|
+
:color => :yellow,
|
68
|
+
:simple => true
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
else
|
73
|
+
@interaction.notice "Remember, Vagrant needs to be provisioned before you can use your new site. Exiting..."
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
else
|
77
|
+
@interaction.error "Setup failed. Running cleanup" do
|
78
|
+
::ThemeJuice::Service::Delete.new({ site_name: @opts[:site_name], restart: false }).delete
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
#
|
86
|
+
# Install Vagrant plugins and clone VVV
|
87
|
+
#
|
88
|
+
# @return {Void}
|
89
|
+
#
|
90
|
+
def setup_vvv
|
91
|
+
@interaction.log "Installing VVV"
|
92
|
+
|
93
|
+
run [
|
94
|
+
"vagrant plugin install vagrant-hostsupdater",
|
95
|
+
"vagrant plugin install vagrant-triggers",
|
96
|
+
"vagrant plugin install landrush",
|
97
|
+
"git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git #{@environment.vvv_path}",
|
98
|
+
"touch #{@environment.vvv_path}/database/init-custom.sql"
|
99
|
+
]
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Ensure project directory structure
|
104
|
+
#
|
105
|
+
# @return {Void}
|
106
|
+
#
|
107
|
+
def setup_project_dir
|
108
|
+
@interaction.log "Creating project directory tree"
|
109
|
+
|
110
|
+
run ["mkdir -p #{@opts[:site_location]}"]
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Enable Landrush for wildcard subdomains
|
115
|
+
#
|
116
|
+
# This will write a Landrush activation block to the global Vagrantfile
|
117
|
+
# if one does not already exist.
|
118
|
+
#
|
119
|
+
# @return {Void}
|
120
|
+
#
|
121
|
+
def setup_wildcard_subdomains
|
122
|
+
@interaction.log "Setting up wildcard subdomains"
|
123
|
+
|
124
|
+
File.open File.expand_path("#{@environment.vvv_path}/Vagrantfile"), "ab+" do |file|
|
125
|
+
file.puts "\n"
|
126
|
+
file.puts "###"
|
127
|
+
file.puts "# Enable wildcard subdomains"
|
128
|
+
file.puts "#"
|
129
|
+
file.puts "# This block is automatically generated by Theme Juice. Do not edit."
|
130
|
+
file.puts "###"
|
131
|
+
file.puts "Vagrant.configure('2') do |config|"
|
132
|
+
file.puts "\tconfig.landrush.enabled = true"
|
133
|
+
file.puts "\tconfig.landrush.tld = 'dev'"
|
134
|
+
file.puts "end"
|
135
|
+
file.puts "\n"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# Create a new directory for site that will be symlinked with the local install
|
141
|
+
#
|
142
|
+
# @return {Void}
|
143
|
+
#
|
144
|
+
def setup_dev_site
|
145
|
+
@interaction.log "Setting up new site in VM"
|
146
|
+
|
147
|
+
run [
|
148
|
+
"cd #{@environment.vvv_path}/www",
|
149
|
+
"mkdir tj-#{@opts[:site_name]}",
|
150
|
+
]
|
151
|
+
end
|
152
|
+
|
153
|
+
#
|
154
|
+
# Create tj.yml file for theme settings
|
155
|
+
#
|
156
|
+
# @return {Void}
|
157
|
+
#
|
158
|
+
def setup_config
|
159
|
+
@interaction.log "Creating config"
|
160
|
+
|
161
|
+
watch = @interaction.prompt "Watch command to use", indent: 2, default: "bundle exec guard"
|
162
|
+
server = @interaction.prompt "Deployment command to use", indent: 2, default: "bundle exec cap"
|
163
|
+
vendor = @interaction.prompt "Vendor command to use", indent: 2, default: "composer"
|
164
|
+
install = @interaction.prompt "Commands to run on theme install (comma-delimited)", indent: 2, default: "composer install"
|
165
|
+
|
166
|
+
File.open "#{@config_path}/tj.yml", "wb" do |file|
|
167
|
+
file.puts "commands:"
|
168
|
+
file.puts "\s\swatch: #{watch}"
|
169
|
+
file.puts "\s\sserver: #{server}"
|
170
|
+
file.puts "\s\svendor: #{vendor}"
|
171
|
+
file.puts "\s\sinstall:"
|
172
|
+
install.split(",").map!(&:strip).each do |command|
|
173
|
+
file.puts "\s\s\s\s- #{command}"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
unless config_is_setup?
|
178
|
+
@interaction.error "Could not create 'tj.yml' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
#
|
183
|
+
# Create vvv-hosts file
|
184
|
+
#
|
185
|
+
# @return {Void}
|
186
|
+
#
|
187
|
+
def setup_hosts
|
188
|
+
@interaction.log "Setting up hosts"
|
189
|
+
|
190
|
+
File.open "#{@opts[:site_location]}/vvv-hosts", "wb" do |file|
|
191
|
+
file.puts @opts[:site_dev_url]
|
192
|
+
end
|
193
|
+
|
194
|
+
unless hosts_is_setup?
|
195
|
+
@interaction.error "Could not create 'vvv-hosts' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
#
|
200
|
+
# Add database block to init-custom.sql, create if not exists
|
201
|
+
#
|
202
|
+
# @return {Void}
|
203
|
+
#
|
204
|
+
def setup_database
|
205
|
+
@interaction.log "Setting up database"
|
206
|
+
|
207
|
+
File.open File.expand_path("#{@environment.vvv_path}/database/init-custom.sql"), "ab+" do |file|
|
208
|
+
file.puts "### Begin '#{@opts[:site_name]}'"
|
209
|
+
file.puts "#"
|
210
|
+
file.puts "# This block is automatically generated by Theme Juice. Do not edit."
|
211
|
+
file.puts "###"
|
212
|
+
file.puts "CREATE DATABASE IF NOT EXISTS `#{@opts[:site_db_name]}`;"
|
213
|
+
file.puts "GRANT ALL PRIVILEGES ON `#{@opts[:site_db_name]}`.* TO '#{@opts[:site_db_user]}'@'localhost' IDENTIFIED BY '#{@opts[:site_db_pass]}';"
|
214
|
+
file.puts "### End '#{@opts[:site_name]}'"
|
215
|
+
file.puts "\n"
|
216
|
+
end
|
217
|
+
|
218
|
+
unless database_is_setup?
|
219
|
+
@interaction.error "Could not add database info for '#{@opts[:site_name]}' to 'init-custom.sql'. Make sure you have write capabilities to '#{@environment.vvv_path}'."
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
#
|
224
|
+
# Create vvv-nginx.conf file for local development site
|
225
|
+
#
|
226
|
+
# @return {Void}
|
227
|
+
#
|
228
|
+
def setup_nginx
|
229
|
+
@interaction.log "Setting up nginx"
|
230
|
+
|
231
|
+
File.open "#{@opts[:site_location]}/vvv-nginx.conf", "wb" do |file|
|
232
|
+
file.puts "server {"
|
233
|
+
file.puts "\tlisten 80;"
|
234
|
+
file.puts "\tserver_name .#{@opts[:site_dev_url]};"
|
235
|
+
file.puts "\troot {vvv_path_to_folder};"
|
236
|
+
file.puts "\tinclude /etc/nginx/nginx-wp-common.conf;"
|
237
|
+
file.puts "}"
|
238
|
+
end
|
239
|
+
|
240
|
+
unless nginx_is_setup?
|
241
|
+
@interaction.error "Could not create 'vvv-nginx.conf' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
#
|
246
|
+
# Create Dotenv environment file
|
247
|
+
#
|
248
|
+
# @return {Void}
|
249
|
+
#
|
250
|
+
def setup_env
|
251
|
+
@interaction.log "Setting up environment"
|
252
|
+
|
253
|
+
File.open "#{@opts[:site_location]}/.env.development", "wb" do |file|
|
254
|
+
file.puts "DB_NAME=#{@opts[:site_db_name]}"
|
255
|
+
file.puts "DB_USER=#{@opts[:site_db_user]}"
|
256
|
+
file.puts "DB_PASSWORD=#{@opts[:site_db_pass]}"
|
257
|
+
file.puts "DB_HOST=#{@opts[:site_db_host]}"
|
258
|
+
file.puts "WP_HOME=http://#{@opts[:site_dev_url]}"
|
259
|
+
file.puts "WP_SITEURL=http://#{@opts[:site_dev_url]}/wp"
|
260
|
+
end
|
261
|
+
|
262
|
+
unless env_is_setup?
|
263
|
+
@interaction.error "Could not create '.env.development' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
#
|
268
|
+
# Setup WordPress
|
269
|
+
#
|
270
|
+
# Clones starter theme into site location
|
271
|
+
#
|
272
|
+
# @return {Void}
|
273
|
+
#
|
274
|
+
def setup_wordpress
|
275
|
+
unless @opts[:site_bare]
|
276
|
+
@interaction.log "Setting up WordPress"
|
277
|
+
|
278
|
+
run [
|
279
|
+
"cd #{@opts[:site_location]}",
|
280
|
+
"git clone --depth 1 #{@opts[:starter_theme]} .",
|
281
|
+
]
|
282
|
+
|
283
|
+
install_theme_dependencies unless config_is_setup?
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
#
|
288
|
+
# Add synced folder block to Vagrantfile
|
289
|
+
#
|
290
|
+
# @return {Void}
|
291
|
+
#
|
292
|
+
def setup_synced_folder
|
293
|
+
@interaction.log "Syncing host theme with VM"
|
294
|
+
|
295
|
+
contents = %Q{
|
296
|
+
### Begin '#{@opts[:site_name]}'
|
297
|
+
#
|
298
|
+
# This block is automatically generated by Theme Juice. Do not edit.
|
299
|
+
###
|
300
|
+
Vagrant.configure('2') do |config|
|
301
|
+
\tconfig.vm.synced_folder '#{@opts[:site_location]}', '/srv/www/tj-#{@opts[:site_name]}', mount_options: ['dmode=777','fmode=777']
|
302
|
+
\tconfig.landrush.host '#{@opts[:site_dev_url]}', '192.168.50.4'
|
303
|
+
end
|
304
|
+
### End '#{@opts[:site_name]}'
|
305
|
+
\n
|
306
|
+
}
|
307
|
+
|
308
|
+
File.open File.expand_path("#{@environment.vvv_path}/Vagrantfile"), "ab+" do |file|
|
309
|
+
file.puts "### Begin '#{@opts[:site_name]}'"
|
310
|
+
file.puts "#"
|
311
|
+
file.puts "# This block is automatically generated by Theme Juice. Do not edit."
|
312
|
+
file.puts "###"
|
313
|
+
file.puts "Vagrant.configure('2') do |config|"
|
314
|
+
file.puts "\tconfig.vm.synced_folder '#{@opts[:site_location]}', '/srv/www/tj-#{@opts[:site_name]}', mount_options: ['dmode=777','fmode=777']"
|
315
|
+
file.puts "\tconfig.landrush.host '#{@opts[:site_dev_url]}', '192.168.50.4'"
|
316
|
+
file.puts "end"
|
317
|
+
file.puts "### End '#{@opts[:site_name]}'"
|
318
|
+
file.puts "\n"
|
319
|
+
end
|
320
|
+
|
321
|
+
unless synced_folder_is_setup?
|
322
|
+
@interaction.error "Could not sync folders for '#{@opts[:site_name]}' in 'Vagrantfile'. Make sure you have write capabilities to '#{@environment.vvv_path}'."
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
#
|
327
|
+
# Initialize Git repo, add remote, initial commit
|
328
|
+
#
|
329
|
+
# @return {Void}
|
330
|
+
#
|
331
|
+
def setup_repo
|
332
|
+
@interaction.log "Setting up Git repository"
|
333
|
+
|
334
|
+
if repo_is_setup?
|
335
|
+
run [
|
336
|
+
"cd #{@opts[:site_location]}",
|
337
|
+
"rm -rf .git",
|
338
|
+
]
|
339
|
+
end
|
340
|
+
|
341
|
+
run [
|
342
|
+
"cd #{@opts[:site_location]}",
|
343
|
+
"git init",
|
344
|
+
"git remote add origin #{@opts[:repository]}",
|
345
|
+
]
|
346
|
+
end
|
347
|
+
|
348
|
+
##
|
349
|
+
# Add wp-cli-ssh block to wp-cli.yml
|
350
|
+
#
|
351
|
+
# @return {Void}
|
352
|
+
#
|
353
|
+
def setup_wpcli
|
354
|
+
@interaction.log "Setting up WP-CLI"
|
355
|
+
|
356
|
+
File.open "#{@opts[:site_location]}/wp-cli.local.yml", "ab+" do |file|
|
357
|
+
file.puts "require:"
|
358
|
+
file.puts "\t- vendor/autoload.php"
|
359
|
+
file.puts "ssh:"
|
360
|
+
file.puts "\tvagrant:"
|
361
|
+
file.puts "\t\turl: #{@opts[:site_dev_url]}"
|
362
|
+
file.puts "\t\tpath: /srv/www/tj-#{@opts[:site_name]}"
|
363
|
+
file.puts "\t\tcmd: cd #{@environment.vvv_path} && vagrant ssh-config > /tmp/vagrant_ssh_config && ssh -q %pseudotty% -F /tmp/vagrant_ssh_config default %cmd%"
|
364
|
+
file.puts "\n"
|
365
|
+
end
|
366
|
+
|
367
|
+
unless wpcli_is_setup?
|
368
|
+
@interaction.error "Could not create 'wp-cli.local.yml' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
#
|
373
|
+
# Install dependencies for starter theme
|
374
|
+
#
|
375
|
+
# @return {Void}
|
376
|
+
#
|
377
|
+
def install_theme_dependencies
|
378
|
+
use_config
|
379
|
+
|
380
|
+
@interaction.log "Installing theme dependencies"
|
381
|
+
|
382
|
+
@config["commands"]["install"].each do |command|
|
383
|
+
run ["cd #{@opts[:site_location]}", command], false
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module ThemeJuice
|
4
|
+
class Service::DeleteSite < ::ThemeJuice::Service
|
5
|
+
|
6
|
+
#
|
7
|
+
# @param {Hash} opts
|
8
|
+
#
|
9
|
+
def initialize(opts)
|
10
|
+
opts = ThemeJuice::Interaction::DeleteSiteOptions.new.get_site_options(opts)
|
11
|
+
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Remove all traces of site from Vagrant
|
17
|
+
#
|
18
|
+
# @return {Void}
|
19
|
+
#
|
20
|
+
def delete
|
21
|
+
@interaction.speak "Are you sure you want to delete '#{@opts[:site_name]}'? (y/N)", {
|
22
|
+
:color => [:white, :on_red],
|
23
|
+
:icon => :notice,
|
24
|
+
:row => true
|
25
|
+
}
|
26
|
+
|
27
|
+
if @interaction.agree? "", { color: :red, simple: true }
|
28
|
+
|
29
|
+
remove_dev_site if dev_site_is_setup?
|
30
|
+
remove_database if database_is_setup?
|
31
|
+
remove_synced_folder if synced_folder_is_setup?
|
32
|
+
|
33
|
+
if removal_was_successful?
|
34
|
+
@interaction.success "Site '#{@opts[:site_name]}' successfully removed!"
|
35
|
+
|
36
|
+
restart_vagrant if @opts[:restart]
|
37
|
+
else
|
38
|
+
@interaction.error "Site '#{@opts[:site_name]}' could not be fully be removed."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
#
|
46
|
+
# Remove all theme files from Vagrant directory
|
47
|
+
#
|
48
|
+
# @return {Void}
|
49
|
+
#
|
50
|
+
def remove_dev_site
|
51
|
+
|
52
|
+
unless Dir.entries("#{@environment.vvv_path}").include? "www"
|
53
|
+
@interaction.error "Cannot load VVV path. Aborting mission before something bad happens."
|
54
|
+
end
|
55
|
+
|
56
|
+
if run ["rm -rf #{@opts[:site_dev_location]}"]
|
57
|
+
@interaction.log "Development site removed"
|
58
|
+
else
|
59
|
+
@interaction.error "Site '#{@opts[:site_name]}' could not be removed. Make sure you have write capabilities to '#{@opts[:site_dev_location]}'."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Remove database block from init-custom.sql
|
65
|
+
#
|
66
|
+
# @return {Void}
|
67
|
+
#
|
68
|
+
def remove_database
|
69
|
+
if remove_traces_from_file "#{@environment.vvv_path}/database/init-custom.sql"
|
70
|
+
@interaction.log "Database removed"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Remove synced folder block from Vagrantfile
|
76
|
+
#
|
77
|
+
# @return {Void}
|
78
|
+
#
|
79
|
+
def remove_synced_folder
|
80
|
+
if remove_traces_from_file "#{@environment.vvv_path}/Vagrantfile"
|
81
|
+
@interaction.log "Synced folders removed"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# Remove all traces of auto-generated content from file
|
87
|
+
#
|
88
|
+
# @param {String} input_file
|
89
|
+
#
|
90
|
+
# @return {Void}
|
91
|
+
#
|
92
|
+
def remove_traces_from_file(input_file)
|
93
|
+
begin
|
94
|
+
# Create new tempfile
|
95
|
+
output_file = Tempfile.new File.basename(input_file)
|
96
|
+
# Copy over contents of actual file to tempfile
|
97
|
+
open File.expand_path(input_file), "rb" do |file|
|
98
|
+
# Remove traces of theme from contents
|
99
|
+
output_file.write "#{file.read}".gsub(/(### Begin '#{@opts[:site_name]}')(.*?)(### End '#{@opts[:site_name]}')\n+/m, "")
|
100
|
+
end
|
101
|
+
# Move temp file to actual file location
|
102
|
+
FileUtils.mv output_file, File.expand_path(input_file)
|
103
|
+
rescue LoadError => err
|
104
|
+
@interaction.error "There was an error!" do
|
105
|
+
puts err
|
106
|
+
end
|
107
|
+
ensure
|
108
|
+
# Make sure that the tempfile closes and is cleaned up, regardless of errors
|
109
|
+
output_file.close
|
110
|
+
output_file.unlink
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module ThemeJuice
|
4
|
+
class Service::ListSites < ::ThemeJuice::Service
|
5
|
+
|
6
|
+
def initialize(opts = {})
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
#
|
11
|
+
# List all development sites
|
12
|
+
#
|
13
|
+
# @return {Void}
|
14
|
+
#
|
15
|
+
def list
|
16
|
+
sites = get_sites
|
17
|
+
|
18
|
+
if sites.empty?
|
19
|
+
@interaction.log "Nothing to list."
|
20
|
+
else
|
21
|
+
@interaction.list "Your sites :", :green, sites
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Get an array of development sites
|
27
|
+
#
|
28
|
+
# @return {Array}
|
29
|
+
#
|
30
|
+
def get_sites
|
31
|
+
sites = []
|
32
|
+
|
33
|
+
Dir.glob(File.expand_path("#{@environment.vvv_path}/www/*")).each do |f|
|
34
|
+
sites << File.basename(f).gsub(/(tj-)/, "") if File.directory?(f) && f.include?("tj-")
|
35
|
+
end
|
36
|
+
|
37
|
+
sites
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/theme-juice/version.rb
CHANGED
data/lib/theme-juice.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "thor"
|
4
|
+
require "forwardable"
|
5
|
+
require "faker"
|
4
6
|
require "fileutils"
|
5
7
|
require "pathname"
|
6
8
|
require "tempfile"
|
7
|
-
require "rubygems"
|
8
|
-
require "thor"
|
9
9
|
require "yaml"
|
10
10
|
require "os"
|
11
11
|
|
@@ -13,7 +13,20 @@ module ThemeJuice
|
|
13
13
|
end
|
14
14
|
|
15
15
|
require_relative "theme-juice/version"
|
16
|
-
require_relative "theme-juice/
|
17
|
-
require_relative "theme-juice/
|
18
|
-
require_relative "theme-juice/
|
16
|
+
require_relative "theme-juice/environment"
|
17
|
+
require_relative "theme-juice/interaction"
|
18
|
+
require_relative "theme-juice/interactions/teejay"
|
19
|
+
require_relative "theme-juice/interactions/create_site_options"
|
20
|
+
require_relative "theme-juice/interactions/delete_site_options"
|
21
|
+
require_relative "theme-juice/service"
|
22
|
+
require_relative "theme-juice/services/config_file"
|
23
|
+
require_relative "theme-juice/services/create_site"
|
24
|
+
require_relative "theme-juice/services/delete_site"
|
25
|
+
require_relative "theme-juice/services/list_sites"
|
26
|
+
require_relative "theme-juice/command"
|
27
|
+
require_relative "theme-juice/commands/install"
|
28
|
+
require_relative "theme-juice/commands/create"
|
29
|
+
require_relative "theme-juice/commands/delete"
|
30
|
+
require_relative "theme-juice/commands/list"
|
31
|
+
require_relative "theme-juice/commands/subcommand"
|
19
32
|
require_relative "theme-juice/cli"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme-juice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezekiel Gabrielse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faker
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: thor
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,9 +76,22 @@ extensions: []
|
|
62
76
|
extra_rdoc_files: []
|
63
77
|
files:
|
64
78
|
- lib/theme-juice/cli.rb
|
65
|
-
- lib/theme-juice/
|
66
|
-
- lib/theme-juice/
|
67
|
-
- lib/theme-juice/
|
79
|
+
- lib/theme-juice/command.rb
|
80
|
+
- lib/theme-juice/commands/create.rb
|
81
|
+
- lib/theme-juice/commands/delete.rb
|
82
|
+
- lib/theme-juice/commands/install.rb
|
83
|
+
- lib/theme-juice/commands/list.rb
|
84
|
+
- lib/theme-juice/commands/subcommand.rb
|
85
|
+
- lib/theme-juice/environment.rb
|
86
|
+
- lib/theme-juice/interaction.rb
|
87
|
+
- lib/theme-juice/interactions/create_site_options.rb
|
88
|
+
- lib/theme-juice/interactions/delete_site_options.rb
|
89
|
+
- lib/theme-juice/interactions/teejay.rb
|
90
|
+
- lib/theme-juice/service.rb
|
91
|
+
- lib/theme-juice/services/config_file.rb
|
92
|
+
- lib/theme-juice/services/create_site.rb
|
93
|
+
- lib/theme-juice/services/delete_site.rb
|
94
|
+
- lib/theme-juice/services/list_sites.rb
|
68
95
|
- lib/theme-juice/version.rb
|
69
96
|
- lib/theme-juice.rb
|
70
97
|
- LICENSE
|
@@ -72,7 +99,7 @@ files:
|
|
72
99
|
- bin/tj
|
73
100
|
homepage: https://github.com/ezekg/theme-juice-cli.git
|
74
101
|
licenses:
|
75
|
-
-
|
102
|
+
- GNU
|
76
103
|
metadata: {}
|
77
104
|
post_install_message:
|
78
105
|
rdoc_options: []
|