capistrano-wpcli-multisite 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gemrelease +3 -0
 - data/.gitignore +35 -0
 - data/Gemfile +4 -0
 - data/Gemfile.lock +38 -0
 - data/LICENSE +21 -0
 - data/README.md +209 -0
 - data/Rakefile +2 -0
 - data/capistrano-wpcli.gemspec +27 -0
 - data/lib/capistrano/tasks/wpcli.rake +21 -0
 - data/lib/capistrano/tasks/wpdb.rake +188 -0
 - data/lib/capistrano/tasks/wprewrite.rake +21 -0
 - data/lib/capistrano/tasks/wpuploads.rake +49 -0
 - data/lib/capistrano/wpcli/version.rb +5 -0
 - data/lib/capistrano/wpcli.rb +5 -0
 - data/lib/capistrano-wpcli.rb +0 -0
 - metadata +117 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 02c274ad6a3b2a7cb6016390acf4e51a08e48e46
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9f2b1f8a716a610d34d9ce30ee166706d8b6abdc
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ab4b84e5a0ffced6dac49c96c31e64a22e1d8414941e35e51756c864dbe6a9ea86801868b3c587abf3de05087e21358fbae79c4432c94d5e87b8bba7779ffcc8
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a5e49f7f5c6b5ec467501df1ca8bc1cd97ba7fd6ce2b832ab60fd30caef02764bcd79d259b12cd13f60cb73afe4546194844ee12173dc811b103b73840300ccd
         
     | 
    
        data/.gemrelease
    ADDED
    
    
    
        data/.gitignore
    ADDED
    
    | 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            *.gem
         
     | 
| 
      
 2 
     | 
    
         
            +
            *.rbc
         
     | 
| 
      
 3 
     | 
    
         
            +
            /.config
         
     | 
| 
      
 4 
     | 
    
         
            +
            /coverage/
         
     | 
| 
      
 5 
     | 
    
         
            +
            /InstalledFiles
         
     | 
| 
      
 6 
     | 
    
         
            +
            /pkg/
         
     | 
| 
      
 7 
     | 
    
         
            +
            /spec/reports/
         
     | 
| 
      
 8 
     | 
    
         
            +
            /test/tmp/
         
     | 
| 
      
 9 
     | 
    
         
            +
            /test/version_tmp/
         
     | 
| 
      
 10 
     | 
    
         
            +
            /tmp/
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ## Specific to RubyMotion:
         
     | 
| 
      
 13 
     | 
    
         
            +
            .dat*
         
     | 
| 
      
 14 
     | 
    
         
            +
            .repl_history
         
     | 
| 
      
 15 
     | 
    
         
            +
            build/
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ## Documentation cache and generated files:
         
     | 
| 
      
 18 
     | 
    
         
            +
            /.yardoc/
         
     | 
| 
      
 19 
     | 
    
         
            +
            /_yardoc/
         
     | 
| 
      
 20 
     | 
    
         
            +
            /doc/
         
     | 
| 
      
 21 
     | 
    
         
            +
            /rdoc/
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## Environment normalisation:
         
     | 
| 
      
 24 
     | 
    
         
            +
            /.bundle/
         
     | 
| 
      
 25 
     | 
    
         
            +
            /lib/bundler/man/
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            # for a library or gem, you might want to ignore these files since the code is
         
     | 
| 
      
 28 
     | 
    
         
            +
            # intended to run in multiple environments; otherwise, check them in:
         
     | 
| 
      
 29 
     | 
    
         
            +
            # Gemfile.lock
         
     | 
| 
      
 30 
     | 
    
         
            +
            # .ruby-version
         
     | 
| 
      
 31 
     | 
    
         
            +
            # .ruby-gemset
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
         
     | 
| 
      
 34 
     | 
    
         
            +
            .rvmrc
         
     | 
| 
      
 35 
     | 
    
         
            +
            .DS_Store
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            PATH
         
     | 
| 
      
 2 
     | 
    
         
            +
              remote: .
         
     | 
| 
      
 3 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                capistrano-wpcli (0.1.5)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  capistrano (~> 3.6)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  sshkit (~> 1.11)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            GEM
         
     | 
| 
      
 9 
     | 
    
         
            +
              remote: https://rubygems.org/
         
     | 
| 
      
 10 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 11 
     | 
    
         
            +
                airbrussh (1.1.1)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  sshkit (>= 1.6.1, != 1.7.0)
         
     | 
| 
      
 13 
     | 
    
         
            +
                capistrano (3.7.1)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  airbrussh (>= 1.0.0)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  capistrano-harrow
         
     | 
| 
      
 16 
     | 
    
         
            +
                  i18n
         
     | 
| 
      
 17 
     | 
    
         
            +
                  rake (>= 10.0.0)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  sshkit (>= 1.9.0)
         
     | 
| 
      
 19 
     | 
    
         
            +
                capistrano-harrow (0.5.3)
         
     | 
| 
      
 20 
     | 
    
         
            +
                i18n (0.7.0)
         
     | 
