wp-capistrano 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -56,6 +56,10 @@ If there exists wp-content/themes/*/*/sass_output.php it will be executed locall
56
56
 
57
57
  A sample sass_output.php can be found in wp-generate ( http://github.com/dxw/wp-generate ).
58
58
 
59
+ === Compass
60
+
61
+ If there's a compass config file in the theme, it will be found and compiled locally, and the stylesheets directory will be uploaded to the correct place.
62
+
59
63
  === htaccess
60
64
 
61
65
  Uploads ./htaccess to .htaccess if it exists.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ class ManifestYML
4
+ attr_accessor :files
5
+
6
+ def initialize f
7
+ @files = []
8
+ y = YAML.load_file f
9
+
10
+ # Files is deprecated
11
+ files = %w[Files Static Executable Invisible]
12
+ for f in files
13
+ if y[f]
14
+ @files += glob(y[f])
15
+ end
16
+ end
17
+
18
+ if y['Manifests']
19
+ glob(y['Manifests']).each do |m|
20
+ pwd = File.dirname(m)
21
+ Dir.chdir pwd do
22
+ newfiles = ManifestYML.new(File.basename(m)).files
23
+ @files += newfiles.map{|f|File.join(pwd, f)}
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def each_file &block
30
+ @files.each &block
31
+ end
32
+
33
+ def glob patterns
34
+ fi = []
35
+ patterns.each do |pat|
36
+ f = Dir.glob pat
37
+
38
+ if f.length < 1
39
+ raise RuntimeError, "Pattern #{pat} returned no matches"
40
+ end
41
+ fi += f
42
+ end
43
+
44
+ fi
45
+ end
46
+ end
data/lib/wp-capistrano.rb CHANGED
@@ -1,14 +1,19 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'erb'
2
4
  require 'digest'
3
5
  require 'digest/sha1'
4
6
 
7
+ require 'manifest-yml'
5
8
  require 'wp-config'
6
9
  require 'wp-capistrano/deploy'
7
10
  require 'wp-capistrano/setup'
8
11
 
9
12
  # Features
10
13
  require 'wp-capistrano/feature/cforms'
14
+ require 'wp-capistrano/feature/compass'
11
15
  require 'wp-capistrano/feature/htaccess'
16
+ require 'wp-capistrano/feature/makefile-manifest'
12
17
  require 'wp-capistrano/feature/plugin-install'
13
18
  require 'wp-capistrano/feature/sass'
14
19
  require 'wp-capistrano/feature/shared-dirs'
@@ -24,6 +29,7 @@ Capistrano::Configuration.instance.load do
24
29
  def set_target target
25
30
  tt = WPConfig.instance.h['deploy'][target]
26
31
  if tt
32
+ set :deploy_target, target
27
33
  t = OpenStruct.new(tt)
28
34
  set :domain, t.ssh_domain
29
35
  set :user, t.ssh_user
@@ -61,11 +67,11 @@ Capistrano::Configuration.instance.load do
61
67
  set :wordpress_version, WPConfig.wordpress.version
62
68
  set :wordpress_git_url, WPConfig.wordpress.repository
63
69
  set :repository, WPConfig.application.repository
70
+ set :branch, WPConfig.application.version
64
71
 
65
72
  # Everything else
66
73
  set :scm, "git"
67
74
  set :deploy_via, :remote_cache
68
- set :branch, "master"
69
75
  set :git_shallow_clone, 1
70
76
  set :git_enable_submodules, 1
71
77
  set :wordpress_db_host, "localhost"
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  Capistrano::Configuration.instance.load do
2
4
  namespace :deploy do
3
5
 
@@ -26,7 +28,8 @@ Capistrano::Configuration.instance.load do
26
28
 
27
29
  set :content_dirs, {'themes' => :copy,
28
30
  'uploads' => :copy,
29
- 'plugins' => :copy}
31
+ 'plugins' => :copy,
32
+ 'languages' => :copy}
30
33
 
31
34
  deploy.content_dirs_configure
32
35
 
@@ -34,9 +37,11 @@ Capistrano::Configuration.instance.load do
34
37
  dest = "#{latest_release}/finalized/wp-content/"
35
38
  case action
36
39
  when :copy
