theme-juice 0.4.4 → 0.5.0

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: 887133839cd619caf478e83517cd079722997dcb
4
- data.tar.gz: f4b1067326aa598fdb346f933f0ae13a7c0a3889
3
+ metadata.gz: 8faea6ee55d26406a1ec3ad715e843ec0780a2f4
4
+ data.tar.gz: 42a01a719dc792239ae5b32c34a715eafee59440
5
5
  SHA512:
6
- metadata.gz: 908ed121cf481f62f75e0ca298818c3aef7029854e85e5ed437f6ec4e1350b235868a5662292766fb2a4cf78ed322ba5f181b70f47127e860442650f7b6e5d0d
7
- data.tar.gz: 10b9f21a9ee6b9ce657c61be80f1eec6f5a24faf0d3916a94d78e83a41655fad9a45506551f69d82fead0216001db687a3742bc8cef853bbd3df56cacd756882
6
+ metadata.gz: bc48633cb614d435ab717a9013377398d00535e44a6c89b8db0ef1f921154f5d5bf62fe80ee32cac6a3389b5fc60c59fd173ca8fa866003e98a3f4fe661480dc
7
+ data.tar.gz: 5c993eb4ef4b00f36d5f0585394550d7244e9ac8ee0e105ecf20ec9c3f90bd0f0babaf0976024a4a094ff077417408434f34aeeeaf7c19577f5b8da38d120116
data/README.md CHANGED
@@ -8,21 +8,22 @@ What is it? Theme Juice is a command line interface created to scaffold out a ne
8
8
  That`s it!
9
9
 
10
10
  ## Config
11
- Because everybody likes to use different tools, you can create a `tj-config.yml` file that will house all of your theme-specific commands. This allows you to use a streamlined set of commands that will act as aliases to your per-project configuration.
11
+ Because everybody likes to use different tools, you can create a `tj.yml` file (with an optional preceding `.`) that will house all of your theme-specific commands. This allows you to use a streamlined set of commands that will act as aliases to your per-project configuration, as well as starter-theme specific information, such as deployment configuration, etc. For right now, we'll just stick to the `commands` section.
12
12
 
13
13
  If you're into [Grunt](https://github.com/gruntjs/grunt), then use it. Prefer [Guard](https://github.com/guard/guard)? Go right ahead. This is obviously relative to the starter theme you use, since you can't exactly use Grunt with a starter theme that doesn't support it. Below is the config that comes baked into [our starter theme](https://github.com/ezekg/theme-juice-starter):
14
14
 
15
15
  ```yml
16
- watch: bundle exec guard
17
- server: bundle exec cap
18
- vendor: composer
19
- install:
20
- - composer install
16
+ commands:
17
+ watch: bundle exec guard
18
+ server: bundle exec cap
19
+ vendor: composer
20
+ install:
21
+ - composer install
21
22
  ```
22
23
 
23
- _Note: If you use a starter theme that doesn't have a `tj-config.yml` file, you'll be prompted through a series of steps in order to create one._
24
+ _Note: If you use a starter theme that doesn't have a `tj.yml` file, you'll be prompted through a series of steps in order to create one._
24
25
 
25
- #### Config options:
26
+ #### Command options:
26
27
  | Option | Usage |
27
28
  |:--------- |:----------------------------------------------------------------------------- |
28
29
  | `watch` | Command to be aliased when you run `tj watch` for bulding assets |
@@ -89,7 +90,7 @@ tj list # Aliases: sites, show
89
90
  ```
90
91
 
91
92
  ### Watching and compiling assets:
