drupistrano 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.
data/README.md CHANGED
@@ -12,3 +12,4 @@
12
12
 
13
13
  * site_uri: Uri of the site as in sites/all/. Eg. example.com. Default Value: default
14
14
  * drush_path: Drush Command to use. Eg. "/opt/bin/drush". Default Value: drush
15
+ * ispconfig: Set this to true if you use ispconfig. Default value: false
@@ -0,0 +1,32 @@
1
+ Capistrano::Configuration.instance.load do
2
+ _cset(:previous_normalized) { previous_release.gsub(deploy_to, '').gsub(/^\//,'') }
3
+ _cset(:latest_normalized) { latest_release.gsub(deploy_to, '').gsub(/^\//,'') }
4
+
5
+ def symlink_configuration_cmd
6
+ if ispconfig
7
+ config_cmd = <<-CMD
8
+ cd #{current_release}/sites/#{site_uri} && \
9
+ ln -nsf ../../../../shared/sites/#{site_uri}/settings.php .
10
+ CMD
11
+ else
12
+ config_cmd = "ln -nsf #{site_config_path}/settings.php #{current_release}/sites/#{site_uri}/"
13
+ end
14
+ end
15
+
16
+ def symlink_execute_cmd
17
+ if ispconfig
18
+ "rm -f #{current_path}; cd #{deploy_to} && ln -s #{latest_normalized} current"
19
+ else
20
+ "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
21
+ end
22
+ end
23
+
24
+ def symlink_rollback_cmd
25
+ if ispconfig
26
+ "rm -f #{current_path}; cd #{deploy_to} && ln -s #{previous_normalized} current; true"
27
+ else
28
+ "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,9 @@
1
+ Capistrano::Configuration.instance.load do
2
+ # Hooks
3
+ after "deploy:update_code", "deploy:symlink_configuration"
4
+
5
+ before "deploy:symlink", "deploy:backup_db"
6
+ before "deploy:symlink", "deploy:move_default_files"
7
+ before "deploy:symlink", "deploy:revert_features"
8
+ before "deploy:symlink", "deploy:clear_cache"
9
+ end
@@ -0,0 +1,99 @@
1
+ require 'drupistrano/commands'
2
+
3
+ Capistrano::Configuration.instance.load do
4
+ # User configurable
5
+ _cset(:site_uri) { "default" }
6
+ _cset(:drush_path) { "drush" }
7
+ _cset(:ispconfig) { false }
8
+
9
+ # Change at your own risk
10
+ _cset(:normalize_asset_timestamps) { false }
11
+ _cset(:drush_cmd) { "#{drush_path} --uri=#{site_uri}" }
12
+ _cset(:site_config_path) { "#{shared_path}/sites/#{site_uri}" }
13
+
14
+ namespace :deploy do
15
+
16
+ task :start do ; end
17
+ task :stop do ; end
18
+ task :restart do ; end
19
+
20
+ desc "Backup the DB before this update"
21
+ task :backup_db, :roles => :db do
22
+ on_rollback { run "rm #{previous_release}/dump.sql" if previous_release }
23
+
24
+ if previous_release
25
+ run "cd #{previous_release} && #{drush_cmd} sql-dump > dump.sql"
26
+ end
27
+ end
28
+
29
+ desc "Move default drupal files if they exist and symlink to shared path"
30
+ task :move_default_files, :roles => :app do
31
+ run <<-CMD
32
+ if [ -d #{release_path}/sites/default/files ]; then \
33
+ cd #{release_path}/sites/default && \
34
+ rsync -avz files/ #{shared_path}/files && \
35
+ rm -rf files; \
36
+ fi; \
37
+ cd #{release_path}/sites/default && ln -nsf ../../../../shared/files/ .
38
+ CMD
39
+ end
40
+
41
+ desc "Symlink site configuration into place"
42
+ task :symlink_configuration, :roles => :app do
43
+ run <<-CMD
44
+ if [ -f #{site_config_path}/settings.php ]; then \
45
+ mkdir -p #{release_path}/sites/#{site_uri} && \
46
+ #{symlink_configuration_cmd}; \
47
+ fi
48
+ CMD
49
+ end
50
+
51
+ desc "Revert all features"
52
+ task :revert_features, :roles => :app do
53
+ if previous_release
54
+ run "cd #{current_release} && #{drush_cmd} -y features-revert-all"
55
+ end
56
+ end
57
+
58
+ desc "Clear all cache"
59
+ task :clear_cache, :roles => :app do
60
+ if previous_release
61
+ run "cd #{current_release} && #{drush_cmd} cache-clear all"
62
+ end
63
+ end
64
+
65
+ desc "Execute database updates"
66
+ task :migrate, :roles => :db do
67
+ run "cd #{current_release} && #{drush_cmd} -y updatedb"
68
+ end
69
+
70
+ desc "Setup configuration"
71
+ task :setup_configuration, :roles => :app do
72
+ run "mkdir -p #{site_config_path}"
73
+ top.upload File.join('sites', 'default', 'default.settings.php'),
74
+ File.join(site_config_path, 'settings.php')
75
+ end
76
+
77
+ # Rewrite symlink task to add support for ISPConfig
78
+ desc <<-DESC
79
+ Updates the symlink to the most recently deployed version. Capistrano works \
80
+ by putting each new release of your application in its own directory. When \
81
+ you deploy a new version, this task's job is to update the `current' symlink \
82
+ to point at the new version. You will rarely need to call this task \
83
+ directly; instead, use the `deploy' task (which performs a complete \
84
+ deploy, including `restart') or the 'update' task (which does everything \
85
+ except `restart').
86
+ DESC
87
+ task :symlink, :except => { :no_release => true } do
88
+ on_rollback do
89
+ if previous_release
90
+ run symlink_rollback_cmd
91
+ else
92
+ logger.important "no previous release to rollback to, rollback of symlink skipped"
93
+ end
94
+ end
95
+
96
+ run symlink_execute_cmd
97
+ end
98
+ end
99
+ end
@@ -1,3 +1,3 @@
1
1
  module Drupistrano
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/drupistrano.rb CHANGED
@@ -2,104 +2,5 @@ unless Capistrano::Configuration.respond_to?(:instance)
2
2
  abort "capistrano/ext/multistage requires Capistrano 2"
3
3
  end
4
4
 
5
- Capistrano::Configuration.instance.load do
6
- # Drupal Customizations
7
- _cset(:normalize_asset_timestamps) { false }
8
- _cset(:site_uri) { "default" }
9
- _cset(:drush_path) { "drush" }
10
- _cset(:drush_cmd) { "#{drush_path} --uri=#{site_uri}" }
11
- _cset(:ispconfig) { false }
12
-
13
- namespace :deploy do
14
- task :start do ; end
15
- task :stop do ; end
16
- task :restart do ; end
17
-
18
- desc "Backup the DB before this update"
19
- task :backup_db, :roles => :db do
20
- on_rollback { run "rm #{previous_release}/dump.sql" if previous_release }
21
-
22
- if previous_release
23
- run "cd #{previous_release} && #{drush_cmd} sql-dump > dump.sql"
24
- end
25
- end
26
-
27
- desc "Move default drupal files if they exist and symlink to shared path"
28
- task :move_default_files, :roles => :app do
29
- run <<-CMD
30
- if [ -d #{release_path}/sites/default/files ]; then \
31
- cd #{release_path}/sites/default && \
32
- rsync -avz files/ #{shared_path}/files && \
33
- rm -rf files; \
34
- fi; \
35
- cd #{release_path}/sites/default && ln -nsf ../../../../shared/files/ .
36
- CMD
37
- end
38
-
39
- desc "Copy site configuration into place"
40
- task :copy_configuration, :roles => :app do
41
- run <<-CMD
42
- if [ -f #{shared_path}/sites/#{site_uri}/settings.php ]; then \
43
- mkdir -p #{release_path}/sites/#{site_uri} && \
44
- cp #{shared_path}/sites/#{site_uri}/settings.php #{current_release}/sites/#{site_uri}/; \
45
- fi
46
- CMD
47
- end
48
-
49
- desc "Revert all features"
50
- task :revert_features, :roles => :app do
51
- run "cd #{current_release} && #{drush_cmd} -y features-revert-all"
52
- end
53
-
54
- desc "Clear all cache"
55
- task :clear_cache, :roles => :app do
56
- run "cd #{current_release} && #{drush_cmd} cache-clear all"
57
- end
58
-
59
- desc "Execute database updates"
60
- task :migrate, :roles => :db do
61
- run "cd #{current_release} && #{drush_cmd} -y updatedb"
62
- end
63
-
64
- # Rewrite symlink task to add support for ISPConfig
65
- desc <<-DESC
66
- Updates the symlink to the most recently deployed version. Capistrano works \
67
- by putting each new release of your application in its own directory. When \
68
- you deploy a new version, this task's job is to update the `current' symlink \
69
- to point at the new version. You will rarely need to call this task \
70
- directly; instead, use the `deploy' task (which performs a complete \
71
- deploy, including `restart') or the 'update' task (which does everything \
72
- except `restart').
73
- DESC
74
- task :symlink, :except => { :no_release => true } do
75
- if ispconfig
76
- previous_normalized = previous_release.gsub(deploy_to, '').gsub(/^\//,'')
77
- latest_normalized = latest_release.gsub(deploy_to, '').gsub(/^\//,'')
78
-
79
- rollback_cmd = "rm -f #{current_path}; cd #{deploy_to} && ln -s #{previous_normalized} current; true"
80
- symlink_cmd = "rm -f #{current_path}; cd #{deploy_to} && ln -s #{latest_normalized} current"
81
- else
82
- rollback_cmd = "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
83
- symlink_cmd = "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
84
- end
85
-
86
- on_rollback do
87
- if previous_release
88
- run rollback_cmd
89
- else
90
- logger.important "no previous release to rollback to, rollback of symlink skipped"
91
- end
92
- end
93
-
94
- run symlink_cmd
95
- end
96
- end
97
-
98
- # Hooks
99
- after "deploy:update_code", "deploy:copy_configuration"
100
-
101
- before "deploy:symlink", "deploy:backup_db"
102
- before "deploy:symlink", "deploy:move_default_files"
103
- before "deploy:symlink", "deploy:revert_features"
104
- before "deploy:symlink", "deploy:clear_cache"
105
- end
5
+ require 'drupistrano/recipe'
6
+ require 'drupistrano/hooks'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drupistrano
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jorge Dias
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-09 00:00:00 +01:00
18
+ date: 2011-02-10 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,9 @@ files:
50
50
  - Rakefile
51
51
  - drupistrano.gemspec
52
52
  - lib/drupistrano.rb
53
+ - lib/drupistrano/commands.rb
54
+ - lib/drupistrano/hooks.rb
55
+ - lib/drupistrano/recipe.rb
53
56
  - lib/drupistrano/version.rb
54
57
  has_rdoc: true
55
58
  homepage: ""