capistrano-didi 0.4.5 → 0.4.12

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
- ---
2
- SHA512:
3
- data.tar.gz: f6c724b62e44dba0b97f1bb999638f291ef84c971dda7363d9934e93f7089305d24f3ccdde8dd8159b2fdd31ef46fabc462a010d4bf05a077051a6ca9374327c
4
- metadata.gz: 6a0013ad8ea262cf9abae39b4ce059089df2dcc3edabd9e8db253c1a99462c9fb33f87504ca3193eeb082676e4efd214728016fce71e41fbe7778ca390737bc1
5
- SHA1:
6
- data.tar.gz: 349f43606d84dd6bbf717557d9d4fac959dd8dcf
7
- metadata.gz: 341d92e5320779d85725ae66d0a10de7164c7143
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2cc823ca1111cbb50e29452e1e1aacad82a431ad
4
+ data.tar.gz: 54bb936e4924b639284c679ddef7d4c35e5d418a
5
+ SHA512:
6
+ metadata.gz: 081ae1ca0cf90dffaf9a3c656ead290f83cafedb3f525224ce33a3125efe362e1b1a129e8b58fae7d33b8b1a6e6896877d9ee284c012b7be1ccf43e915d27c4b
7
+ data.tar.gz: 0af2db40303aa683f9b64e6701405fe3c9145a5deea8f0b15cf8c14193d46eb286849c2e73f347490c1c1a7fe6f5554eab18369e543b508ab8f117e17a36ffd3
@@ -1,3 +1,18 @@
1
+ ## 0.4.12 / 22 December 2014
2
+
3
+ * PE-75: use local copy when cloning repositories
4
+ * PE-75: removed test files
5
+ * PE-75: added dev and acc environments to didify
6
+
7
+ ## 0.4.11 / 28 November 2014
8
+
9
+ * added Grunt task support
10
+ * added environments module support
11
+ * added baseline module support
12
+ * added l10n_update module support
13
+ * added migrate module support
14
+ * improved cached copy settings
15
+
1
16
  ## 0.4.5 / 3 July 2013
2
17
 
3
18
  * added support for private files directory, using the user_private_files flag.
data/Gemfile CHANGED
@@ -6,10 +6,10 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "railsless-deploy", ">= 1.0.2"
10
- gem "capistrano", ">= 2.12.0"
11
- gem "shoulda", ">= 0"
12
- gem "bundler", "~> 1.1.3"
13
- gem "jeweler", "~> 1.6.4"
14
- gem "rcov", ">= 0"
9
+ gem "railsless-deploy", ">= 1.0"
10
+ gem "capistrano", ">= 2.12"
11
+ gem "shoulda", ">= 3.0"
12
+ gem "bundler", ">= 1"
13
+ gem "jeweler", ">= 1.6"
14
+ #gem "rcov", ">= 0"
15
15
  end
@@ -22,7 +22,6 @@ GEM
22
22
  net-ssh (>= 1.99.1)
23
23
  railsless-deploy (1.0.2)
24
24
  rake (0.9.2.2)
25
- rcov (1.0.0)
26
25
  shoulda (3.0.1)
27
26
  shoulda-context (~> 1.0.0)
28
27
  shoulda-matchers (~> 1.0.0)
@@ -33,9 +32,8 @@ PLATFORMS
33
32
  ruby
34
33
 
35
34
  DEPENDENCIES
36
- bundler (~> 1.1.3)
37
- capistrano (>= 2.12.0)
38
- jeweler (~> 1.6.4)
39
- railsless-deploy (>= 1.0.2)
40
- rcov
41
- shoulda
35
+ bundler (>= 1)
36
+ capistrano (>= 2.12)
37
+ jeweler (>= 1.6)
38
+ railsless-deploy (>= 1.0)
39
+ shoulda (>= 3.0)
data/Rakefile CHANGED
@@ -15,14 +15,14 @@ require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "capistrano-didi"
18
- gem.homepage = "http://github.com/koenvw/didi"
18
+ gem.homepage = "https://github.com/Crosscheck/didi"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{didi - drupal deployment script based on capistrano}
21
21
  gem.description = %Q{didi is a collection of recipes for capistrano that allow drupal to be deployed, tested and used in a CI environment}
22
- gem.email = "koenvw@gmail.com"
23
- gem.authors = ["Koen Van Winckel"]
24
- gem.add_dependency "capistrano", ">= 2.12.0"
25
- gem.add_dependency "railsless-deploy", ">= 1.0.2"
22
+ gem.email = "support@crosscheck.be"
23
+ gem.authors = ["CrossCheck"]
24
+ #gem.add_dependency "capistrano", "~> 2.12"
25
+ #gem.add_dependency "railsless-deploy", "~> 1.0.2"
26
26
  gem.post_install_message = '=> "didify" and "didi" commands installed. Try them out!'
27
27
  # dependencies defined in Gemfile
28
28
  end
@@ -35,13 +35,13 @@ Rake::TestTask.new(:test) do |test|
35
35
  test.verbose = true
36
36
  end
37
37
 
38
- require 'rcov/rcovtask'
39
- Rcov::RcovTask.new do |test|
40
- test.libs << 'test'
41
- test.pattern = 'test/**/test_*.rb'
42
- test.verbose = true
43
- test.rcov_opts << '--exclude "gems/*"'
44
- end
38
+ #require 'rcov/rcovtask'
39
+ #Rcov::RcovTask.new do |test|
40
+ # test.libs << 'test'
41
+ # test.pattern = 'test/**/test_*.rb'
42
+ # test.verbose = true
43
+ # test.rcov_opts << '--exclude "gems/*"'
44
+ #end
45
45
 
46
46
  task :default => :test
47
47
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.11
data/bin/didify CHANGED
@@ -44,32 +44,62 @@ files = {
44
44
  FILE
45
45
 
46
46
  "config/deploy.rb" => 'set :default_stage, "staging"
47
- set :stages, %w(staging production)
48
- set :application, "your_application_name"
49
- set :repository, "your_repository_location_here"
50
- set :drupal_path, "drupal" # change this to your drupal folder
47
+ set :stages, %w(dev acc staging prod)
48
+ set :application, "PROJECT_NAME"
49
+ set :repository, "git@gitlab.crosscheck.be:crosscheck/PROJECT_NAME"
50
+ set :drupal_path, "docroot"
51
+ set :baseline, "PROJECT_NAME_core"
52
+ set :profile, "PROJECT_NAME_kickstart"
53
+ set :domain, "PROJECT_NAME"
54
+ set :sitemail, "support@crosscheck.be"
55
+ set :adminpass, "drupal_admin_pass"
56
+
57
+ # Compile .sass files to .css
58
+ before "deploy:create_symlink", "grunt"
59
+
60
+ # Re-enable the core module so dependencies are taken care of.
61
+ before "drush:update", "drush:bl"
62
+
63
+ # Clear cache before running any update commands (e.g. to update class registry
64
+ # early).
65
+ before "drush:update", "drush:cc"
66
+
67
+ # Always trigger environment switch after deploy so the settings get updated.
68
+ after "deploy", "drush:env_switch"
69
+
70
+ # Development jobs, should not be executed after go-live.
71
+ after "deploy", "drush:migrate"
72
+ after "deploy", "drush:baseline_build"
73
+ after "deploy", "drush:l10n_update"
74
+
51
75
  ',
52
- "config/deploy/staging.rb" => 'set :user, "ssh_user_name"
53
- server "server.example.com", :app, :web, :db, :primary => true
76
+ "config/deploy/dev.rb" => 'set :user, "crosscheck"
77
+ server "SITE_NAME.dev.one-agency.be", :app, :web, :db, :primary => true
54
78
 
55
- set :deploy_to, "the_path_on_the_remote_server"
79
+ set :deploy_to, "/home/www/vhosts/projects/PROJECT_NAME/dev/http"
56
80
  set :branch, "master"
81
+ set :site, "SITE_NAME.dev.one-agency.be"
57
82
 
58
83
  set :db_type, "mysql"
59
- set :db_name, "database_name"
60
- set :db_username, "database_user_name"
84
+ set :db_name, "PROJECT_NAME_dev"
85
+ set :db_username, "PROJECT_NAME"
61
86
  set :db_password, "database_password"
62
- set :db_prefix, "database_prefix"
87
+ set :db_prefix, ""
88
+ ',
89
+ "config/deploy/acc.rb" => 'set :user, "crosscheck"
90
+ server "SITE_NAME.acc.one-agency.be", :app, :web, :db, :primary => true
63
91
 
64
- set :profile, "minimal"
65
- set :domain, "default"
66
- set :site, "apache_vhost"
67
- set :sitemail, "drupal_site_email_address"
68
- set :adminpass, "drupal_admin_pass"
92
+ set :deploy_to, "/home/www/vhosts/projects/PROJECT_NAME/acc/http"
93
+ set :branch, "acc"
94
+ set :site, "SITE_NAME.acc.one-agency.be"
69
95
 
70
- set :baseline, "drupal_feature_to_activate_after_fresh_install"
96
+ set :db_type, "mysql"
97
+ set :db_name, "PROJECT_NAME_acc"
98
+ set :db_username, "PROJECT_NAME"
99
+ set :db_password, "database_password"
100
+ set :db_prefix, ""
71
101
  ',
72
- "config/sql/staging.sql" => <<scrub
102
+ "config/sql/scrub-database.sql" => <<scrub
73
103
  --
74
104
  -- Scrub important information from a Drupal database.
75
105
  --
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "capistrano-didi"
8
- s.version = "0.4.5"
8
+ s.version = "0.4.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Koen Van Winckel"]
12
- s.date = "2013-07-03"
11
+ s.authors = ["CrossCheck"]
12
+ s.date = "2014-11-28"
13
13
  s.description = "didi is a collection of recipes for capistrano that allow drupal to be deployed, tested and used in a CI environment"