37
- run "cp -rv #{latest_release}/#{dir} #{dest}"
40
+ src = "#{latest_release}/#{dir}"
41
+ run "[ -e #{src} ] && cp -rv #{src} #{dest} || true"
38
42
  when :link then 'ln -s'
39
- run "ln -s #{shared_path}/#{dir} #{dest}"
43
+ src = "#{shared_path}/#{dir}"
44
+ run "[ -e #{src} ] && ln -s #{src} #{dest} || true"
40
45
  end
41
46
  end
42
47
 
@@ -65,6 +70,8 @@ Capistrano::Configuration.instance.load do
65
70
  # For certain cases we may allow the user write access (i.e. module plugin-install)
66
71
  # it should always be direct filesystem access (and WordPress' autodetection is pants)
67
72
  preconfig['FS_METHOD'] = "'direct'"
73
+ # Generally speaking we don't want file editing
74
+ preconfig['DISALLOW_FILE_EDIT'] = 'true'
68
75
 
69
76
  # Allow modules a chance to interfere
70
77
  deploy.wp_config_configure
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # Make the cforms plugin work
2
4
 
3
5
  Capistrano::Configuration.instance.load do
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ # Assumes you're using DXW's sass_output.php convention
4
+ # A sample can be found in dxw/wp-generate:
5
+ # http://github.com/dxw/wp-generate/blob/master/lib/wp_generate/templates/theme/sass/sass_output.php
6
+
7
+ begin
8
+ require 'compass'
9
+
10
+ Capistrano::Configuration.instance.load do
11
+ after 'deploy:finalize_update' do
12
+
13
+ Dir.glob("themes/*").each do |theme_dir|
14
+
15
+ # Config
16
+ cfg_file = Compass.detect_configuration_file(theme_dir)
17
+
18
+ if cfg_file
19
+ cfg = Compass.add_project_configuration(cfg_file)
20
+ abs_css = File.expand_path(File.join(theme_dir, cfg.css_path))
21
+
22
+ # Compile
23
+ compiled = system("compass compile --trace --force --output-style compressed #{theme_dir}")
24
+ #TODO: do this instead
25
+ #Compass.compiler.options[:style] = :compressed
26
+ #Compass.compiler.run
27
+
28
+ if compiled
29
+
30
+ # Path fiddling
31
+
32
+ pwd = File.expand_path(Dir.pwd)
33
+
34
+ unless pwd == abs_css[0...pwd.length]
35
+ raise RuntimeError, 'opps'
36
+ end
37
+
38
+ relative_css = abs_css[pwd.length+1..-1]
39
+
40
+ remote_css = "#{latest_release}/finalized/wp-content/#{relative_css}"
41
+
42
+ # Upload
43
+ top.upload(abs_css, remote_css, :via => :scp, :recursive => true)
44
+
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ rescue LoadError
52
+ # Don't die horribly
53
+ end
@@ -1,9 +1,60 @@
1
+ # encoding: utf-8
2
+
1
3
  # Custom htaccess
2
4
 
3
5
  Capistrano::Configuration.instance.load do
4
6
  after 'deploy:finalize_update' do
5
7
  if File.exist? 'htaccess'
8
+
6
9
  top.upload("htaccess", "#{latest_release}/finalized/.htaccess" , :via => :scp)
10
+
11
+ else
12
+
13
+ htaccess = <<END
14
+ # BEGIN WordPress
15
+ <IfModule mod_rewrite.c>
16
+ RewriteEngine On
17
+ RewriteBase /
18
+ RewriteCond %{REQUEST_FILENAME} !-f
19
+ RewriteCond %{REQUEST_FILENAME} !-d
20
+ RewriteRule . /index.php [L]
21
+ </IfModule>
22
+ # END WordPress
23
+ END
24
+
25
+ if deploy_profile.modules.include? 'wp-super-cache'
26
+ htaccess = <<END + htaccess
27
+ # BEGIN WPSuperCache
28
+ <IfModule mod_rewrite.c>
29
+ RewriteEngine On
30
+ RewriteBase /
31
+ AddDefaultCharset UTF-8
32
+ RewriteCond %{REQUEST_URI} !^.*[^/]$
33
+ RewriteCond %{REQUEST_URI} !^.*//.*$
34
+ RewriteCond %{REQUEST_METHOD} !POST
35
+ RewriteCond %{QUERY_STRING} !.*=.*
36
+ RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
37
+ RewriteCond %{HTTP:Accept-Encoding} gzip
38
+ RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
39
+ RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
40
+
41
+ RewriteCond %{REQUEST_URI} !^.*[^/]$
42
+ RewriteCond %{REQUEST_URI} !^.*//.*$
43
+ RewriteCond %{REQUEST_METHOD} !POST
44
+ RewriteCond %{QUERY_STRING} !.*=.*
45
+ RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
46
+ RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
47
+ RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
48
+ </IfModule>
49
+ # END WPSuperCache
50
+ END
51
+ end
52
+
53
+ put(htaccess, "#{latest_release}/finalized/.htaccess", :via => :scp)
54
+
7
55
  end
