vagrant-solidus 0.1.0 → 0.2.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWZhZTFkNWJmNGMxY2ZmZGIxNmJlYTY1MzljMDY0NjY2MWU1N2M0NA==
4
+ ZTBjZWQ1OTAxNDc3NmI5ZDA0MTZiZjBkYTc2ZmU0Nzk3YzRkOWEwNg==
5
5
  data.tar.gz: !binary |-
6
- MWM5Y2Y4NGY3ZDRkZjg5NGRiNjA4NTg3OWFmNzlkMjU5YmJiOGE3Yg==
6
+ NjQ4OWVjMzFiMDFlNmNkMzRlODVkZGM1MmQwZDAwMDU4ZjRhMTI3Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTczZjRlYmEzMDMwNjEyMjFlNjhiMTU0MTQ2ZTkwNzI5NDg4NTRhMjk5NjFi
10
- MzMyZWNhNTc3ZDM3N2ZhZmNmMTgxMmViNWRlZjNiN2UxODUzNzkxY2M5NDMz
11
- NmY2ZDQwYjRlZjhmYWYwMjk2NDVkNjNmN2UwMGZmYjE1NTg1MGE=
9
+ MmQ3ZTIxNjhiYzc2ZGJmZjU1OTFiN2EyMTAyZDBmM2YzZWVmYTVmZjhkMmIz
10
+ ODI4ZTk0NDA1NTlhZGI1ODU1NGU5ZDRlMGI3NjFmNGU0MjI4Njg4M2IzYmQ5
11
+ NmJiZTYxYWFmZWZjZWY2ZThjOTJmZTM3Yjc2NWZjOGFlODFmMWM=
12
12
  data.tar.gz: !binary |-
13
- ZmY2YzhiOTI0NjE0MDM0Y2I5MmNiOTMwMzhmY2M1MzQ0ZGU5NTNmZGVkYzll
14
- ZTgyYzE1NzlkYmMxNmI5OTQ1ZWE2MGMxY2QwZjE0OWI2OWQ0OTVkMDYxNWQ2
15
- MTc2MDY4ZjNlNTJlODk2Nzg2NmU2YzAwOWY3YmY3M2JmZjQ4YTk=
13
+ NzI1YjY5YzQ0NWRhMGFjYTJhOWZjOTkwZWQwNTdhODc3NTgxMTIxOTM2Yzhk
14
+ MDkxZmZkZjY4NGNiNzZiYzFmNGEyMGFhZjJmNjIxNjk0YTMyMTkzNzljNGU5
15
+ MDVmNjlhOGQ1MjJlZWJiNDYzN2U0NTA5ZmRmMWVjNDU2ZDU5NjQ=
data/README.md CHANGED
@@ -183,6 +183,16 @@ $ vagrant destroy
183
183
  $ vagrant up
184
184
  ```
185
185
 
186
+ ### Adding or changing the forwarded ports
187
+
188
+ When a site is started, it requires 3 forwarded ports for the Solidus server, the log server and LiveReload. By default, 45 ports are forwarded when the box is started. Once a site has been started, its used ports will be reserved for later use. If you run out of ports, or if a default port is already used by another application on your machine, you can manage them directly in the Vagrantfile, with the following config variables, which should be arrays of available ports. Note that the box should be reloaded if those values are changed.
189
+
190
+ * `config.solidus.site_ports`
191
+ * `config.solidus.livereload_ports`
192
+ * `config.solidus.log_server_ports`
193
+
194
+ It's also possible to remove ports reserved by older unused sites. The reserved ports are listed in this file: `.vagrant-solidus/data/sites.json`.
195
+
186
196
  [virtualbox]: https://www.virtualbox.org
187
197
  [virtualbox-install]: https://www.virtualbox.org/wiki/Downloads
188
198
  [vagrant]: http://www.vagrantup.com
@@ -7,6 +7,11 @@ module VagrantPlugins
7
7
  name 'Solidus'
8
8
  description 'This plugin provides a provisioner and a `site` command that allows Solidus sites to be managed by Vagrant.'
9
9
 
10
+ config(:solidus) do
11
+ require_relative 'vagrant-solidus/config'
12
+ Config
13
+ end
14
+
10
15
  provisioner(:solidus) do
11
16
  require_relative 'vagrant-solidus/provisioner'
12
17
  Provisioner
@@ -0,0 +1,13 @@
1
+ module VagrantPlugins
2
+ module Solidus
3
+ class Config < Vagrant.plugin('2', :config)
4
+ attr_accessor :site_ports, :livereload_ports, :log_server_ports
5
+
6
+ def initialize
7
+ @site_ports = (8081..8095).to_a
8
+ @livereload_ports = (35730..35744).to_a
9
+ @log_server_ports = (35745..35759).to_a
10
+ end
11
+ end
12
+ end
13
+ end
@@ -4,15 +4,8 @@ module VagrantPlugins
4
4
  include VagrantPlugins::Solidus::SiteHelpers
5
5
 
6
6
  def configure(root_config)
7
- # TODO: Make this configurable
8
- 15.times do |i|
9
- port = VagrantPlugins::Solidus::SiteHelpers::BASE_PORT + i
7
+ (root_config.solidus.site_ports + root_config.solidus.livereload_ports + root_config.solidus.log_server_ports).each do |port|
10
8
  root_config.vm.network :forwarded_port, guest: port, host: port
11
-
12
- 2.times do |j|
13
- port = VagrantPlugins::Solidus::SiteHelpers::BASE_UTILS_PORT + (2 * i) + j
14
- root_config.vm.network :forwarded_port, guest: port, host: port
15
- end
16
9
  end
17
10
  end
18
11
 
@@ -16,11 +16,13 @@ module VagrantPlugins
16
16
  with_running_vm do
17
17
  stop_site
18
18
 
19
+ @env.ui.info("Installing site...")
19
20
  unless @fast
20
- @env.ui.info("Installing site...")
21
- fail("Site could not be installed") unless install_site
22
- install_pow_site if pow_installed?
21
+ fail("Site could not be installed") unless install_site_dependencies && install_site_node_packages
23
22
  end
23
+ fail("Out of available ports, add more to the Vagrantfile or remove unused sites from #{SITES_CONFIGS_FILE_HOST_PATH}") unless set_site_ports
24
+ fail("Site could not be installed") unless install_site_service
25
+ install_pow_site if pow_installed?
24
26
 
25
27
  @env.ui.info("Starting dev server...")
26
28
  fail("Site could not be started") unless start_site_service
@@ -40,12 +42,6 @@ module VagrantPlugins
40
42
  # Success, exit status 0
41
43
  0
42
44
  end
43
-
44
- private
45
-
46
- def install_site
47
- install_site_dependencies && install_site_node_packages && install_site_service
48
- end
49
45
  end
50
46
  end
51
47
  end
@@ -75,18 +75,19 @@ module VagrantPlugins
75
75
  @site_livereload_port = config['livereload-port']
76
76
  @site_log_server_port = config['log-server-port']
77
77
  end
78
+ end
78
79
 
79
- @site_port ||= find_next_available_port(BASE_PORT)
80
- @site_livereload_port ||= find_next_available_port(BASE_UTILS_PORT)
81
- @site_log_server_port ||= find_next_available_port(BASE_UTILS_PORT)
80
+ def set_site_ports
81
+ all = @machine.config.solidus
82
+ used = sites.values
83
+ return unless @site_port = find_port(@site_port, all.site_ports, used.map {|c| c['port']})
84
+ return unless @site_livereload_port = find_port(@site_livereload_port, all.livereload_ports, used.map {|c| c['livereload-port']})
85
+ return unless @site_log_server_port = find_port(@site_log_server_port, all.log_server_ports, used.map {|c| c['log-server-port']})
86
+ true
82
87
  end
83
88
 
84
- def find_next_available_port(port)
85
- ports = sites.values.map(&:values).flatten + [@site_port, @site_livereload_port, @site_log_server_port].compact
86
- loop do
87
- return port unless ports.index(port)
88
- port += 1
89
- end
89
+ def find_port(current_port, all_ports, used_ports)
90
+ all_ports.include?(current_port) ? current_port : (all_ports - used_ports).first
90
91
  end
91
92
 
92
93
  def validate_site
@@ -260,7 +261,7 @@ module VagrantPlugins
260
261
 
261
262
  def site_start_command_line_options(opts)
262
263
  site_name_command_line_option(opts)
263
- opts.on("-f", "--fast", "Fast mode. Don't install the site first.") do
264
+ opts.on("-f", "--fast", "Fast mode. Don't install the site dependencies first.") do
264
265
  @fast = true
265
266
  end
266
267
  opts.on("-d", "--deaf", "Don't automatically launch the `watch` command in background (file events will be much slower).") do
@@ -27,4 +27,13 @@ Vagrant.configure('2') do |config|
27
27
  # The vagrant-solidus plugin handles the rest, see:
28
28
  # https://github.com/solidusjs/vagrant-solidus
29
29
  config.vm.provision :solidus
30
+
31
+ # List of available ports for the Solidus sites, reload the box if you change this
32
+ #config.solidus.site_ports = [...]
33
+
34
+ # List of available ports for LiveReload, reload the box if you change this
35
+ #config.solidus.livereload_ports = [...]
36
+
37
+ # List of available ports for the Solidus log servers, reload the box if you change this
38
+ #config.solidus.log_server_ports = [...]
30
39
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Solidus
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-solidus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joannic Laborde
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,7 @@ files:
52
52
  - Rakefile
53
53
  - lib/vagrant-solidus.rb
54
54
  - lib/vagrant-solidus/command.rb
55
+ - lib/vagrant-solidus/config.rb
55
56
  - lib/vagrant-solidus/provisioner.rb
56
57
  - lib/vagrant-solidus/provisioner/.bashrc
57
58
  - lib/vagrant-solidus/provisioner/.gemrc