92
- Use this to watch and compile assets with your preferred build tool, whether that be [Grunt](https://github.com/gruntjs/grunt), [Gulp](https://github.com/gulpjs/gulp), [Guard](https://github.com/guard/guard), or whatever. This is simply a wrapper for whatever command is in your `tj-config.yml` file.
93
+ Use this to watch and compile assets with your preferred build tool, whether that be [Grunt](https://github.com/gruntjs/grunt), [Gulp](https://github.com/gulpjs/gulp), [Guard](https://github.com/guard/guard), or whatever. This is simply a wrapper for whatever command is in your `tj.yml` file.
93
94
  ```bash
94
95
  tj watch # Aliases: dev, assets
95
96
  ```
@@ -101,13 +102,13 @@ tj vm # Aliases: vagrant, vvv
101
102
  ```
102
103
 
103
104
  ### Managing vendor dependencies:
104
- Use this to easily manage your dependencies with [Composer](https://github.com/composer/composer), or whatever other command you set in your `tj-config.yml`. This is a wrapper for whatever command is in your config file.
105
+ Use this to easily manage your dependencies with [Composer](https://github.com/composer/composer), or whatever other command you set in your `tj.yml`. This is a wrapper for whatever command is in your config file.
105
106
  ```bash
106
107
  tj vendor # Aliases: deps, dependencies
107
108
  ```
108
109
 
109
110
  ### Managing deployment and migration:
110
- Use this to easily manage your deployment and migration with [Capistrano](https://github.com/capistrano/capistrano) (or again, anything else set within your `tj-config.yml`). This is just a wrapper for your chosen command.
111
+ Use this to easily manage your deployment and migration with [Capistrano](https://github.com/capistrano/capistrano) (or again, anything else set within your `tj.yml`). This is just a wrapper for your chosen command.
111
112
  ```bash
112
113
  tj server # Aliases: deploy, remote
113
114
  ```
@@ -124,8 +125,8 @@ alias wpv="wp ssh --host=vagrant"
124
125
  ## Contributing
125
126
 
126
127
  1. First, create an [issue](https://github.com/ezekg/theme-juice-cli/issues) for your proposed feature. If it's a bug fix, go right to step 2.
127
- 2. [Fork the repository](https://github.com/ezekg/theme-juice-cli/fork).
128
- 3. Create a new feature branch. (`git checkout -b my-new-feature`)
129
- 4. Commit your changes. (`git commit -am `Add some feature``)
130
- 5. Push to the new branch. (`git push origin my-new-feature`)
131
- 6. Create a new Pull Request.
128
+ 1. [Fork the repository](https://github.com/ezekg/theme-juice-cli/fork).
129
+ 1. Create a new feature branch. (`git checkout -b my-new-feature`)
130
+ 1. Commit your changes. (`git commit -am 'add some feature'`)
131
+ 1. Push to the new branch. (`git push origin my-new-feature`)
132
+ 1. Create a new Pull Request.
data/bin/tj CHANGED
@@ -3,10 +3,20 @@
3
3
 
4
4
  require "thor"
5
5
 
6
+ Signal.trap "INT" do
7
+ ThemeJuice::UI.speak "Bye bye!", {
8
+ color: :yellow,
9
+ icon: :general,
10
+ newline: true
11
+ }
12
+
13
+ exit 130
14
+ end
15
+
6
16
  begin
7
17
  require_relative "../lib/theme-juice"
8
18
  rescue LoadError => err
9
- warn err
19
+ warn err
10
20
  exit 1
11
21
  end
12
22
 
data/lib/theme-juice.rb CHANGED
@@ -7,6 +7,7 @@ require "tempfile"
7
7
  require "rubygems"
8
8
  require "thor"
9
9
  require "yaml"
10
+ require "os"
10
11
 
11
12
  module ThemeJuice
12
13
  end
@@ -17,61 +17,6 @@ module ThemeJuice
17
17
  class_option :no_colors, type: :boolean, alias: "-nc", desc: "Disable colored output"
18
18
  class_option :vvv_path, type: :string, alias: "-fp", default: nil, desc: "Force path to VVV installation"
19
19
 
20
- ###
21
- # Non-Thor commands
22
- ###
23
- no_commands do
24
-
25
- ###
26
- # Disable unicode characters if flag is passed
27
- #
28
- # @return {Void}
29
- ###
30
- def use_unicode_chars?
31
- ::ThemeJuice::Utilities.no_unicode = true if options[:no_unicode]
32
- end
33
-
34
- ###
35
- # Disable unicode characters if flag is passed
36
- #
37
- # @return {Void}
38
- ###
39
- def use_terminal_colors?
40
- ::ThemeJuice::Utilities.no_colors = true if options[:no_colors]
41
- end
42
-
43
- ###
44
- # Set VVV path
45
- #
46
- # @return {Void}
47
- ###
48
- def force_vvv_path?
49
- if options[:vvv_path].nil?
50
- ::ThemeJuice::Utilities.vvv_path = File.expand_path("~/vagrant")
51
- else
52
- ::ThemeJuice::Utilities.vvv_path = options[:vvv_path]
53
- ::ThemeJuice::UI.notice "You're using a custom VVV path : (#{::ThemeJuice::Utilities.vvv_path})"
54
-
55
- unless ::ThemeJuice::UI.agree? "Is the path correct?"
56
- ::ThemeJuice::UI.error "Good call. Let's create a working dev environment, not a broken computer. Aborting mission."
57
- end
58
- end
59
-
60
- unless Dir.exist? ::ThemeJuice::Utilities.vvv_path
61
- ::ThemeJuice::UI.error "Cannot load VVV path (#{::ThemeJuice::Utilities.vvv_path}). Aborting mission before something bad happens."
62
- end
63
- end
64
-
65
- ###
66
- # Output welcome message
67
- #
68
- # @return {Void}
69
- ###
70
- def welcome_message
71
- ::ThemeJuice::UI.success "Welcome to Theme Juice!"
72
- end
73
- end
74
-
75
20
  ###
76
21
  # Print current version
77
22
  #
@@ -83,7 +28,7 @@ module ThemeJuice
83
28
 
84
29
  ::ThemeJuice::UI.speak ::ThemeJuice::VERSION, {
85
30
  color: :green,
86
- icon: :arrow_right
31
+ icon: :notice
87
32
  }
88
33
  end
89
34
 
@@ -110,43 +55,36 @@ module ThemeJuice
110
55
  def create(site = nil)
111
56
  self.use_terminal_colors?
112
57
  self.use_unicode_chars?
113
-
114
- self.welcome_message
115
-
116
58
  self.force_vvv_path?
117
59
 
118
60
  if options[:site]
119
61
  site = options[:site]
120
62
  end
121
63
 
64
+ # Make sure site name is valid
65
+ unless site.nil?
66
+ self.validate_site_name(site)
67
+ end
68
+
69
+ # No errors yet, say hi
70
+ self.welcome_message
71
+
122
72
  # Check if user passed all required options through flags
123
73
  if options.length >= 6 || options[:use_defaults]
124
- ::ThemeJuice::UI.speak "Well... looks like you just have everything all figured out, huh?", {
125
- color: [:black, :on_green],
126
- icon: :arrow_right,
127
- full_width: true
128
- }
74
+ ::ThemeJuice::UI.success "Well... looks like you just have everything all figured out, huh?"
129
75
  elsif site.nil?
130
76
  ::ThemeJuice::UI.speak "Just a few questions before we begin...", {
131
77
  color: [:black, :on_green],
132
- icon: :arrow_right,
133
- full_width: true
78
+ icon: :notice,
79
+ row: true
134
80
  }
135
81
  else
136
- ::ThemeJuice::UI.speak "Your site name shall be '#{site}'! Just a few more questions before we begin...", {
137
- color: [:black, :on_green],
138
- icon: :arrow_right,
139
- full_width: true
140
- }
82
+ ::ThemeJuice::UI.success "Your site name shall be '#{site}'! Just a few more questions before we begin..."
141
83
  end
142
84
 
143
85
  # Ask for the Site name if not passed directly
144
- site ||= ::ThemeJuice::UI.prompt "What's the site name? (only ascii characters are allowed)"
145
-
146
- # Make sure site name is valid
147
- if site.match /[^0-9A-Za-z.\-]/
148
- ::ThemeJuice::UI.error "Site name contains invalid non-ascii characters. This name is used for creating directories, so that's not gonna work. Aborting mission."
149
- end
86
+ site ||= ::ThemeJuice::UI.prompt "What's the site name? (letters, numbers and dashes only)"
87
+ self.validate_site_name(site)
150
88
 
151
89
  # Bare install?
152
90
  bare_setup ||= options[:bare]
@@ -186,21 +124,29 @@ module ThemeJuice
186
124
  else
187
125
  ::ThemeJuice::UI.speak "Which starter theme would you like to use? (partial name is acceptable)", {
188
126
  color: :blue,
189
- icon: :bullet_hollow
127
+ icon: :question
190
128
  }
191
129
 
192
130
  choose do |menu|
193
- menu.index = " #{::ThemeJuice::UI::BULLET_HOLLOW}"
194
- menu.prompt = set_color " #{::ThemeJuice::UI::ARROW_RIGHT} Choose one :".ljust(16), :blue
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
+ }
195
144
 
196
145
  themes.each do |theme, repo|
197
146
  menu.choice theme do
198
147
 
199
148
  if theme == "theme-juice/theme-juice-starter"
200
- ::ThemeJuice::UI.speak "Awesome choice!", {
201
- color: :green,
202
- icon: :arrow_up
203
- }
149
+ ::ThemeJuice::UI.success "Awesome choice!"
204
150
  end
205
151
 
206
152
  starter_theme = repo
@@ -347,8 +293,8 @@ module ThemeJuice
347
293
 
348
294
  ::ThemeJuice::UI.speak "Are you sure you want to delete '#{site}'? (y/N)", {
349
295
  color: [:white, :on_red],
350
- icon: :arrow_right,
351
- full_width: true
296
+ icon: :notice,
297
+ row: true
352
298
  }
353
299
 
354
300
  if ::ThemeJuice::UI.agree? "", { color: :red, simple: true }
@@ -380,6 +326,7 @@ module ThemeJuice
380
326
  def install
381
327
  self.use_terminal_colors?
382
328
  self.use_unicode_chars?
329
+ self.force_vvv_path?
383
330
 
384
331
  ::ThemeJuice::Executor::install options[:config]
385
332
  end
@@ -396,6 +343,7 @@ module ThemeJuice
396
343
  def watch(*commands)
397
344
  self.use_terminal_colors?
398
345
  self.use_unicode_chars?
346
+ self.force_vvv_path?
399
347
 
400
348
  ::ThemeJuice::Executor::subcommand "#{__method__}", commands.join(" ")
401
349
  end
@@ -412,6 +360,7 @@ module ThemeJuice
412
360
  def vendor(*commands)
413
361
  self.use_terminal_colors?
414
362
  self.use_unicode_chars?
363
+ self.force_vvv_path?
415
364
 
416
365
  ::ThemeJuice::Executor::subcommand "#{__method__}", commands.join(" ")
417
366
  end
@@ -449,5 +398,76 @@ module ThemeJuice
449
398
 
450
399
  system "cd #{::ThemeJuice::Utilities.vvv_path} && vagrant #{commands.join(" ")}"
451
400
  end
401
+
402
+ ###
403
+ # Non-Thor commands
404
+ ###
405
+ no_commands do
406
+
407
+ ###
408
+ # Disable unicode characters if flag is passed
409
+ #
410
+ # @return {Void}
411
+ ###
412
+ def use_unicode_chars?
413
+ ::ThemeJuice::Utilities.no_unicode = true if options[:no_unicode]
414
+ end
415
+
416
+ ###
417
+ # Disable unicode characters if flag is passed
418
+ #
419
+ # @return {Void}
420
+ ###
421
+ def use_terminal_colors?
422
+ ::ThemeJuice::Utilities.no_colors = true if options[:no_colors]
423
+ end
424
+
425
+ ###
426
+ # Set VVV path
427
+ #
428
+ # @return {Void}
429
+ ###
430
+ def force_vvv_path?
431
+ if options[:vvv_path].nil?
432
+ ::ThemeJuice::Utilities.vvv_path = File.expand_path("~/vagrant")
433
+ else
434
+ ::ThemeJuice::Utilities.vvv_path = options[:vvv_path]
435
+ ::ThemeJuice::UI.notice "You're using a custom VVV path : (#{::ThemeJuice::Utilities.vvv_path})"
436
+
437
+ unless ::ThemeJuice::UI.agree? "Is the path correct?"
438
+ ::ThemeJuice::UI.error "Good call. Let's create a working dev environment, not a broken computer. Aborting mission."
439
+ end
440
+ end
441
+
442
+ unless Dir.exist? ::ThemeJuice::Utilities.vvv_path
443
+ ::ThemeJuice::UI.error "Cannot load VVV path (#{::ThemeJuice::Utilities.vvv_path}). Aborting mission before something bad happens."
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."
457
+ end
458
+ 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
+ end
452
472
  end
453
473
  end
@@ -18,7 +18,7 @@ module ThemeJuice
18
18
 
19
19
  use_config config_path
20
20
 
21
- @config["install"].each do |command|
21
+ @config["commands"]["install"].each do |command|
22
22
  run ["cd #{config_path}", command], false
23
23
  end
24
24
  end
@@ -27,19 +27,19 @@ module ThemeJuice
27
27
  # Run subcommand from config
28
28
  #
29
29
  # @param {String} subcommand
30
- # @param {String} commands
30
+ # @param {String} command
31
31
  #
32
32
  # @return {Void}
33
33
  ###
34
- def subcommand(subcommand, commands)
34
+ def subcommand(subcommand, command)
35
35
  config_path = File.expand_path(Dir.pwd)
36
36
 
37
37
  use_config config_path
38
38
 
39
- if @config[subcommand]
40
- run ["#{@config[subcommand]} #{commands}"], false
39
+ if @config["commands"][subcommand]
40
+ run ["#{@config["commands"][subcommand]} #{command}"], false
41
41
  else
42
- ::ThemeJuice::UI.error "Unable to find '#{subcommand}' command in '#{config_path}/tj-config.yml'. Aborting mission."
42
+ ::ThemeJuice::UI.error "Unable to find '#{subcommand}' command in '#{config_path}/tj.yml'. Aborting mission."
43
43
  end
44
44
  end
45
45
 
@@ -113,14 +113,14 @@ module ThemeJuice
113
113
  ::ThemeJuice::UI.success "Setup complete!"
114
114
  ::ThemeJuice::UI.speak "In order to finish creating your site, you need to provision Vagrant. Do it now? (y/N)", {
115
115
  color: [:black, :on_blue],
116
- icon: :arrow_reload,
117
- full_width: true
116
+ icon: :restart,
117
+ row: true
118
118
  }
119
119
 
120
120
  if ::ThemeJuice::UI.agree? "", { simple: true }
121
121
  ::ThemeJuice::UI.speak "Restarting VVV...", {
122
122
  color: :yellow,
123
- icon: :bullet_solid
123
+ icon: :general
124
124
  }
125
125
 
126
126
  if restart_vagrant
@@ -140,6 +140,14 @@ module ThemeJuice
140
140
  "Database password: #{@opts[:db_pass]}"
141
141
  ]
142
142
  end
143
+
144
+ unless OS.windows?
145
+ ::ThemeJuice::UI.notice "Do you want to open up your new site 'http://#{@opts[:dev_url]}' now? (y/N)"
146
+
147
+ if ::ThemeJuice::UI.agree? "", { color: :yellow, simple: true }
148
+ run ["open http://#{@opts[:dev_url]}"]
149
+ end
150
+ end
143
151
  else
144
152
  ::ThemeJuice::UI.notice "Remember, Vagrant needs to be provisioned before you can use your new site. Exiting..."
145
153
  exit
@@ -190,7 +198,7 @@ module ThemeJuice
190
198
  if restart
191
199
  ::ThemeJuice::UI.speak "Restarting VVV...", {
192
200
  color: :yellow,
193
- icon: :bullet_solid
201
+ icon: :general
194
202
  }
195
203
 
196
204
  restart_vagrant
@@ -215,7 +223,7 @@ module ThemeJuice
215
223
  if sites.empty?
216
224
  ::ThemeJuice::UI.speak "Nothing to list. Why haven't you created a site yet?", {
217
225
  color: :yellow,
218
- icon: :bullet_solid
226
+ icon: :general
219
227
  }
220
228
  else
221
229
  ::ThemeJuice::UI.list "Your sites :", :green, sites
@@ -251,9 +259,9 @@ module ThemeJuice
251
259
  def use_config(config_path)
252
260
 
253
261
  if config_is_setup? config_path
254
- @config = YAML.load_file "#{config_path}/tj-config.yml"
262
+ @config = YAML.load_file(Dir["#{config_path}/*"].select { |f| File.basename(f) =~ /^(\.)?(tj.y(a)?ml)/ }.last)
255
263
  else
256
- ::ThemeJuice::UI.notice "Unable to find 'tj-config.yml' file in '#{config_path}'."
264
+ ::ThemeJuice::UI.notice "Unable to find 'tj.yml' file in '#{config_path}'."
257
265
 
258
266
  if ::ThemeJuice::UI.agree? "Would you like to create one?"
259
267
 
@@ -312,7 +320,7 @@ module ThemeJuice
312
320
  # @return {Bool}
313
321
  ###
314
322
  def config_is_setup?(config_path)
315
- File.exist? "#{config_path}/tj-config.yml"
323
+ !Dir["#{config_path}/*"].select { |f| File.basename(f) =~ /^(\.)?(tj.y(a)?ml)/ }.empty?
316
324
  end
317
325
 
318
326
  ###
@@ -400,7 +408,7 @@ module ThemeJuice
400
408
  def setup_vvv
401
409
  ::ThemeJuice::UI.speak "Installing VVV into '#{File.expand_path("#{::ThemeJuice::Utilities.vvv_path}")}'...", {
402
410
  color: :yellow,
403
- icon: :bullet_solid
411
+ icon: :general
404
412
  }
405
413
 
406
414
  run [
@@ -420,7 +428,7 @@ module ThemeJuice
420
428
  def setup_project_dir
421
429
  ::ThemeJuice::UI.speak "Creating project directory tree in '#{@opts[:site_location]}'...", {
422
430
  color: :yellow,
423
- icon: :bullet_solid
431
+ icon: :general
424
432
  }
425
433
 
426
434
  run ["mkdir -p #{@opts[:site_location]}"]
@@ -437,10 +445,10 @@ module ThemeJuice
437
445
  def setup_wildcard_subdomains
438
446
  ::ThemeJuice::UI.speak "Setting up wildcard subdomains...", {
439
447
  color: :yellow,
440
- icon: :bullet_solid
448
+ icon: :general
441
449
  }
442
450
 
443
- open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"), "a+" do |file|
451
+ open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"), "ab+" do |file|
444
452
  file.puts "\n"
445
453
  file.puts "###"
446
454
  file.puts "# Enable wildcard subdomains"
@@ -463,7 +471,7 @@ module ThemeJuice
463
471
  def setup_dev_site
464
472
  ::ThemeJuice::UI.speak "Setting up new development site at '#{@opts[:dev_location]}'...", {
465
473
  color: :yellow,
466
- icon: :bullet_solid
474
+ icon: :general
467
475
  }
468
476
 
469
477
  run [
@@ -473,7 +481,7 @@ module ThemeJuice
473
481
  end
474
482
 
475
483
  ###
476
- # Create tj-config.yml file for theme settings
484
+ # Create tj.yml file for theme settings
477
485
  #
478
486
  # @param {String} config_path
479
487
  #
@@ -485,21 +493,22 @@ module ThemeJuice
485
493
  vendor = ::ThemeJuice::UI.prompt "Vendor command to use", indent: 2, default: "composer"
486
494
  install = ::ThemeJuice::UI.prompt "Commands to run on theme install", indent: 2, default: "composer install"
487
495
 
488
- File.open "#{config_path}/tj-config.yml", "w" do |file|
489
- file.puts "watch: #{watch}"
490
- file.puts "server: #{server}"
491
- file.puts "vendor: #{vendor}"
492
- file.puts "install:"
496
+ File.open "#{config_path}/tj.yml", "wb" do |file|
497
+ file.puts "commands:"
498
+ file.puts "\s\swatch: #{watch}"
499
+ file.puts "\s\sserver: #{server}"
500
+ file.puts "\s\svendor: #{vendor}"
501
+ file.puts "\s\sinstall:"
493
502
  file.puts "\s\s\s\s- #{install}"
494
503
  end
495
504
 
496
505
  if config_is_setup? config_path
497
- ::ThemeJuice::UI.speak "Successfully added 'tj-config.yml' file.", {
506
+ ::ThemeJuice::UI.speak "Successfully added 'tj.yml' file.", {
498
507
  color: :green,
499
- icon: :bullet_solid
508
+ icon: :general
500
509
  }
501
510
  else
502
- ::ThemeJuice::UI.error "Could not create 'tj-config.yml' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
511
+ ::ThemeJuice::UI.error "Could not create 'tj.yml' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
503
512
  end
504
513
  end
505
514
 
@@ -509,14 +518,14 @@ module ThemeJuice
509
518
  # @return {Void}
510
519
  ###
511
520
  def setup_hosts
512
- File.open "#{@opts[:site_location]}/vvv-hosts", "w" do |file|
521
+ File.open "#{@opts[:site_location]}/vvv-hosts", "wb" do |file|
513
522
  file.puts @opts[:dev_url]
514
523
  end
515
524
 
516
525
  if hosts_is_setup?
517
526
  ::ThemeJuice::UI.speak "Successfully added 'vvv-hosts' file.", {
518
527
  color: :green,
519
- icon: :bullet_solid
528
+ icon: :general
520
529
  }
521
530
  else
522
531
  ::ThemeJuice::UI.error "Could not create 'vvv-hosts' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
@@ -529,7 +538,7 @@ module ThemeJuice
529
538
  # @return {Void}
530
539
  ###
531
540
  def setup_database
532
- File.open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/database/init-custom.sql"), "a+" do |file|
541
+ File.open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/database/init-custom.sql"), "ab+" do |file|
533
542
  file.puts "### Begin '#{@opts[:site_name]}'"
534
543
  file.puts "#"
535
544
  file.puts "# This block is automatically generated by ThemeJuice. Do not edit."
@@ -543,7 +552,7 @@ module ThemeJuice
543
552
  if database_is_setup?
544
553
  ::ThemeJuice::UI.speak "Successfully added database to 'init-custom.sql'.", {
545
554
  color: :green,
546
- icon: :bullet_solid
555
+ icon: :general
547
556
  }
548
557
  else
549
558
  ::ThemeJuice::UI.error "Could not add database info for '#{@opts[:site_name]}' to 'init-custom.sql'. Make sure you have write capabilities to '#{@opts[:site_location]}'."
@@ -556,7 +565,7 @@ module ThemeJuice
556
565
  # @return {Void}
557
566
  ###
558
567
  def setup_nginx
559
- File.open "#{@opts[:site_location]}/vvv-nginx.conf", "w" do |file|
568
+ File.open "#{@opts[:site_location]}/vvv-nginx.conf", "wb" do |file|
560
569
  file.puts "server {"
561
570
  file.puts "\tlisten 80;"
562
571
  file.puts "\tserver_name .#{@opts[:dev_url]};"
@@ -568,7 +577,7 @@ module ThemeJuice
568
577
  if nginx_is_setup?
569
578
  ::ThemeJuice::UI.speak "Successfully added 'vvv-nginx.conf' file.", {
570
579
  color: :green,
571
- icon: :bullet_solid
580
+ icon: :general
572
581
  }
573
582
  else
574
583
  ::ThemeJuice::UI.error "Could not create 'vvv-nginx.conf' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
@@ -581,7 +590,7 @@ module ThemeJuice
581
590
  # @return {Void}
582
591
  ###
583
592
  def setup_env
584
- File.open "#{@opts[:site_location]}/.env.development", "w" do |file|
593
+ File.open "#{@opts[:site_location]}/.env.development", "wb" do |file|
585
594
  file.puts "DB_NAME=#{@opts[:db_name]}"
586
595
  file.puts "DB_USER=#{@opts[:db_user]}"
587
596
  file.puts "DB_PASSWORD=#{@opts[:db_pass]}"
@@ -593,7 +602,7 @@ module ThemeJuice
593
602
  if env_is_setup?
594
603
  ::ThemeJuice::UI.speak "Successfully added '.env.development' file.", {
595
604
  color: :green,
596
- icon: :bullet_solid
605
+ icon: :general
597
606
  }
598
607
  else
599
608
  ::ThemeJuice::UI.error "Could not create '.env.development' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
@@ -610,7 +619,7 @@ module ThemeJuice
610
619
  def setup_wordpress
611
620
  ::ThemeJuice::UI.speak "Setting up WordPress...", {
612
621
  color: :yellow,
613
- icon: :bullet_solid
622
+ icon: :general
614
623
  }
615
624
 
616
625
  unless @opts[:bare_setup]
@@ -629,10 +638,10 @@ module ThemeJuice
629
638
  def install_theme_dependencies
630
639
  ::ThemeJuice::UI.speak "Installing theme dependencies...", {
631
640
  color: :yellow,
632
- icon: :bullet_solid
641
+ icon: :general
633
642
  }
634
643
 
635
- @config["install"].each do |command|
644
+ @config["commands"]["install"].each do |command|
636
645
  run ["cd #{@opts[:site_location]}", command], false
637
646
  end
638
647
  end
@@ -645,10 +654,10 @@ module ThemeJuice
645
654
  def setup_synced_folder
646
655
  ::ThemeJuice::UI.speak "Syncing host theme directory '#{@opts[:site_location]}' with VM theme directory '/srv/www/tj-#{@opts[:site_name]}'...", {
647
656
  color: :yellow,
648
- icon: :bullet_solid
657
+ icon: :general
649
658
  }
650
659
 
651
- open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"), "a+" do |file|
660
+ open File.expand_path("#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"), "ab+" do |file|
652
661
  file.puts "### Begin '#{@opts[:site_name]}'"
653
662
  file.puts "#"
654
663
  file.puts "# This block is automatically generated by ThemeJuice. Do not edit."
@@ -670,7 +679,7 @@ module ThemeJuice
670
679
  def setup_repo
671
680
  ::ThemeJuice::UI.speak "Setting up Git repository at '#{@opts[:repository]}'...", {
672
681
  color: :yellow,
673
- icon: :bullet_solid
682
+ icon: :general
674
683
  }
675
684
 
676
685
  if repo_is_setup?
@@ -693,7 +702,7 @@ module ThemeJuice
693
702
  # @return {Void}
694
703
  ###
695
704
  def setup_wpcli
696
- File.open "#{@opts[:site_location]}/wp-cli.local.yml", "a+" do |file|
705
+ File.open "#{@opts[:site_location]}/wp-cli.local.yml", "ab+" do |file|
697
706
  file.puts "require:"
698
707
  file.puts "\t- vendor/autoload.php"
699
708
  file.puts "ssh:"
@@ -707,7 +716,7 @@ module ThemeJuice
707
716
  if wpcli_is_setup?
708
717
  ::ThemeJuice::UI.speak "Successfully added ssh settings to 'wp-cli.local.yml' file.", {
709
718
  color: :green,
710
- icon: :bullet_solid
719
+ icon: :general
711
720
  }
712
721
  else
713
722
  ::ThemeJuice::UI.error "Could not create 'wp-cli.local.yml' file. Make sure you have write capabilities to '#{@opts[:site_location]}'."
@@ -728,8 +737,8 @@ module ThemeJuice
728
737
 
729
738
  if run ["rm -rf #{@opts[:dev_location]}"]
730
739
  ::ThemeJuice::UI.speak "VVV installation for '#{@opts[:site_name]}' successfully removed.", {
731
- color: :green,
732
- icon: :bullet_solid
740
+ color: :yellow,
741
+ icon: :general
733
742
  }
734
743
  else
735
744
  ::ThemeJuice::UI.error "Theme '#{@opts[:site_name]}' could not be removed. Make sure you have write capabilities to '#{@opts[:dev_location]}'."
@@ -745,7 +754,7 @@ module ThemeJuice
745
754
  if remove_traces_from_file "#{::ThemeJuice::Utilities.vvv_path}/database/init-custom.sql"
746
755
  ::ThemeJuice::UI.speak "Database for '#{@opts[:site_name]}' successfully removed.", {
747
756
  color: :yellow,
748
- icon: :bullet_solid
757
+ icon: :general
749
758
  }
750
759
  end
751
760
  end
@@ -759,7 +768,7 @@ module ThemeJuice
759
768
  if remove_traces_from_file "#{::ThemeJuice::Utilities.vvv_path}/Vagrantfile"
760
769
  ::ThemeJuice::UI.speak "Synced folders for '#{@opts[:site_name]}' successfully removed.", {
761
770
  color: :yellow,
762
- icon: :bullet_solid
771
+ icon: :general
763
772
  }
764
773
  end
765
774
  end
@@ -783,8 +792,7 @@ module ThemeJuice
783
792
  # Move temp file to actual file location
784
793
  FileUtils.mv output_file, File.expand_path(input_file)
785
794
  rescue LoadError => err
786
- say "#{err}".ljust(terminal_width), [:white, :on_red]
787
- exit 1
795
+ ::ThemeJuice::UI.error "#{err}"
788
796
  ensure
789
797
  # Make sure that the tempfile closes and is cleaned up, regardless of errors
790
798
  output_file.close
@@ -3,17 +3,14 @@
3
3
  module ThemeJuice
4
4
  module UI
5
5
 
6
- QUESTION_MARK = "?"
7
- BULLET_HOLLOW = "\u25CB"
8
- BULLET_SOLID = "\u2022"
9
- ARROW_UP = "\u2191"
10
- ARROW_RIGHT = "\u2192"
11
- ARROW_DOWN = "\u2193"
12
- ARROW_LEFT = "\u2190"
13
- ARROW_RELOAD = "\u21AA"
14
- BLOCK_LARGE = "\u2588"
15
- BLOCK_MED = "\u258D"
16
- BLOCK_SMALL = "\u258F"
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"
17
14
 
18
15
  class << self
19
16
  include ::Thor::Actions
@@ -31,7 +28,7 @@ module ThemeJuice
31
28
  format_message! message, opts
32
29
 
33
30
  # Check if we're suppressing terminal output
34
- if opts.key? :suppress
31
+ if opts.key? :quiet
35
32
  message
36
33
  else
37
34
  say message
@@ -48,7 +45,8 @@ module ThemeJuice
48
45
  def success(message)
49
46
  self.speak message, {
50
47
  color: [:black, :on_green, :bold],
51
- full_width: true
48
+ icon: :success,
49
+ row: true
52
50
  }
53
51
  end
54
52
 
@@ -62,8 +60,8 @@ module ThemeJuice
62
60
  def notice(message)
63
61
  self.speak message, {
64
62
  color: [:black, :on_yellow],
65
- icon: :arrow_right,
66
- full_width: true
63
+ icon: :notice,
64
+ row: true
67
65
  }
68
66
  end
69
67
 
@@ -78,8 +76,8 @@ module ThemeJuice
78
76
  def error(message)
79
77
  self.speak message, {
80
78
  color: [:white, :on_red],
81
- icon: :arrow_up,
82
- full_width: true
79
+ icon: :error,
80
+ row: true
83
81
  }
84
82
 
85
83
  yield if block_given?
@@ -99,14 +97,14 @@ module ThemeJuice
99
97
  def list(header, color, list)
100
98
  self.speak header, {
101
99
  color: [:black, :"on_#{color}"],
102
- icon: :arrow_right,
103
- full_width: true
100
+ icon: :notice,
101
+ row: true
104
102
  }
105
103
 
106
104
  list.each do |item|
107
105
  self.speak item, {
108
106
  color: :"#{color}",
109
- icon: :bullet_solid
107
+ icon: :general
110
108
  }
111
109
  end
112
110
  end
@@ -122,7 +120,7 @@ module ThemeJuice
122
120
  def prompt(question, *opts)
123
121
  format_message! question, {
124
122
  color: :blue,
125
- icon: :bullet_hollow
123
+ icon: :question
126
124
  }
127
125
 
128
126
  opts.each do |opt|
@@ -159,7 +157,7 @@ module ThemeJuice
159
157
 
160
158
  format_message! question, {
161
159
  color: opts[:color],
162
- icon: :bullet_hollow
160
+ icon: :question
163
161
  }
164
162
 
165
163
  if opts.key? :simple
@@ -181,28 +179,38 @@ module ThemeJuice
181
179
  ###
182
180
  def format_message!(message, opts = {})
183
181
 
184
- # Check if we're using an icon
185
182
  unless ::ThemeJuice::Utilities.no_unicode
186
183
  if opts.key? :icon
187
- set!(message) { |msg| " #{self.const_get(opts[:icon].to_s.upcase)} " << msg if opts[:icon].is_a? Symbol }
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
188
189
  else
189
190
  set!(message) { |msg| " " << msg }
190
191
  end
191
192
  end
192
193
 
193
- # Check if message should take up entire width
194
- # of the terminal window
195
- if opts.key? :full_width
194
+ if opts.key? :indent
195
+ set!(message) { |str| (" " * opts[:indent]) << str }
196
+ end
197
+
198
+ if opts.key? :row
196
199
  set!(message) { |msg| msg.ljust(terminal_width) }
200
+ elsif opts.key? :width
201
+ set!(message) { |msg| msg.ljust(opts[:width]) }
197
202
  end
198
203
 
199
- # Check if we're using colors
200
204
  unless ::ThemeJuice::Utilities.no_colors
201
205
  if opts.key? :color
202
206
  set!(message) { |msg| set_color(msg, *opts[:color]) }
203
207
  end
204
208
  end
205
209
 
210
+ if opts.key? :newline
211
+ set!(message) { |msg| "\n" << msg }
212
+ end
213
+
206
214
  message
207
215
  end
208
216
 
@@ -40,14 +40,14 @@ module ThemeJuice
40
40
  if ::Gem::Version.new(local_version) < ::Gem::Version.new(remote_version)
41
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
42
  color: [:black, :on_yellow],
43
- icon: :arrow_right,
44
- full_width: true
43
+ icon: :notice,
44
+ row: true
45
45
  }
46
46
  else
47
47
  ::ThemeJuice::UI.speak "Your version of Theme Juice (#{local_version}) up to date.", {
48
48
  color: [:black, :on_green],
49
- icon: :arrow_right,
50
- full_width: true
49
+ icon: :notice,
50
+ row: true
51
51
  }
52
52
  end
53
53
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module ThemeJuice
4
- VERSION = "0.4.4"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: theme-juice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.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-07 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: thor
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: highline
42
+ name: os
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - '>='