14
- s.email = "koenvw@gmail.com"
15
- s.executables = ["didify", "didi"]
14
+ s.email = "support@crosscheck.be"
15
+ s.executables = ["didi", "didify"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE.txt",
18
18
  "README.rdoc"
@@ -33,44 +33,35 @@ Gem::Specification.new do |s|
33
33
  "test/helper.rb",
34
34
  "test/test_didi.rb"
35
35
  ]
36
- s.homepage = "http://github.com/koenvw/didi"
36
+ s.homepage = "https://github.com/Crosscheck/didi"
37
37
  s.licenses = ["MIT"]
38
38
  s.post_install_message = "=> \"didify\" and \"didi\" commands installed. Try them out!"
39
39
  s.require_paths = ["lib"]
40
- s.rubygems_version = "1.8.11"
40
+ s.rubygems_version = "2.0.14"
41
41
  s.summary = "didi - drupal deployment script based on capistrano"
42
42
 
43
43
  if s.respond_to? :specification_version then
44
- s.specification_version = 3
44
+ s.specification_version = 4
45
45
 
46
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_development_dependency(%q<railsless-deploy>, [">= 1.0.2"])
48
- s.add_development_dependency(%q<capistrano>, [">= 2.12.0"])
49
- s.add_development_dependency(%q<shoulda>, [">= 0"])
50
- s.add_development_dependency(%q<bundler>, ["~> 1.1.3"])
51
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
52
- s.add_development_dependency(%q<rcov>, [">= 0"])
53
- s.add_runtime_dependency(%q<capistrano>, [">= 2.12.0"])
54
- s.add_runtime_dependency(%q<railsless-deploy>, [">= 1.0.2"])
47
+ s.add_development_dependency(%q<railsless-deploy>, [">= 1.0"])
48
+ s.add_development_dependency(%q<capistrano>, [">= 2.12"])
49
+ s.add_development_dependency(%q<shoulda>, [">= 3.0"])
50
+ s.add_development_dependency(%q<bundler>, [">= 1"])
51
+ s.add_development_dependency(%q<jeweler>, [">= 1.6"])
55
52
  else
56
- s.add_dependency(%q<railsless-deploy>, [">= 1.0.2"])
57
- s.add_dependency(%q<capistrano>, [">= 2.12.0"])
58
- s.add_dependency(%q<shoulda>, [">= 0"])
59
- s.add_dependency(%q<bundler>, ["~> 1.1.3"])
60
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
61
- s.add_dependency(%q<rcov>, [">= 0"])
62
- s.add_dependency(%q<capistrano>, [">= 2.12.0"])
63
- s.add_dependency(%q<railsless-deploy>, [">= 1.0.2"])
53
+ s.add_dependency(%q<railsless-deploy>, [">= 1.0"])
54
+ s.add_dependency(%q<capistrano>, [">= 2.12"])
55
+ s.add_dependency(%q<shoulda>, [">= 3.0"])
56
+ s.add_dependency(%q<bundler>, [">= 1"])
57
+ s.add_dependency(%q<jeweler>, [">= 1.6"])
64
58
  end
65
59
  else
66
- s.add_dependency(%q<railsless-deploy>, [">= 1.0.2"])
67
- s.add_dependency(%q<capistrano>, [">= 2.12.0"])
68
- s.add_dependency(%q<shoulda>, [">= 0"])
69
- s.add_dependency(%q<bundler>, ["~> 1.1.3"])
70
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
71
- s.add_dependency(%q<rcov>, [">= 0"])
72
- s.add_dependency(%q<capistrano>, [">= 2.12.0"])
73
- s.add_dependency(%q<railsless-deploy>, [">= 1.0.2"])
60
+ s.add_dependency(%q<railsless-deploy>, [">= 1.0"])
61
+ s.add_dependency(%q<capistrano>, [">= 2.12"])
62
+ s.add_dependency(%q<shoulda>, [">= 3.0"])
63
+ s.add_dependency(%q<bundler>, [">= 1"])
64
+ s.add_dependency(%q<jeweler>, [">= 1.6"])
74
65
  end
75
66
  end
76
67
 
@@ -6,61 +6,71 @@ Capistrano::Configuration.instance.load do
6
6
  # These variables MUST be set in the client capfiles. If they are not set,
7
7
  # the deploy will fail with an error.
8
8
  # =========================================================================
9
- _cset(:db_type) { abort "Please specify the Drupal database type (:db_type)." }
10
- _cset(:db_name) { abort "Please specify the Drupal database name (:db_name)." }
11
- _cset(:db_username) { abort "Please specify the Drupal database username (:db_username)." }
12
- _cset(:db_password) { abort "Please specify the Drupal database password (:db_password)." }
13
- _cset(:db_prefix) { abort "Please specify the Drupal database prefix (:db_prefix)." }
14
-
15
- _cset(:profile) { abort "Please specify the Drupal install profile (:profile)." }
16
- _cset(:site) { abort "Please specify the Drupal site (:site)." }
17
- _cset(:sitemail) { abort "Please specify the Drupal site mail (:sitemail)." }
18
- _cset(:adminpass) { abort "Please specify the Drupal admin password (:adminpass)." }
19
- _cset(:baseline) { abort "Please specify the Baseline feature (:baseline)." }
20
-
9
+ _cset(:db_type) { abort "Please specify the Drupal database type (:db_type)." }
10
+ _cset(:db_name) { abort "Please specify the Drupal database name (:db_name)." }
11
+ _cset(:db_username) { abort "Please specify the Drupal database username (:db_username)." }
12
+ _cset(:db_password) { abort "Please specify the Drupal database password (:db_password)." }
13
+ _cset(:db_prefix) { abort "Please specify the Drupal database prefix (:db_prefix)." }
14
+
15
+ _cset(:profile) { abort "Please specify the Drupal install profile (:profile)." }
16
+ _cset(:site) { abort "Please specify the Drupal site (:site)." }
17
+ _cset(:sitemail) { abort "Please specify the Drupal site mail (:sitemail)." }
18
+ _cset(:adminpass) { abort "Please specify the Drupal admin password (:adminpass)." }
19
+ _cset(:baseline) { abort "Please specify the Baseline feature (:baseline)." }
20
+
21
+ # Added by KimKennof.
22
+ _cset(:theme) { abort "Please specify the theme name (:theme)." }
23
+ _cset(:theme_path) { abort "Please specify the theme name (:theme_path)." }
21
24
 