| 
      
 21 
     | 
    
         
            +
                net-scp (1.2.1)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  net-ssh (>= 2.6.5)
         
     | 
| 
      
 23 
     | 
    
         
            +
                net-ssh (3.2.0)
         
     | 
| 
      
 24 
     | 
    
         
            +
                rake (13.0.1)
         
     | 
| 
      
 25 
     | 
    
         
            +
                sshkit (1.11.5)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  net-scp (>= 1.1.2)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  net-ssh (>= 2.8.0)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            PLATFORMS
         
     | 
| 
      
 30 
     | 
    
         
            +
              ruby
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            DEPENDENCIES
         
     | 
| 
      
 33 
     | 
    
         
            +
              bundler (~> 1.12)
         
     | 
| 
      
 34 
     | 
    
         
            +
              capistrano-wpcli!
         
     | 
| 
      
 35 
     | 
    
         
            +
              rake (~> 13.0)
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            BUNDLED WITH
         
     | 
| 
      
 38 
     | 
    
         
            +
               1.13.6
         
     | 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2014 lavmeiker
         
     | 
| 
      
 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 all
         
     | 
| 
      
 13 
     | 
    
         
            +
            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 THE
         
     | 
| 
      
 21 
     | 
    
         
            +
            SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,209 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Capistrano::WPCLI
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            **Note: this plugin works only with Capistrano 3.**
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Provides command line tools to facilitate Wordpress deploy.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## Multisite database support changes for The Number!
         
     | 
| 
      
 8 
     | 
    
         
            +
            We have added some changes to allow wordpress search-replace to modify all domains and subdomains for wp multisites.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            ### Configuration
         
     | 
| 
      
 11 
     | 
    
         
            +
            #### For Multisite
         
     | 
| 
      
 12 
     | 
    
         
            +
            `:wp_cli_local_url` and `:wp_cli_remote_url` have been replaced with `:wp_cli_local_urls` and `:wp_cli_remote_urls` which take an array of domain names including subdomains, but **excluding** the protocol (`http://` or `https://`).
         
     | 
| 
      
 13 
     | 
    
         
            +
            ##### Important!
         
     | 
| 
      
 14 
     | 
    
         
            +
            Your domains in `:wp_cli_local_urls` and `:wp_cli_remote_urls` arrays must be the same length. Since it subs out the each domain with the matching index on the other array.
         
     | 
| 
      
 15 
     | 
    
         
            +
            ##### Example:
         
     | 
| 
      
 16 
     | 
    
         
            +
            In deploy.rb
         
     | 
| 
      
 17 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 18 
     | 
    
         
            +
            set :wp_cli_local_urls, ['sub.domain.test:8888', 'sub2.domain.test:8888', 'sub3.domain2.test:8888']
         
     | 
| 
      
 19 
     | 
    
         
            +
            ```
         
     | 
| 
      
 20 
     | 
    
         
            +
            In production.rb
         
     | 
| 
      
 21 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 22 
     | 
    
         
            +
            set :wp_cli_remote_urls, ['sub.domain.com', 'sub2.domain.com', 'sub3.domain2.com']
         
     | 
| 
      
 23 
     | 
    
         
            +
            ```
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ### How it works
         
     | 
| 
      
 26 
     | 
    
         
            +
                wpcli:db:pull
         
     | 
| 
      
 27 
     | 
    
         
            +
            1. Replaces your local db with a copy of the remote db (same as always)
         
     | 
| 
      
 28 
     | 
    
         
            +
            2. Loops through `:wp_cli_remote_urls` array
         
     | 
| 
      
 29 
     | 
    
         
            +
            3. Runs `wp search-replace` on the entire db changing all instances of `remote_url` value with `wp_cli_local_urls` value on the same index.
         
     | 
| 
      
 30 
     | 
    
         
            +
            4. Runs `wp search-replace` to change the protocol from `https://` to `http://`. This has to be done seperately because there are a few places where the url is stored without the protocol and we want to catch those in our first search-replace.
         
     | 
| 
      
 31 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 32 
     | 
    
         
            +
                wpcli:db:push
         
     | 
| 
      
 33 
     | 
    
         
            +
            1. Replaces your remote db with a copy of the local db (same as always)
         
     | 
| 
      
 34 
     | 
    
         
            +
            2. Loops through `:wp_cli_local_urls` array
         
     | 
| 
      
 35 
     | 
    
         
            +
            3. Runs `wp search-replace` on the entire db changing all instances of `local_url` value with `wp_cli_remote_url` value on the same index.
         
     | 
| 
      
 36 
     | 
    
         
            +
            4. Runs `wp search-replace` to change the protocol from `http://` to `https://`. This has to be done seperately because there are a few places where the url is stored without the protocol and we want to catch those in our first search-replace.
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            #### For Single Site
         
     | 
| 
      
 39 
     | 
    
         
            +
            Gem works the same as the default. (See below)
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 44 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 45 
     | 
    
         
            +
            gem 'capistrano-wpcli', :git => 'https://github.com/thenumber/capistrano-wpcli'
         
     | 
