capifony 2.1.9 → 2.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,23 @@
1
+ == 2.1.10 / July 16, 2012
2
+
3
+ * Fix CS
4
+ * Add ownership check before changing permissions
5
+ * Add pretty output
6
+ * Fix normalizing assets
7
+ * Fix build bootstrap
8
+ * Added set_permissions task
9
+ * Fix PR #158
10
+ * fix for remote check of composer.phar, File.exist? only checks local files
11
+ * Fix capifony script
12
+ * Use `--no-scripts` during `composer install/update` to avoid useless/duplicate processing.
13
+ * Fixed database tasks for postgresql
14
+ * Better pretty output if error raised
15
+ * Add task for updating `assets_version` in `config.yml`
16
+ * Avoid the use of try_sudo
17
+ * More `:no_release`...
18
+ * Since `:roles` isn't used in Capifony, these need `:no_release` *at least*.
19
+ * Fixing missing `pretty_print`.
20
+
1
21
  == 2.1.9 / July 3, 2012
2
22
 
3
23
  * fixed regression
@@ -53,7 +53,7 @@ if symfony_version == 2
53
53
  files = {
54
54
  "Capfile" => unindent(<<-FILE),
55
55
  load 'deploy' if respond_to?(:namespace) # cap2 differentiator
56
- Dir['vendor/bundles/*/*/recipes/*.rb'].each { |bundle| load(bundle) }
56
+ Dir['vendor/**/Resources/recipes/*.rb'].each { |bundle| load(bundle) }
57
57
  load Gem.find_files('symfony2.rb').last.to_s
58
58
  load '#{symfony_app_path}/config/deploy'
59
59
  FILE
@@ -73,7 +73,7 @@ if symfony_version == 2
73
73
 
74
74
  role :web, domain # Your HTTP server, Apache/etc
75
75
  role :app, domain # This may be the same as your `Web` server
76
- role :db, domain, :primary => true # This is where Rails migrations will run
76
+ role :db, domain, :primary => true # This is where Symfony2 migrations will run
77
77
 
78
78
  set :keep_releases, 3
79
79
 
@@ -100,7 +100,7 @@ set :scm, :git
100
100
 
101
101
  role :web, domain # Your HTTP server, Apache/etc
102
102
  role :app, domain # This may be the same as your `Web` server
103
- role :db, domain, :primary => true # This is where Rails migrations will run
103
+ role :db, domain, :primary => true # This is where symfony migrations will run
104
104
 
105
105
  set :keep_releases, 3'
106
106
  }
@@ -122,4 +122,4 @@ files.each do |file, content|
122
122
  end
123
123
  end
124
124
 
125
- puts "[done] Symfony#{symfony_version.to_s} project capifonied!"
125
+ puts "[done] symfony #{symfony_version.to_s} project capifonied!"
@@ -48,7 +48,7 @@ namespace :deploy do
48
48
  DESC
49
49
  task :setup, :except => { :no_release => true } do
50
50
  dirs = [deploy_to, releases_path, shared_path]
51
- run "#{try_sudo} mkdir -p #{dirs.join(' ')}"
52
- run "#{try_sudo} chmod g+w #{dirs.join(' ')}" if fetch(:group_writable, true)
51
+ run "mkdir -p #{dirs.join(' ')}"
52
+ run "chmod g+w #{dirs.join(' ')}" if fetch(:group_writable, true)
53
53
  end
54
54
  end
@@ -51,6 +51,9 @@ set :dump_assetic_assets, false
51
51
  # Assets install
52
52
  set :assets_install, true
53
53
 
54
+ # Whether to update `assets_version` in `config.yml`
55
+ set :update_assets_version, false
56
+
54
57
  # Files that need to remain the same between deploys
55
58
  set :shared_files, false
56
59
 
@@ -60,6 +63,15 @@ set :shared_children, [log_path, web_path + "/uploads"]
60
63
  # Asset folders (that need to be timestamped)
61
64
  set :asset_children, [web_path + "/css", web_path + "/images", web_path + "/js"]
62
65
 
66
+ # Dirs that need to be writable by the HTTP Server (i.e. cache, log dirs)
67
+ set :writable_dirs, [log_path, cache_path]
68
+
69
+ # Name used by the Web Server (i.e. www-data for Apache)
70
+ set :webserver_user, "www-data"
71
+
72
+ # Method used to set permissions (:chmod, :acl, or :chown)
73
+ set :permission_method, false
74
+
63
75
  # Model manager: (doctrine, propel)
64
76
  set :model_manager, "doctrine"
65
77
 
@@ -77,7 +89,11 @@ def load_database_config(data, env)
77
89
  end
78
90
 
79
91
  def guess_symfony_version
80
- capture("cd #{latest_release} && #{php_bin} #{symfony_console} --version |cut -d \" \" -f 3")
92
+ capture("cd #{latest_release} && #{php_bin} #{symfony_console} --version |cut -d \" \" -f 3")
93
+ end
94
+
95
+ def remote_file_exists?(full_path)
96
+ 'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
81
97
  end
82
98
 
83
99
  after "deploy:finalize_update" do
@@ -95,25 +111,29 @@ after "deploy:finalize_update" do
95
111
  when "install" then symfony.vendors.install
96
112
  when "reinstall" then symfony.vendors.reinstall
97
113
  end
98
- else
99
- symfony.bootstrap.build
100
114
  end
101
115
  end
102
116
 
117
+ symfony.bootstrap.build
118
+
103
119
  if model_manager == "propel"
104
120
  symfony.propel.build.model
105
121
  end
106
122
 
107
123
  if assets_install
108
- symfony.assets.install # 2. Publish bundle assets
124
+ symfony.assets.install # 2. Publish bundle assets
109
125
  end
110
126
 
111
127
  if cache_warmup
112
- symfony.cache.warmup # 3. Warmup clean cache
128
+ symfony.cache.warmup # 3. Warmup clean cache
129
+ end
130
+
131
+ if update_assets_version
132
+ symfony.assets.update_version # 4. Update `assets_version`
113
133
  end
114
134
 
115
135
  if dump_assetic_assets
116
- symfony.assetic.dump # 4. Dump assetic assets
136
+ symfony.assetic.dump # 5. Dump assetic assets
117
137
  end
118
138
  end
119
139
 
@@ -20,7 +20,7 @@ namespace :database do
20
20
  puts data
21
21
  end
22
22
  when "pdo_pgsql", "pgsql"
23
- run "pg_dump -U #{config['database_user']} #{config['database_name']} | gzip -c > #{file}" do |ch, stream, data|
23
+ run "pg_dump -U #{config['database_user']} #{config['database_name']} --clean | gzip -c > #{file}" do |ch, stream, data|
24
24
  puts data
25
25
  end
26
26
  end
@@ -49,7 +49,7 @@ namespace :database do
49
49
  when "pdo_mysql", "mysql"
50
50
  `mysqldump -u#{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} > #{tmpfile}`
51
51
  when "pdo_pgsql", "pgsql"
52
- `pg_dump -U #{config['database_user']} #{config['database_name']} > #{tmpfile}`
52
+ `pg_dump -U #{config['database_user']} #{config['database_name']} --clean > #{tmpfile}`
53
53
  end
54
54
 
55
55
  File.open(tmpfile, "r+") do |f|
@@ -88,7 +88,7 @@ namespace :database do
88
88
  when "pdo_mysql", "mysql"
89
89
  `mysql -u#{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} < backups/#{sqlfile}`
90
90
  when "pdo_pgsql", "pgsql"
91
- `psql -U #{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} < backups/#{sqlfile}`
91
+ `psql -U #{config['database_user']} #{config['database_name']} < backups/#{sqlfile}`
92
92
  end
93
93
  FileUtils.rm("backups/#{sqlfile}")
94
94
  end
@@ -115,7 +115,7 @@ namespace :database do
115
115
  puts data
116
116
  end
117
117
  when "pdo_pgsql", "pgsql"
118
- run "psql -U #{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} < /tmp/#{sqlfile}" do |ch, stream, data|
118
+ run "psql -U #{config['database_user']} #{config['database_name']} < /tmp/#{sqlfile}" do |ch, stream, data|
119
119
  puts data
120
120
  end
121
121
  end
@@ -1,7 +1,55 @@
1
1
  # Overrided Capistrano tasks
2
2
  namespace :deploy do
3
+ desc <<-DESC
4
+ Sets permissions for writable_dirs folders as described in the Symfony documentation
5
+ (http://symfony.com/doc/master/book/installation.html#configuration-and-setup)
6
+ DESC
7
+ task :set_permissions, :roles => :app do
8
+ if writable_dirs && permission_method
9
+ dirs = []
10
+
11
+ writable_dirs.each do |link|
12
+ if shared_children && shared_children.include?(link)
13
+ absolute_link = shared_path + "/" + link
14
+ else
15
+ absolute_link = latest_release + "/" + link
16
+ end
17
+
18
+ dirs << absolute_link
19
+ end
20
+
21
+ methods = {
22
+ :chmod => "#{try_sudo} chmod +a \"#{webserver_user} allow delete,write,append,file_inherit,directory_inherit\" %s",
23
+ :acl => "#{try_sudo} setfacl -dR -m u:#{webserver_user}:rwx %s",
24
+ :chown => "#{try_sudo} chown #{webserver_user} %s"
25
+ }
26
+
27
+ if methods[permission_method]
28
+ pretty_print "--> Setting permissions"
29
+
30
+ if use_sudo
31
+ run sprintf(methods[permission_method], dirs.join(' '))
32
+ else if permission_method == :chown
33
+ puts " You can't use chown method without sudoing"
34
+ else
35
+ dirs.each do |dir|
36
+ is_owner = (capture "`echo stat #{dir} -c %U`").chomp == user
37
+ if is_owner && permission_method != :chown
38
+ run sprintf(methods[permission_method], dir)
39
+ else
40
+ puts " #{dir} is not owned by #{user} or you are using 'chown' method without 'use_sudo'"
41
+ end
42
+ end
43
+ end
44
+ puts_ok
45
+ else
46
+ puts " Permission method '#{permission_method}' does not exist.".yellow
47
+ end
48
+ end
49
+ end
50
+
3
51
  desc "Symlinks static directories and static files that need to remain between deployments"
4
- task :share_childs do
52
+ task :share_childs, :except => { :no_release => true } do
5
53
  if shared_children
6
54
  pretty_print "--> Creating symlinks for shared directories"
7
55
 
@@ -51,7 +99,7 @@ namespace :deploy do
51
99
  else
52
100
  pretty_print "--> Normalizing asset timestamps"
53
101
 
54
- run "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" }
102
+ run "find #{asset_paths} -exec touch -t #{stamp} {} ';' >& /dev/null || true", :env => { "TZ" => "UTC" }
55
103
  puts_ok
56
104
  end
57
105
  end
@@ -67,7 +115,7 @@ namespace :deploy do
67
115
  end
68
116
 
69
117
  desc "Deploys the application and runs the test suite"
70
- task :testall do
118
+ task :testall, :except => { :no_release => true } do
71
119
  update_code
72
120
  create_symlink
73
121
  run "cd #{latest_release} && phpunit -c #{app_path} src"
@@ -1,9 +1,12 @@
1
1
  require 'colored'
2
2
 
3
+ STDOUT.sync
4
+ $error = false
5
+ $pretty_errors_defined = false
6
+
3
7
  # Be less verbose by default
4
8
  logger.level = Logger::IMPORTANT
5
9
 
6
- STDOUT.sync
7
10
  def pretty_print(msg)
8
11
  if logger.level == Logger::IMPORTANT
9
12
  pretty_errors
@@ -16,12 +19,12 @@ def pretty_print(msg)
16
19
  end
17
20
 
18
21
  def puts_ok
19
- if logger.level == Logger::IMPORTANT
22
+ if logger.level == Logger::IMPORTANT && !$error
20
23
  puts '✔'.green
21
24
  end
22
- end
23
25
 
24
- $pretty_errors_defined = false
26
+ $error = false
27
+ end
25
28
 
26
29
  def pretty_errors
27
30
  if !$pretty_errors_defined
@@ -38,6 +41,7 @@ def pretty_errors
38
41
  end
39
42
 
40
43
  _write(s.red)
44
+ $error = true
41
45
  end
42
46
  end
43
47
  end
@@ -7,8 +7,13 @@ namespace :symfony do
7
7
  end
8
8
 
9
9
  namespace :assets do
10
+ desc "Updates assets version (in config.yml)"
11
+ task :update_version, :except => { :no_release => true } do
12
+ run "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/app/config/config.yml"
13
+ end
14
+
10
15
  desc "Installs bundle's assets"
11
- task :install do
16
+ task :install, :except => { :no_release => true } do
12
17
  pretty_print "--> Installing bundle's assets"
13
18
 
14
19
  run "cd #{latest_release} && #{php_bin} #{symfony_console} assets:install #{web_path} --env=#{symfony_env_prod}"
@@ -18,8 +23,8 @@ namespace :symfony do
18
23
 
19
24
  namespace :assetic do
20
25
  desc "Dumps all assets to the filesystem"
21
- task :dump do
22
- puts "--> Dumping all assets to the filesystem"
26
+ task :dump, :except => { :no_release => true } do
27
+ pretty_print "--> Dumping all assets to the filesystem"
23
28
 
24
29
  run "cd #{latest_release} && #{php_bin} #{symfony_console} assetic:dump --env=#{symfony_env_prod} --no-debug"
25
30
  puts_ok
@@ -28,7 +33,7 @@ namespace :symfony do
28
33
 
29
34
  namespace :vendors do
30
35
  desc "Runs the bin/vendors script to install the vendors (fast if already installed)"
31
- task :install do
36
+ task :install, :except => { :no_release => true } do
32
37
  pretty_print "--> Installing vendors"