22
25
  # =========================================================================
23
26
  # These variables may be set in the client capfile if their default values
24
27
  # are not sufficient.
25
28
  # =========================================================================
26
- set :scm, :git
27
- set :deploy_via, :remote_cache
28
- set :drupal_version, '7'
29
- set :keep_releases, 5
30
- set :use_sudo, false
31
-
32
- set :domain, 'default'
33
- set :db_host, 'localhost'
34
- set :drupal_path, 'drupal'
35
- set :srv_usr, 'www-data'
36
- set :enable_robots, false
37
- set :no_disable, true
38
- set :local_database, nil
39
- set :backup_database, true
40
- set :push_dump_enabled, false
41
- set :make_install_profile, false
42
- set :make_file, ''
43
- set :use_private_files, false
44
-
45
- ssh_options[:forward_agent] = true
46
- #ssh_options[:verbose] = :debug #FIXME
29
+ set :scm, :git
30
+ set :deploy_via, :copy
31
+ set :drupal_version, '7'
32
+ set :keep_releases, 5
33
+ set :use_sudo, false
34
+
35
+ set :domain, 'default'
36
+ set :db_host, 'localhost'
37
+ set :drupal_path, 'drupal'
38
+ set :srv_usr, 'www-data'
39
+ set :enable_robots, false
40
+ set :no_disable, true
41
+ set :local_database, nil
42
+ set :backup_database, true
43
+ set :push_dump_enabled, false
44
+ set :make_install_profile, false
45
+ set :make_file, ''
46
+ set :use_private_files, false
47
+
48
+ set :stage, 'production'
49
+ set :copy_exclude, ['.git']
50
+ set :copy_dir, File.expand_path("~/.capistrano/#{application}")
51
+ set :copy_cache, "#{copy_dir}/#{stage}"
52
+ set :assets_path, 'assets'
53
+
54
+ ssh_options[:forward_agent] = true
55
+ #ssh_options[:verbose] = :debug #FIXME
47
56
 
48
57
  # =========================================================================
49
58
  # These variables should NOT be changed unless you are very confident in
50
59
  # what you are doing. Make sure you understand all the implications of your
51
60
  # changes if you do decide to muck with these!
52
61
  # =========================================================================
53
- _cset :settings, 'settings.php'
54
- _cset :files, 'files'
55
- _cset :private_files, 'private'
56
- _cset :dbbackups, 'db_backups'
57
- _cset :drush_path, ''
58
-
59
- _cset(:shared_settings) { domain.to_a.map { |d| File.join(shared_path, d, settings) } }
60
- _cset(:shared_files) { domain.to_a.map { |d| File.join(shared_path, d, files) } }
61
- _cset(:shared_private_files) { domain.to_a.map { |d| File.join(shared_path, d, private_files) } }
62
- _cset(:dbbackups_path) { domain.to_a.map { |d| File.join(deploy_to, dbbackups, d) } }
63
- _cset(:drush) { "drush -r #{current_path}" + (domain == 'default' ? '' : " -l #{domain}") } # FIXME: not in use?
62
+ _cset :settings, 'settings.php'
63
+ _cset :files, 'files'
64
+ _cset :private_files, 'private'
65
+ _cset :dbbackups, 'db_backups'
66
+ _cset :drush_path, ''
67
+
68
+ _cset(:shared_settings) { convert_domain().map { |d| File.join(shared_path, d, settings) } }
69
+ _cset(:shared_files) { convert_domain().map { |d| File.join(shared_path, d, files) } }
70
+ _cset(:shared_private_files) { convert_domain().map { |d| File.join(shared_path, d, private_files) } }
71
+ _cset(:dbbackups_path) { convert_domain().map { |d| File.join(deploy_to, dbbackups, d) } }
72
+ _cset(:drush) { "drush -r #{current_path}" + (domain == 'default' ? '' : " -l #{domain}") } # FIXME: not in use?
73
+
64
74
 
65
75
  # these variables are still in rails-less deploy gem
66
76
  # but have been updated in the latest capistrano gem