56
+
57
+ run("chmod 755 #{latest_release}/finalized/.htaccess")
58
+
8
59
  end
9
60
  end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ # Runs make deploy in the root of the project if Makefile is found
4
+ # And uploads any files listed in Manifest.yml
5
+
6
+ Capistrano::Configuration.instance.load do
7
+ after 'deploy:finalize_update' do
8
+
9
+ # Makefiles
10
+ if File.exist? 'Makefile'
11
+ unless system 'make deploy'
12
+ raise RuntimeError, 'make deploy failed'
13
+ end
14
+ end
15
+
16
+ # ... and Manifests
17
+ if File.exist? 'Manifest.yml'
18
+ ManifestYML.new('Manifest.yml').each_file do |f|
19
+ top.upload(f, "#{latest_release}/finalized/wp-content/#{f}")
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # Allow plugin installation by end-users
2
4
 
3
5
  Capistrano::Configuration.instance.load do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # Assumes you're using DXW's sass_output.php convention
2
4
  # A sample can be found in dxw/wp-generate:
3
5
  # http://github.com/dxw/wp-generate/blob/master/lib/wp_generate/templates/theme/sass/sass_output.php
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # Shared directories get uploaded at setup-time and don't change
2
4
 
3
5
  Capistrano::Configuration.instance.load do
@@ -58,10 +60,6 @@ Capistrano::Configuration.instance.load do
58
60
  end
59
61
 
60
62
  before 'deploy:content_dirs_configure' do
61
- p 'hihi'
62
-
63
- p shared_dirs
64
-
65
63
  shared_dirs.each do |dir|
66
64
  content_dirs[dir] = :link
67
65
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # WP Super Cache
2
4
 
3
5
  Capistrano::Configuration.instance.load do
@@ -14,23 +16,23 @@ Capistrano::Configuration.instance.load do
14
16
  top.upload("plugins/wp-super-cache/advanced-cache.php", "#{latest_release}/finalized/wp-content/" , :via => :scp)
