capcake 0.0.4 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,4 +1,4 @@
1
- # capcake
1
+ # capcake ![Project status](http://stillmaintained.com/jadb/capcake.png)
2
2
 
3
3
  Looking to deploy a [CakePHP](http://cakephp.org) application you've built? Capcake extends [Capistrano](http://capify.org), removing the *rails-ism*, replacing them by more *cake-ish* ones.
4
4
 
@@ -51,9 +51,7 @@ We need to tell it where to deploy, using what methods:
51
51
 
52
52
  And finally, some CakePHP related settings (if omitted, Capcake will NOT handle deploying CakePHP):
53
53
 
54
- set :cake_branch, "1.3.0-alpha"
55
-
56
- For this to work, *deployer*'s SSH keys must be added to the [Chaw](http://thechaw.com/users/account).
54
+ set :cake_branch, " "
57
55
 
58
56
  You can change the default values for the following variables also:
59
57
 
@@ -62,6 +60,20 @@ You can change the default values for the following variables also:
62
60
  set :user, "your_username"
63
61
  set :branch, "tag"
64
62
 
63
+ Append the following lines to your .git/info/exclude file:
64
+
65
+ .DS_Store
66
+ tmp/*
67
+
68
+ ## Alternative Easy Configuration
69
+
70
+ Simply replace your deploy.rb configuration file with the one provided in the template directory, and change all variables on the lines that have comments with your values.
71
+
72
+ This configuration file is meant to work with [Multiple Stages Without Multistage Extension](https://github.com/capistrano/capistrano/wiki/2.x-Multiple-Stages-Without-Multistage-Extension) so every cap command will have to contain the stage you want to deploy to. For instance:
73
+
74
+ $ cap staging deploy:setup
75
+ $ cap staging deploy
76
+
65
77
  ## Deployment
66
78
 
67
79
  The first time you are deploying, you need to run:
@@ -94,6 +106,21 @@ Which will change the directory structure to become:
94
106
  [deploy_to]/shared/system
95
107
  [deploy_to]/shared/tmp
96
108
 
109
+ ## Credits
110
+
111
+ * Jamis Buck ([Capistrano's](https://github.com/capistrano) original author)
112
+ * [Jad Bitar](http://github.com/jadb) (capcake code)
113
+ * [damusnet](https://github.com/damusnet) (capcake code)
114
+ * [Michael Franze](http://github.com/franzem) (capcake wiki)
115
+
116
+ ## Patches & Features
117
+
118
+ * Fork
119
+ * Mod, fix
120
+ * Test - this is important, so it's not unintentionally broken
121
+ * Commit - do not mess with license, todo, version, etc. (if you do change any, make them into commits of their own that I can ignore when I pull)
122
+ * Pull request - bonus point for topic branches
123
+
97
124
  ## Bugs & Feedback
98
125
 
99
- http://github.com/jadb/capcake/issues
126
+ http://github.com/jadb/capcake/issues
data/lib/capcake.rb CHANGED
@@ -28,32 +28,36 @@ Capistrano::Configuration.instance(:must_exist).load do
28
28
  # changes if you do decide to muck with these!
29
29
  # =========================================================================
30
30
 
31
+ set :cake2, true
31
32
  set :scm, :git
32
33
  set :git_enable_submodules, 1
33
- set :revision, source.head
34
34
  set :deploy_via, :checkout
35
- set :shared_children, %w(config system tmp)
36
35
 
37
36
  set :git_flag_quiet, ""
38
37
 
39
38
  _cset(:cake_branch) { "" }
40
- _cset(:cake_repo) { "http://github.com/cakephp/cakephp1x.git" }
39
+ _cset(:cake_repo) { "git://github.com/cakephp/cakephp.git" }
41
40
  _cset :tmp_children, %w(cache logs sessions tests)
42
41
  _cset :cache_children, %w(models persistent views)
43
42
  _cset :logs_files, %w(debug error)
44
43
 
45
44
  def capcake()
46
- set :deploy_to, "/var/www/#{application}" if (deploy_to.empty?)
45
+ set :deploy_to, "/var/www/#{application}" if (deploy_to.empty?)
47
46
  set(:current_path) { File.join(deploy_to, current_dir) }
48
- set(:database_path) { File.join(File.join(shared_path, "config"), "database.php") }
47
+ if cake2
48
+ set :shared_children, %w(Config System tmp)
49
+ set :database_partial_path, "Config/database.php"
50
+ else
51
+ set :shared_children, %w(config system tmp)
52
+ set :database_partial_path, "config/database.php"
53
+ end
54
+ set(:database_path) { File.join(shared_path, database_partial_path) }
49
55
  set(:shared_path) { File.join(deploy_to, shared_dir) }
50
56
  _cset(:cake_path) { shared_path }
51
57
  _cset(:tmp_path) { File.join(shared_path, "tmp") }
52
58
  _cset(:cache_path) { File.join(tmp_path, "cache") }
53
59
  _cset(:logs_path) { File.join(tmp_path, "logs") }
54
60
 
55
- after("deploy:setup", "cake:database:config") if (!remote_file_exists?(database_path))
56
- after("deploy:symlink", "cake:database:symlink") if (remote_file_exists?(database_path))
57
61
  end
58
62
 
59
63
  def defaults(val, default)
@@ -73,9 +77,9 @@ Capistrano::Configuration.instance(:must_exist).load do
73
77
 
74
78
  namespace :deploy do
75
79
  desc <<-DESC
76
- Deploys your project. This calls `update'. Note that \
80
+ Deploys your project. This calls `update`. Note that \
77
81
  this will generally only work for applications that have already been deployed \
78
- once. For a "cold" deploy, you'll want to take a look at the `deploy:cold' \
82
+ once. For a "cold" deploy, you'll want to take a look at the `deploy:cold` \
79
83
  task, which handles the cold start specifically.
80
84
  DESC
81
85
  task :default do
@@ -84,7 +88,7 @@ Capistrano::Configuration.instance(:must_exist).load do
84
88
  desc <<-DESC
85
89
  Prepares one or more servers for deployment. Before you can use any \
86
90
  of the Capistrano deployment tasks with your project, you will need to \
87
- make sure all of your servers have been prepared with `cap deploy:setup'. When \
91
+ make sure all of your servers have been prepared with `cap deploy:setup`. When \
88
92
  you add a new server to your cluster, you can easily run the setup task \
89
93
  on just that server by specifying the HOSTS environment variable:
90
94
 
@@ -101,20 +105,22 @@ Capistrano::Configuration.instance(:must_exist).load do
101
105
  run "#{try_sudo} mkdir -p #{(dirs + tmp_dirs).join(' ')} && #{try_sudo} chmod -R 777 #{tmp_path}" if (!user.empty?)
102
106
  set :git_flag_quiet, "-q "
103
107
  cake.setup if (!cake_branch.empty?)
108
+ cake.database.config if (!remote_file_exists?(database_path))
104
109
  end
105
110
 
106
111
  desc <<-DESC
107
112
  Copies your project and updates the symlink. It does this in a \
108
- transaction, so that if either `update_code' or `symlink' fail, all \
113
+ transaction, so that if either `update_code` or `symlink` fail, all \
109
114
  changes made to the remote servers will be rolled back, leaving your \
110
- system in the same state it was in before `update' was invoked. Usually, \
111
- you will want to call `deploy' instead of `update', but `update' can be \
115
+ system in the same state it was in before `update` was invoked. Usually, \
116
+ you will want to call `deploy` instead of `update`, but `update` can be \
112
117
  handy if you want to deploy, but not immediately restart your application.
113
118
  DESC
114
119
  task :update do
115
120
  transaction do
116
121
  update_code
117
122
  symlink
123
+ cake.cache.clear
118
124
  end
119
125
  end
120
126
 
@@ -122,8 +128,8 @@ Capistrano::Configuration.instance(:must_exist).load do
122
128
  Copies your project to the remote servers. This is the first stage \
123
129
  of any deployment; moving your updated code and assets to the deployment \
124
130
  servers. You will rarely call this task directly, however; instead, you \
125
- should call the `deploy' task (to do a complete deploy) or the `update' \
126
- task (if you want to perform the `restart' task separately).
131
+ should call the `deploy` task (to do a complete deploy) or the `update` \
132
+ task (if you want to perform the `restart` task separately).
127
133
 
128
134
  You will need to make sure you set the :scm variable to the source \
129
135
  control software you are using (it defaults to :subversion), and the \
@@ -137,19 +143,8 @@ Capistrano::Configuration.instance(:must_exist).load do
137
143
  end
138
144
 
139
145
  desc <<-DESC
140
- [internal] Touches up the released code. This is called by update_code \
141
- after the basic deploy finishes. It assumes a Rails project was deployed, \
142
- so if you are deploying something else, you may want to override this \
143
- task with your own environment's requirements.
144
-
145
- This task will make the release group-writable (if the :group_writable \
146
- variable is set to true, which is the default). It will then set up \
147
- symlinks to the shared directory for the log, system, and tmp/pids \
148
- directories, and will lastly touch all assets in public/images, \
149
- public/stylesheets, and public/javascripts so that the times are \
150
- consistent (so that asset timestamping works). This touch process \
151
- is only carried out if the :normalize_asset_timestamps variable is \
152
- set to true, which is the default.
146
+ [internal] This task will make the release group-writable (if the :group_writable \
147
+ variable is set to true, which is the default).
153
148
  DESC
154
149
  task :finalize_update, :except => { :no_release => true } do
155
150
  run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
@@ -158,12 +153,12 @@ Capistrano::Configuration.instance(:must_exist).load do
158
153
  desc <<-DESC
159
154
  Updates the symlinks to the most recently deployed version. Capistrano works \
160
155
  by putting each new release of your application in its own directory. When \
161
- you deploy a new version, this task's job is to update the `current', \
162
- `current/tmp', `current/webroot/system' symlinks to point at the new version. \
156
+ you deploy a new version, this task's job is to update the `current`, \
157
+ `current/tmp`, `current/webroot/system` symlinks to point at the new version. \
163
158
 
164
- You will rarely need to call this task directly; instead, use the `deploy' \
165
- task (which performs a complete deploy, including `restart') or the 'update' \
166
- task (which does everything except `restart').
159
+ You will rarely need to call this task directly; instead, use the `deploy` \
160
+ task (which performs a complete deploy, including `restart`) or the 'update` \
161
+ task (which does everything except `restart`).
167
162
  DESC
168
163
  task :symlink, :except => { :no_release => true } do
169
164
  on_rollback do
@@ -175,6 +170,7 @@ Capistrano::Configuration.instance(:must_exist).load do
175
170
  end
176
171
  run "ln -s #{shared_path}/system #{latest_release}/webroot/system && ln -s #{shared_path}/tmp #{latest_release}/tmp";
177
172
  run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
173
+ cake.database.symlink if (remote_file_exists?(database_path))
178
174
  end
179
175
 
180
176
  desc <<-DESC
@@ -226,7 +222,7 @@ Capistrano::Configuration.instance(:must_exist).load do
226
222
  end
227
223
 
228
224
  desc <<-DESC
229
- Rolls back to the previously deployed version. The `current' symlink will \
225
+ Rolls back to the previously deployed version. The `current` symlink will \
230
226
  be updated to point at the previously deployed version, and then the \
231
227
  current release will be removed from the servers.
232
228
  DESC
@@ -237,7 +233,7 @@ Capistrano::Configuration.instance(:must_exist).load do
237
233
 
238
234
  desc <<-DESC
239
235
  Rolls back to a previous version and restarts. This is handy if you ever \
240
- discover that you've deployed a lemon; `cap rollback' and you're right \
236
+ discover that you've deployed a lemon; `cap rollback` and you're right \
241
237
  back where you were, on the previously deployed version.
242
238
  DESC
243
239
  task :default do
@@ -271,7 +267,7 @@ Capistrano::Configuration.instance(:must_exist).load do
271
267
  Test deployment dependencies. Checks things like directory permissions, \
272
268
  necessary utilities, and so forth, reporting on the things that appear to \
273
269
  be incorrect or missing. This is good for making sure a deploy has a \
274
- chance of working before you actually run `cap deploy'.
270
+ chance of working before you actually run `cap deploy`.
275
271
 
276
272
  You can define your own dependencies, as well, using the `depend' method:
277
273
 
@@ -307,7 +303,7 @@ Capistrano::Configuration.instance(:must_exist).load do
307
303
  end
308
304
 
309
305
  desc <<-DESC
310
- Deploys and starts a `cold' application. This is useful if you have never \
306
+ Deploys and starts a `cold` application. This is useful if you have never \
311
307
  deployed your application before. It currently runs `deploy:setup` followed \
312
308
  by `deploy:update`. \
313
309
  (This is still an experimental feature, and is subject to change without \
@@ -320,7 +316,7 @@ Capistrano::Configuration.instance(:must_exist).load do
320
316
 
321
317
  namespace :pending do
322
318
  desc <<-DESC
323
- Displays the `diff' since your last deploy. This is useful if you want \
319
+ Displays the `diff` since your last deploy. This is useful if you want \
324
320
  to examine what changes are about to be deployed. Note that this might \
325
321
  not be supported on all SCM's.
326
322
  DESC
@@ -416,7 +412,7 @@ Capistrano::Configuration.instance(:must_exist).load do
416
412
  Prepares server for deployment of a CakePHP application. \
417
413
 
418
414
  By default, it will create a shallow clone of the CakePHP repository \
419
- inside #{shared_path}/cakephp and run deploy:cake:update.
415
+ inside #{shared_path}/cakephp and run `deploy:cake:update`.
420
416
 
421
417
  For more info about shallow clones: \
422
418
  http://www.kernel.org/pub/software/scm/git/docs/git-clone.html \
@@ -444,6 +440,17 @@ Capistrano::Configuration.instance(:must_exist).load do
444
440
  task :update do
445
441
  set :cake_branch, ENV['BRANCH'] if ENV.has_key?('BRANCH')
446
442
  stream "cd #{cake_path}/cakephp && git checkout #{git_flag_quiet}#{cake_branch}"
443
+ if cake2
444
+ run "#{try_sudo} ln -s #{shared_path}/cakephp/lib/Cake #{deploy_to}/#{version_dir}/Cake"
445
+ else
446
+ run "#{try_sudo} ln -s #{shared_path}/cakephp/cake #{deploy_to}/#{version_dir}/cake"
447
+ end
448
+ run "#{try_sudo} mkdir -m 777 -p #{shared_path}/cakephp/media/transfer/img"
449
+ run "#{try_sudo} mkdir -m 777 -p #{shared_path}/cakephp/media/static/img"
450
+ run "#{try_sudo} mkdir -m 777 -p #{shared_path}/cakephp/media/filter"
451
+ run "#{try_sudo} ln -s #{shared_path}/cakephp/media #{deploy_to}/#{version_dir}/media"
452
+ run "#{try_sudo} ln -s #{shared_path}/cakephp/plugins #{deploy_to}/#{version_dir}/plugins"
453
+ run "#{try_sudo} ln -s #{shared_path}/cakephp/vendors #{deploy_to}/#{version_dir}/vendors"
447
454
  end
448
455
 
449
456
  namespace :cache do
@@ -454,8 +461,8 @@ Capistrano::Configuration.instance(:must_exist).load do
454
461
  is renamed/removed after it was found but before it removes it, no error \
455
462
  will prompt (-ignore_readdir_race). If symlinks are found, they will not be followed
456
463
 
457
- You will rarely need to call this task directly; instead, use the `deploy' \
458
- task (which performs a complete deploy, including `cake:cache:clear')
464
+ You will rarely need to call this task directly; instead, use the `deploy` \
465
+ task (which performs a complete deploy, including `cake:cache:clear`)
459
466
  DESC
460
467
  task :clear, :roles => :web, :except => { :no_release => true } do
461
468
  run "#{try_sudo} find -P #{cache_path} -ignore_readdir_race -type f -name '*' -exec rm -f {} \\;"
@@ -524,7 +531,7 @@ Capistrano::Configuration.instance(:must_exist).load do
524
531
  #{deploy_to}/shared/config/database.php
525
532
  DESC
526
533
  task :symlink, :roles => :web, :except => { :no_release => true } do
527
- run "#{try_sudo} ln -s #{database_path} #{current_path}/config/database.php"
534
+ run "#{try_sudo} rm -f #{current_path}/#{database_partial_path} && #{try_sudo} ln -s #{database_path} #{current_path}/#{database_partial_path}"
528
535
  end
529
536
  end
530
537
 
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'capcake'
3
+
4
+ set :application, "your_app_name" # Your application name
5
+
6
+ set :scm, :git
7
+ set :repository, "git@domain.com:path/to/repo" # Your repository url
8
+ set :scm_username, "username" # Your username to log into your repository
9
+ set :scm_passphrase, Capistrano::CLI.password_prompt("Type your ssh passphrase for user #{scm_username}: ")
10
+ set :branch, "master"
11
+ set :use_sudo, false
12
+
13
+ set :deploy_via, :remote_cache
14
+ set(:group_writable, false)
15
+
16
+ ###
17
+ # Staging
18
+ ###
19
+
20
+ task :staging do
21
+ set :deploy_to, "/var/www/application/staging" # Your staging root path
22
+ set :user, "user" # Your staging user
23
+ set :group, "www-data" # Your staging group
24
+ server "staging.example.com", :web # Your staging server url
25
+ end
26
+
27
+ ###
28
+ # Production
29
+ ###
30
+
31
+ task :production do
32
+ set :deploy_to, "/var/www/application/production" # Your production root path
33
+ set :user, "user" # Your production user
34
+ set :group, "www-data" # Your production group
35
+ server "example.com", :web # Your production server url
36
+ end
37
+
38
+ ssh_options[:forward_agent] = true
39
+
40
+ set :cake_branch, " "
41
+
42
+ capcake
43
+
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capcake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 1
9
+ version: 2.0.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jad Bitar
@@ -9,19 +14,22 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-17 00:00:00 -05:00
17
+ date: 2012-01-28 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: capistrano
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 5
23
30
  version: "2.5"
24
- version:
31
+ type: :runtime
32
+ version_requirements: *id001
25
33
  description: Deploy CakePHP applications using Capistrano
26
34
  email: jadbitar@mac.com
27
35
  executables: []
@@ -32,10 +40,10 @@ extra_rdoc_files:
32
40
  - LICENSE
33
41
  - README.markdown
34
42
  files:
35
- - lib/TODO
36
43
  - lib/capcake.rb
37
44
  - lib/templates/create_database.rsql
38
45
  - lib/templates/database.rphp
46
+ - lib/templates/deploy.rb.default
39
47
  - lib/templates/maintenance.rhtml
40
48
  - LICENSE
41
49
  - README.markdown
@@ -44,26 +52,28 @@ homepage: http://github.com/jadb/capcake
44
52
  licenses: []
45
53
 
46
54
  post_install_message:
47
- rdoc_options:
48
- - --charset=UTF-8
55
+ rdoc_options: []
56
+
49
57
  require_paths:
50
58
  - lib
51
59
  required_ruby_version: !ruby/object:Gem::Requirement
52
60
  requirements:
53
61
  - - ">="
54
62
  - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
55
65
  version: "0"
56
- version:
57
66
  required_rubygems_version: !ruby/object:Gem::Requirement
58
67
  requirements:
59
68
  - - ">="
60
69
  - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
61
72
  version: "0"
62
- version:
63
73
  requirements: []
64
74
 
65
75
  rubyforge_project:
66
- rubygems_version: 1.3.5
76
+ rubygems_version: 1.3.6
67
77
  signing_key:
68
78
  specification_version: 3
69
79
  summary: Deploy CakePHP applications using Capistrano
data/lib/TODO DELETED
@@ -1,7 +0,0 @@
1
- * create cake:logs:tail to find every file modified in the last N hours and then tail them all
2
- * update deploy:check to check if shared/system/database.php is created or not - force creation if :db is set
3
- * override deploy:migrate and deploy:migrations to use cake schema shell commands
4
- * test what's simpler for people in general:
5
- - using multistage extension for Capistrano
6
- - creating deploy:production, deploy:staging tasks to reset variables' values
7
- * refactor code so it looks more like Ruby stuff (ie: Capitate)