@@ -68,512 +78,584 @@ _cset(:drush) { "drush -r #{current_path}" + (domain == 'defau
68
78
  # see https://github.com/capistrano/capistrano/commit/92941e855d70a5778eb094a972fdf43c70802b95#lib/capistrano/recipes/deploy.rb
69
79
  # and https://github.com/capistrano/capistrano/commit/8638f2278ebe484ebcb1a1950e157c30c2d70960#lib/capistrano/recipes/deploy.rb
70
80
  # for background
71
- set(:releases) { capture("ls -x #{releases_path}", :except => { :no_release => true }).split.sort }
81
+ set(:releases) { capture("ls -x #{releases_path}", :except => {:no_release => true}).split.sort }
72
82
 
73
- set(:current_revision) { capture("cat #{current_path}/REVISION", :except => { :no_release => true }).chomp }
74
- set(:latest_revision) { capture("cat #{current_release}/REVISION", :except => { :no_release => true }).chomp }
75
- set(:previous_revision) { capture("cat #{previous_release}/REVISION", :except => { :no_release => true }).chomp if previous_release }
83
+ set(:current_revision) { capture("cat #{current_path}/REVISION", :except => {:no_release => true}).chomp }
84
+ set(:latest_revision) { capture("cat #{current_release}/REVISION", :except => {:no_release => true}).chomp }
85
+ set(:previous_revision) { capture("cat #{previous_release}/REVISION", :except => {:no_release => true}).chomp if previous_release }
76
86
  # end fix
77
87
 
78
- _cset(:release_settings) { domain.to_a.map { |d| File.join(release_path, drupal_path, 'sites', d, settings) } }
79
- _cset(:release_files) { domain.to_a.map { |d| File.join(release_path, drupal_path, 'sites', d, files) } }
80
- _cset(:release_private_files) { domain.to_a.map { |d| File.join(release_path, drupal_path, 'sites', d, private_files) } }
81
- _cset(:release_domain) { domain.to_a.map { |d| File.join(release_path, drupal_path, 'sites', d) } }
88
+ _cset(:release_settings) { convert_domain().map { |d| File.join(release_path, drupal_path, 'sites', d, settings) } }
89
+ _cset(:release_files) { convert_domain().map { |d| File.join(release_path, drupal_path, 'sites', d, files) } }
90
+ _cset(:release_private_files) { convert_domain().map { |d| File.join(release_path, drupal_path, 'sites', d, private_files) } }
91
+ _cset(:release_domain) { convert_domain().map { |d| File.join(release_path, drupal_path, 'sites', d) } }
92
+
93
+ _cset(:previous_release_settings) { releases.length > 1 ? convert_domain().map { |d| File.join(previous_release, drupal_path, 'sites', d, settings) } : nil }
94
+ _cset(:previous_release_files) { releases.length > 1 ? convert_domain().map { |d| File.join(previous_release, drupal_path, 'sites', d, files) } : nil }
95
+ _cset(:previous_release_private_files) { releases.length > 1 ? convert_domain().map { |d| File.join(previous_release, drupal_path, 'sites', d, private_files) } : nil }
96
+ _cset(:previous_release_domain) { releases.length > 1 ? convert_domain().map { |d| File.join(previous_release, drupal_path, 'sites', d) } : nil }
82
97
 
83
- _cset(:previous_release_settings) { releases.length > 1 ? domain.to_a.map { |d| File.join(previous_release, drupal_path, 'sites', d, settings) } : nil }
84
- _cset(:previous_release_files) { releases.length > 1 ? domain.to_a.map { |d| File.join(previous_release, drupal_path, 'sites', d, files) } : nil }
85
- _cset(:previous_release_private_files) { releases.length > 1 ? domain.to_a.map { |d| File.join(previous_release, drupal_path, 'sites', d, private_files) } : nil }
86
- _cset(:previous_release_domain) { releases.length > 1 ? domain.to_a.map { |d| File.join(previous_release, drupal_path, 'sites', d) } : nil }
98
+ _cset(:is_multisite) { convert_domain().size > 1 }
87
99
 
88
- _cset(:is_multisite) { domain.to_a.size > 1 }
89
100
 
90
101
  # =========================================================================
91
102
  # Extra dependency checks
92
103
  # =========================================================================
93
- depend :local, :command, "drush"
94
- depend :remote, :command, "#{drush_path}drush"
104
+ depend :local, :command, "drush"
105
+ depend :remote, :command, "#{drush_path}drush"
95
106
 
96
107
 
97
108
  # =========================================================================
98
109
  # Overwrites to the DEPLOY tasks in the capistrano library.
99
110
  # =========================================================================
100
111
 
101
- namespace :deploy do
102
-
103
- desc <<-DESC
112
+ namespace :deploy do
113
+ desc <<-DESC
104
114
  Deploys your Drupal site, runs drush:update. It supposes that the Setup task was already executed.
105
115
  This overrides the default Capistrano Deploy task to handle database operations and backups,
106
116
  all of them via Drush.
107
- DESC
108
- task :default do
109
- update
110
- manage.dbdump_previous
111
- cleanup
112
- end
113
- after "deploy", "drush:update"
117
+ DESC
114
118
 
115
- desc "Setup a drupal site from scratch"
116
- task :cold do
117
- transaction do
118
- setup
119
+ task :default do
119
120
  update
121
+ manage.dbdump_previous
122
+ cleanup
120
123
  end
121
- end
122
- after "deploy:cold", "drush:si"
124
+ after "deploy", "drush:update"
123
125
 
124
- desc "Deploys latest code and rebuild the database"
125
- task :rebuild do
126
- update
127
- manage.dbdump_previous
128
- cleanup
129
- end
130
- after "deploy:rebuild", "drush:si"
126
+ desc "Setup a drupal site from scratch"
127
+ task :cold do
128
+ transaction do
129
+ setup
130
+ update
131
+ end
132
+ end
133
+ after "deploy:cold", "drush:si"
134
+
135
+ desc "Deploys latest code and rebuild the database"
136
+ task :rebuild do
137
+ update
138
+ manage.dbdump_previous
139
+ cleanup
140
+ end
141
+ after "deploy:rebuild", "drush:si"
131
142
 
132
- desc <<-DESC
143
+ desc <<-DESC
133
144
  Prepares one or more servers for deployment.
134
145
  Creates the necessary file structure and the shared Drupal settings file.
135
- DESC
136
- task :setup, :except => { :no_release => true } do
137
- #Create shared directories
138
- # FIXME: chown / chmod require user to be member of
139
- dirs = [deploy_to, releases_path, shared_path, dbbackups_path, shared_files]
140
- dirs += domain.map { |d| File.join(shared_path, d) }
141
-
142
- run <<-CMD
143
- mkdir -p #{dirs.join(' ')} && #{try_sudo} chown #{user}:#{srv_usr} #{shared_files.join(' ')} && #{try_sudo} chmod g+w #{shared_files.join(' ')}
144
- CMD
146
+ DESC
147
+
148
+ task :setup, :except => {:no_release => true} do
149
+ #Create shared directories
150
+ # FIXME: chown / chmod require user to be member of
151
+ dirs = [deploy_to, releases_path, shared_path, dbbackups_path, shared_files]
152
+ dirs += convert_domain().map { |d| File.join(shared_path, d) }
145
153
 
146
- # Generate private files when enabled.
147
- if use_private_files
148
154
  run <<-CMD
149
- mkdir -p #{shared_private_files} && #{try_sudo} chown #{user}:#{srv_usr} #{shared_private_files.join(' ')} && #{try_sudo} chmod g+w #{shared_private_files.join(' ')}
155
+ mkdir -p #{dirs.join(' ')} && #{try_sudo} chown #{user}:#{srv_usr} #{shared_files.join(' ')} && #{try_sudo} chmod g+w #{shared_files.join(' ')}
150
156
  CMD
151
- end
152
157
 
153
- #create drupal config file
154
- domain.each_with_index do |d, i|
155
- configuration = drupal_settings(drupal_version, d)
156
- put configuration, shared_settings[i]
157
- end
158
+ # Generate private files when enabled.
159
+ if use_private_files
160
+ run <<-CMD
161
+ mkdir -p #{shared_private_files} && #{try_sudo} chown #{user}:#{srv_usr} #{shared_private_files.join(' ')} && #{try_sudo} chmod g+w #{shared_private_files.join(' ')}
162
+ CMD
163
+ end
158
164
 
159
- end
165
+ #create drupal config file
166
+ convert_domain().each_with_index do |d, i|
167
+ configuration = drupal_settings(drupal_version, d)
168
+ put configuration, shared_settings[i]
169
+ end
160
170
 
161
- desc "[internal] Rebuild files and settings symlinks"
162
- task :finalize_update, :except => { :no_release => true } do
163
- if make_install_profile
164
- run "cd #{current_release} && drush make #{make_file} #{drupal_path}"
165
171
  end
166
- # Specifies an on_rollback hook for the currently executing task. If this
167
- # or any subsequent task then fails, and a transaction is active, this
168
- # hook will be executed.
169
- on_rollback do
170
- if previous_release
171
- #FIXME: won't work on mulitsite config
172
- run "ln -nfs #{shared_files} #{previous_release_files} && ln -nfs #{shared_settings} #{previous_release_settings}"
173
- if use_private_files
174
- run "ln -nfs #{shared_private_files} #{previous_release_private_files}"
172
+
173
+ desc "[internal] Fixing release permissions."
174
+ task :fix_permissions, :except => {:no_release => false} do
175
+ run "cd #{current_release}/../../ && chmod -R 775 releases/"
176
+ end
177
+
178
+ desc "[internal] Rebuild files and settings symlinks"
179
+ task :finalize_update, :except => {:no_release => true} do
180
+ if make_install_profile
181
+ run "cd #{current_release} && drush make #{make_file} #{drupal_path}"
182
+ end
183
+ # Specifies an on_rollback hook for the currently executing task. If this
184
+ # or any subsequent task then fails, and a transaction is active, this
185
+ # hook will be executed.
186
+ on_rollback do
187
+ if previous_release
188
+ #FIXME: won't work on mulitsite config
189
+ run ["ln -nfs #{shared_files} #{previous_release_files}",
190
+ "ln -nfs #{shared_settings} #{previous_release_settings}"].join("; ")
191
+ if use_private_files
192
+ run "ln -nfs #{shared_private_files} #{previous_release_private_files}"
193
+ end
194
+ else
195
+ logger.important "no previous release to rollback to, rollback of drupal shared data skipped."
175
196
  end
176
- else
177
- logger.important "no previous release to rollback to, rollback of drupal shared data skipped."
178
197
  end
179
- end
180
198
 
181
- release_domain.each do |rd|
182
- run "if [ ! -d #{rd} ]; then mkdir #{rd}; fi" # in case the default folder is not versioned
183
- end
199
+ release_domain.each do |rd|
200
+ run "if [ ! -d #{rd} ]; then mkdir #{rd}; fi" # in case the default folder is not versioned
201
+ end
184
202
 
185
- shared_files.each_with_index do |sf, i|
186
- run <<-CMD
187
- ln -nfs #{sf} #{release_files[i]} &&
188
- ln -nfs #{shared_settings[i]} #{release_settings[i]}
203
+ shared_files.each_with_index do |sf, i|
204
+ run <<-CMD
205
+ ln -nfs #{sf} #{release_files[i]} && ln -nfs #{shared_settings[i]} #{release_settings[i]}
189
206
  CMD
190
- end
207
+ end
191
208
 
192
- if use_private_files
193
- shared_private_files.each_with_index do |sf, i|
194
- run <<-CMD
209
+ if use_private_files
210
+ shared_private_files.each_with_index do |sf, i|
211
+ run <<-CMD
195
212
  ln -nfs #{sf} #{release_private_files[i]}
196
213
  CMD
214
+ end
197
215
  end
198
216
  end
199
- end
217
+ after "deploy:finalize_update", "deploy:fix_permissions"
200
218
 
201
- desc "[internal] cleanup old symlinks, must run after deploy:symlink"
202
- task :cleanup_shared_symlinks, :except => { :no_release => true } do
203
- if previous_release
204
- previous_release_domain.each_with_index do |prd, i|
205
- run "if [ -d #{prd} ]; then chmod 777 #{prd}; fi" # if drupal changed the permissions of the folder
206
- run <<-CMD
207
- rm -f #{previous_release_settings[i]} &&
208
- rm -f #{previous_release_files[i]}
209
- CMD
210
- if use_private_files
219
+ desc "[internal] cleanup old symlinks, must run after deploy:symlink"
220
+ task :cleanup_shared_symlinks, :except => {:no_release => true} do
221
+ if previous_release
222
+ previous_release_domain.each_with_index do |prd, i|
223
+ run "if [ -d #{prd} ]; then chmod 777 #{prd}; fi" # if drupal changed the permissions of the folder
211
224
  run <<-CMD
212
- rm -f #{previous_release_private_files[i]}
225
+ rm -f #{previous_release_settings[i]} && rm -rf #{previous_release_files[i]}
213
226
  CMD
227
+ if use_private_files
228
+ run <<-CMD
229
+ rm -rf #{previous_release_private_files[i]}
230
+ CMD
231
+ end
214
232
  end
215
233
  end
216
234
  end
217
- end
218
- after "deploy:symlink", "deploy:cleanup_shared_symlinks"
235
+ after "deploy:symlink", "deploy:cleanup_shared_symlinks"
219
236
 
220
- desc <<-DESC
237
+ desc <<-DESC
221
238
  Removes old releases and corresponding DB backups.
222
- DESC
223
- task :cleanup, :except => { :no_release => true } do
224
- count = fetch(:keep_releases, 5).to_i
225
- if count >= releases.length
226
- logger.important "No old releases to clean up"
227
- else
228
- logger.info "keeping #{count} of #{releases.length} deployed releases"
229
- old_releases = (releases - releases.last(count))
230
- directories = old_releases.map { |release| File.join(releases_path, release) }.join(" ")
231
- databases = dbbackups_path.product(old_releases.map { |release| "#{release}.sql"} ).map { |p| File.join(p)}.join(" ") if backup_database
232
- run "rm -rf #{directories} #{databases}"
239
+ DESC
240
+
241
+ task :cleanup, :except => {:no_release => true} do
242
+ count = fetch(:keep_releases, 5).to_i
243
+ if count >= releases.length
244
+ logger.important "No old releases to clean up"
245
+ else
246
+ logger.info "keeping #{count} of #{releases.length} deployed releases"
247
+ old_releases = (releases - releases.last(count))
248
+ directories = old_releases.map { |release| File.join(releases_path, release) }.join(" ")
249
+ databases = dbbackups_path.product(old_releases.map { |release| "#{release}.sql" }).map { |p| File.join(p) }.join(" ") if backup_database
250
+ run "rm -rf #{directories} #{databases}"
251
+ end
233
252
  end
234
- end
235
253
 
236
- namespace :rollback do
254
+ namespace :rollback do
237
255
 
238
- desc <<-DESC
239
- go back to the previous release (code and database)
240
- DESC
241
- task :default do
242
- revision
243
- #db_rollback if domain.to_a.size == 1 # FIXME: not supported in multisite configuration, does not work
244
- cleanup
245
- end
256
+ desc <<-DESC
257
+ go back to the previous release (code and database)
258
+ DESC
246
259
 
247
- desc <<-DESC
260
+ task :default do
261
+ revision
262
+ #db_rollback if domain.to_a.size == 1 # FIXME: not supported in multisite configuration, does not work
263
+ cleanup
264
+ end
265
+
266
+ desc <<-DESC
248
267
  [internal] Removes the most recently deployed release.
249
268
  This is called by the rollback sequence, and should rarely
250
269
  (if ever) need to be called directly.
251
- DESC
252
- task :cleanup, :except => { :no_release => true } do
253
- # FIXME: this doesn't cleanup dbbackups
254
- run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
255
- end
270
+ DESC
256
271
 
257
- desc <<-DESC
258
- [internal] Points the current, files, and settings symlinks at the previous revision.
259
- DESC
260
- task :revision, :except => { :no_release => true } do
261
- if previous_release
262
- run <<-CMD
272
+ task :cleanup, :except => {:no_release => true} do
273
+ # FIXME: this doesn't cleanup dbbackups
274
+ run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
275
+ end
276
+
277
+ desc <<-DESC
278
+ [internal] Points the current, files, and settings symlinks at the previous revision.
279
+ DESC
280
+
281
+ task :revision, :except => {:no_release => true} do
282
+ if previous_release
283
+ run <<-CMD
263
284
  rm #{current_path};
264
285
  ln -s #{previous_release} #{current_path};
265
- CMD
266
- shared_files.each_with_index do |sf, i|
267
- run <<-CMD
286
+ CMD
287
+ shared_files.each_with_index do |sf, i|
288
+ run <<-CMD
268
289
  ln -nfs #{sf} #{previous_release_files[i]} &&
269
290
  ln -nfs #{shared_settings[i]} #{previous_release_settings[i]}
270
- CMD
271
- end
291
+ CMD
292
+ end
272
293
 
273
- if use_private_files
274
- shared_private_files.each_with_index do |sf, i|
275
- run <<-CMD
294
+ if use_private_files
295
+ shared_private_files.each_with_index do |sf, i|
296
+ run <<-CMD
276
297
  ln -nfs #{sf} #{previous_release_private_files[i]}
277
- CMD
298
+ CMD
299
+ end
278
300
  end
301
+ else
302
+ abort "could not rollback the code because there is no prior release"
279
303
  end
280
- else
281
- abort "could not rollback the code because there is no prior release"
282
304
  end
283
- end
284
305
 
285
306
 
286
- desc <<-DESC
287
- [internal] If a database backup from the previous release is found, dump the current
288
- database and import the backup. This task should NEVER be called standalone.
289
- DESC
290
- task :db_rollback, :except => { :no_release => true } do
291
- #FIXME: does not work
292
- if previous_release
293
- logger.info "Dumping current database and importing previous one (If one is found)."
294
- previous_db = File.join(dbbackups_path, "#{releases[-2]}.sql")
295
- import_cmd = "cd #{previous_release}/#{drupal_path} && drush sql-drop -y && drush sql-cli < #{previous_db} && rm #{previous_db}"
296
- run "if [ -e #{previous_db} ]; then #{import_cmd}; fi"
297
- else
298
- abort "could not rollback the database because there is no prior release db backups"
307
+ desc <<-DESC
308
+ [internal] If a database backup from the previous release is found, dump the current
309
+ database and import the backup. This task should NEVER be called standalone.
310
+ DESC
311
+
312
+ task :db_rollback, :except => {:no_release => true} do
313
+ #FIXME: does not work
314
+ if previous_release
315
+ logger.info "Dumping current database and importing previous one (If one is found)."
316
+ previous_db = File.join(dbbackups_path, "#{releases[-2]}.sql")
317
+ import_cmd = "cd #{previous_release}/#{drupal_path} && drush sql-drop -y && drush sql-cli < #{previous_db} && rm #{previous_db}"
318
+ run "if [ -e #{previous_db} ]; then #{import_cmd}; fi"
319
+ else
320
+ abort "could not rollback the database because there is no prior release db backups"
321
+ end
299
322
  end
300
- end
301
-
302
- end
303
323
 
304
- namespace :web do
305
- desc "Makes the application web-accessible again."
306
- task :enable do
307
- drush.ensite
308
324
  end
309
- desc "Present a maintenance page to visitors."
310
- task :disable do
311
- drush.dissite
325
+
326
+ namespace :web do
327
+ desc "Makes the application web-accessible again."
328
+ task :enable do
329
+ drush.ensite
330
+ end
331
+ desc "Present a maintenance page to visitors."
332
+ task :disable do
333
+ drush.dissite
334
+ end
312
335
  end
313
- end
314
336
 
315
- end
337
+ end
316
338
 
317
339
  # =========================
318
340
  # Drush namespace tasks
319
341
  # =========================
320
- namespace :drush do
342
+ namespace :drush do
321
343
 
322
- desc "Clear the Drupal site cache"
323
- task :cc do
324
- domain.each do |d|
325
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " cache-clear all"
344
+ desc "Trigger the environment switch."
345
+ task :env_switch do
346
+ domain.each do |d|
347
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " env-switch --force #{stage}"
348
+ end
326
349
  end
327
- end
328
350
 
329
- desc "Show features diff status"
330
- task :fd do
331
- domain.each do |d|
332
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " features-diff"
351
+ desc "Execute all migrations."
352
+ task :migrate do
353
+ domain.each do |d|
354
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " migrate-import --all"
355
+ end
333
356
  end
334
- end
335
357
 
336
- desc "Revert all enabled feature modules on your site"
337
- task :fra do
338
- domain.each do |d|
339
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " features-revert-all -y"
358
+ desc "Import translations."
359
+ task :l10n_update do
360
+ domain.each do |d|
361
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " l10n-update"
362
+ end
340
363
  end
341
- end
342
364
 
343
- desc "Force revert all enabled feature modules on your site"
344
- task :fraforce do
345
- domain.each do |d|
346
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " features-revert-all --force -y"
365
+ desc "Rebuild baseline."
366
+ task :baseline_build do
367
+ domain.each do |d|
368
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " baseline --yes"
369
+ end
347
370
  end
348
- end
349
371
 
350
- desc "Install Drupal along with modules/themes/configuration using the specified install profile"
351
- task :si do
352
- domain.each do |d|
353
- dburl = "#{db_type}://#{db_username}:#{db_password}@#{db_host}/#{db_name.gsub("%domain", d)}"
354
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush site-install #{profile} --db-url=#{dburl} --sites-subdir=#{d} --account-name=admin --account-pass=#{adminpass} --account-mail=#{sitemail} --site-mail='#{sitemail}' --site-name='#{site.gsub("%domain", d)}' -y"
372
+ desc "Clear the Drupal site cache"
373
+ task :cc do
374
+ convert_domain().each do |d|
375
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " cache-clear all"
376
+ end
355
377
  end
356
- bl
357
- end
358
378
 
359
- desc "[internal] Enable the baseline feature"
360
- task :bl do
361
- domain.each do |d|
362
- baseline.to_a.each do |bl_item|
363
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " pm-enable #{bl_item.gsub("%domain", d)} -y"
379
+ desc "Show features diff status"
380
+ task :fd do
381
+ convert_domain().each do |d|
382
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " features-diff"
364
383
  end
365
384
  end
366
- cc
367
- end
368
- desc "[internal] Enable the simpletest feature"
369
- task :enst do
370
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush pm-enable simpletest -y"
371
- cc
372
- end
373
385
 
374
- desc "[internal] Disable maintenance mode, enabling the site"
375
- task :ensite do
376
- if drupal_version == 6
377
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush vset --always-set site_offline 0"
378
- else
379
- domain.each do |d|
380
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " vset --always-set maintenance_mode 0"
386
+ desc "Revert all enabled feature modules on your site"
387
+ task :fra do
388
+ convert_domain().each do |d|
389
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " features-revert-all -y"
381
390
  end
382
391
  end
383
- end
384
392
 
385
- desc "[internal] Enable maintenance mode, disabling the site"
386
- task :dissite do
387
- if drupal_version == 6
388
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush vset --always-set site_offline 1"
389
- else
390
- domain.each do |d|
391
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " vset --always-set maintenance_mode 1"
393
+ desc "Force revert all enabled feature modules on your site"
394
+ task :fraforce do
395
+ convert_domain().each do |d|
396
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " features-revert-all --force -y"
397
+ end
398
+ end
399
+
400
+ desc "Install Drupal along with modules/themes/configuration using the specified install profile"
401
+ task :si do
402
+ convert_domain().each do |d|
403
+ dburl = "#{db_type}://#{db_username}:#{db_password}@#{db_host}/#{db_name.gsub("%domain", d)}"
404
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush site-install #{profile} --db-url=#{dburl} --sites-subdir=#{d} --account-name=admin --account-pass=#{adminpass} --account-mail=#{sitemail} --site-mail='#{sitemail}' --site-name='#{site.gsub("%domain", d)}' -y"
405
+ end
406
+ bl
407
+ end
408
+
409
+ desc "[internal] Enable the baseline feature"
410
+ task :bl do
411
+ convert_domain().each do |d|
412
+ #baseline.to_a.each do |bl_item|
413
+ convert_baseline().each do |bl_item|
414
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " pm-enable #{bl_item.gsub("%domain", d)} -y"
415
+ end
416
+ end
417
+ cc
418
+ end
419
+
420
+ desc "[internal] Enable the simpletest feature"
421
+ task :enst do
422
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush pm-enable simpletest -y"
423
+ cc
424
+ end
425
+
426
+ desc "[internal] Disable maintenance mode, enabling the site"
427
+ task :ensite do
428
+ if drupal_version == 6
429
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush vset --always-set site_offline 0"
430
+ else
431
+ convert_domain().each do |d|
432
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " vset --always-set maintenance_mode 0"
433
+ end
392
434
  end
393
435
  end
394
- end
395
436
 
396
- desc "Apply any database updates required (as with running update.php)"
397
- task :updb do
398
- domain.each do |d|
399
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " updatedb -y"
437
+ desc "[internal] Enable maintenance mode, disabling the site"
438
+ task :dissite do
439
+ if drupal_version == 6
440
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush vset --always-set site_offline 1"
441
+ else
442
+ convert_domain().each do |d|
443
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " vset --always-set maintenance_mode 1"
444
+ end
445
+ end
446
+ end
447
+
448
+ desc "Apply any database updates required (as with running update.php)"
449
+ task :updb do
450
+ convert_domain().each do |d|
451
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " updatedb -y"
452
+ end
400
453
  end
454
+
455
+ desc "Update via drush, runs fra, updb and cc"
456
+ task :update do
457
+ dissite unless no_disable
458
+ updb # database updates (also handles modules that have been moved around)
459
+ cc # fix for user_permissions constraint (install new modules)
460
+ fra # reverts all features
461
+ cc # clear cache (required for new menu items, hook_menu)
462
+ ensite unless no_disable
463
+ manage.block_robots unless enable_robots
464
+ end
465
+
401
466
  end
402
467
 
403
- desc "Update via drush, runs fra, updb and cc"
404
- task :update do
405
- dissite unless no_disable
406
- updb # database updates (also handles modules that have been moved around)
407
- cc # fix for user_permissions constraint (install new modules)
408
- fra # reverts all features
409
- cc # clear cache (required for new menu items, hook_menu)
410
- ensite unless no_disable
411
- manage.block_robots unless enable_robots
468
+ namespace :grunt do
469
+ task :default do
470
+ current_host = capture("echo $CAPISTRANO:HOST$").strip
471
+ run_locally "cd #{copy_cache}/#{theme_path} && bundle exec grunt"
472
+ run_locally "rsync -av #{copy_cache}/#{theme_path}/#{assets_path}/ #{user}@#{current_host}:#{current_path}/#{theme_path}/#{assets_path}/;"
473
+ end
412
474
  end
413
475
 
414
- end
415
476
 
416
477
  # =========================
417
478
  # Tests methods
418
479
  # =========================
419
480
 
420
- namespace :tests do
421
-
422
- desc "Test php lint"
423
- task :php_lint_test do
424
- errors = []
425
- test_files = Dir.glob( File.join( drupal_path, 'sites', '**', '*.{engine,inc,info,install,make,module,php,profile,test,theme,tpl,xtmpl}' ) )
426
- if test_files.any?
427
- test_files.each do |test_file|
428
- begin
429
- fail unless system("php -l '#{test_file}' > /dev/null")
430
- rescue
431
- errors << test_file
481
+ namespace :tests do
482
+
483
+ desc "Test php lint"
484
+ task :php_lint_test do
485
+ errors = []
486
+ test_files = Dir.glob(File.join(drupal_path, 'sites', '**', '*.{engine,inc,info,install,make,module,php,profile,test,theme,tpl,xtmpl}'))
487
+ if test_files.any?
488
+ test_files.each do |test_file|
489
+ begin
490
+ fail unless system("php -l '#{test_file}' > /dev/null")
491
+ rescue
492
+ errors << test_file
493
+ end
432
494
  end
433
495
  end
496
+ puts "Commit tests failed on files:\n" + errors.join("\n") unless errors.empty?
497
+ exit 1 unless errors.empty?
434
498
  end
435
- puts "Commit tests failed on files:\n" + errors.join( "\n" ) unless errors.empty?
436
- exit 1 unless errors.empty?
437
- end
438
499
 
439
- desc "Core hack detection"
440
- task :checksum_core_test do
500
+ desc "Core hack detection"
501
+ task :checksum_core_test do
441
502
 
442
- end
503
+ end
443
504
 
444
- desc 'Runs unit tests for given site'
445
- task :unit do
446
- run "mkdir -p #{current_path}/build/simpletest"
447
- test_files = Dir.glob( File.join( drupal_path, 'sites', '**', '*.test' ) )
448
- test_files.map! {|f| f.sub!(drupal_path + "/","")}
449
- if test_files.any?
450
- test_files.each do |test_file|
451
- run "cd #{current_path}/#{drupal_path} && php scripts/run-tests.sh --url http://#{site} --xml '../build/simpletest' --file '#{test_file}'" unless test_file.include?('/contrib/')
505
+ desc 'Runs unit tests for given site'
506
+ task :unit do
507
+ run "mkdir -p #{current_path}/build/simpletest"
508
+ test_files = Dir.glob(File.join(drupal_path, 'sites', '**', '*.test'))
509
+ test_files.map! { |f| f.sub!(drupal_path + "/", "") }
510
+ if test_files.any?
511
+ test_files.each do |test_file|
512
+ run "cd #{current_path}/#{drupal_path} && php scripts/run-tests.sh --url http://#{site} --xml '../build/simpletest' --file '#{test_file}'" unless test_file.include?('/contrib/')
513
+ end
452
514
  end
453
- end
454
515
 
455
- run "cd #{current_path}/build && tar czf simpletest.tgz simpletest"
456
- system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
457
- download "#{current_path}/build/simpletest.tgz", "build/", :once => true, :via => :scp
458
- system "tar xzf build/simpletest.tgz -C build"
516
+ run "cd #{current_path}/build && tar czf simpletest.tgz simpletest"
517
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
518
+ download "#{current_path}/build/simpletest.tgz", "build/", :once => true, :via => :scp
519
+ system "tar xzf build/simpletest.tgz -C build"
520
+
521
+ end
522
+ before "tests:unit", "drush:enst"
459
523
 
460
- end
461
- before "tests:unit", "drush:enst"
524
+ desc 'Runs all unit tests for given site'
525
+ task :unit_all do
526
+ run "mkdir -p #{current_path}/build/simpletest"
527
+ run "cd #{current_path}/#{drupal_path} && php scripts/run-tests.sh --url http://#{site} --xml '../build/simpletest' --all"
462
528
 
463
- desc 'Runs all unit tests for given site'
464
- task :unit_all do
465
- run "mkdir -p #{current_path}/build/simpletest"
466
- run "cd #{current_path}/#{drupal_path} && php scripts/run-tests.sh --url http://#{site} --xml '../build/simpletest' --all"
529
+ run "cd #{current_path}/build && tar czf simpletest.tgz simpletest"
530
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
531
+ download "#{current_path}/build/simpletest.tgz", "build/", :once => true, :via => :scp
532
+ system "tar xzf build/simpletest.tgz -C build"
467
533
 
468
- run "cd #{current_path}/build && tar czf simpletest.tgz simpletest"
469
- system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
470
- download "#{current_path}/build/simpletest.tgz", "build/", :once => true, :via => :scp
471
- system "tar xzf build/simpletest.tgz -C build"
534
+ end
535
+ before "tests:unit_all", "drush:enst"
472
536
 
473
537
  end
474
- before "tests:unit_all", "drush:enst"
475
-
476
- end
477
538
 
478
539
  # =========================
479
540
  # Manage methods
480
541
  # =========================
481
542
 
482
- namespace :manage do
543
+ namespace :manage do
483
544
 
484
- desc "Block bots via robots.txt"
485
- task :block_robots do
486
- put "User-agent: *\nDisallow: /", "#{current_path}/#{drupal_path}/robots.txt"
487
- end
545
+ desc "Block bots via robots.txt"
546
+ task :block_robots do
547
+ put "User-agent: *\nDisallow: /", "#{current_path}/#{drupal_path}/robots.txt"
548
+ end
488
549
 
489
- task :dbdump_previous do
490
- #Backup the previous release's database
491
- if previous_release && backup_database
492
- domain.each_with_index do |d,i|
493
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " sql-dump > #{ File.join(dbbackups_path[i], "#{releases[-2]}.sql") }"
550
+ task :dbdump_previous do
551
+ #Backup the previous release's database
552
+ if previous_release && backup_database
553
+ convert_domain().each_with_index do |d, i|
554
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush" + (d == 'default' ? '' : " -l #{d}") + " sql-dump > #{ File.join(dbbackups_path[i], "#{releases[-2]}.sql") }"
555
+ end
494
556
  end
495
557
  end
496
- end
497
558
 
498
- desc 'Dump remote database and restore locally'
499
- task :pull_dump do
500
- abort("ERROR: multisite not supported") if is_multisite
501
- abort("NO LOCAL DATABASE FOUND, set :local_database in the config file..") unless local_database
502
-
503
- set(:runit, Capistrano::CLI.ui.ask("WARNING!! will overwrite this local database: '#{local_database}', type 'yes' to continue: "))
504
- if runit == 'yes'
505
- sql_file = File.join(dbbackups_path, "#{releases.last}-pull.sql")
506
- # dump & gzip remote file
507
- run "cd #{current_path}/#{drupal_path} && #{drush_path}drush sql-dump > #{sql_file} && gzip -f #{sql_file}"
508
- # copy to local
509
- system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
510
- download "#{sql_file}.gz", "build/", :once => true, :via => :scp
511
- run "rm #{sql_file}.gz"
512
- # extract and restore
513
- system "gunzip -f build/#{File.basename(sql_file)}.gz && echo \"DROP DATABASE #{local_database};CREATE DATABASE #{local_database}\" | mysql && mysql #{local_database} < build/#{File.basename(sql_file)}" if local_database
514
- # check if file sanitation sql file exists
515
- if File.exists?("config/sql/#{stage}.sql")
516
- puts " * executing \"config/sql/#{stage}.sql\""
517
- system "mysql #{local_database} < config/sql/#{stage}.sql"
559
+ desc 'Dump remote database and restore locally'
560
+ task :pull_dump do
561
+ abort("ERROR: multisite not supported") if is_multisite
562
+ abort("NO LOCAL DATABASE FOUND, set :local_database in the config file..") unless local_database
563
+
564
+ set(:runit, Capistrano::CLI.ui.ask("WARNING!! will overwrite this local database: '#{local_database}', type 'yes' to continue: "))
565
+ if runit == 'yes'
566
+ sql_file = File.join(dbbackups_path, "#{releases.last}-pull.sql")
567
+ # dump & gzip remote file
568
+ run "cd #{current_path}/#{drupal_path} && #{drush_path}drush sql-dump > #{sql_file} && gzip -f #{sql_file}"
569
+ # copy to local
570
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
571
+ download "#{sql_file}.gz", "build/", :once => true, :via => :scp
572
+ run "rm #{sql_file}.gz"
573
+ # extract and restore
574
+ system "gunzip -f build/#{File.basename(sql_file)}.gz && echo \"DROP DATABASE #{local_database};CREATE DATABASE #{local_database}\" | mysql && mysql #{local_database} < build/#{File.basename(sql_file)}" if local_database
575
+ # check if file sanitation sql file exists
576
+ if File.exists?("config/sql/#{stage}.sql")
577
+ puts " * executing \"config/sql/#{stage}.sql\""
578
+ system "mysql #{local_database} < config/sql/#{stage}.sql"
579
+ end
518
580
  end
519
581
  end
520
- end
521
-
522
- desc 'Dump local database and restore remote'
523
- task :push_dump do
524
- abort("ERROR: multisite not supported") if is_multisite
525
- abort("NO LOCAL DATABASE FOUND, set :local_database in the config file..") unless local_database
526
- abort("THIS STAGE: #{stage} DOES NOT SUPPORT manage:push_dump") unless push_dump_enabled
527
582
 
528
- set(:runit, Capistrano::CLI.ui.ask("WARNING!! will overwrite this REMOTE database: '#{db_name}', type 'yes' to continue: "))
529
- if runit == 'yes'
530
- sql_file = "#{Time.now.to_i}.sql"
531
- system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
532
- # dump & gzip local file
533
- system "cd #{drupal_path} && drush sql-dump > ../build/#{sql_file} && gzip ../build/#{sql_file}"
534
- # copy to remote
535
- upload "build/#{sql_file}.gz", File.join(dbbackups_path, "#{sql_file}.gz"), :once => true, :via => :scp
536
- system "rm build/#{sql_file}.gz"
537
- # extract and restore
538
- run "gunzip -f #{File.join(dbbackups_path, "#{sql_file}.gz")} && cd #{current_path}/#{drupal_path} && #{drush_path}drush sql-cli < #{File.join(dbbackups_path, "#{sql_file}")}"
539
- run "rm #{File.join(dbbackups_path, "#{sql_file}")}"
583
+ desc 'Dump local database and restore remote'
584
+ task :push_dump do
585
+ abort("ERROR: multisite not supported") if is_multisite
586
+ abort("NO LOCAL DATABASE FOUND, set :local_database in the config file..") unless local_database
587
+ abort("THIS STAGE: #{stage} DOES NOT SUPPORT manage:push_dump") unless push_dump_enabled
588
+
589
+ set(:runit, Capistrano::CLI.ui.ask("WARNING!! will overwrite this REMOTE database: '#{db_name}', type 'yes' to continue: "))
590
+ if runit == 'yes'
591
+ sql_file = "#{Time.now.to_i}.sql"
592
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
593
+ # dump & gzip local file
594
+ system "cd #{drupal_path} && drush sql-dump > ../build/#{sql_file} && gzip ../build/#{sql_file}"
595
+ # copy to remote
596
+ upload "build/#{sql_file}.gz", File.join(dbbackups_path, "#{sql_file}.gz"), :once => true, :via => :scp
597
+ system "rm build/#{sql_file}.gz"
598
+ # extract and restore
599
+ run "gunzip -f #{File.join(dbbackups_path, "#{sql_file}.gz")} && cd #{current_path}/#{drupal_path} && #{drush_path}drush sql-cli < #{File.join(dbbackups_path, "#{sql_file}")}"
600
+ run "rm #{File.join(dbbackups_path, "#{sql_file}")}"
601
+ end
540
602
  end
541
- end
542
603
 
543
- desc 'Download files and extract locally'
544
- task :pull_files do
545
- abort("ERROR: multisite not supported") if is_multisite
546
-
547
- set(:runit, Capistrano::CLI.ui.ask("Do you want to download the files? type 'yes' to continue: "))
548
- if runit == 'yes'
549
- run "if [ ! -d #{deploy_to}/tmp ]; then mkdir #{deploy_to}/tmp; fi" # create tmp folder if needed
550
- # pack and remote file
551
- file = "#{deploy_to}/tmp/#{releases.last}.tar.gz"
552
- run "cd #{current_path}/#{drupal_path}/sites/default && tar -zcvf #{file} files/*"
553
- # copy to local
554
- system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
555
- download "#{file}", "build/", :once => true, :via => :scp
556
- run "rm #{file}"
557
- set(:extract, Capistrano::CLI.ui.ask("Do you want to extract #{File.basename(file)}? type 'yes' to continue: "))
558
- if extract == 'yes'
559
- # extract the files
560
- set(:where, Capistrano::CLI.ui.ask("Where? (default: build): "))
561
- dest = where == '' ? "build" : "#{where}"
562
- system "tar -zxvf build/#{File.basename(file)} -C #{dest}"
604
+ desc 'Download files and extract locally'
605
+ task :pull_files do
606
+ abort("ERROR: multisite not supported") if is_multisite
607
+
608
+ set(:runit, Capistrano::CLI.ui.ask("Do you want to download the files? type 'yes' to continue: "))
609
+ if runit == 'yes'
610
+ run "if [ ! -d #{deploy_to}/tmp ]; then mkdir #{deploy_to}/tmp; fi" # create tmp folder if needed
611
+ # pack and remote file
612
+ file = "#{deploy_to}/tmp/#{releases.last}.tar.gz"
613
+ run "cd #{current_path}/#{drupal_path}/sites/default && tar -zcvf #{file} files/*"
614
+ # copy to local
615
+ system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
616
+ download "#{file}", "build/", :once => true, :via => :scp
617
+ run "rm #{file}"
618
+ set(:extract, Capistrano::CLI.ui.ask("Do you want to extract #{File.basename(file)}? type 'yes' to continue: "))
619
+ if extract == 'yes'
620
+ # extract the files
621
+ set(:where, Capistrano::CLI.ui.ask("Where? (default: build): "))
622
+ dest = where == '' ? "build" : "#{where}"
623
+ system "tar -zxvf build/#{File.basename(file)} -C #{dest}"
624
+ end
563
625
  end
564
626
  end
565
627
  end
566
- end
567
628
 
568
629
  # =========================
569
630
  # Helper methods
570
631
  # =========================
571
632
 
572
633
  # Builds initial contents of the Drupal website's settings file
573
- def drupal_settings(version, domain)
574
- db_domain_name = db_name.gsub("%domain", domain)
575
- if version.to_s == '6'
576
- settings = <<-STRING
634
+
635
+ def convert_domain()
636
+ temp_dom = fetch(:domain)
637
+ if temp_dom.kind_of?(String)
638
+ temp_arr = [temp_dom]
639
+ return temp_arr
640
+ end
641
+
642
+ return temp_dom
643
+ end
644
+
645
+ def convert_baseline()
646
+ temp_bl = fetch(:baseline)
647
+ if temp_bl.kind_of?(String)
648
+ temp_arr = [temp_bl]
649
+ return temp_arr
650
+ end
651
+
652
+ return temp_bl
653
+ end
654
+
655
+ def drupal_settings(version, domain)
656
+ db_domain_name = db_name.gsub("%domain", domain)
657
+ if version.to_s == '6'
658
+ settings = <<-STRING
577
659
  <?php
578
660
  $db_url = "#{db_type}://#{db_username}:#{db_password}@#{db_host}/#{db_domain_name}";
579
661
  ini_set('arg_separator.output', '&amp;');
@@ -589,9 +671,9 @@ ini_set('session.use_cookies', 1);
589
671
  ini_set('session.use_only_cookies', 1);
590
672
  ini_set('session.use_trans_sid', 0);
591
673
  ini_set('url_rewriter.tags', '');
592
- STRING
593
- elsif version == '7'
594
- settings = <<-STRING
674
+ STRING
675
+ elsif version == '7'
676
+ settings = <<-STRING
595
677
  <?php
596
678
  $databases = array ('default' => array ('default' => array (
597
679
  'database' => '#{db_domain_name}',
@@ -614,10 +696,10 @@ if (file_exists($path)) {
614
696
  include_once($path);
615
697
  }
616
698
 
617
- STRING
618
- else
619
- abort "Unsupported Drupal version #{version}."
699
+ STRING
700
+ else
701
+ abort "Unsupported Drupal version #{version}."
702
+ end
620
703
  end
621
- end
622
704
 
623
705
  end # Capistrano::Configuration.instance.load