wp-capistrano3 0.0.7 → 0.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1e6df5f94f90b486745d8351692c078263b21e7a3e9338ac2409b60e3633760
4
- data.tar.gz: 2458831aff2c7ae5a1e7b6d3d02b82280d3866f38ebd6d45ee7e4f1f29d1aa65
3
+ metadata.gz: ea6d7bcea76690bc3763159325b682fe79d69838c588ab3a620d45c3b6856940
4
+ data.tar.gz: 8280fab03cc2e2ed940987b1c7bae4729017bc5919d6400b2b03ac2521b71e38
5
5
  SHA512:
6
- metadata.gz: dd9508e405ec8a73d99d852939619034a7216e3a6b7d966814a54556301b075cca7fd7a4276b96a83e47e6b470e75590921073dfa5246dd7dd80fbf12a49fe2c
7
- data.tar.gz: f17e06bbeb8cbdeedf73c1e528c1c837e439abc68190e9d051476bb6501311b73776e7f1856b7195260fa0e8554d47c9f89f1f1ee217d72aa6b8744e2ffe49bc
6
+ metadata.gz: e3c63e11c095a653156c9591d94dfdeb81fb39dbba34c2046f1a08613b816803fd361ec899e33fc0a2601b9b463159a6260c7254a2626b9e895741ea70ad4991
7
+ data.tar.gz: 4b29cb62cad00b9ec4c4c610cdabc1746bebd9c709c7ec9851b05b23ecb26d1e68344719bb60cdb1e62b6a97b9fe7634e8ed61e4275848e0d1fd17d593bdafd5
@@ -5,6 +5,7 @@ namespace "wp-capistrano" do
5
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
7
  execute "wget -N https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P /tmp/"
8
+ execute "chmod u+x /tmp/wp-cli.phar"
8
9
  end
9
10
  end
10
- end
11
+ end
@@ -2,82 +2,63 @@ require 'json'
2
2
  namespace "wp-capistrano" do
3
3
  desc 'Install wordpress plugins'
4
4
  task :install_plugins do
5
- on roles(:app) do
6
- bashScript = <<BASH
7
- #!/bin/bash
8
-
9
- Help()
10
- {
11
- # Display Help
12
- echo "Download installed wordpress plugins"
13
- echo
14
- echo "Syntax: install_plugins [-c|n|h|v]"
15
- echo "options:"
16
- echo "-c | --current_path Current wordpress path."
17
- echo "-n | --new_path Path of release currently in deployment."
18
- echo "-h | --help Print this Help."
19
- echo "-v | --verbose Verbose mode."
20
- echo
21
- }
22
-
23
- while [ "$1" != "" ]; do
24
- case $1 in
25
- -c | --current_path ) shift
26
- current_path="$1"
27
- ;;
28
- -p | --plugins ) shift
29
- plugins="$1"
30
- ;;
31
- -n | --new_path ) shift
32
- new_path="$1"
33
- ;;
34
- -h | --help ) Help
35
- exit
36
- ;;
37
- * ) Help
38
- exit 1
39
- esac
40
- shift
41
- done
42
-
43
-
44
- if [ -z $new_path ];
45
- then
46
- echo -e "\e[31mArgument -n | --new_path is mandatory\e[0m"
47
- exit 1
48
- fi
49
-
50
- if [ -z $current_path ];
51
- then
52
- echo -e "\e[32mArgument -c | --current_path not defined. Plugin installation skipped.\e[0m"
53
- exit
54
- fi
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
55
31
 
56
- echo $plugins
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 => "active" }
38
+ plugins.push(pluginInfo)
39
+ end
40
+ end
57
41
 
58
- echo -e "\e[32mInstalling plugins ...\e[0m"
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
59
48
 
60
- plugins=($(/usr/local/bin/php /tmp/wp-cli.phar plugin list --path=$current_path |awk '{ print $1 }'))
61
- nbPlugins=$((${#plugins[@]} - 1))
62
- plugins_status=($(/usr/local/bin/php /tmp/wp-cli.phar plugin list --path=$current_path |awk '{ print $2 }'))
63
- plugins_versions=($(/usr/local/bin/php /tmp/wp-cli.phar plugin list --path=$current_path |awk '{ print $4 }'))
64
- for i in `seq 1 $nbPlugins`;
65
- do
66
- /usr/local/bin/php /tmp/wp-cli.phar plugin install ${plugins[i]} --path=$new_path --version=${plugins_versions[i]}
67
- echo /usr/local/bin/php /tmp/wp-cli.phar plugin install ${plugins[i]} --path=$new_path
68
- if [ ${plugins_status[i]} = "active" ];
69
- then
70
- /usr/local/bin/php /tmp/wp-cli.phar plugin activate ${plugins[i]} --path=$new_path
71
- else
72
- /usr/local/bin/php /tmp/wp-cli.phar plugin deactivate ${plugins[i]} --path=$new_path
73
- fi
74
- done
75
- BASH
76
- upload! StringIO.new(bashScript), "/tmp/install_plugins.sh"
77
- if(File.exist?("#{release_path}/plugins.json"))
78
- then plugins = JSON.parse(File.read("#{release_path}/plugins.json"))
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
+ end
52
+ plugins.each do |plugin|
53
+ if (plugin[:status] == "active")
54
+ execute "/usr/bin/env php /tmp/wp-cli.phar plugin activate #{plugin[:slug]} --path=#{release_path}"
55
+ info "activate #{plugin}"
56
+ else
57
+ execute "/usr/bin/env php /tmp/wp-cli.phar plugin deactivate #{plugin[:slug]} --path=#{release_path}"
58
+ info "deactivate #{plugin[:slug]}"
59
+ end
60
+ end
79
61
  end
80
- execute "/bin/bash /tmp/install_plugins.sh -c \"#{current_path}\" -n #{release_path} -p #{plugins}"
81
62
  end
82
63
  end
83
- end
64
+ end
@@ -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:install_wordpress'
6
- after 'wp-capistrano:install_wordpress', 'wp-capistrano:install_plugins'
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.7'
7
+ spec.version = '0.0.12'
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.7
4
+ version: 0.0.12
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-31 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano