vagrant-solidus 0.0.1

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODIzMzI0NmQ0YTgyNWUzNjdhYjY5MDRjNmM4NjY4M2Y0ODM1NTFkYw==
5
+ data.tar.gz: !binary |-
6
+ MDU5NzMzYWMyNzFmYmQxN2U4NTRlMGIxY2IyNWZlZDlhMjM2NjYzOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDg0NjJlMDFiMzdlYTMyM2Y1Yjg3Mzk3NDUwYmE0OGIzZTc0YTFhNjlhN2Vi
10
+ ZTIwZTBiZTg3NGU5YTliYjk2OTQ0MDkxMzE0N2Y5Yjk2NWQ3NjcwODg1ZDI4
11
+ YmEzMzY5NzlmY2VmZWU4MDhhNzY5YmJjNjczMmY5NTE5NWY3ZmE=
12
+ data.tar.gz: !binary |-
13
+ OTVlY2IxMTczYTg4NzUyNzg5YTdmZDYyMzI0OTkwNzRjZTZiZTNjMTJhMDgw
14
+ N2IwNTAyM2JjMDIyZjkwZWM5MDc1ZjliNDZkNmY3ZDgwYjkyZWIwZTQzZTBm
15
+ ZThlOGYyMzM5YmIyNDg0NGIwN2M1MWUxOWQ2NWFhNWI4ZGFjNmU=
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git"
5
+ end
6
+
7
+ group :plugins do
8
+ gem "vagrant-solidus", path: "."
9
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sparkart Group, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,201 @@
1
+ # Vagrant plugin for Solidus sites development
2
+
3
+ This is a [Vagrant][vagrant] plugin that adds a [Solidus][solidus] provisioner and command to manage Solidus sites. It enables you to easily create, run and update Solidus sites in the virtual machine without having to setup or log into the machine itself, through the vagrant command line interface.
4
+
5
+ ## Getting Started
6
+
7
+ ### [Install VirtualBox][virtualbox-install]
8
+
9
+ [VirtualBox][virtualbox] is a free cross-platform virtualization app that makes it easy to simultaneously run multiple operating systems on your machine. In our usage it is merely a [provider][vagrant-provider] for Vagrant.
10
+
11
+ ### [Install Vagrant][vagrant-install]
12
+
13
+ [Vagrant][vagrant] layers provisioning, file-based configuration, and a command-line interface on top of VirtualBox. This provides disposable, consistent environments for running development servers. [Synced Folders][vagrant-synced-folders] and [Networking][vagrant-networking] features make the development experience the same as if running in your own environment: your own tools and whatever ports you’d like for access via your browser and other clients.
14
+
15
+ ### [Install Pow][pow] (Mac only)
16
+
17
+ Among other things, Pow enables port proxying on your Mac, to let you route all web traffic on a particular hostname to another port on your computer. So you'll be able to access your site on `http://sitename.dev` instead of `http://localhost:8081` or `http://lvh.me:8081`. No need to remember weird urls with changing port numbers! Install [Anvil][anvil] to get a handy menubar extra showing all of your Pow-powered hosts. This plugin will automatically configure Pow for your sites, if it is installed.
18
+
19
+ ### Create the Vagrant environment
20
+
21
+ Using this plugin, you can easily create a `Vagrantfile` ready for Solidus:
22
+
23
+ ```
24
+ $ vagrant plugin install vagrant-solidus
25
+ $ mkdir solidus
26
+ $ cd solidus
27
+ $ vagrant solidus-box init
28
+ ```
29
+
30
+ ### Up!
31
+
32
+ You are now ready to start the virtual machine:
33
+
34
+ ```
35
+ $ vagrant up
36
+ ```
37
+
38
+ This will boot the VM, and automatically install and configure everything that is required to run Solidus sites, a process called [Provisioning][vagrant-provisioning]: `Vagrantfile` defines a pre-built 64-bit Ubuntu 12.04.3 LTS (Precise) “box” provided by the Vagrant team. This file also defines basic configuration such as port mapping and synced folder locations, it can be updated at any time. New boxes are only downloaded to your machine the first time you provision a new VM however. Once the operating system is booted, this plugin will perform additional provisioning. You can redo the provisioning process at any time by running `vagrant provision`.
39
+
40
+ At this point, you are ready to work on your Solidus site!
41
+
42
+ ## Development Process
43
+
44
+ A number of ports are automatically opened and forwarded to the virtual machine: `8081 to 8095` for the Solidus sites, and `35730 to 35744` for [LiveReload][livereload]. Whenever a site is started, two ports will be used for that site, so you can load them on your local browser.
45
+
46
+ A new `site` Vagrant command has been added to help create and manage your Solidus sites. To see all available sub-commands:
47
+
48
+ ```
49
+ $ vagrant site
50
+ ```
51
+
52
+ For help on a specific command, use the `-h` argument. For example:
53
+
54
+ ```
55
+ $ vagrant site create -h
56
+ ```
57
+
58
+ ### Creating a site
59
+
60
+ The easiest way to create a new Solidus site is to use the handy Solidus site template. And the easiest way to do that is to use the following command:
61
+
62
+ ```
63
+ $ vagrant site create my-site
64
+ ```
65
+
66
+ This will create a new sub-directory called `my-site`, initialized with a new site based on the latest [Solidus site template][solidus-site-template]. Another option is to create the directory and site yourself, from the ground up.
67
+
68
+ ### Adding an existing site
69
+
70
+ To work on an existing Solidus site, copy it or clone it to a sub-directory of this repo. The name of the site will be the name of that sub-directory.
71
+
72
+ ### Starting a site
73
+
74
+ Once the site has been added, start the Solidus server (which will run within the virtual machine) with this command:
75
+
76
+ ```
77
+ $ cd my-site
78
+ $ vagrant site start
79
+ ```
80
+
81
+ You can now access the website on http://my-site.dev if you installed Pow. If not, look at the `start` command's output, the site's urls will have been displayed. Note that many sites can run at the same time.
82
+
83
+ Hint: Site files are actually stored on your machine, not in the virtual machine. You can edit them as usual, and the server will load them from your machine. Stopping or deleting the virtual machine will not affect your files.
84
+
85
+ ### Stopping a site
86
+
87
+ ```
88
+ $ vagrant site stop
89
+ ```
90
+
91
+ ### Restarting a site
92
+
93
+ ```
94
+ $ vagrant site restart
95
+ ```
96
+
97
+ ### Updating a site
98
+
99
+ As the Solidus and Solidus site templates projects progress, you'll probably want to update your sites to use the latest versions of those repos. This is done with the `update` command:
100
+
101
+ ```
102
+ $ vagrant site update
103
+ ```
104
+
105
+ Note that this command will modify some of your site files. Make sure to review all changes applied to your files before committing those changes.
106
+
107
+ ### Running command line commands
108
+
109
+ If you need to run custom commands for your site, for example [Grunt tasks][gruntjs], you will need to run them in the VM itself.
110
+
111
+ Hard way (ssh into the VM and run your commands):
112
+
113
+ ```
114
+ $ vagrant ssh
115
+ $ cd my-site
116
+ $ grunt my-task --option=something
117
+ $ exit
118
+ ```
119
+
120
+ Easy way (use the `run` command):
121
+
122
+ ```
123
+ $ vagrant site run grunt my-site --option=something
124
+ ```
125
+
126
+ ### Are my sites running?
127
+
128
+ ```
129
+ $ vagrant site status
130
+ ```
131
+
132
+ ### Debugging a site
133
+
134
+ Run this command to follow the site's log:
135
+
136
+ ```
137
+ $ vagrant site log
138
+ ```
139
+
140
+ ### Deleting a site
141
+
142
+ Warning: you will obviously lose your local site files!
143
+
144
+ ```
145
+ $ vagrant site stop
146
+ $ cd ..
147
+ $ rm -rf my-site
148
+ ```
149
+
150
+ ### Managing the VM
151
+
152
+ To stop the virtual machine, run:
153
+
154
+ ```
155
+ $ vagrant halt
156
+ ```
157
+
158
+ [See the CLI docs][vagrant-cli] for other commands.
159
+
160
+ ### Updating
161
+
162
+ To use the latest version of vagrant-solidus, simply update the plugin and re-initialize your `Vagrantfile`:
163
+
164
+ ```
165
+ $ vagrant halt
166
+ $ vagrant plugin update vagrant-solidus
167
+ $ vagrant solidus-box init
168
+ $ vagrant up
169
+ ```
170
+
171
+ ## Troubleshooting ##
172
+
173
+ ### Windows: 'ssh' executable not found
174
+
175
+ Vagrant needs an `ssh.exe` executable to log into the virtual machine when running `vagrant ssh`. Windows doesn't provide such an executable by default, but Git does. The easiest way to fix this problem is by adding Git's `bin` path to the system's `PATH` environment variable. In the Start menu, search for "system environment variables". Then locate the `PATH` system environment variable, click `Edit` and add Git's `bin` path (probably located in `C:\Program Files (x86)\Git\bin`). Note that you will need to restart your Command Prompt for the changes to take effect. Also, note that Git's own executables like `find.exe` will be now be used instead of Windows' default executables.
176
+
177
+ ### Resetting the VM
178
+
179
+ If your virtual machine is in a weird state, the simplest solution is sometimes to rebuild it. All you need to do is destroy the VM and rebuild. This process will not delete your sites files, since they are hosted on your machine, not in the virtual machine.
180
+
181
+ ```
182
+ $ vagrant destroy
183
+ $ vagrant up
184
+ ```
185
+
186
+ [virtualbox]: https://www.virtualbox.org
187
+ [virtualbox-install]: https://www.virtualbox.org/wiki/Downloads
188
+ [vagrant]: http://www.vagrantup.com
189
+ [vagrantfile]: https://docs.vagrantup.com/v2/vagrantfile/
190
+ [vagrant-provider]: http://docs.vagrantup.com/v2/providers
191
+ [vagrant-install]: http://www.vagrantup.com/downloads.html
192
+ [vagrant-synced-folders]: http://docs.vagrantup.com/v2/synced-folders/index.html
193
+ [vagrant-networking]: http://docs.vagrantup.com/v2/networking/index.html
194
+ [vagrant-provisioning]: http://docs.vagrantup.com/v2/provisioning/index.html
195
+ [solidus]: https://github.com/solidusjs/solidus
196
+ [pow]: http://pow.cx
197
+ [anvil]: http://anvilformac.com
198
+ [livereload]: http://livereload.com
199
+ [solidus-site-template]: https://github.com/solidusjs/solidus-site-template
200
+ [gruntjs]: http://gruntjs.com
201
+ [vagrant-cli]: http://docs.vagrantup.com/v2/cli
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ require_relative 'vagrant-solidus/site_helpers'
2
+ require_relative 'vagrant-solidus/version'
3
+
4
+ module VagrantPlugins
5
+ module Solidus
6
+ class Plugin < Vagrant.plugin('2')
7
+ name 'Solidus'
8
+ description 'This plugin provides a provisioner and a `site` command that allows Solidus sites to be managed by Vagrant.'
9
+
10
+ provisioner(:solidus) do
11
+ require_relative 'vagrant-solidus/provisioner'
12
+ Provisioner
13
+ end
14
+
15
+ command(:site) do
16
+ require_relative 'vagrant-solidus/site/command'
17
+ Site::Command
18
+ end
19
+
20
+ command('solidus-box') do
21
+ require_relative 'vagrant-solidus/solidus-box/command'
22
+ SolidusBox::Command
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,70 @@
1
+ module VagrantPlugins
2
+ module Solidus
3
+ class Command < Vagrant.plugin('2', :command)
4
+ def self.synopsis
5
+ 'command description'
6
+ end
7
+
8
+ def command
9
+ 'the-command'
10
+ end
11
+
12
+ def subcommands
13
+ %w[the subcommands]
14
+ end
15
+
16
+ def initialize(argv, env)
17
+ super
18
+
19
+ @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
20
+
21
+ @subcommands = Vagrant::Registry.new
22
+ subcommands.each do |subcommand|
23
+ @subcommands.register(subcommand.to_sym) do
24
+ require_relative "#{command}/#{subcommand}"
25
+ eval((self.class.to_s.split('::')[0...-1] + [subcommand.capitalize]).join('::'))
26
+ end
27
+ end
28
+ end
29
+
30
+ def execute
31
+ if @main_args.include?("-h") || @main_args.include?("--help")
32
+ # Print the help for all the site commands.
33
+ return help
34
+ end
35
+
36
+ # If we reached this far then we must have a subcommand. If not,
37
+ # then we also just print the help and exit.
38
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
39
+ return help if !command_class || !@sub_command
40
+ @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
41
+
42
+ # Initialize and execute the command class
43
+ command_class.new(@sub_args, @env).execute
44
+ end
45
+
46
+ # Prints the help out for this command
47
+ def help
48
+ opts = OptionParser.new do |opts|
49
+ opts.banner = "Usage: vagrant #{command} SUBCOMMAND [OPTIONS]"
50
+ opts.separator ""
51
+ opts.separator "Available subcommands:"
52
+
53
+ # Add the available subcommands as separators in order to print them
54
+ # out as well.
55
+ keys = []
56
+ @subcommands.each { |key, value| keys << key.to_s }
57
+
58
+ keys.sort.each do |key|
59
+ opts.separator " #{key}"
60
+ end
61
+
62
+ opts.separator ""
63
+ opts.separator "For help on any individual subcommand run `vagrant #{command} SUBCOMMAND -h`"
64
+ end
65
+
66
+ @env.ui.info(opts.help, :prefix => false)
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,87 @@
1
+ module VagrantPlugins
2
+ module Solidus
3
+ class Provisioner < Vagrant.plugin('2', :provisioner)
4
+ include VagrantPlugins::Solidus::SiteHelpers
5
+
6
+ def configure(root_config)
7
+ # TODO: Make this configurable
8
+ 15.times do |i|
9
+ port = VagrantPlugins::Solidus::SiteHelpers::BASE_PORT + i
10
+ root_config.vm.network :forwarded_port, guest: port, host: port
11
+
12
+ port = VagrantPlugins::Solidus::SiteHelpers::BASE_LIVERELOAD_PORT + i
13
+ root_config.vm.network :forwarded_port, guest: port, host: port
14
+ end
15
+ end
16
+
17
+ def provision
18
+ # ***********************************************************************
19
+ # !! IMPORTANT !! Update SiteHelpers::PROVISION_ID when this method is
20
+ # changed, to force a re-provisioning.
21
+ # ***********************************************************************
22
+
23
+ @env = @machine.env
24
+
25
+ @env.ui.info('Retrieving new lists of packages')
26
+ execute('apt-get update', sudo: true)
27
+
28
+ @env.ui.info('Installing curl')
29
+ execute('apt-get -y install curl', sudo: true)
30
+
31
+ @env.ui.info('Installing vim')
32
+ execute('apt-get -y install vim', sudo: true)
33
+
34
+ @env.ui.info('Installing git')
35
+ execute('apt-get -y install git', sudo: true)
36
+
37
+ @env.ui.info('Installing dos2unix')
38
+ execute('apt-get -y install dos2unix', sudo: true)
39
+
40
+ @env.ui.info('Installing nvm, node.js and npm')
41
+ execute('curl -s https://raw.githubusercontent.com/creationix/nvm/v0.5.1/install.sh | sh')
42
+ execute('source ~/.nvm/nvm.sh')
43
+ execute('nvm install 0.10.22')
44
+ execute('nvm use 0.10.22')
45
+ execute('nvm alias default 0.10.22')
46
+
47
+ @env.ui.info('Installing grunt.js')
48
+ execute('npm install grunt-cli@"~0.1.13" -g')
49
+ execute('npm install grunt-init@"~0.3.1" -g')
50
+
51
+ @env.ui.info('Configuring rubygems')
52
+ @machine.communicate.upload(File.expand_path('provisioner/.gemrc', File.dirname(__FILE__)), '/home/vagrant/.gemrc')
53
+ execute('dos2unix -o ~/.gemrc')
54
+
55
+ @env.ui.info('Installing rvm and ruby')
56
+ execute('curl -sSL https://get.rvm.io | bash -s stable --ruby=1.9.3-p545')
57
+ execute('source ~/.rvm/scripts/rvm')
58
+ execute('rvm rvmrc warning ignore allGemfiles')
59
+ execute('rvm use --default ruby-1.9.3-p545')
60
+
61
+ @env.ui.info('Configuring bash')
62
+ @machine.communicate.upload(File.expand_path('provisioner/.bashrc', File.dirname(__FILE__)), '/home/vagrant/.bashrc-vagrant-solidus')
63
+ execute('dos2unix -o ~/.bashrc-vagrant-solidus')
64
+ unless guest_exec(nil, 'grep "^\. ~/.bashrc-vagrant-solidus" ~/.bashrc')
65
+ execute('echo ". ~/.bashrc-vagrant-solidus" >> ~/.bashrc')
66
+ execute('. ~/.bashrc-vagrant-solidus')
67
+ end
68
+
69
+ execute(provisioned!)
70
+
71
+ # ***********************************************************************
72
+ # !! IMPORTANT !! Update SiteHelpers::PROVISION_ID when this method is
73
+ # changed, to force a re-provisioning.
74
+ # ***********************************************************************
75
+ end
76
+
77
+ private
78
+
79
+ def execute(*args)
80
+ unless guest_exec(:log_on_error, *args)
81
+ @env.ui.error('Virtual machine could not be provisioned')
82
+ abort
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end