| 
      
 46 
     | 
    
         
            +
            ```
         
     | 
| 
      
 47 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            All you need to do is put the following in `Capfile` file:
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                require 'capistrano/wpcli'
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            ### How it works (Tasks)
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                wpcli:run
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            Executes the WP-CLI command passed as parameter.
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                cap production wpcli:run["core language install fr_FR"]
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                wpcli:db:push
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            Pushes the local WP database to the remote server and replaces the urls.
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            Optionally backs up the remote database before pushing (if `wpcli_backup_db` is set to true, see Configuration).
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                cap production wpcli:db:push
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                wpcli:db:pull
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            Pulls the remote server WP database to local and replaces the urls.
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                cap production wpcli:db:pull
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                wpcli:db:backup:remote
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            Pulls the remote server WP database to localhost, uses `wpcli_local_db_backup_dir` to define the location of the export.
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                wpcli:db:backup:local
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            Backs up the local WP database to localhost, uses `wpcli_local_db_backup_dir` to define the location of the export.
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                wpcli:rewrite:flush
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            Flush rewrite rules.
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                wpcli:rewrite:hard_flush
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
            Perform a hard flush - updates `.htaccess` rules as well as rewrite rules in database.
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                wpcli:uploads:rsync:push
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            Push local uploads delta to remote machine using rsync.
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                wpcli:uploads:rsync:pull
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            Pull remote uploads delta to local machine using rsync.
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            ### Configuration
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            This plugin needs some configuration to work properly. You can put all your configs in Capistrano stage files i.e. `config/deploy/production.rb`.
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
            Here's the list of options and the defaults for each option:
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                set :wpcli_remote_url
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            Url of the WP root installation on the remote server (used by search-replace command).
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                set :wpcli_local_url
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            Url of the WP root installation on the local server (used by search-replace command).
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                set :local_tmp_dir
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
            Absolute path to local directory temporary directory which is read and writeable.
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
            Defaults to `/tmp`
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                set :wpcli_backup_db
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
            Set to true if you would like to create backups of databases on each push. Defaults to false.
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                set :wpcli_local_db_backup_dir
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
            Absolute or relative path to local directory for storing database backups which is read and writeable.
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
            Defaults to `config/backup`
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
            **IMPORTANT: Make sure to add the folder to .gitignore to prevent db backups from being in version control.**
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                set :wpcli_args
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
            You can pass arguments directly to WPCLI using this var.
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
            Defaults to `ENV['WPCLI_ARGS']`
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
                set :wpcli_local_uploads_dir
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
            Absolute or relative path to local WP uploads directory.
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
            Defaults to `web/app/uploads/`.
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
            **IMPORTANT: Add trailing slash!**
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
            - - -
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                set :wpcli_remote_uploads_dir
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
            Absolute path to remote wordpress uploads directory.
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            Defaults to `#{shared_path.to_s}/web/app/uploads/`
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
            **IMPORTANT: Add trailing slash!**
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
            ### FAQ
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
            - What if i want to use a custom port for rsync?
         
     | 
| 
      
 192 
     | 
    
         
            +
              You can by setting your port somewhere inside the :ssh_options precedence.
         
     | 
