capdrupal 2.0.0 → 3.0.0

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
1
  ---
2
- SHA1:
3
- metadata.gz: 4cc5619d823734b1d9d997fa25c6a7088a952bec
4
- data.tar.gz: f8f0b637a41c13a58353c8ae0d11c52a2c25d751
2
+ SHA256:
3
+ metadata.gz: '042712619fa7d2d53940074bc660a4d7694d5fe35cbb1485a4cfddee98985ba9'
4
+ data.tar.gz: 36af6488a30d9d1614148a2db60ed2b3af2db7b1eb508d09b9d405fa86c8ba30
5
5
  SHA512:
6
- metadata.gz: b2e17b1992ec423f35c5a0cac4faa239da74b3fdd6eced5f1fad27a3895c5551d26d5354ea05a67894bf993c59ba59f290bfde4c3135acc2b3a1c0d453b3a544
7
- data.tar.gz: 9ab4b29438b5bf47726e7b79d3ec1bc77d5c02588a0b2345483d5c7fe21f8e8d8c344a441249409cb550c94f99f6422d4d3f92acb8e2c96f765f3f65069057a8
6
+ metadata.gz: 36b40858994b05c1a630a6eb6395e238b0ab714a642e7e4f569ddf5792e7629d89b855d13606523f435628e2ca0c97c47be8b0e14eb59070cd732ab32689684c
7
+ data.tar.gz: a3bd3657a97322ed2e235db1b6aed11efb573e6a396352e53ecb24a8350c2bc9c0cef94af2faee177283ba791f23f3f8a80bab4f8b98011eab50262fb684fff1
data/.gitignore CHANGED
@@ -1,4 +1,19 @@
1
- pkg
2
- DS_Store
3
- *.gem
1
+ ## JetBrains template
2
+ .idea/
3
+
4
+ ## Environment normalization:
5
+ /.bundle/
6
+ /vendor/bundle
7
+ /lib/bundler/man/
8
+
9
+ Gemfile.lock
10
+ .ruby-version
11
+ .ruby-gemset
12
+
13
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
14
+ .rvmrc
15
+
16
+ ## macOS template
4
17
  .DS_Store