33
38
 
34
39
  run "cd #{latest_release} && #{php_bin} #{symfony_vendors} install"
@@ -36,7 +41,7 @@ namespace :symfony do
36
41
  end
37
42
 
38
43
  desc "Runs the bin/vendors script to reinstall the vendors"
39
- task :reinstall do
44
+ task :reinstall, :except => { :no_release => true } do
40
45
  pretty_print "--> Reinstalling vendors"
41
46
 
42
47
  run "cd #{latest_release} && #{php_bin} #{symfony_vendors} install --reinstall"
@@ -44,7 +49,7 @@ namespace :symfony do
44
49
  end
45
50
 
46
51
  desc "Runs the bin/vendors script to upgrade the vendors"
47
- task :upgrade do
52
+ task :upgrade, :except => { :no_release => true } do
48
53
  pretty_print "--> Upgrading vendors"
49
54
 
50
55
  run "cd #{latest_release} && #{php_bin} #{symfony_vendors} update"
@@ -54,17 +59,23 @@ namespace :symfony do
54
59
 
55
60
  namespace :bootstrap do
56
61
  desc "Runs the bin/build_bootstrap script"
57
- task :build do
62
+ task :build, :except => { :no_release => true } do
58
63
  pretty_print "--> Building bootstrap file"
59
64
 
60
- run "cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} || echo '#{build_bootstrap} not found, skipped'"
65
+ if !remote_file_exists?("#{latest_release}/#{build_bootstrap}") && true == use_composer then
66
+ build_bootstrap = "vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php"
67
+ run "cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} #{app_path} || echo '#{build_bootstrap} not found, skipped'"
68
+ else
69
+ run "cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} || echo '#{build_bootstrap} not found, skipped'"
70
+ end
71
+
61
72
  puts_ok
62
73
  end
63
74
  end
64
75
 
65
76
  namespace :composer do
66
77
  desc "Gets composer and installs it"
67
- task :get do
78
+ task :get, :except => { :no_release => true } do
68
79
  pretty_print "--> Downloading Composer"
69
80
 
70
81
  run "cd #{latest_release} && curl -s http://getcomposer.org/installer | #{php_bin}"
@@ -72,33 +83,33 @@ namespace :symfony do
72
83
  end
73
84
 
74
85
  desc "Runs composer to install vendors from composer.lock file"
75
- task :install do
76
- if !File.exist?("#{latest_release}/composer.phar")
86
+ task :install, :except => { :no_release => true } do
87
+ if !remote_file_exists?("#{latest_release}/composer.phar")
77
88
  symfony.composer.get
78
89
  end
79
90
 
80
91
  pretty_print "--> Installing Composer dependencies"
81
92
 
82
- run "cd #{latest_release} && #{php_bin} composer.phar install -v"
93
+ run "cd #{latest_release} && #{php_bin} composer.phar install --no-scripts --verbose"
83
94
  puts_ok
84
95
  end
85
96
 
86
97
  desc "Runs composer to update vendors, and composer.lock file"
87
- task :update do
88
- if !File.exist?("#{latest_release}/composer.phar")
98
+ task :update, :except => { :no_release => true } do
99
+ if !remote_file_exists?("#{latest_release}/composer.phar")
89
100
  symfony.composer.get
90
101
  end
91
102
 
92
103
  pretty_print "--> Updating Composer dependencies"
93
104
 
94
- run "cd #{latest_release} && #{php_bin} composer.phar update -v"
105
+ run "cd #{latest_release} && #{php_bin} composer.phar update --no-scripts --verbose"
95
106
  puts_ok
96
107
  end
97
108
  end
98
109
 
99
110
  namespace :cache do
100
111
  desc "Clears cache"
101
- task :clear do
112
+ task :clear, :except => { :no_release => true } do
102
113
  pretty_print "--> Clearing cache"
103
114
 
104
115
  run "cd #{latest_release} && #{php_bin} #{symfony_console} cache:clear --env=#{symfony_env_prod}"
@@ -107,7 +118,7 @@ namespace :symfony do
107
118
  end
108
119
 
109
120
  desc "Warms up an empty cache"
110
- task :warmup do
121
+ task :warmup, :except => { :no_release => true } do
111
122
  pretty_print "--> Warming up cache"
112
123
 
113
124
  run "cd #{latest_release} && #{php_bin} #{symfony_console} cache:warmup --env=#{symfony_env_prod}"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capifony
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 9
10
- version: 2.1.9
9
+ - 10
10
+ version: 2.1.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Konstantin Kudryashov
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-07-02 00:00:00 Z
19
+ date: 2012-07-16 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: capistrano