| 
      
 193 
     | 
    
         
            +
              See here: http://capistranorb.com/documentation/advanced-features/properties/#precedence
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
            ### Vagrant
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
            If you are using another machine as a development server (Vagrant for example), you should define a `dev` role and indicate the path where the project lives on that server. This normally goes on `deploy.rb` file. Here's an example:
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                server "example.dev", user: 'vagrant', password: 'vagrant', roles: %w{dev}
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                set :dev_path, '/srv/www/example.dev/current'
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
            1. Fork it ( https://github.com/lavmeiker/capistrano-wpcli/fork )
         
     | 
| 
      
 206 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 207 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 208 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 209 
     | 
    
         
            +
            5. Create a new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'capistrano/wpcli/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "capistrano-wpcli-multisite"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = Capistrano::Wpcli::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Juancito Arias", "Jeremy Zahner", "Jacob Galati"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["tech@thenumber.ca"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = %q{Simple Capistrano wrapper around WP-CLI}
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = %q{Capistrano tasks for managing Wordpress a fork of https://github.com/lavmeiker/capistrano-wpcli}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.homepage      = "https://github.com/thenumber/capistrano-wpcli"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 17 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_dependency 'capistrano', '~> 3.6'
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_dependency 'sshkit', '~> 1.11'
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.12"
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 13.0"
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            namespace :load do
         
     | 
| 
      
 2 
     | 
    
         
            +
              task :defaults do
         
     | 
| 
      
 3 
     | 
    
         
            +
                set :wp_roles, :all
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                # You can pass parameters to WPCLI setting
         
     | 
| 
      
 6 
     | 
    
         
            +
                # env var WPCLI_ARGS on each run
         
     | 
| 
      
 7 
     | 
    
         
            +
                set :wpcli_args, ENV['WPCLI_ARGS']
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            namespace :wpcli do
         
     | 
| 
      
 12 
     | 
    
         
            +
              desc "Runs a WP-CLI command"
         
     | 
| 
      
 13 
     | 
    
         
            +
              task :run, :command do |t, args|
         
     | 
| 
      
 14 
     | 
    
         
            +
                args.with_defaults(:command => :help)
         
     | 
| 
      
 15 
     | 
    
         
            +
                on release_roles(fetch(:wp_roles)) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  within release_path do
         
     | 
| 
      
 17 
     | 
    
         
            +
                    execute :wp, args[:command], fetch(:wpcli_args)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,188 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            namespace :load do
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              task :defaults do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                # The url under which the wordpress installation is
         
     | 
| 
      
 6 
     | 
    
         
            +
                # available on the remote server
         
     | 
| 
      
 7 
     | 
    
         
            +
                set :wpcli_remote_url, "http://example.com"
         
     | 
| 
      
 8 
     | 
    
         
            +
                # array of domains for use on multisites
         
     | 
| 
      
 9 
     | 
    
         
            +
                set :wpcli_remote_urls, []
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                # The url under which the wordpress installation is
         
     | 
| 
      
 12 
     | 
    
         
            +
                # available on the local server
         
     | 
| 
      
 13 
     | 
    
         
            +
                set :wpcli_local_url, "http://example.dev"
         
     | 
| 
      
 14 
     | 
    
         
            +
                # array of local domains for use on multisite
         
     | 
| 
      
 15 
     | 
    
         
            +
                set :wpcli_local_urls, []
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # A local temp dir which is read and writeable
         
     | 
| 
      
 19 
     | 
    
         
            +
                set :local_tmp_dir, "/tmp"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                # Use current time for annotating the backup file
         
     | 
| 
      
 22 
     | 
    
         
            +
                set :current_time, -> { Time.now.strftime("%Y%m%d%H%M") }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                # Boolean to determine wether the database should be backed up or not
         
     | 
| 
      
 25 
     | 
    
         
            +
                set :wpcli_backup_db, false
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                # Set the location of the db backup files. This is relative to the local project root path.
         
     | 
| 
      
 28 
     | 
    
         
            +
                set :wpcli_local_db_backup_dir, "config/backup"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                # Temporary db dumps path
         
     | 
| 
      
 31 
     | 
    
         
            +
                set :wpcli_remote_db_file, -> {"#{fetch(:tmp_dir)}/wpcli_database.sql.gz"}
         
     | 
| 
      
 32 
     | 
    
         
            +
                set :wpcli_local_db_file, -> {"#{fetch(:local_tmp_dir)}/wpcli_database.sql.gz"}
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                # Backup file filename
         
     | 
| 
      
 35 
     | 
    
         
            +
                set :wpcli_local_db_backup_filename, -> {"db_#{fetch(:stage)}_#{fetch(:current_time)}.sql.gz"}
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            namespace :wpcli do
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              namespace :db do
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                desc "Pull the remote data"
         
     | 
| 
      
 46 
     | 
    
         
            +
                task :pull do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  on roles(:web) do
         
     | 
| 
      
 48 
     | 
    
         
            +
                    within release_path do
         
     | 
| 
      
 49 
     | 
    
         
            +
                      execute :wp, :db, :export, "- |", :gzip, ">", fetch(:wpcli_remote_db_file)
         
     | 
| 
      
 50 
     | 
    
         
            +
                      download! fetch(:wpcli_remote_db_file), fetch(:wpcli_local_db_file)
         
     | 
| 
      
 51 
     | 
    
         
            +
                      execute :rm, fetch(:wpcli_remote_db_file)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  unless roles(:dev).empty?
         
     | 
| 
      
 56 
     | 
    
         
            +
                    on roles(:dev) do
         
     | 
| 
      
 57 
     | 
    
         
            +
                      within fetch(:dev_path) do
         
     | 
| 
      
 58 
     | 
    
         
            +
                        local_tmp_file = fetch(:wpcli_local_db_file).gsub(/\.gz$/, "")
         
     | 
| 
      
 59 
     | 
    
         
            +
                        upload! fetch(:wpcli_local_db_file), fetch(:wpcli_local_db_file)
         
     | 
| 
      
 60 
     | 
    
         
            +
                        execute :gunzip, "-c", fetch(:wpcli_local_db_file), ">", local_tmp_file
         
     | 
| 
      
 61 
     | 
    
         
            +
                        execute :wp, :db, :import, local_tmp_file
         
     | 
| 
      
 62 
     | 
    
         
            +
                        execute :rm, fetch(:wpcli_local_db_file), local_tmp_file
         
     | 
| 
      
 63 
     | 
    
         
            +
                        if fetch(:wpcli_remote_urls).length > 0 || fetch(:wpcli_local_urls).length > 0
         
     | 
| 
      
 64 
     | 
    
         
            +
                          if fetch(:wpcli_remote_urls).length == fetch(:wpcli_local_urls).length
         
     | 
| 
      
 65 
     | 
    
         
            +
                            fetch(:wpcli_remote_urls).each_with_index do |url, i|
         
     | 
| 
      
 66 
     | 
    
         
            +
                              execute :wp, "search-replace", url, fetch(:wpcli_local_urls)[i], fetch(:wpcli_args) || "--skip-columns=guid", "--all-tables-with-prefix=wp"
         
     | 
| 
      
 67 
     | 
    
         
            +
                              execute :wp, "search-replace", "https://#{url}", "http://#{url}", fetch(:wpcli_args) || "--skip-columns=guid", "--all-tables-with-prefix=wp"
         
     | 
| 
      
 68 
     | 
    
         
            +
                            end
         
     | 
| 
      
 69 
     | 
    
         
            +
                          else
         
     | 
| 
      
 70 
     | 
    
         
            +
                            error = CommandError.new("remote_urls array and local_urls array not the same length")
         
     | 
| 
      
 71 
     | 
    
         
            +
                            raise error
         
     | 
| 
      
 72 
     | 
    
         
            +
                          end
         
     | 
| 
      
 73 
     | 
    
         
            +
                        else
         
     | 
| 
      
 74 
     | 
    
         
            +
                          execute :wp, "search-replace", fetch(:wpcli_remote_url), fetch(:wpcli_local_url), fetch(:wpcli_args) || "--skip-columns=guid", "--url=" + fetch(:wpcli_remote_url)
         
     | 
| 
      
 75 
     | 
    
         
            +
                        end
         
     | 
| 
      
 76 
     | 
    
         
            +
                      end
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end
         
     | 
| 
      
 78 
     | 
    
         
            +
                    run_locally do
         
     | 
| 
      
 79 
     | 
    
         
            +
                      execute :rm, fetch(:wpcli_local_db_file)
         
     | 
| 
      
 80 
     | 
    
         
            +
                    end
         
     | 
| 
      
 81 
     | 
    
         
            +
                  else
         
     | 
| 
      
 82 
     | 
    
         
            +
                    run_locally do
         
     | 
| 
      
 83 
     | 
    
         
            +
                      local_tmp_file = fetch(:wpcli_local_db_file).gsub(/\.gz$/, "")
         
     | 
| 
      
 84 
     | 
    
         
            +
                      execute :gunzip, "-c", fetch(:wpcli_local_db_file), ">", local_tmp_file
         
     | 
| 
      
 85 
     | 
    
         
            +
                      execute :wp, :db, :import, local_tmp_file
         
     | 
| 
      
 86 
     | 
    
         
            +
                      execute :rm, fetch(:wpcli_local_db_file), local_tmp_file
         
     | 
| 
      
 87 
     | 
    
         
            +
                      if fetch(:wpcli_remote_urls).length > 0 || fetch(:wpcli_local_urls).length > 0
         
     | 
| 
      
 88 
     | 
    
         
            +
                        if fetch(:wpcli_remote_urls).length == fetch(:wpcli_local_urls).length
         
     | 
| 
      
 89 
     | 
    
         
            +
                          fetch(:wpcli_remote_urls).each_with_index do |url, i|
         
     | 
| 
      
 90 
     | 
    
         
            +
                            execute :wp, "search-replace", url, fetch(:wpcli_local_urls)[i], fetch(:wpcli_args) || "--skip-columns=guid", "--all-tables-with-prefix=wp"
         
     | 
| 
      
 91 
     | 
    
         
            +
                            execute :wp, "search-replace", "https://#{url}", "http://#{url}", fetch(:wpcli_args) || "--skip-columns=guid", "--all-tables-with-prefix=wp"
         
     | 
| 
      
 92 
     | 
    
         
            +
                          end
         
     | 
| 
      
 93 
     | 
    
         
            +
                        else
         
     | 
| 
      
 94 
     | 
    
         
            +
                          error = CommandError.new("remote_urls array and local_urls array not the same length")
         
     | 
| 
      
 95 
     | 
    
         
            +
                          raise error
         
     | 
| 
      
 96 
     | 
    
         
            +
                        end
         
     | 
| 
      
 97 
     | 
    
         
            +
                      else
         
     | 
| 
      
 98 
     | 
    
         
            +
                        execute :wp, "search-replace", fetch(:wpcli_remote_url), fetch(:wpcli_local_url), fetch(:wpcli_args) || "--skip-columns=guid", "--url=" + fetch(:wpcli_remote_url)
         
     | 
| 
      
 99 
     | 
    
         
            +
                      end
         
     | 
| 
      
 100 
     | 
    
         
            +
                    end
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                desc "Push the local database"
         
     | 
| 
      
 105 
     | 
    
         
            +
                task :push do
         
     | 
| 
      
 106 
     | 
    
         
            +
                  unless roles(:dev).empty?
         
     | 
| 
      
 107 
     | 
    
         
            +
                    on roles(:dev) do
         
     | 
| 
      
 108 
     | 
    
         
            +
                      within fetch(:dev_path) do
         
     | 
| 
      
 109 
     | 
    
         
            +
                        execute :wp, :db, :export, "- |", :gzip, ">", fetch(:wpcli_local_db_file)
         
     | 
| 
      
 110 
     | 
    
         
            +
                        download! fetch(:wpcli_local_db_file), fetch(:wpcli_local_db_file)
         
     | 
| 
      
 111 
     | 
    
         
            +
                      end
         
     | 
| 
      
 112 
     | 
    
         
            +
                    end
         
     | 
| 
      
 113 
     | 
    
         
            +
                  else
         
     | 
| 
      
 114 
     | 
    
         
            +
                    run_locally do
         
     | 
| 
      
 115 
     | 
    
         
            +
                      execute :wp, :db, :export, "- |", :gzip, ">", fetch(:wpcli_local_db_file)
         
     | 
| 
      
 116 
     | 
    
         
            +
                    end
         
     | 
| 
      
 117 
     | 
    
         
            +
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
                  on roles(:web) do
         
     | 
| 
      
 119 
     | 
    
         
            +
                    upload! fetch(:wpcli_local_db_file), fetch(:wpcli_remote_db_file)
         
     | 
| 
      
 120 
     | 
    
         
            +
                    within release_path do
         
     | 
| 
      
 121 
     | 
    
         
            +
                      remote_tmp_file = fetch(:wpcli_remote_db_file).gsub(/\.gz$/, "")
         
     | 
| 
      
 122 
     | 
    
         
            +
                      execute :gunzip, "-c", fetch(:wpcli_remote_db_file), ">", remote_tmp_file
         
     | 
| 
      
 123 
     | 
    
         
            +
                      execute :wp, :db, :import, remote_tmp_file
         
     | 
| 
      
 124 
     | 
    
         
            +
                      execute :rm, fetch(:wpcli_remote_db_file), remote_tmp_file
         
     | 
| 
      
 125 
     | 
    
         
            +
                      if fetch(:wpcli_remote_urls).length > 0 || fetch(:wpcli_local_urls).length > 0
         
     | 
| 
      
 126 
     | 
    
         
            +
                        if fetch(:wpcli_remote_urls).length == fetch(:wpcli_local_urls).length
         
     | 
| 
      
 127 
     | 
    
         
            +
                          fetch(:wpcli_local_urls).each_with_index do |url, i|
         
     | 
| 
      
 128 
     | 
    
         
            +
                            execute :wp, "search-replace", url, fetch(:wpcli_remote_urls)[i], fetch(:wpcli_args) || "--skip-columns=guid", "--all-tables-with-prefix=wp"
         
     | 
| 
      
 129 
     | 
    
         
            +
                            execute :wp, "search-replace", "http://#{url}", "https://#{url}", fetch(:wpcli_args) || "--skip-columns=guid", "--all-tables-with-prefix=wp"
         
     | 
| 
      
 130 
     | 
    
         
            +
                          end
         
     | 
| 
      
 131 
     | 
    
         
            +
                        else
         
     | 
| 
      
 132 
     | 
    
         
            +
                          error = CommandError.new("remote_urls array and local_urls array not the same length")
         
     | 
| 
      
 133 
     | 
    
         
            +
                          raise error
         
     | 
| 
      
 134 
     | 
    
         
            +
                        end
         
     | 
| 
      
 135 
     | 
    
         
            +
                      else
         
     | 
| 
      
 136 
     | 
    
         
            +
                        execute :wp, "search-replace", fetch(:wpcli_local_url), fetch(:wpcli_remote_url), fetch(:wpcli_args) || "--skip-columns=guid", "--url=" + fetch(:wpcli_local_url)
         
     | 
| 
      
 137 
     | 
    
         
            +
                      end
         
     | 
| 
      
 138 
     | 
    
         
            +
                    end
         
     | 
| 
      
 139 
     | 
    
         
            +
                  end
         
     | 
| 
      
 140 
     | 
    
         
            +
                  unless roles(:dev).empty?
         
     | 
| 
      
 141 
     | 
    
         
            +
                    on roles(:dev) do
         
     | 
| 
      
 142 
     | 
    
         
            +
                      within fetch(:dev_path) do
         
     | 
| 
      
 143 
     | 
    
         
            +
                        execute :rm, fetch(:wpcli_local_db_file)
         
     | 
| 
      
 144 
     | 
    
         
            +
                      end
         
     | 
| 
      
 145 
     | 
    
         
            +
                    end
         
     | 
| 
      
 146 
     | 
    
         
            +
                  end
         
     | 
| 
      
 147 
     | 
    
         
            +
                  run_locally do
         
     | 
| 
      
 148 
     | 
    
         
            +
                    execute :rm, fetch(:wpcli_local_db_file)
         
     | 
| 
      
 149 
     | 
    
         
            +
                  end
         
     | 
| 
      
 150 
     | 
    
         
            +
                end
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                namespace :backup do
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                  desc "Checking / Creating backup directory"
         
     | 
| 
      
 155 
     | 
    
         
            +
                  task :create_backup_dir do
         
     | 
| 
      
 156 
     | 
    
         
            +
                    run_locally do
         
     | 
| 
      
 157 
     | 
    
         
            +
                      unless test("[ -d #{fetch(:wpcli_local_db_backup_dir)} ]")
         
     | 
| 
      
 158 
     | 
    
         
            +
                        execute :mkdir, Pathname.new(fetch(:wpcli_local_db_backup_dir))
         
     | 
| 
      
 159 
     | 
    
         
            +
                      end
         
     | 
| 
      
 160 
     | 
    
         
            +
                    end
         
     | 
| 
      
 161 
     | 
    
         
            +
                  end
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                  desc "Backup the remote database"
         
     | 
| 
      
 164 
     | 
    
         
            +
                  task :remote do
         
     | 
| 
      
 165 
     | 
    
         
            +
                    on roles(:web) do
         
     | 
| 
      
 166 
     | 
    
         
            +
                      within release_path do
         
     | 
| 
      
 167 
     | 
    
         
            +
                        execute :wp, :db, :export, "- |", :gzip, ">", fetch(:wpcli_remote_db_file)
         
     | 
| 
      
 168 
     | 
    
         
            +
                        download! fetch(:wpcli_remote_db_file), File.join(fetch(:wpcli_local_db_backup_dir), fetch(:wpcli_local_db_backup_filename))
         
     | 
| 
      
 169 
     | 
    
         
            +
                        execute :rm, fetch(:wpcli_remote_db_file)
         
     | 
| 
      
 170 
     | 
    
         
            +
                      end
         
     | 
| 
      
 171 
     | 
    
         
            +
                    end
         
     | 
| 
      
 172 
     | 
    
         
            +
                  end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
                  desc "Backup the local database"
         
     | 
| 
      
 175 
     | 
    
         
            +
                  task :local do
         
     | 
| 
      
 176 
     | 
    
         
            +
                    run_locally do
         
     | 
| 
      
 177 
     | 
    
         
            +
                      set :stage, :local
         
     | 
| 
      
 178 
     | 
    
         
            +
                      execute :wp, :db, :export, "- |", :gzip, ">", File.join(fetch(:wpcli_local_db_backup_dir), fetch(:wpcli_local_db_backup_filename))
         
     | 
| 
      
 179 
     | 
    
         
            +
                    end
         
     | 
| 
      
 180 
     | 
    
         
            +
                  end
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                  before :push, 'backup:remote' if :wpcli_backup_db
         
     | 
| 
      
 183 
     | 
    
         
            +
                  before :local, :create_backup_dir
         
     | 
| 
      
 184 
     | 
    
         
            +
                  before :remote, :create_backup_dir
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
                end
         
     | 
| 
      
 187 
     | 
    
         
            +
              end
         
     | 
| 
      
 188 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            namespace :wpcli do
         
     | 
| 
      
 2 
     | 
    
         
            +
              namespace :rewrite do
         
     | 
| 
      
 3 
     | 
    
         
            +
                desc "Flush rewrite rules."
         
     | 
| 
      
 4 
     | 
    
         
            +
                task :flush do
         
     | 
| 
      
 5 
     | 
    
         
            +
                  on roles(:web) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                    within release_path do
         
     | 
| 
      
 7 
     | 
    
         
            +
                      execute :wp, :rewrite, :flush, fetch(:wpcli_args)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                desc "Perform a hard flush - update `.htaccess` rules as well as rewrite rules in database."
         
     | 
| 
      
 13 
     | 
    
         
            +
                task :hard_flush do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  on roles(:web) do
         
     | 
| 
      
 15 
     | 
    
         
            +
                    within release_path do
         
     | 
| 
      
 16 
     | 
    
         
            +
                      execute :wp, :rewrite, :flush, "--hard", fetch(:wpcli_args)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,49 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            namespace :load do
         
     | 
| 
      
 2 
     | 
    
         
            +
              task :defaults do
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                # These options are passed directly to rsync
         
     | 
| 
      
 5 
     | 
    
         
            +
                # Append your options, overwriting the defaults may result in malfunction
         
     | 
| 
      
 6 
     | 
    
         
            +
                # Ex: --recursive --delete --exclude .git*
         
     | 
| 
      
 7 
     | 
    
         
            +
                set :wpcli_rsync_options, "-avz --rsh=ssh --progress"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                # Local dir where WP stores the uploads
         
     | 
| 
      
 10 
     | 
    
         
            +
                # IMPORTANT: Add trailing slash!
         
     | 
| 
      
 11 
     | 
    
         
            +
                set :wpcli_local_uploads_dir, "web/app/uploads/"
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                # Remote dir where WP stores the uploads
         
     | 
| 
      
 14 
     | 
    
         
            +
                # IMPORTANT: Add trailing slash!
         
     | 
| 
      
 15 
     | 
    
         
            +
                set :wpcli_remote_uploads_dir, -> {"#{shared_path.to_s}/web/app/uploads/"}
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            namespace :wpcli do
         
     | 
| 
      
 21 
     | 
    
         
            +
              namespace :uploads do
         
     | 
| 
      
 22 
     | 
    
         
            +
                namespace :rsync do
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  desc "Push local uploads delta to remote machine"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  task :push do
         
     | 
| 
      
 26 
     | 
    
         
            +
                    roles(:web).each do |role|
         
     | 
| 
      
 27 
     | 
    
         
            +
                      puts role.netssh_options[:port]
         
     | 
| 
      
 28 
     | 
    
         
            +
                      port = role.netssh_options[:port] || 22
         
     | 
| 
      
 29 
     | 
    
         
            +
                      set :wpcli_rsync_options, fetch(:wpcli_rsync_options) + (" -e 'ssh -p #{port}'")
         
     | 
| 
      
 30 
     | 
    
         
            +
                      run_locally do
         
     | 
| 
      
 31 
     | 
    
         
            +
                        execute :rsync, fetch(:wpcli_rsync_options), fetch(:wpcli_local_uploads_dir), "#{role.user}@#{role.hostname}:#{fetch(:wpcli_remote_uploads_dir)}"
         
     | 
| 
      
 32 
     | 
    
         
            +
                      end
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  desc "Pull remote uploads delta to local machine"
         
     | 
| 
      
 37 
     | 
    
         
            +
                  task :pull do
         
     | 
| 
      
 38 
     | 
    
         
            +
                    roles(:web).each do |role|
         
     | 
| 
      
 39 
     | 
    
         
            +
                      run_locally do
         
     | 
| 
      
 40 
     | 
    
         
            +
                        puts role.netssh_options[:port]
         
     | 
| 
      
 41 
     | 
    
         
            +
                        port = role.netssh_options[:port] || 22
         
     | 
| 
      
 42 
     | 
    
         
            +
                        set :wpcli_rsync_options, fetch(:wpcli_rsync_options) + (" -e 'ssh -p #{port}'")
         
     | 
| 
      
 43 
     | 
    
         
            +
                        execute :rsync, fetch(:wpcli_rsync_options), "#{role.user}@#{role.hostname}:#{fetch(:wpcli_remote_uploads_dir)}", fetch(:wpcli_local_uploads_dir)
         
     | 
| 
      
 44 
     | 
    
         
            +
                      end
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
            end
         
     | 
| 
         
            File without changes
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,117 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: capistrano-wpcli-multisite
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.7
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Juancito Arias
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Jeremy Zahner
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Jacob Galati
         
     | 
| 
      
 10 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 11 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 12 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2021-10-01 00:00:00.000000000 Z
         
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 16 
     | 
    
         
            +
              name: capistrano
         
     | 
| 
      
 17 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 26 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 27 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 28 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
      
 29 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 30 
     | 
    
         
            +
              name: sshkit
         
     | 
| 
      
 31 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 32 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 33 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 34 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 35 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
      
 36 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 37 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 38 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 39 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 40 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 42 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
      
 43 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 44 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 45 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 46 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 47 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 48 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 49 
     | 
    
         
            +
                    version: '1.12'
         
     | 
| 
      
 50 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 51 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 52 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 53 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 54 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 55 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 56 
     | 
    
         
            +
                    version: '1.12'
         
     | 
| 
      
 57 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 58 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 59 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 60 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 61 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 62 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 63 
     | 
    
         
            +
                    version: '13.0'
         
     | 
| 
      
 64 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 65 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 66 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 67 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 68 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 69 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 70 
     | 
    
         
            +
                    version: '13.0'
         
     | 
| 
      
 71 
     | 
    
         
            +
            description: Capistrano tasks for managing Wordpress a fork of https://github.com/lavmeiker/capistrano-wpcli
         
     | 
| 
      
 72 
     | 
    
         
            +
            email:
         
     | 
| 
      
 73 
     | 
    
         
            +
            - tech@thenumber.ca
         
     | 
| 
      
 74 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 75 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 76 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 77 
     | 
    
         
            +
            files:
         
     | 
| 
      
 78 
     | 
    
         
            +
            - ".gemrelease"
         
     | 
| 
      
 79 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 80 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 81 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 82 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 83 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 84 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 85 
     | 
    
         
            +
            - capistrano-wpcli.gemspec
         
     | 
| 
      
 86 
     | 
    
         
            +
            - lib/capistrano-wpcli.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            - lib/capistrano/tasks/wpcli.rake
         
     | 
| 
      
 88 
     | 
    
         
            +
            - lib/capistrano/tasks/wpdb.rake
         
     | 
| 
      
 89 
     | 
    
         
            +
            - lib/capistrano/tasks/wprewrite.rake
         
     | 
| 
      
 90 
     | 
    
         
            +
            - lib/capistrano/tasks/wpuploads.rake
         
     | 
| 
      
 91 
     | 
    
         
            +
            - lib/capistrano/wpcli.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
            - lib/capistrano/wpcli/version.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            homepage: https://github.com/thenumber/capistrano-wpcli
         
     | 
| 
      
 94 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 95 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 96 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 97 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 98 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 99 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 100 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 101 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 102 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 103 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 104 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 105 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 106 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 109 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 111 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 112 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 113 
     | 
    
         
            +
            rubygems_version: 2.5.2
         
     | 
| 
      
 114 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 115 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 116 
     | 
    
         
            +
            summary: Simple Capistrano wrapper around WP-CLI
         
     | 
| 
      
 117 
     | 
    
         
            +
            test_files: []
         
     |