wp-capistrano3 0.0.4 → 0.0.9

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
2
  SHA256:
3
- metadata.gz: 5179e44e2c944df4a90551c7360aa71be3e96aa137322496ee9407b5951086d4
4
- data.tar.gz: 853646832db6c551396c822c8f2a02c38345b4e1f9494fc8ecab89e7081b57de
3
+ metadata.gz: 3f90a13a009316acd1bb220748d0cee8ed5d71adaa03408ce44f075426147929
4
+ data.tar.gz: c8c0ec23292987328b0d8b6f26380b0e48eddf37c78506b1e19807ca492e3bcf
5
5
  SHA512:
6
- metadata.gz: 9bf50a931e3fc2bee91a4d1fe08da852cf8698918cddc7ad50910d5da23fb5331816aa493215ed01a126a54d62884d1dc72ed1fe5163e37eba6566f76b23b81a
7
- data.tar.gz: 910752b6842817f2fe3b6af869654eb30e88dee84f46c7b6ca882533facddc8fed3a1f079ee5ff99f71b8e031b06d92087d71bec29c7d888e6bf19f79d149173
6
+ metadata.gz: 9f7c94f2a02743ca55a064af5aa0ee9daf7056f8d240149baec9dd1162ff1d682e5a0fc87df936827ec4d37d394131bf769b0b42e59327aaad661bad8a1516cb
7
+ data.tar.gz: 6b2f5c85cc3b170ac51cc92e9dea627678f7a1ccfa7940259026ea05be232cc30c79e3cd9c05a3675aa0e3445c717350180eaf5e077f7ce0fe1f37569558f0ef
data/README.md CHANGED
@@ -18,6 +18,23 @@ Then run
18
18
  bundle install
19
19
  #or bundle update
20
20
  ```
21
+ set following variables in your deploy.rb
22
+ These variables will be used to generate wp_config.php at first deployment.
23
+ And will install an empty wordpress
24
+ ```ruby
25
+ set :wp_db_name, "wp_db_name"
26
+ set :wp_db_password, "wp_db_password"
27
+ set :wp_db_user, "wp_db_user"
28
+ set :wp_db_host, "127.0.0.1"
29
+ #ADMIN LOCALE
30
+ set :wp_locale, "en_GB"
31
+
32
+ set :wp_url, "wp_domain"
33
+ set :wp_title, "wp site name"
34
+ set :wp_admin_user, "admin"
35
+ set :wp_admin_password, "password"
36
+ set :wp_admin_email, "admin@xxxx.com"
37
+ ```
21
38
 
22
39
  ## Workflow
23
40
 
@@ -28,4 +45,5 @@ before 'deploy:check:linked_files', 'wp-capistrano:create_wp_config'
28
45
  before 'deploy:updating', 'wp-capistrano:download_wordpress'
29
46
  after 'wp-capistrano:download_wordpress', 'wp-capistrano:install_wordpress'
30
47
  after 'wp-capistrano:download_wordpress', 'wp-capistrano:update_wordpress'
48
+ after 'wp-capistrano:install_wordpress', 'wp-capistrano:install_plugins'
31
49
  ```
@@ -2,9 +2,9 @@ namespace "wp-capistrano" do
2
2
  desc 'Download wordpress'
3
3
  task :download_wordpress do
4
4
  on roles(:app) do
5
- execute "wget http://wordpress.org/latest.tar.gz -P /tmp/"
5
+ execute "wget -N http://wordpress.org/latest.tar.gz -P /tmp/"
6
6
  execute "tar xzf /tmp/latest.tar.gz -C #{release_path} wordpress --strip-components=1"
7
- execute "wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P /tmp/"
7
+ execute "wget -N https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P /tmp/"
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,62 @@
1
+ require 'json'
2
+ namespace "wp-capistrano" do
3
+ desc 'Install wordpress plugins'
4
+ task :install_plugins do
5
+ on roles(:app) do
6
+ info "Check file #{release_path}/plugins.json"
7
+ if (test("[ -f #{release_path}/plugins.json ]"))
8
+ debug "#{release_path}/plugins.json exist"
9
+ pluginsStr = capture("cat #{release_path}/plugins.json")
10
+ jsonPlugins = JSON.parse(pluginsStr)
11
+ end
12
+
13
+ if(test("[ -L #{current_path} ]"))
14
+ info "installing pluggins..."
15
+ installedPlugins = capture("/usr/bin/env php /tmp/wp-cli.phar plugin list --path=#{current_path} |awk '{ print $1 }'")
16
+ installedPluginsArr = installedPlugins.to_s.gsub(/\n/, '|').split("|")
17
+ installedPluginsStatus = capture("/usr/bin/env php /tmp/wp-cli.phar plugin list --path=#{current_path} |awk '{ print $2 }'")
18
+ installedPluginsStatusArr = installedPluginsStatus.to_s.gsub(/\n/, '|').split("|")
19
+ installedPluginsVersion = capture("/usr/bin/env php /tmp/wp-cli.phar plugin list --path=#{current_path} |awk '{ print $4 }'")
20
+ installedPluginsVersionArr = installedPluginsVersion.to_s.gsub(/\n/, '|').split("|")
21
+
22
+ plugins = [];
23
+
24
+ installedPluginsArr.each_with_index do |plugin, index|
25
+ if(index == 0)
26
+ next
27
+ end
28
+ pluginInfo = {:slug => plugin, :version => installedPluginsVersionArr[index], :status => installedPluginsStatusArr[index] }
29
+ plugins.push(pluginInfo)
30
+ end
31
+
32
+ jsonPlugins.each do |plugin, version|
33
+ plugginInfo = plugins.detect {|f| f["slug"] == plugin }
34
+ if(plugginInfo)
35
+ plugginInfo[:version] = version
36
+ else
37
+ pluginInfo = {:slug => plugin, :version => version, :status => "activate" }
38
+ plugins.push(pluginInfo)
39
+ end
40
+ end
41
+
42
+ plugins.each do |plugin|
43
+ existingPlugins = capture("/usr/bin/env php /tmp/wp-cli.phar plugin search #{plugin[:slug]} --path=#{release_path} --field=slug --per-page=999999")
44
+ if (existingPlugins.to_s.gsub(/\n/, '|').split("|").include?("#{plugin[:slug]}") == false)
45
+ warn "Pluggin #{plugin[:slug]} not known in wordpress repository. skip installation"
46
+ next
47
+ end
48
+
49
+ info "install #{plugin[:slug]}:#{plugin[:version]}"
50
+ execute "/usr/bin/env php /tmp/wp-cli.phar plugin install #{plugin[:slug]} --path=#{release_path} --version=#{plugin[:version]}"
51
+ if (plugin[:status] == "active")
52
+ execute "/usr/bin/env php /tmp/wp-cli.phar plugin activate #{plugin[:slug]} --path=#{release_path}"
53
+ info "activate #{plugin}"
54
+ else
55
+ execute "/usr/bin/env php /tmp/wp-cli.phar plugin deactivate #{plugin[:slug]} --path=#{release_path}"
56
+ info "deactivate #{plugin[:slug]}"
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,5 +1,5 @@
1
1
  namespace "wp-capistrano" do
