drupal-vm-sites 0.0.1 → 0.0.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b09cc4d4b92aaf1ae1f62ccb1686b9b6e7d44c04
4
- data.tar.gz: c27f683787a02d6b781e9fe0f8fad99e5e60fc3d
3
+ metadata.gz: 37eb2af4855778e961c16b06c6bafe4c5c664d53
4
+ data.tar.gz: 3b10c3f80b0c1c6d8860115171fb8e9e07306a8d
5
5
  SHA512:
6
- metadata.gz: 5c2784ca3dcda0def66334436421d7bdee96be41a3b3bdfad14ee0f2fe254f925c3a2f2684aecd546030bd8b33bf6a9275ec2b311ed569dee3fa72943d5e5888
7
- data.tar.gz: 7ffc6846384c20e1a62e47c489322455a06f4187c7e1ad7d5125e69f7fd3753196449b8881cbbd3ece917d79494f4c57f327ad9061516b1d83840263e1bab48b
6
+ metadata.gz: 2fd30805779f5b5ebf1cd65c44083da2e1a6a1bb9af5bbe6621aa650471c0281fea4692e77c16fbcdcd296fb14ad5c879394353dbbffe270ebf5163c0b3966f6
7
+ data.tar.gz: b8a30e3143803bd1d23c114b90331f97f1f1c8787db65ca5c02465daba5427f9dbdbe544eae9a55a55d99b66476ee8181a27d976a9c8143367a6d93e50d4a3a0
@@ -0,0 +1,22 @@
1
+ # For more information about the properties used in
2
+ # this file, please see the EditorConfig documentation:
3
+ # http://editorconfig.org/
4
+
5
+ root = true
6
+
7
+ [*]
8
+ charset = utf-8
9
+ end_of_line = lf
10
+ indent_size = 2
11
+ indent_style = tabs
12
+ insert_final_newline = true
13
+ trim_trailing_whitespace = true
14
+
15
+ [*.md]
16
+ trim_trailing_whitespace = false
17
+
18
+ # The indent size used in the `package.json` file cannot be changed
19
+ # https://github.com/npm/npm/pull/3180#issuecomment-16336516
20
+ [{.travis.yml,package.json}]
21
+ indent_size = 2
22
+ indent_style = space
@@ -0,0 +1,21 @@
1
+ # OS-specific
2
+ .DS_Store
3
+
4
+ # editors
5
+ *.swp
6
+
7
+ # Bundler/Rubygems
8
+ *.gem
9
+ .bundle
10
+ pkg/*
11
+ tags
12
+ Gemfile.lock
13
+
14
+ # Vagrant
15
+ .vagrant
16
+ Vagrantfile
17
+ !example_box/Vagrantfile
18
+
19
+ # RVM files for gemset/ruby setting
20
+ .ruby-*
21
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ # We depend on Vagrant for development, but we don't add it as a
5
+ # gem dependency because we expect to be installed within the
6
+ # Vagrant environment itself using `vagrant plugin`.
7
+ gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git"
8
+ end
9
+
10
+ group :plugins do
11
+ gem "drupal-vm-sites", path: "."
12
+ end
@@ -0,0 +1,48 @@
1
+ # Drupal VM Config
2
+
3
+ This Vagrant plugin makes it easy to manage multiple Drupal sites on a single Vagrant instance. It is used to generate a `config.yml` file for Drupal VM. See [Drupal VM Documentation](http://docs.drupalvm.com/en/latest/) for additional documentation.
4
+
5
+ ## Setup
6
+
7
+ 1. `vagrant plugin install drupal-vm-sites`
8
+
9
+ 2. TBD
10
+
11
+ 3. Add Drupal websites to `sites.yml`
12
+
13
+ ```yml
14
+ site1:
15
+ url: site1.com
16
+ site2:
17
+ url: site2.edu
18
+ path: ~/path/to/site
19
+ site3:
20
+ url: site3.us.gov
21
+ path: ~/some/other/path
22
+ ```
23
+
24
+ **Note:** path defaults to `~/Sites/site.com/www` if not specified
25
+
26
+ 4. TBD
27
+
28
+ 5. `vagrant up`
29
+
30
+ You now have a functional Drupal vagrant install for your sites! Now you can configure Drupal.
31
+
32
+ ## Configure Drupal
33
+
34
+ #### New Database?
35
+
36
+ A new database was created during Vagrant provision so you're all set.
37
+
38
+ - dbname: `sitename`
39
+ - user: `root`
40
+ - pass: `root`
41
+
42
+ #### Existing Database?
43
+
44
+ Export database from the base site and then use [Drush](http://www.drush.org/en/master/):
45
+
46
+ drush @skycatchfire.dev sql-drop
47
+ drush @skycatchfire.dev sql-cli < ~/my-sql-dump-file-name.sql
48
+ 0
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ # Change to the directory of this file.
5
+ Dir.chdir(File.expand_path("../", __FILE__))
6
+
7
+ # This installs the tasks that help with gem creation and
8
+ # publishing.
9
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,50 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ require "drupal-vm-sites/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "drupal-vm-sites"
6
+ s.version = VagrantPlugins::DrupalVmSites::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.license = "MIT"
9
+ s.authors = "SKYCATCHFIRE"
10
+ s.email = "hello@SKYCATCHFIRE.com"
11
+ s.summary = "Generate sites config for Drupal VM"
12
+ s.description = "Generate sites config for Drupal VM"
13
+ s.homepage = "https://github.com/skycatchfire/drupal-vm-config"
14
+
15
+ s.add_development_dependency "rake"
16
+
17
+ # The following block of code determines the files that should be included
18
+ # in the gem. It does this by reading all the files in the directory where
19
+ # this gemspec is, and parsing out the ignored files from the gitignore.
20
+ # Note that the entire gitignore(5) syntax is not supported, specifically
21
+ # the "!" syntax, but it should mostly work correctly.
22
+ root_path = File.dirname(__FILE__)
23
+ all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
24
+ all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
25
+ gitignore_path = File.join(root_path, ".gitignore")
26
+ gitignore = File.readlines(gitignore_path)
27
+ gitignore.map! { |line| line.chomp.strip }
28
+ gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
29
+
30
+ unignored_files = all_files.reject do |file|
31
+ # Ignore any directories, the gemspec only cares about files
32
+ next true if File.directory?(file)
33
+
34
+ # Ignore any paths that match anything in the gitignore. We do
35
+ # two tests here:
36
+ #
37
+ # - First, test to see if the entire path matches the gitignore.
38
+ # - Second, match if the basename does, this makes it so that things
39
+ # like '.DS_Store' will match sub-directories too (same behavior
40
+ # as git).
41
+ #
42
+ gitignore.any? do |ignore|
43
+ File.fnmatch(ignore, file, File::FNM_PATHNAME) || File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
44
+ end
45
+ end
46
+
47
+ s.files = unignored_files
48
+ s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
49
+ s.require_path = 'lib'
50
+ end
@@ -0,0 +1,16 @@
1
+ require "pathname"
2
+
3
+ require 'drupal-vm-sites/plugin'
4
+
5
+ module VagrantPlugins
6
+ module DrupalVmSites
7
+ lib_path = Pathname.new(File.expand_path("../drupal-vm-sites", __FILE__))
8
+
9
+ # This returns the path to the source of this plugin.
10
+ #
11
+ # @return [Pathname]
12
+ def self.source_root
13
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,56 @@
1
+ require 'yaml'
2
+
3
+ module VagrantPlugins
4
+ module DrupalVmSites
5
+ class Command < Vagrant.plugin(2, :command)
6
+
7
+ def editConfig(url, path)
8
+ projectDirectory = File.expand_path(File.dirname(__FILE__) + '/templates/')
9
+ sitesConfig = YAML.load_file(projectDirectory + '/config-template.yml')
10
+
11
+ if path
12
+ sitesConfig['vagrant_synced_folders'][0]['local_path'] = path
13
+ else
14
+ sitesConfig['vagrant_synced_folders'][0]['local_path'] = '~/Sites/' + url + '/www';
15
+ end
16
+
17
+ sitesConfig['vagrant_synced_folders'][0]['destination'] = '/var/www/' + url;
18
+ sitesConfig['apache_vhosts'][0]['servername'] = url.split('.')[0] + '.dev';
19
+ sitesConfig['apache_vhosts'][0]['serveralias'] = 'www.' + url.split('.')[0] + '.dev';
20
+ sitesConfig['apache_vhosts'][0]['documentroot'] = '/var/www/' + url;
21
+ sitesConfig['mysql_databases'][0]['name'] = url.split('.')[0];
22
+
23
+ return sitesConfig;
24
+ end
25
+
26
+ def execute
27
+ currentDirectory = Dir.pwd
28
+ sites = YAML.load_file(currentDirectory + '/sites.yml')
29
+
30
+ config = {};
31
+ folders = [];
32
+ vhosts = [];
33
+ databases = [];
34
+
35
+ for site in sites
36
+ config['vagrant_synced_folders'] = editConfig(site[1]['url'], site[1]['path'])['vagrant_synced_folders']
37
+ config['apache_vhosts'] = editConfig(site[1]['url'], site[1]['path'])['apache_vhosts']
38
+ config['mysql_databases'] = editConfig(site[1]['url'], site[1]['path'])['mysql_databases']
39
+
40
+ folders.push(config['vagrant_synced_folders'][0])
41
+ vhosts.push(config['apache_vhosts'][0])
42
+ databases.push(config['mysql_databases'][0])
43
+ end
44
+
45
+ config['vagrant_synced_folders'] = folders
46
+ config['apache_vhosts'] = vhosts
47
+ config['mysql_databases'] = databases
48
+
49
+ File.open(currentDirectory + '/config.yml', 'w') {|f| f.write config.to_yaml }
50
+
51
+ puts 'Configuration file generated!'
52
+ 0
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,12 @@
1
+ module VagrantPlugins
2
+ module DrupalVmSites
3
+ class Plugin < Vagrant.plugin("2")
4
+ name "Drupal Vm Sites"
5
+
6
+ command "config-sites" do
7
+ require_relative "command"
8
+ Command
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ vagrant_synced_folders:
2
+ - local_path:
3
+ destination:
4
+ type: nfs
5
+ create: true
6
+ apache_vhosts:
7
+ - servername:
8
+ serveralias:
9
+ documentroot:
10
+ extra_parameters: ''
11
+ mysql_databases:
12
+ - name:
13
+ encoding: utf8mb4
14
+ collation: utf8mb4_general_ci
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module DrupalVmSites
3
+ VERSION = '0.0.2'
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drupal-vm-sites
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SKYCATCHFIRE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-10 00:00:00.000000000 Z
11
+ date: 2017-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -29,8 +29,19 @@ email: hello@SKYCATCHFIRE.com
29
29
  executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
- files: []
33
- homepage:
32
+ files:
33
+ - ".editorconfig"
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - README.md
37
+ - Rakefile
38
+ - drupal-vm-sites.gemspec
39
+ - lib/drupal-vm-sites.rb
40
+ - lib/drupal-vm-sites/command.rb
41
+ - lib/drupal-vm-sites/plugin.rb
42
+ - lib/drupal-vm-sites/templates/config-template.yml
43
+ - lib/drupal-vm-sites/version.rb
44
+ homepage: https://github.com/skycatchfire/drupal-vm-config
34
45
  licenses:
35
46
  - MIT
36
47
  metadata: {}