18
+ .AppleDouble
19
+ .LSOverride
File without changes
@@ -0,0 +1,14 @@
1
+ # Capdrupal Changelog
2
+
3
+ ## 3.0.0 (2020-08-07)
4
+ - Support for Drupal 8 & Drupal 9
5
+ - Complete code refactoring
6
+
7
+ ## 0.11.0 (2016-01-21)
8
+ - Support for Drupal 8 & Drupal 9
9
+
10
+ ## 0.10.0 (2015-04-24)
11
+ - Task `deploy` do not clear cache, revert features, updatedb, etc. For this use `deploy:full` task
12
+
13
+ ## 0.9.6 (2014-06-14)
14
+ * Fix capistrano deps
@@ -0,0 +1,44 @@
1
+ # Developing on Capdrupal
2
+
3
+ * Issues should be filed at
4
+ https://github.com/antistatique/capdrupal/issues
5
+ * Pull requests can be made against
6
+ https://github.com/antistatique/capdrupal/pulls
7
+
8
+ ## 📦 Repositories
9
+
10
+ Github repo
11
+
12
+ ```bash
13
+ git remote add github https://github.com/antistatique/capdrupal.git
14
+ ```
15
+
16
+ ## 🔧 Prerequisites
17
+
18
+ First of all, you will need to have the following tools installed
19
+ globally on your environment:
20
+
21
+ * ruby
22
+ * bundle
23
+ * capistrano
24
+ * gem
25
+
26
+ ## 💎 Specify local.capdrupal Ruby gems in your Gemfile
27
+
28
+ For local development, you will need to use on your local checkout of `capdrupal`.
29
+ To achieve this goal, you may update your project `Gemfile` and use `gem "capdrupal", path: "/path/to/capdrupal"`.
30
+
31
+ Please **don't do that** as explain here https://rossta.net/blog/how-to-specify-local-ruby-gems-in-your-gemfile.html
32
+
33
+ Instead, use the `bundle config local` and declare a new `local.capdrupal` gem:
34
+
35
+ ```bash
36
+ bundle config local.capdrupal /path/to/capdrupal
37
+ ```
38
+
39
+ Though convenient, using the `:path` option in our Gemfile to point to a local gem elsewhere on our machine sets us
40
+ up for three potential problems without automated prevention:
41
+
42
+ * Committing a nonexistent lookup path on other machines
43
+ * Failing to point to the correct repository branch
44
+ * Failing to point to an existing git reference
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capdrupal.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Antistatique SA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,250 @@
1
+ # Capdrupal
2
+
3
+ This gem provides a number of tasks which are useful for deploying & managing Drupal projects with [Capistrano](https://github.com/capistrano/capistrano).
4
+
5
+ # Capdrupal version
6
+
7
+ Capdrupal Gem Version | Branch | Capistrano Version | Drupal Version
8
+ --------------------- | ------ | ------------------ | --------------
9
+ 0.11.0 | d7 | 2 | 7.x
10
+ 3.x | main | 3.x | 8.x
11
+ 3.x | main | 3.x | 9.x
12
+
13
+ ## Prerequisites
14
+
15
+ By default, Capdrupal will use **Drush** to run every Drupal commands. Therefore, your Drupal project **must** to require
16
+ `drush/drush`.
17
+
18
+ You may add Drush as a dependency using `composer require drush/drush` in your Drupal project. Read more at [drush/drush](https://github.com/drush-ops/drush).
19
+
20
+ ## Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ ```ruby
25
+ gem 'capdrupal', '~>8.0'
26
+ ```
27
+
28
+ And then execute:
29
+
30
+ ```shell
31
+ bundle
32
+ ```
33
+
34
+ Or install it yourself if [gems](http://rubygems.org) is installed on your system:
35
+
36
+ ```shell
37
+ gem install capdrupal
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ First, go to your project directory and launch Capistrano.
43
+
44
+ ```shell
45
+ cd path/to/your/drupal/project/
46
+ cap install
47
+ ```
48
+
49
+ Capistrano will create the following skeleton
50
+
51
+ ```
52
+ .
53
+ ├── Capfile
54
+ ├── config
55
+ │ └── deploy.rb
56
+ │ └── deploy
57
+ │ └── production.rb
58
+ │ └── staging.rb
59
+ ├── lib
60
+ │ └── capistrano
61
+ │ └── tasks
62
+
63
+ ```
64
+
65
+ Create two files `Capfile` and `config/deploy.rb`. Open `Capfile` and set the dependencies.
66
+
67
+ ```ruby
68
+ # Load DSL and set up stages.
69
+ require 'capistrano/setup'
70
+
71
+ # Include default deployment tasks.
72
+ require 'capistrano/deploy'
73
+
74
+ # Composer is needed to install drush on the server.
75
+ require 'capistrano/composer'
76
+
77
+ # Drupal Tasks.
78
+ require 'capdrupal/capistrano'
79
+
80
+ # Load custom tasks from `lib/capistrano/tasks` if you have any defined.
81
+ Dir.glob('config/capistrano/tasks/*.rake').each { |r| import r }
82
+ ```
83
+
84
+ Then, go to `config/deploy.rb` to set the parameters of your project. First you have to define the general information about the user, server and the app himself.
85
+
86
+ ```ruby
87
+ set :application, 'application-name'
88
+ set :repo_url, 'git@github.com:company/application.git'
89
+
90
+ server 'ssh.example.org', user: 'username', roles: %w{app db web}
91
+ ```
92
+
93
+ The specific Drupal information
94
+
95
+ ```ruby
96
+ set :install_composer, true
97
+ set :install_drush, true
98
+
99
+ set :app_path, 'web'
100
+ set :config_path, 'config/sync'
101
+
102
+ # Setup the backup before/after failed strategy.
103
+ set :backup_path, 'backups'
104
+ set :keep_backups, 5
105
+
106
+ # Link file settings.php
107
+ set :linked_files, fetch(:linked_files, []).push("#{fetch(:app_path)}/sites/default/settings.php", "drush/drush.yml")
108
+
109
+ # Link dirs files and private-files
110
+ set :linked_dirs, fetch(:linked_dirs, []).push("#{fetch(:app_path)}/sites/default/files")
111
+ ```
112
+
113
+ Then, all the others information related to your Git repository or debug level
114
+
115
+ ```ruby
116
+ # Default value for :scm is :git
117
+ set :scm, :git
118
+
119
+ # Default value for :log_level is :debug
120
+ set :log_level, :debug
121
+ ```
122
+
123
+ Finally, set the deployment to use the proper Drupal 8 strategy
124
+
125
+ ```ruby
126
+ namespace :deploy do
127
+ # Ensure everything is ready to deploy.
128
+ after "deploy:check:directories", "drupal:db:backup:check"
129
+
130
+ # Backup the database before starting a deployment and rollback on fail.
131
+ # after :updated, "drupal:db:backup"
132
+ # before :failed, "drupal:db:rollback"
133
+ # before :cleanup, "drupal:db:backup:cleanup"
134
+
135
+ # Set the maintenance Mode on your Drupal online project when deploying.
136
+ after :updated, "drupal:maintenance:on"
137
+
138
+ # Must updatedb before import configurations, E.g. when composer install new
139
+ # version of Drupal and need updatedb scheme before importing new config.
140
+ # This is executed without raise on error, because sometimes we need to do drush config-import before updatedb.
141
+ after :updated, "drupal:updatedb:silence"
142
+
143
+ # Remove the cache after the database update
144
+ after :updated, "drupal:cache:clear"
145
+ after :updated, "drupal:config:import"
146
+
147
+ # Update the database after configurations has been imported.
148
+ after :updated, "drupal:updatedb"
149
+
150
+ # Clear your Drupal 8 cache.
151
+ after :updated, "drupal:cache:clear"
152
+
153
+ # Disable the maintence on the Drupal project.
154
+ after :updated, "drupal:maintenance:off"
155
+
156
+ # Ensure permissions are properly set.
157
+ after :updated, "drupal:permissions:recommended"
158
+ after :updated, "drupal:permissions:writable_shared"
159
+
160
+ # Fix the release permissions (due to Drupal restrictive permissions)
161
+ # before deletting old release.
162
+ before :cleanup, "drupal:permissions:cleanup"
163
+ end
164
+ ```
165
+
166
+ You may now can configure your `staging.rb` and `production.rb` strategy, has you will certainly deploy on different environment
167
+
168
+ ```shell
169
+ vi config/deploy/staging.rb
170
+ ```
171
+
172
+ ```ruby
173
+ # staging.example.org
174
+ set :deploy_to, '/var/www/staging.example.org'
175
+
176
+ # set a branch for this release
177
+ set :branch, 'dev'
178
+
179
+ # Map composer and drush commands
180
+ # NOTE: If stage have different deploy_to
181
+ # you have to copy those line for each <stage_name>.rb
182
+ # See https://github.com/capistrano/composer/issues/22
183
+ SSHKit.config.command_map[:composer] = -> { shared_path.join('composer.phar') }
184
+ SSHKit.config.command_map[:drush] = -> { release_path.join('vendor/bin/drush') }
185
+ ```
186
+
187
+ ```shell
188
+ vi config/deploy/production.rb
189
+ ```
190
+
191
+ ```ruby
192
+ # www.example.org
193
+ set :deploy_to, '/var/www/example.org'
194
+
195
+ # set a branch for this release
196
+ set :branch, 'master'
197
+
198
+ # Map composer and drush commands
199
+ # NOTE: If stage have different deploy_to
200
+ # you have to copy those line for each <stage_name>.rb
201
+ # See https://github.com/capistrano/composer/issues/22
202
+ SSHKit.config.command_map[:composer] = -> { shared_path.join('composer.phar') }
203
+ SSHKit.config.command_map[:drush] = -> { release_path.join('vendor/bin/drush') }
204
+ ```
205
+
206
+ Awesome, your configuration is complete !
207
+
208
+ ## Usage
209
+
210
+ So, after configuration come action ! The first time, you have to run this command with the choosing stage.
211
+
212
+ ```shell
213
+ cap [staging|production] deploy:setup
214
+ ```
215
+
216
+ In fact, Capistrano create directories and symlink to the targeted server. The `shared` directory contains all shared files of your app who don't need to be change. `Releases` contains the different releases of your app with a number define in `deploy.rb` and finally `current` is the symlink who target the right release.
217
+
218
+ ```
219
+ example.org
220
+ ├── current -> /home/example.org/releases/20130527070530
221
+ ├── releases
222
+ │ ├── 20130527065508
223
+ │ ├── 20130527065907
224
+ │ └── 20130527070530
225
+ └── shared
226
+ ```
227
+
228
+ Now, every time you want to deploy your app !
229
+
230
+ ```
231
+ cap [staging|production] deploy
232
+ ```
233
+
234
+ And if some troubles occur, just launch the rollback command to return to the previous release.
235
+
236
+ ```
237
+ cap [staging|production] deploy:rollback
238
+ ```
239
+
240
+ You should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:
241
+
242
+ ```
243
+ cap -T
244
+ ```
245
+
246
+ ## Credits
247
+
248
+ Inspired by [capistrano-drupal](https://github.com/previousnext/capistrano-drupal).
249
+
250
+ Made by [Antistatique](https://antistatique.net) who's always looking for new talented developers ! Just mail us on [job@antistatique.net](mailto:job@antistatique.net).
@@ -0,0 +1,4 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ # Do nothing by default
4
+ task :default
@@ -1,30 +1,29 @@
1
- # coding: utf-8
2
-
3
1
  lib = File.expand_path('../lib', __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
 
6
4
  Gem::Specification.new do |spec|
7
- spec.name = 'capdrupal'
8
- spec.version = '2.0.0'
9
- spec.license = 'MIT'
10
- spec.authors = [ "Simon Perdrisat", "Gilles Doge" ]
11
- spec.email = 'gilles.doge@gmail.com'
12
- spec.homepage = %q{http://github.com/antistatique/capdrupal/}
5
+ spec.name = 'capdrupal'
6
+ spec.version = '3.0.0'
7
+ spec.authors = ['Kevin Wenger', 'Yann Lugrin', 'Gilles Doge', 'Toni Fisler', 'Simon Perdrisat', 'Robert Wohleb', 'Kim Pepper']
8
+ spec.email = ['hello@antistatique.net']
13
9
 
14
- spec.platform = Gem::Platform::RUBY
15
- spec.description = <<-DESC
16
- A set of tasks for deploying Drupal 8 projects with Capistrano 3 and the help of Drush.
10
+ spec.description = <<-DESC
11
+ A set of tasks for deploying Drupal 9, Drupal 8 and Drupal 7 projects with Capistrano and the help of Drush.
17
12
  DESC
18
- spec.summary = 'A set of tasks for deploying Drupal 8 projects with Capistrano 3'
19
-
20
-
21
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
- spec.files = `git ls-files`.split($/)
23
- specrequire_paths = ['lib']
24
-
25
- spec.add_dependency 'capistrano', '~> 3.0', '>= 3.2.0'
26
-
27
- spec.add_development_dependency 'bundler', '~> 1.3'
28
- spec.add_development_dependency 'rake', '~> 10.1'
29
-
13
+ spec.summary = 'A set of tasks for deploying and managing Drupal projects with Capistrano'
14
+ spec.homepage = %q{http://github.com/antistatique/capdrupal/}
15
+ spec.license = 'MIT'
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'capistrano', '~> 3.5'
25
+ spec.add_dependency 'capistrano-composer', '~> 0.0.6'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 2.0'
28
+ spec.add_development_dependency 'rake', '~> 10.0.0'
30
29
  end
@@ -0,0 +1,16 @@
1
+ # Documentation for maintainers
2
+
3
+ Since this is a Ruby tool used by PHP programmers it might be a good idea to document
4
+ some things.
5
+
6
+ ## Making a release
7
+
8
+ Checklist for making a release:
9
+
10
+ - Write changelog
11
+ - Update version number in `capdrupal.gemspec`
12
+ - Make a [new release with GitHub](https://github.com/antistatique/capdrupal/releases/new)
13
+ - Build the gem with `gem build capdrupal.gemspec`
14
+ - Push the gem to rubygems.org: `gem push capdrupal-X.X.X.gem`
15
+ - Add the `capdrupal-X.X.X.gem` to the GitHub release
16
+
@@ -0,0 +1,288 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :app_path, 'web'
4
+ set :config_path, 'config/sync'
5
+ set :backup_path, 'backups'
6
+ set :keep_backups, 5
7
+ set :enable_modules, []
8
+ set :disable_modules, []
9
+ end
10
+ end
11
+
12
+ namespace :drush do
13
+ desc "Install Drush - only once for bootstraping"
14
+ task :install do
15
+ on roles(:app) do
16
+ within shared_path do
17
+ execute :composer, 'require drush/drush'
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ namespace :drupal do
24
+
25
+ desc 'Run any drush command'
26
+ task :drush do
27
+ ask(:drush_command, "Drush command you want to run (eg. 'cache-clear css-js'). Type 'help' to have a list of avaible drush commands.")
28
+ on roles(:app) do
29
+ within release_path.join(fetch(:app_path)) do
30
+ execute :drush, fetch(:drush_command)
31
+ end
32
+ end
33
+ end
34
+
35
+ namespace :db do
36
+ desc "Revert the current release drupal site database backup"
37
+ task :rollback do
38
+ on roles(:app) do
39
+ within release_path.join(fetch(:app_path)) do
40
+ backup = "#{shared_path}/#{fetch(:backup_path)}/#{fetch(:stage)}_#{release_timestamp}"
41
+
42
+ # Unzip the file for rollback.
43
+ execute "gunzip #{backup}.gz"
44
+
45
+ unless test "[ -f #{backup} ]"
46
+ warn "backup file #{backup} does not exist."
47
+ next
48
+ end
49
+
50
+ # Revert from backup.
51
+ execute :drush, 'sql:drop --yes'
52
+ execute :drush, "sql:cli < #{backup}"
53
+
54
+ # Delete the unziped backup.
55
+ execute :rm, backup
56
+ end
57
+ end
58
+ end
59
+
60
+ desc "Backup drupal site database"
61
+ task :backup do
62
+ on roles(:app) do
63
+ within release_path.join(fetch(:app_path)) do
64
+ backup_destination = "#{shared_path}/#{fetch(:backup_path)}/#{fetch(:stage)}_#{release_timestamp}"
65
+ execute :drush, "sql:dump --result-file=#{backup_destination} --gzip"
66
+ end
67
+ end
68
+ end
69
+
70
+ namespace :backup do
71
+ desc "Check required files and directories exist"
72
+ task :check do
73
+ on release_roles :all do
74
+ execute :mkdir, "-p", "#{shared_path}/#{fetch(:backup_path)}"
75
+ end
76
+ end
77
+
78
+ desc "Clean up old drupal site database backup"
79
+ task :cleanup do
80
+ on roles(:app) do
81
+ within release_path.join(fetch(:app_path)) do
82
+ backup_path = "#{shared_path}/#{fetch(:backup_path)}"
83
+ keep_backups = fetch(:keep_backups, 5)
84
+
85
+ # Fetch every file from the backup directory, oldest on top.
86
+ backups = capture(:ls, "-ltrx", backup_path).split
87
+ info "Keeping #{keep_backups} of #{backups.count} backup dump on #{backup_path}."
88
+
89
+ # If we found less file than the keep number finish the task here
90
+ next "" unless backups.count > keep_backups.to_i
91
+
92
+ # Calculate number of file to delete.
93
+ to_delete = backups.count - keep_backups.to_i
94
+
95
+ # Loop throught file to delete (oldest files on top).
96
+ backups[0, to_delete].map do |backup|
97
+ execute :rm, "#{backup_path}/#{backup}"
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ namespace :cache do
106
+ desc 'Clear all caches'
107
+ task :clear do
108
+ on roles(:app) do
109
+ within release_path.join(fetch(:app_path)) do
110
+ execute :drush, 'cr'
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ namespace :module do
117
+ desc 'Enable module(s)'
118
+ task :enable do
119
+ on roles(:app) do
120
+ within release_path.join(fetch(:app_path)) do
121
+ for mod in fetch(:enable_modules)
122
+ execute :drush, "en '#{mod}' -y"
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ desc 'Disable module(s)'
129
+ task :disable do
130
+ on roles(:app) do
131
+ within release_path.join(fetch(:app_path)) do
132
+ for mod in fetch(:disable_modules)
133
+ execute :drush, "pmu '#{mod}' -y"
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+ namespace :maintenance do
141
+ desc "Set maintenance mode"
142
+ task :on do
143
+ on roles(:app) do
144
+ within release_path.join(fetch(:app_path)) do
145
+ execute :drush, "state:set system.maintenance_mode 1 -y"
146
+ execute :drush, 'cr', raise_on_non_zero_exit: false
147
+ end
148
+ end
149
+ end
150
+
151
+ desc "Remove maintenance mode"
152
+ task :off do
153
+ on roles(:app) do
154
+ within release_path.join(fetch(:app_path)) do
155
+ execute :drush, "state:set system.maintenance_mode 0 -y"
156
+ execute :drush, 'cr'
157
+ end
158
+ end
159
+ end
160
+ end
161
+
162
+ desc 'Update database with migrations scripts'
163
+ task :updatedb do
164
+ on roles(:app) do
165
+ within release_path.join(fetch(:app_path)) do
166
+ execute :drush, 'updatedb -y'
167
+ end
168
+ end
169
+ end
170
+
171
+ namespace :updatedb do
172
+ desc 'Update database with migrations scripts'
173
+ task :silence do
174
+ on roles(:app) do
175
+ within release_path.join(fetch(:app_path)) do
176
+ execute :drush, 'updatedb -y', raise_on_non_zero_exit: false
177
+ end
178
+ end
179
+ end
180
+ end
181
+
182
+ desc 'Apply pending entity schema updates'
183
+ task :entup do
184
+ on roles(:app) do
185
+ within release_path.join(fetch(:app_path)) do
186
+ execute :drush, 'entup -y'
187
+ end
188
+ end
189
+ end
190
+
191
+ namespace :config do
192
+ desc 'Import configuration to active stage'
193
+ task :import do
194
+ on roles(:app) do
195
+ try = 0
196
+ full_config_path = release_path.join(fetch(:config_path))
197
+ within release_path.join(fetch(:app_path)) do
198
+ execute :drush, "config-import -y"
199
+ rescue
200
+ try += 1
201
+ try < 5 ? retry : raise
202
+ end
203
+ end
204
+ end
205
+ end
206
+
207
+ namespace :permissions do
208
+ desc 'Set recommended Drupal permissions'
209
+ task :recommended do
210
+ on roles(:app) do
211
+ within release_path.join(fetch(:app_path)) do
212
+ execute :chmod, '-R', '555', '.'
213
+
214
+ # Remove execution for files, keep execution on folder.
215
+ execute 'find', './ -type f -executable -exec chmod -x {} \;'
216
+ execute 'find', './ -type d -exec chmod +x {} \;'
217
+ end
218
+ end
219
+ end
220
+
221
+ desc 'Set cleanup permissions to allow deletion of releases'
222
+ task :cleanup do
223
+ on roles(:app) do
224
+ releases = capture(:ls, '-x', releases_path).split
225
+ valid, invalid = releases.partition { |e| /^\d{14}$/ =~ e }
226
+
227
+ if valid.count >= fetch(:keep_releases)
228
+ directories = (valid - valid.last(fetch(:keep_releases))).map do |release|
229
+ releases_path.join(release)
230
+ end
231
+ if test("[ -d #{current_path} ]")
232
+ current_release = capture(:readlink, current_path).to_s
233
+ if directories.include?(current_release)
234
+ directories.delete(current_release)
235
+ end
236
+ end
237
+ if directories.any?
238
+ directories.each_slice(100) do |directories_batch|
239
+ execute :chmod, '-R' ,'ug+w', *directories_batch
240
+ end
241
+ end
242
+ end
243
+ end
244
+ end
245
+
246
+ desc 'Initalize shared path permissions'
247
+ task :writable_shared do
248
+ on roles(:app) do
249
+ within shared_path do
250
+ # "web/sites/default/files" is a shared dir and should be writable.
251
+ execute :chmod, '-R', '775', "#{fetch(:app_path)}/sites/default/files"
252
+
253
+ # Remove execution for files, keep execution on folder.
254
+ execute 'find', "#{fetch(:app_path)}/sites/default/files", '-type f -executable -exec chmod -x {} \;'
255
+ execute 'find', "#{fetch(:app_path)}/sites/default/files", '-type d -exec chmod +sx {} \;'
256
+ end
257
+ end
258
+ end
259
+ end
260
+
261
+ namespace :files do
262
+ desc "Download drupal sites files (from remote to local)"
263
+ task :download do
264
+ run_locally do
265
+ on release_roles :app do |server|
266
+ ask(:answer, "Do you really want to download the files on the server to your local files? Nothings will be deleted but files can be ovewrite. (y/N)");
267
+ if fetch(:answer) == 'y' then
268
+ remote_files_dir = "#{shared_path}/#{(fetch(:app_path))}/sites/default/files/"
269
+ local_files_dir = "#{(fetch(:app_path))}/sites/default/files/"
270
+ system("rsync --recursive --times --rsh=ssh --human-readable --progress --exclude='.*' --exclude='css' --exclude='js' #{server.user}@#{server.hostname}:#{remote_files_dir} #{local_files_dir}")
271
+ end
272
+ end
273
+ end
274
+ end
275
+
276
+ desc "Upload drupal sites files (from local to remote)"
277
+ task :upload do
278
+ on release_roles :app do |server|
279
+ ask(:answer, "Do you really want to upload your local files to the server? Nothings will be deleted but files can be ovewrite. (y/N)");
280
+ if fetch(:answer) == 'y' then
281
+ remote_files_dir = "#{shared_path}/#{(fetch(:app_path))}/sites/default/files/"
282
+ local_files_dir = "#{(fetch(:app_path))}/sites/default/files/"
283
+ system("rsync --recursive --times --rsh=ssh --human-readable --progress --exclude='.*' --exclude='css' --exclude='js' #{local_files_dir} #{server.user}@#{server.hostname}:#{remote_files_dir}")
284
+ end
285
+ end
286
+ end
287
+ end
288
+ end
metadata CHANGED
@@ -1,15 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capdrupal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Simon Perdrisat
7
+ - Kevin Wenger
8
+ - Yann Lugrin
8
9
  - Gilles Doge
10
+ - Toni Fisler
11
+ - Simon Perdrisat
12
+ - Robert Wohleb
13
+ - Kim Pepper
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2014-07-24 00:00:00.000000000 Z
17
+ date: 2020-08-07 00:00:00.000000000 Z
13
18
  dependencies:
14
19
  - !ruby/object:Gem::Dependency
15
20
  name: capistrano
@@ -17,62 +22,75 @@ dependencies:
17
22
  requirements:
18
23
  - - "~>"
19
24
  - !ruby/object:Gem::Version
20
- version: '3.0'
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 3.2.0
25
+ version: '3.5'
24
26
  type: :runtime
25
27
  prerelease: false
26
28
  version_requirements: !ruby/object:Gem::Requirement
27
29
  requirements:
28
30
  - - "~>"
29
31
  - !ruby/object:Gem::Version
30
- version: '3.0'
31
- - - ">="
32
+ version: '3.5'
33
+ - !ruby/object:Gem::Dependency
34
+ name: capistrano-composer
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.0.6
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
32
45
  - !ruby/object:Gem::Version
33
- version: 3.2.0
46
+ version: 0.0.6
34
47
  - !ruby/object:Gem::Dependency
35
48
  name: bundler
36
49
  requirement: !ruby/object:Gem::Requirement
37
50
  requirements:
38
51
  - - "~>"
39
52
  - !ruby/object:Gem::Version
40
- version: '1.3'
53
+ version: '2.0'
41
54
  type: :development
42
55
  prerelease: false
43
56
  version_requirements: !ruby/object:Gem::Requirement
44
57
  requirements:
45
58
  - - "~>"
46
59
  - !ruby/object:Gem::Version
47
- version: '1.3'
60
+ version: '2.0'
48
61
  - !ruby/object:Gem::Dependency
49
62
  name: rake
50
63
  requirement: !ruby/object:Gem::Requirement
51
64
  requirements:
52
65
  - - "~>"
53
66
  - !ruby/object:Gem::Version
54
- version: '10.1'
67
+ version: 10.0.0
55
68
  type: :development
56
69
  prerelease: false
57
70
  version_requirements: !ruby/object:Gem::Requirement
58
71
  requirements:
59
72
  - - "~>"
60
73
  - !ruby/object:Gem::Version
61
- version: '10.1'
62
- description: |2
63
- A set of tasks for deploying Drupal 8 projects with Capistrano 3 and the help of Drush.
64
- email: gilles.doge@gmail.com
74
+ version: 10.0.0
75
+ description: " A set of tasks for deploying Drupal 9, Drupal 8 and Drupal 7 projects
76
+ with Capistrano and the help of Drush.\n"
77
+ email:
78
+ - hello@antistatique.net
65
79
  executables: []
66
80
  extensions: []
67
81
  extra_rdoc_files: []
68
82
  files:
69
83
  - ".gitignore"
70
- - README.markdown
71
- - VERSION
84
+ - ".gitkeep"
85
+ - CHANGELOG.md
86
+ - CONTRIBUTING.md
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
72
91
  - capdrupal.gemspec
92
+ - docs/maintainers.md
73
93
  - lib/capdrupal.rb
74
- - lib/capistrano/drupal.rb
75
- - lib/capistrano/tasks/drupal.rake
76
94
  homepage: http://github.com/antistatique/capdrupal/
77
95
  licenses:
78
96
  - MIT
@@ -92,9 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
110
  - !ruby/object:Gem::Version
93
111
  version: '0'
94
112
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.2.2
113
+ rubygems_version: 3.1.2
97
114
  signing_key:
98
115
  specification_version: 4
99
- summary: A set of tasks for deploying Drupal 8 projects with Capistrano 3
116
+ summary: A set of tasks for deploying and managing Drupal projects with Capistrano
100
117
  test_files: []
@@ -1,168 +0,0 @@
1
- # Capdrupal
2
-
3
- This gem provides a number of tasks which are useful for deploying Drupal projects with [Capistrano](https://github.com/capistrano/capistrano).
4
-
5
-
6
- ## Installation
7
- [gems](http://rubygems.org) must be installed on your system first.
8
-
9
- ### From RubyGems.org
10
-
11
- $ gem install capdrupal
12
-
13
- ### From Github
14
-
15
- $ git clone git://github.com/antistatique/capdrupal.git
16
- $ cd capdrupal
17
- $ gem build capdrupal.gemspec
18
- $ gem install capdrupal-{version}.gem
19
-
20
- ### Use Bundler to avoid conflict with Capistrano 3
21
-
22
- This version use capistrano 2. Installation with [bundler](http://bundler.io/) let you use both version and avoid conflict.
23
-
24
- Create a 'Gemfile' on the root of your project
25
-
26
-
27
- group :development do
28
- gem 'capistrano', '~> 2.15.5'
29
- gem 'railsless-deploy'
30
- gem 'capdrupal'
31
- #other development gems...
32
- end
33
-
34
- Install the depencies
35
-
36
- $ bundle install
37
-
38
- Use capistrano throuw bundle
39
-
40
- $ bundle exec cap deploy
41
-
42
-
43
- ## Configuration
44
-
45
- It's highly recommended to use Git in your project, but you can also use Subversion or your favorite versionning software. This tutorial his made for multistage deployment, but you can easily use it just for one target.
46
-
47
- First, go to your project directory and launch Capistrano.
48
-
49
- $ cd path/to/your/directory/
50
- $ capify .
51
-
52
- Capistrano create two files `capfile` and `config/deploy.rb`. Open `capfile` and set the depencies.
53
-
54
- require 'rubygems'
55
- require 'capdrupal'
56
- load 'config/deploy'
57
-
58
- Then, go to `config/deploy.rb` to set the parameters of your project. First you have to define the general informations about the user, server and the app himself.
59
-
60
- # USER
61
- set :user, "name"
62
- set :group, "name"
63
- set :runner_group, "name"
64
-
65
- # APP
66
- set :application, "appName"
67
-
68
- # The domain and the path to your app directory
69
- set :domain, "staging.domain.com"
70
- set :deploy_to, "/home/path/to/my/app/"
71
-
72
- The specific Drupal informations and if you have already or not [Drush](https://drupal.org/project/drush) installed on your server (if your not sure, keep it TRUE).
73
-
74
- # DRUPAL
75
- set :app_path, "drupal"
76
- set :shared_children, ['drupal/sites/default/files']
77
- set :shared_files, ['drupal/sites/default/settings.php']
78
- set :download_drush, true
79
-
80
- Then, all the informations related to your Git repository
81
-
82
- set :scm, "git"
83
- set :repository, "git@github.com:user/repo-name.git"
84
- set :branch, "dev"
85
-
86
- Finally, set the other Capistrano related options, the number of realeases you want and the cleanup at the end of the deployment.
87
-
88
- set :use_sudo, false
89
- default_run_options[:pty] = true
90
- ssh_options[:forward_agent] = true
91
- role :app, domain
92
- role :db, domain
93
-
94
- set :keep_releases, 5
95
- after "deploy:update", "deploy:cleanup"
96
-
97
- Awesome, your configuration file is complete ! You can also use Capdrupal for [multistage](https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension).
98
-
99
-
100
- ## Usage
101
-
102
- So, after configuration come action ! The first time, you have to run this command with the choosing stage.
103
-
104
- $ cap deploy:setup
105
-
106
- In fact, Capistrano create directories and symlink to the targeted server. The `shared` directory contains all shared files of your app who don't need to be change. `Releases` contains the different releases of your app with a number define in `deploy.rb` and finally `current` is the symlink who target the right release.
107
-
108
- myApp
109
- ├── current -> /home/myApp/releases/20130527070530
110
- ├── releases
111
- │ ├── 20130527065508
112
- │ ├── 20130527065907
113
- │ └── 20130527070530
114
- └── shared
115
-
116
- Now, every time you want to deploy you app !
117
-
118
- $ cap deploy
119
-
120
- And if some troubles occur, juste launch the rollback command to return to the previous release.
121
-
122
- $ cap deploy:rollback
123
-
124
-
125
- You should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:
126
-
127
- $ cap -T
128
-
129
- This show a list of all avaible commands:
130
-
131
-
132
- cap deploy # Deploys your project.
133
- cap deploy:check # Test deployment dependencies.
134
- cap deploy:cleanup # Clean up old releases.
135
- cap deploy:cold # Deploys and starts a `cold' application.
136
- cap deploy:create_symlink # Updates the symlink to the most recently deployed version.
137
- cap deploy:pending # Displays the commits since your last deploy.
138
- cap deploy:pending:diff # Displays the `diff' since your last deploy.
139
- cap deploy:rollback # Rolls back to a previous version and restarts.
140
- cap deploy:rollback:code # Rolls back to the previously deployed version.
141
- cap deploy:setup # Prepares one or more servers for deployment.
142
- cap deploy:symlink # Deprecated.
143
- cap deploy:update # Copies your project and updates the symlink.
144
- cap deploy:update_code # Copies your project to the remote servers.
145
- cap deploy:upload # Copy files to the currently deployed version.
146
- cap dev # Set the target stage to `dev'.
147
- cap drupal:symlink_shared # Symlinks static directories and static files that need to remain between d...
148
- cap drush:backupdb # Backup the database
149
- cap drush:cache_clear # Clear the drupal cache
150
- cap drush:feature_revert # Revert feature
151
- cap drush:get # Gets drush and installs it
152
- cap drush:site_offline # Set the site offline
153
- cap drush:site_online # Set the site online
154
- cap drush:updatedb # Run Drupal database migrations if required
155
- cap files:pull # Pull drupal sites files (from remote to local)
156
- cap files:push # Push drupal sites files (from local to remote)
157
- cap git:push_deploy_tag # Place release tag into Git and push it to origin server.
158
- cap invoke # Invoke a single command on the remote servers.
159
- cap multistage:prepare # Stub out the staging config files.
160
- cap prod # Set the target stage to `prod'.
161
- cap shell # Begin an interactive Capistrano session.
162
-
163
-
164
- ## Credits
165
-
166
- Inspired by [capistrano-drupal](https://github.com/previousnext/capistrano-drupal).
167
-
168
- Made by [Antistatique](http://www.antistatique.net) who's always looking for new talented developpers ! Just mail us on [job@antistatique.net](mailto:hello@antistatique.net).
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.0.0
@@ -1 +0,0 @@
1
- load File.expand_path('../tasks/drupal.rake', __FILE__)
@@ -1,127 +0,0 @@
1
-
2
- # Load default values the capistrano 3.x way.
3
- # See https://github.com/capistrano/capistrano/pull/605
4
- namespace :load do
5
- task :defaults do
6
- set :composer_download_url, "https://getcomposer.org/installer"
7
- end
8
- end
9
-
10
-
11
- # Specific Drupal tasks
12
- namespace :drupal do
13
-
14
- desc 'Run any drush command'
15
- task :drush do
16
- ask(:drush_command, "Drush command you want to run (eg. 'cache-rebuild'). Type 'help' to have a list of avaible command.")
17
- on roles(:app) do
18
- within fetch(:drupal_path) do
19
- execute :drush, fetch(:drush_command)
20
- end
21
- end
22
- end
23
-
24
- desc 'Show logs'
25
- task :logs do
26
- on roles(:app) do
27
- within fetch(:drupal_path) do
28
- execute :drush, 'watchdog-show --tail'
29
- end
30
- end
31
- end
32
-
33
- desc 'Provides information about things that may be wrong in your Drupal installation, if any.'
34
- task :requirements do
35
- on roles(:app) do
36
- within fetch(:drupal_path) do
37
- execute :drush, 'core-requirements'
38
- end
39
- end
40
- end
41
-
42
- desc 'Open an interactive shell on a Drupal site.'
43
- task :cli do
44
- on roles(:app) do
45
- within fetch(:drupal_path) do
46
- execute :drush, 'core-cli'
47
- end
48
- end
49
- end
50
-
51
- namespace :config do
52
- desc 'List any pending database updates.'
53
- task :import do
54
- on roles(:app) do
55
- within fetch(:drupal_path) do
56
- execute :drush, 'config-import'
57
- end
58
- end
59
- end
60
- end
61
-
62
- namespace :update do
63
- desc 'List any pending database updates.'
64
- task :updatedb_status do
65
- on roles(:app) do
66
- within fetch(:drupal_path) do
67
- execute :drush, 'updatedb-status'
68
- end
69
- end
70
- end
71
-
72
- desc 'Apply any database updates required (as with running update.php).'
73
- task :updatedb do
74
- on roles(:app) do
75
- within fetch(:drupal_path) do
76
- execute :drush, 'updatedb'
77
- end
78
- end
79
- end
80
-
81
- desc 'Show a report of available minor updates to Drupal core and contrib projects.'
82
- task :updatedb_status do
83
- on roles(:app) do
84
- within fetch(:drupal_path) do
85
- execute :drush, 'pm-refresh'
86
- execute :drush, 'pm-updatestatus'
87
- end
88
- end
89
- end
90
- end
91
-
92
- namespace :cache do
93
- desc 'Clear all caches'
94
- task :clear do
95
- on roles(:app) do
96
- within fetch(:drupal_path) do
97
- execute :drush, 'cache-rebuild'
98
- end
99
- end
100
- end
101
- end
102
-
103
- end
104
-
105
- # Install composer
106
- namespace :composer do
107
- desc "Install composer"
108
- task :install do
109
- on roles(:app) do
110
- within shared_path do
111
- execute 'curl', '-s' ,fetch(:composer_download_url) , '| php'
112
- end
113
- end
114
- end
115
- end
116
-
117
- # Install drush
118
- namespace :drush do
119
- desc "Install Drush"
120
- task :install do
121
- on roles(:app) do
122
- within shared_path do
123
- execute :composer, 'require drush/drush:dev-master'
124
- end
125
- end
126
- end
127
- end