2
- desc 'Download wordpress'
2
+ desc 'Install wordpress'
3
3
  task :install_wordpress do
4
4
  on roles(:app), filter: :no_release do
5
5
  execute "rm #{shared_path}/wp-config.php"
@@ -1,9 +1,8 @@
1
- #load File.expand_path("../tasks/deploy-theme.rake", __FILE__)
2
1
  load File.expand_path("../tasks/create_wp_config.rake", __FILE__)
3
2
  load File.expand_path("../tasks/download_wordpress.rake", __FILE__)
4
3
  load File.expand_path("../tasks/install_wordpress.rake", __FILE__)
5
4
  load File.expand_path("../tasks/update_wordpress.rake", __FILE__)
6
-
5
+ load File.expand_path("../tasks/install_plugins.rake", __FILE__)
7
6
 
8
7
  namespace :load do
9
8
  task :defaults do
@@ -2,5 +2,5 @@
2
2
  before 'deploy:check:linked_files', 'wp-capistrano:create_wp_config'
3
3
  before 'deploy:updating', 'wp-capistrano:download_wordpress'
4
4
  after 'wp-capistrano:download_wordpress', 'wp-capistrano:install_wordpress'
5
- after 'wp-capistrano:download_wordpress', 'wp-capistrano:update_wordpress'
6
- #before 'deploy:updated', 'wp-capistrano:deploy-theme'
5
+ after 'wp-capistrano:install_wordpress', 'wp-capistrano:update_wordpress'
6
+ after 'deploy:updating', 'wp-capistrano:install_plugins'
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'wp-capistrano3'
7
- spec.version = '0.0.4'
7
+ spec.version = '0.0.9'
8
8
  spec.authors = ['Nicolas RENAULT']
9
9
  spec.email = ['nrenault@tangkoko.com']
10
10
  spec.description = %q{Wordpress tasks for Capistrano 3.x}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wp-capistrano3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas RENAULT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2021-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -64,10 +64,9 @@ files:
64
64
  - README.md
65
65
  - Rakefile
66
66
  - gemfile
67
- - lib/capistrano/Rakefile
68
67
  - lib/capistrano/tasks/create_wp_config.rake
69
- - lib/capistrano/tasks/deploy-theme.rake
70
68
  - lib/capistrano/tasks/download_wordpress.rake
69
+ - lib/capistrano/tasks/install_plugins.rake
71
70
  - lib/capistrano/tasks/install_wordpress.rake
72
71
  - lib/capistrano/tasks/update_wordpress.rake
73
72
  - lib/capistrano/wp-capistrano.rb
@@ -93,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
92
  - !ruby/object:Gem::Version
94
93
  version: '0'
95
94
  requirements: []
96
- rubygems_version: 3.1.2
95
+ rubygems_version: 3.2.15
97
96
  signing_key:
98
97
  specification_version: 4
99
98
  summary: Wordpress tasks for Capistrano 3.x
@@ -1 +0,0 @@
1
- require 'bundler/gem_tasks'
@@ -1,15 +0,0 @@
1
- namespace "wp-capistrano" do
2
- desc 'upload theme compiled files'
3
- task :deploy-theme do
4
- run_locally do
5
- role_properties(:app) do |server|
6
- ssh_options = server.ssh_options
7
- fetch(:themes_to_deploy).each do |theme|
8
- themesParentDir = theme.split("/")
9
- themesParentDir.pop()
10
- execute "scp -r -P #{server.ssh_options[:port]} #{ENV['SOURCE_PATH']}/#{theme} #{server.user}@#{server.hostname}:#{release_path}/#{themesParentDir.join("/")}"
11
- end
12
- end
13
- end
14
- end
15
- end