15
17
  sedable_path = "#{latest_release}/finalized/wp-content/plugins/wp-super-cache/".gsub(/\//,'\/')
16
18
  run("sed -i 's/CACHEHOME/#{sedable_path}/g' #{latest_release}/finalized/wp-content/advanced-cache.php")
17
- else
18
- raise IOError, 'Are you sure you have the WP Super Cache plugin?'
19
+ elsif deploy_profile.modules.include? 'wp-super-cache'
20
+ raise IOError, 'Are you sure you have the WP Super Cache plugin? Could not find advanced-cache.php'
19
21
  end
20
22
 
21
23
  if File.exist? 'wp-cache-config.php'
22
24
  top.upload("wp-cache-config.php", "#{latest_release}/finalized/wp-content/" , :via => :scp)
23
25
  elsif File.exist? 'plugins/wp-super-cache/wp-cache-config-sample.php'
24
26
  top.upload("plugins/wp-super-cache/wp-cache-config-sample.php", "#{latest_release}/finalized/wp-content/wp-cache-config.php" , :via => :scp)
25
- else
26
- raise IOError, 'Are you sure you have the WP Super Cache plugin?'
27
+ elsif deploy_profile.modules.include? 'wp-super-cache'
28
+ raise IOError, 'Are you sure you have the WP Super Cache plugin? Could not find wp-cache-config.php'
27
29
  end
28
30
 
29
- run("mkdir -p #{latest_release}/finalized/wp-content/cache/blogs &&
30
- mkdir -p #{latest_release}/finalized/wp-content/cache/meta")
31
-
32
- # Keep writables to a bare minimum
31
+ # Keep writable directories to a bare minimum
33
32
  if deploy_profile.modules.include? 'wp-super-cache'
33
+ run("mkdir -p #{latest_release}/finalized/wp-content/cache/blogs &&
34
+ mkdir -p #{latest_release}/finalized/wp-content/cache/meta")
35
+
34
36
  run("chmod -R 777 #{latest_release}/finalized/wp-content/cache &&
35
37
  chmod -R 777 #{latest_release}/finalized/wp-content/wp-cache-config.php")
36
38
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  Capistrano::Configuration.instance.load do
2
4
  namespace :setup do
3
5
 
@@ -16,7 +18,7 @@ Capistrano::Configuration.instance.load do
16
18
  run "rm -rf #{shared_path}/wordpress || true"
17
19
  raise Exception, 'wordpress.repository must be set in config.yml' if wordpress_git_url.nil?
18
20
  run "git clone --depth 1 #{wordpress_git_url} #{shared_path}/wordpress"
19
- run "cd #{shared_path}/wordpress && git fetch --tags && git checkout #{wordpress_version}"
21
+ run "cd #{shared_path}/wordpress && git fetch --tags && git reset --hard HEAD && git checkout #{wordpress_version}"
20
22
  end
21
23
 
22
24
  desc "Sets up shared wp-config.php"
data/lib/wp-config.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ # encoding: utf-8
2
2
 
3
3
  require 'singleton'
4
4
 
@@ -1,2 +1,4 @@
1
+ # encoding: utf-8
2
+
1
3
  warn "[DeprecationWarning] Capfile should not require 'wp_capistrano/deploy' - require 'wp-capistrano instead'"
2
4
  require 'wp-capistrano' # Compatability
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - The Dextrous Web
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-02 00:00:00 +01:00
17
+ date: 2011-04-11 00:00:00 -04:00
18
18
  default_executable: wpcapify
19
19
  dependencies: []
20
20
 
@@ -27,16 +27,18 @@ extensions: []
27
27
  extra_rdoc_files:
28
28
  - README.rdoc
29
29
  files:
30
- - .gitignore
31
30
  - LICENCE
32
31
  - README.rdoc
33
32
  - Rakefile
34
33
  - VERSION
35
34
  - bin/wpcapify
35
+ - lib/manifest-yml.rb
36
36
  - lib/wp-capistrano.rb
37
37
  - lib/wp-capistrano/deploy.rb
38
38
  - lib/wp-capistrano/feature/cforms.rb
39
+ - lib/wp-capistrano/feature/compass.rb
39
40
  - lib/wp-capistrano/feature/htaccess.rb
41
+ - lib/wp-capistrano/feature/makefile-manifest.rb
40
42
  - lib/wp-capistrano/feature/plugin-install.rb
41
43
  - lib/wp-capistrano/feature/sass.rb
42
44
  - lib/wp-capistrano/feature/shared-dirs.rb
@@ -50,11 +52,12 @@ homepage: http://github.com/dxw/wp-capistrano
50
52
  licenses: []
51
53
 
52
54
  post_install_message:
53
- rdoc_options:
54
- - --charset=UTF-8
55
+ rdoc_options: []
56
+
55
57
  require_paths:
56
58
  - lib
57
59
  required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
58
61
  requirements:
59
62
  - - ">="
60
63
  - !ruby/object:Gem::Version
@@ -62,6 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
65
  - 0
63
66
  version: "0"
64
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
65
69
  requirements:
66
70
  - - ">="
67
71
  - !ruby/object:Gem::Version
@@ -71,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
75
  requirements: []
72
76
 
73
77
  rubyforge_project:
74
- rubygems_version: 1.3.6
78
+ rubygems_version: 1.3.7
75
79
  signing_key:
76
80
  specification_version: 3
77
81
  summary: Capistrano receipe for WordPress
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- pkg/
2
- wp-capistrano.gemspec